Skip to content

Commit

Permalink
Invalid audio files
Browse files Browse the repository at this point in the history
- Added a popup when an invalid .wav file is supplied instead of a hard crash.
  • Loading branch information
BJDubb committed May 10, 2023
1 parent dcfce85 commit 178602c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions SirenSharp/SirenBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,17 @@ public static void GenerateSirenAWC(string awcName, string wavFolder, Siren[] si
var doc = new XmlDocument();
doc.LoadXml(awcXml);

byte[] data = XmlMeta.GetData(doc, mformat, wavFolder); // awc file data
byte[] data = new byte[] { };

try
{
data = XmlMeta.GetData(doc, mformat, wavFolder); // awc file data
}
catch (Exception ex)
{
MessageBox.Show($"One of the audio files provided was invalid.\n\n {ex.Message}\n {ex.StackTrace}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

File.WriteAllBytes(outputPath, data);
}
Expand Down Expand Up @@ -184,16 +194,7 @@ public static void GenerateFiveMResource(string folderPath, string resourceName,
var doc = new XmlDocument();
doc.LoadXml(datXml);

byte[] data = new byte[] { 0x0 };

try
{
data = XmlMeta.GetData(doc, mformat, ""); // rel file data
}
catch (Exception ex)
{
MessageBox.Show($"One of the audio files provided was invalid.\n\n {ex.Message}\n {ex.StackTrace}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
byte[] data = XmlMeta.GetData(doc, mformat, ""); // rel file data

File.WriteAllBytes(Path.Combine(dataDir.FullName, "custom_sounds.dat54.rel"), data); // write rel to disk

Expand Down

0 comments on commit 178602c

Please sign in to comment.