diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 92f2347..22f9dc3 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -60,20 +60,26 @@ namespace DSPRE { } private bool DecompressArm9() { - if (new FileInfo(workDir + @"arm9.bin").Length < 0xBC000) { - BinaryWriter arm9Truncate = new BinaryWriter(File.OpenWrite(workDir + @"arm9.bin")); - long arm9Length = new FileInfo(workDir + @"arm9.bin").Length; - arm9Truncate.BaseStream.SetLength(arm9Length - 0xc); - arm9Truncate.Close(); - } + int attempts = 0; + + do { + attempts++; + if (new FileInfo(workDir + @"arm9.bin").Length < 0xBC000) { + BinaryWriter arm9Truncate = new BinaryWriter(File.OpenWrite(workDir + @"arm9.bin")); + long arm9Length = new FileInfo(workDir + @"arm9.bin").Length; + arm9Truncate.BaseStream.SetLength(arm9Length - 0xc); + arm9Truncate.Close(); + + Process decompress = new Process(); + decompress.StartInfo.FileName = @"Tools\blz.exe"; + decompress.StartInfo.Arguments = @" -d " + '"' + workDir + "arm9.bin" + '"'; + decompress.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + decompress.StartInfo.CreateNoWindow = true; + decompress.Start(); + decompress.WaitForExit(); + } + } while (new FileInfo(workDir + @"arm9.bin").Length < 1122000 && attempts < 2); - Process decompress = new Process(); - decompress.StartInfo.FileName = @"Tools\blz.exe"; - decompress.StartInfo.Arguments = @" -d " + '"' + workDir + "arm9.bin" + '"'; - decompress.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - decompress.StartInfo.CreateNoWindow = true; - decompress.Start(); - decompress.WaitForExit(); return (new FileInfo(workDir + @"arm9.bin").Length > 1122000); }