Merge pull request #8147 from DeadlySurprise/vqaAudioFix

Fixed gdi3lose.vqa crash
This commit is contained in:
Pavel Penev
2015-05-13 03:50:45 +03:00
2 changed files with 8 additions and 2 deletions

View File

@@ -187,7 +187,9 @@ namespace OpenRA.FileFormats
{
case "SND0":
case "SND2":
if (audioChannels == 1)
if (audioChannels == 0)
throw new NotSupportedException();
else if (audioChannels == 1)
{
var rawAudio = stream.ReadBytes((int)length);
audio1.Write(rawAudio);
@@ -198,11 +200,15 @@ namespace OpenRA.FileFormats
audio1.Write(rawAudio);
rawAudio = stream.ReadBytes((int)length / 2);
audio2.Write(rawAudio);
if (length % 2 != 0)
stream.ReadBytes(2);
}
compressed = type == "SND2";
break;
default:
if (length + stream.Position > stream.Length)
throw new NotSupportedException("Vqa uses unknown Subtype: {0}".F(type));
stream.ReadBytes((int)length);
break;
}

View File

@@ -304,7 +304,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (!GlobalFileSystem.Exists(filename))
return false;
if (Path.GetExtension(filename) == ".vqa")
if (Path.GetExtension(filename).ToLower() == ".vqa")
{
player = panel.Get<VqaPlayerWidget>("PLAYER");
currentFilename = filename;