Fixed crash

This commit is contained in:
DeadlySurprise
2015-05-11 17:41:21 +02:00
parent 648dc31e24
commit 35445775c2
2 changed files with 8 additions and 2 deletions

View File

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

View File

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