Fix B2W2 key unlocked get/set

Closes #4295
This commit is contained in:
Kurt 2024-06-09 08:54:02 -05:00
parent 67fc0d0885
commit 992deea183

View file

@ -64,7 +64,7 @@ public sealed class KeySystem5(SAV5B2W2 SAV, Memory<byte> raw) : SaveBlock<SAV5B
{ {
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)key, (uint)KeyType5.Iceberg); ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)key, (uint)KeyType5.Iceberg);
var offset = OffsetKeysUnlocked + (sizeof(uint) * (int)key); var offset = OffsetKeysUnlocked + (sizeof(uint) * (int)key);
var expect = MagicKeyUnlocked[(int)key + 5] ^ Crypto; var expect = MagicKeyUnlocked[(int)key] ^ Crypto;
var value = ReadUInt32LittleEndian(Data[offset..]); var value = ReadUInt32LittleEndian(Data[offset..]);
return value == expect; return value == expect;
} }
@ -73,7 +73,7 @@ public sealed class KeySystem5(SAV5B2W2 SAV, Memory<byte> raw) : SaveBlock<SAV5B
{ {
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)key, (uint)KeyType5.Iceberg); ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)key, (uint)KeyType5.Iceberg);
var offset = OffsetKeysUnlocked + (sizeof(uint) * (int)key); var offset = OffsetKeysUnlocked + (sizeof(uint) * (int)key);
var expect = MagicKeyUnlocked[(int)key + 5] ^ Crypto; var expect = MagicKeyUnlocked[(int)key] ^ Crypto;
WriteUInt32LittleEndian(Data[offset..], value ? expect : 0); WriteUInt32LittleEndian(Data[offset..], value ? expect : 0);
} }