Fix RSTB sizes not using decompressed size
This commit is contained in:
parent
1b2de8c7cf
commit
8f18e77ab7
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,9 +22,9 @@ namespace Switch_Toolbox.Library
|
||||
public Dictionary<string, uint> NameTables { get; set; }
|
||||
public Dictionary<uint, uint> Crc32Tables { get; set; }
|
||||
|
||||
private int ParseSize(string FilePath, byte[] Data = null, bool Force = false)
|
||||
private int ParseSize(string FilePath, byte[] Data = null, bool IsYaz0Compressed = false, bool Force = false)
|
||||
{
|
||||
var size = new RSTB.SizeCalculator().CalculateFileSize(FilePath, Data, IsWiiU, Force);
|
||||
var size = new RSTB.SizeCalculator().CalculateFileSize(FilePath, Data, IsWiiU, IsYaz0Compressed, Force);
|
||||
if (size == 0)
|
||||
{
|
||||
var result = MessageBox.Show("Error! Could not calculate size for resource entry! Do you want to remove it instead?", "Resource Table", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
@ -36,10 +36,10 @@ namespace Switch_Toolbox.Library
|
||||
return size;
|
||||
}
|
||||
|
||||
public void SetEntry(string FileName, byte[] Data = null, bool Force = false)
|
||||
public void SetEntry(string FileName, byte[] Data = null, bool IsYaz0Compressed = false, bool Force = false)
|
||||
{
|
||||
uint OldSize = GetSize(FileName);
|
||||
uint NewSize = (uint)ParseSize(FileName, Data, Force);
|
||||
uint NewSize = (uint)ParseSize(FileName, Data, IsYaz0Compressed, Force);
|
||||
|
||||
STConsole.WriteLine($"Setting RSTB Entry!");
|
||||
STConsole.WriteLine($"{FileName} OldSize {OldSize}");
|
||||
@ -265,17 +265,17 @@ namespace Switch_Toolbox.Library
|
||||
float.TryParse(value, out output);
|
||||
}
|
||||
|
||||
public int CalculateFileSize(string FileName, byte[] Data, bool IsWiiU, bool Force)
|
||||
public int CalculateFileSize(string FileName, byte[] Data, bool IsWiiU,bool IsYaz0Compressed, bool Force)
|
||||
{
|
||||
return CalculateFileSizeByExtension(FileName, Data, IsWiiU, System.IO.Path.GetExtension(FileName), Force);
|
||||
return CalculateFileSizeByExtension(FileName, Data, IsWiiU, System.IO.Path.GetExtension(FileName), IsYaz0Compressed, Force);
|
||||
}
|
||||
|
||||
private int CalculateFileSizeByExtension(string FileName, byte[] Data, bool WiiU, string Ext, bool Force = false)
|
||||
private int CalculateFileSizeByExtension(string FileName, byte[] Data, bool WiiU, string Ext, bool IsYaz0Compressed, bool Force = false)
|
||||
{
|
||||
int Size = 0;
|
||||
if (System.IO.File.Exists(FileName))
|
||||
{
|
||||
if (Ext.StartsWith("s"))
|
||||
if (Ext.StartsWith("s") || IsYaz0Compressed)
|
||||
{
|
||||
using (var reader = new FileReader(FileName))
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ namespace Switch_Toolbox.Library.IO
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
private static string SatisfyFileTables(IFileFormat FileFormat, string FilePath, byte[] Data, uint DecompressedSize, uint CompressedSize, bool IsCompressed)
|
||||
private static string SatisfyFileTables(IFileFormat FileFormat, string FilePath, byte[] Data, uint DecompressedSize, uint CompressedSize, bool IsYaz0Compressed)
|
||||
{
|
||||
string FileLog = "";
|
||||
|
||||
@ -95,7 +95,7 @@ namespace Switch_Toolbox.Library.IO
|
||||
|
||||
}
|
||||
|
||||
BotwResourceTable.SetEntry(newFilePath, Data);
|
||||
BotwResourceTable.SetEntry(newFilePath, Data, IsYaz0Compressed);
|
||||
BotwResourceTable.Write(new FileWriter(RstbPath));
|
||||
File.WriteAllBytes(RstbPath, EveryFileExplorer.YAZ0.Compress(RstbPath));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user