Skip to content

Commit

Permalink
[HaCreator] fix InvalidCastException
Browse files Browse the repository at this point in the history
Sound.wz/BgmTW.img

Unable to cast object of type 'MapleLib.WzLib.WzProperties.WzUOLProperty' to type 'MapleLib.WzLib.WzProperties.WzBinaryProperty'.
   at HaCreator.Wz.WzFileManager.ExtractSoundFile(String soundWzFile) in \Harepacker-resurrected\HaCreator\Wz\WzFileManager.cs:line 245
  • Loading branch information
eaxvac committed Nov 30, 2020
1 parent 441d4b6 commit 0a2a267
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions HaCreator/Wz/WzFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,24 @@ public void ExtractSoundFile(string soundWzFile)
soundImage.ParseImage();
try
{
foreach (WzBinaryProperty bgm in soundImage.WzProperties)
foreach (WzImageProperty bgmImage in soundImage.WzProperties)
{
Program.InfoManager.BGMs[WzInfoTools.RemoveExtension(soundImage.Name) + @"/" + bgm.Name] = bgm;
WzBinaryProperty binProperty = null;
if (bgmImage is WzBinaryProperty bgm)
{
binProperty = bgm;
}
else if (bgmImage is WzUOLProperty uolBGM) // is UOL property
{
WzObject linkVal = ((WzUOLProperty)bgmImage).LinkValue;
if (linkVal is WzBinaryProperty linkCanvas)
{
binProperty = linkCanvas;
}
}

if (binProperty != null)
Program.InfoManager.BGMs[WzInfoTools.RemoveExtension(soundImage.Name) + @"/" + binProperty.Name] = binProperty;
}
}
catch (Exception e)
Expand Down

0 comments on commit 0a2a267

Please sign in to comment.