Skip to content

Commit

Permalink
fix: fix config checksum typo
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulusParssinen committed Jun 19, 2024
1 parent 7cbfdea commit 8f10cde
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions Shockky/Resources/Config.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Drawing;
using System.Diagnostics;
using System.Drawing;

using Shockky.IO;
using Shockky.Resources.Cast;
Expand Down Expand Up @@ -126,6 +127,8 @@ public Config(ref ShockwaveReader input, ReaderContext context)
Field5E = input.ReadInt16BigEndian();
Field60 = input.ReadInt16BigEndian();
Field62 = input.ReadInt16BigEndian();

Debug.Assert(Checksum == CalculateChecksum(), "Config checksum mismatch!");
}

public uint CalculateChecksum()
Expand Down Expand Up @@ -157,7 +160,7 @@ public uint CalculateChecksum()
checksum += (uint)(ScoreUsedChannelsMask >> 32) + 23;
checksum += (uint)(ScoreUsedChannelsMask & 0xFFFFFFFF) + 24;
checksum *= (uint)Field34 + 25;
checksum *= (uint)Tempo + 26;
checksum += (uint)Tempo + 26;
checksum *= (uint)Platform + 27;
checksum *= (uint)((SaveSeed * 0xE06) + 0xFFF450000); // - 0xBB000
checksum ^= 0x72616C66;
Expand Down
4 changes: 2 additions & 2 deletions Shockky/Resources/IResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static IResource Read(scoped ref ShockwaveReader input, ReaderContext con
OsType.Fcdr => new FileCompressionTypes(ref bodyInput, context),
OsType.ABMP => new AfterburnerMap(ref bodyInput, context),

OsType.imap => new IndexMap(ref bodyInput, context),
OsType.mmap => new MemoryMap(ref bodyInput, context),
OsType.imap => new IndexMap(ref bodyInput),
OsType.mmap => new MemoryMap(ref bodyInput),
OsType.KEYPtr => new KeyMap(ref bodyInput, context),
OsType.VWCF or OsType.DRCF => new Config(ref bodyInput, context),

Expand Down
2 changes: 1 addition & 1 deletion Shockky/Resources/IndexMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class IndexMap : IShockwaveItem, IResource
public int Field10 { get; set; }
public int Field14 { get; set; }

public IndexMap(ref ShockwaveReader input, ReaderContext context)
public IndexMap(ref ShockwaveReader input)
{
int memoryMapCount = input.ReadInt32BigEndian();
Debug.Assert(memoryMapCount == 1);
Expand Down
4 changes: 2 additions & 2 deletions Shockky/Resources/MemoryMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class MemoryMap : IShockwaveItem, IResource

public ResourceEntry this[int index] => Entries[index];

public MemoryMap(ref ShockwaveReader input, ReaderContext context)
public MemoryMap(ref ShockwaveReader input)
{
input.ReadInt16BigEndian();
input.ReadInt16BigEndian();
Expand All @@ -31,7 +31,7 @@ public MemoryMap(ref ShockwaveReader input, ReaderContext context)

for (int i = 0; i < Entries.Length; i++)
{
Entries[i] = new ResourceEntry(ref input, context);
Entries[i] = new ResourceEntry(ref input);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Shockky/Resources/ResourceEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class ResourceEntry : IShockwaveItem
public short Unknown { get; set; }
public int Link { get; set; }

public ResourceEntry(ref ShockwaveReader input, ReaderContext context)
public ResourceEntry(ref ShockwaveReader input)
{
Kind = (OsType)input.ReadInt32BigEndian();
Length = input.ReadInt32BigEndian();
Expand Down

0 comments on commit 8f10cde

Please sign in to comment.