Fix a crash when encountering 0 byte .vqa placeholders.
This commit is contained in:
committed by
abcdefg30
parent
9e34299085
commit
91fbd618ce
@@ -21,6 +21,9 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
||||
{
|
||||
video = null;
|
||||
|
||||
if (s.Length == 0)
|
||||
return false;
|
||||
|
||||
if (!IsWestwoodVqa(s))
|
||||
return false;
|
||||
|
||||
@@ -28,7 +31,7 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsWestwoodVqa(Stream s)
|
||||
static bool IsWestwoodVqa(Stream s)
|
||||
{
|
||||
var start = s.Position;
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
||||
{
|
||||
video = null;
|
||||
|
||||
if (s.Length == 0)
|
||||
return false;
|
||||
|
||||
if (!IsWsa(s))
|
||||
return false;
|
||||
|
||||
@@ -29,7 +32,7 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsWsa(Stream s)
|
||||
static bool IsWsa(Stream s)
|
||||
{
|
||||
var start = s.Position;
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
Log.Write("lua", "Couldn't play movie {0}! File doesn't exist.", e.FileName);
|
||||
Log.Write("lua", $"Couldn't play movie {e.FileName}! File doesn't exist.");
|
||||
onCompleteRadar();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -343,6 +343,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
playingVideo = pv;
|
||||
player.Load(video);
|
||||
|
||||
if (player.Video == null)
|
||||
{
|
||||
StopVideo(player);
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Unable to play video",
|
||||
text: "Something went wrong during video playback.",
|
||||
cancelText: "Back",
|
||||
onCancel: () => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
// video playback runs asynchronously
|
||||
player.PlayThen(() =>
|
||||
{
|
||||
@@ -354,6 +366,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
MuteSounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StopVideo(VideoPlayerWidget player)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (filename == cachedVideoFileName)
|
||||
return;
|
||||
|
||||
var video = VideoLoader.GetVideo(Game.ModData.DefaultFileSystem.Open(filename), true, Game.ModData.VideoLoaders);
|
||||
var stream = Game.ModData.DefaultFileSystem.Open(filename);
|
||||
var video = VideoLoader.GetVideo(stream, true, Game.ModData.VideoLoaders);
|
||||
Open(video);
|
||||
|
||||
cachedVideoFileName = filename;
|
||||
@@ -56,6 +57,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
this.video = video;
|
||||
|
||||
if (video == null)
|
||||
return;
|
||||
|
||||
stopped = true;
|
||||
paused = true;
|
||||
Game.Sound.StopVideo();
|
||||
|
||||
Reference in New Issue
Block a user