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;
|
video = null;
|
||||||
|
|
||||||
|
if (s.Length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!IsWestwoodVqa(s))
|
if (!IsWestwoodVqa(s))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsWestwoodVqa(Stream s)
|
static bool IsWestwoodVqa(Stream s)
|
||||||
{
|
{
|
||||||
var start = s.Position;
|
var start = s.Position;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
|||||||
{
|
{
|
||||||
video = null;
|
video = null;
|
||||||
|
|
||||||
|
if (s.Length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!IsWsa(s))
|
if (!IsWsa(s))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -29,7 +32,7 @@ namespace OpenRA.Mods.Cnc.VideoLoaders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsWsa(Stream s)
|
static bool IsWsa(Stream s)
|
||||||
{
|
{
|
||||||
var start = s.Position;
|
var start = s.Position;
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
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();
|
onCompleteRadar();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,15 +343,28 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
playingVideo = pv;
|
playingVideo = pv;
|
||||||
player.Load(video);
|
player.Load(video);
|
||||||
|
|
||||||
// video playback runs asynchronously
|
if (player.Video == null)
|
||||||
player.PlayThen(() =>
|
|
||||||
{
|
{
|
||||||
StopVideo(player);
|
StopVideo(player);
|
||||||
onComplete?.Invoke();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Mute other distracting sounds
|
ConfirmationDialogs.ButtonPrompt(
|
||||||
MuteSounds();
|
title: "Unable to play video",
|
||||||
|
text: "Something went wrong during video playback.",
|
||||||
|
cancelText: "Back",
|
||||||
|
onCancel: () => { });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// video playback runs asynchronously
|
||||||
|
player.PlayThen(() =>
|
||||||
|
{
|
||||||
|
StopVideo(player);
|
||||||
|
onComplete?.Invoke();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mute other distracting sounds
|
||||||
|
MuteSounds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
if (filename == cachedVideoFileName)
|
if (filename == cachedVideoFileName)
|
||||||
return;
|
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);
|
Open(video);
|
||||||
|
|
||||||
cachedVideoFileName = filename;
|
cachedVideoFileName = filename;
|
||||||
@@ -56,6 +57,9 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
this.video = video;
|
this.video = video;
|
||||||
|
|
||||||
|
if (video == null)
|
||||||
|
return;
|
||||||
|
|
||||||
stopped = true;
|
stopped = true;
|
||||||
paused = true;
|
paused = true;
|
||||||
Game.Sound.StopVideo();
|
Game.Sound.StopVideo();
|
||||||
|
|||||||
Reference in New Issue
Block a user