Ok so logically speaking when i use my calculator on this variable padding1 i get 6B2 but in the program i get FFFFFFFFFEADF6B2 how come it adds those extra numbers on there and also newoffsets[i] * 0x800 is 0x1561000 and WAL.Position is 156094E when you get the sum of those answers you should get 6B2 why do i get this super large FFFFFFFFFEADF6B2 number WAL.Position is a long and newoffsets[i] is a int
using (FileStream WAL = new FileStream(@"C:\Users\denar\source\repos\Sly_WAL_Editor\TEST.WAL", FileMode.Create, FileAccess.Write))
{
List<long> newOffsets = new List<long>();
WAL.Write(BitConverter.GetBytes(wal.unk), 0, sizeof(uint));
WAL.Write(BitConverter.GetBytes(wal.entries.Count), 0, sizeof(uint));
uint walNextSector = maxTOCSize / 2048;
for (int i = 0; i < 1; i++)
{
tocEntry = wal.entries[i];
WAL.Write(Encoding.ASCII.GetBytes(tocEntry.folderName), 0, tocEntry.folderName.Length);
WAL.WriteByte(0);
WAL.Write(Encoding.ASCII.GetBytes(tocEntry.fileNames), 0, tocEntry.fileNames.Length);
WAL.WriteByte(0);
Alignrebuild(WAL);
for (int b = 0; b < tocEntry.fileNames.Length; b++)
{
tocFileEntry = tocEntry.files[b];
tocFileEntry.offset = walNextSector;
walNextSector += (tocFileEntry.size + 0x800 - 0x1) / 0x800;
newOffsets.Add(tocFileEntry.offset);
WAL.Write(BitConverter.GetBytes(tocFileEntry.offset), 0, sizeof(int));
WAL.Write(BitConverter.GetBytes(tocFileEntry.size), 0, sizeof(int));
}
}
long padding = maxTOCSize - WAL.Position;
byte[] buffer = new byte[padding];
WAL.Write(buffer, 0, buffer.Length);
for (int i = 0; i < 1; i++)
{
tocEntry = wal.entries[i];
for(int j = 0; j < tocEntry.fileNames.Length; j++)
{
tocFileEntry = tocEntry.files[j];
var padding1 = (newOffsets[i] * 0x800) - WAL.Position;
MessageBox.Show(padding1.ToString("X"));
byte[] buffer1 = new byte[padding1];
WAL.Write(buffer1, 0, buffer1.Length);
WAL.Write(tocFileEntry.fileData, 0, tocFileEntry.fileData.Length);
}
}
This is showing the super large number i get in a variable padding1