Fix sav2 clone

Regression from the version-detect enhancement where we weren't expecting specific versions to be passed, only the lumped ones.
This commit is contained in:
Kurt 2024-04-28 11:25:46 -05:00
parent e7f79be41d
commit e9de611735
4 changed files with 21 additions and 12 deletions

View file

@ -55,7 +55,7 @@ public sealed class SAV2 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo
break;
}
Offsets = new SAV2Offsets(this);
Personal = Version == GameVersion.GS ? PersonalTable.GS : PersonalTable.C;
Personal = Version == GameVersion.C ? PersonalTable.C : PersonalTable.GS;
Initialize();
ClearBoxes();
}
@ -69,7 +69,7 @@ public sealed class SAV2 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo
Language = Japanese ? 1 : Korean ? (int)LanguageID.Korean : -1;
Offsets = new SAV2Offsets(this);
Personal = Version == GameVersion.GS ? PersonalTable.GS : PersonalTable.C;
Personal = Version == GameVersion.C ? PersonalTable.C : PersonalTable.GS;
Initialize();
}
@ -183,8 +183,10 @@ public sealed class SAV2 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo
{
switch (Version)
{
case GameVersion.GS: Data.AsSpan(Offsets.Trainer1, 0xC83).CopyTo(Data.AsSpan(0x7209)); break;
case GameVersion.C: Data.AsSpan(Offsets.Trainer1, 0xADA).CopyTo(Data.AsSpan(0x7209)); break;
case GameVersion.C:
Data.AsSpan(Offsets.Trainer1, 0xADA).CopyTo(Data.AsSpan(0x7209)); break;
default:
Data.AsSpan(Offsets.Trainer1, 0xC83).CopyTo(Data.AsSpan(0x7209)); break;
}
}
else if (Korean)
@ -210,16 +212,16 @@ public sealed class SAV2 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo
{
switch (Version)
{
case GameVersion.GS:
case GameVersion.C:
Array.Copy(Data, 0x2009, Data, 0x1209, 0xB7A);
break;
default:
Array.Copy(Data, 0x2009, Data, 0x15C7, 0x222F - 0x2009);
Array.Copy(Data, 0x222F, Data, 0x3D69, 0x23D9 - 0x222F);
Array.Copy(Data, 0x23D9, Data, 0x0C6B, 0x2856 - 0x23D9);
Array.Copy(Data, 0x2856, Data, 0x7E39, 0x288A - 0x2856);
Array.Copy(Data, 0x288A, Data, 0x10E8, 0x2D69 - 0x288A);
break;
case GameVersion.C:
Array.Copy(Data, 0x2009, Data, 0x1209, 0xB7A);
break;
}
}
return Data;

View file

@ -66,6 +66,8 @@ internal sealed class SAV2Offsets
switch (version)
{
case GameVersion.GD:
case GameVersion.SI:
case GameVersion.GS:
TimePlayed = 0x2053;
Palette = 0x206B;
@ -134,6 +136,8 @@ internal sealed class SAV2Offsets
switch (version)
{
case GameVersion.GD:
case GameVersion.SI:
case GameVersion.GS:
RTCFlags = 0x1000;

View file

@ -13,14 +13,14 @@ public sealed class Roamer3 : IContestStats
public Roamer3(SAV3 sav)
{
var buffer = sav.Large;
var offset = sav.Version switch
var offset = sav switch
{
GameVersion.RS => 0x3144,
GameVersion.E => 0x31DC,
SAV3RS => 0x3144,
SAV3E => 0x31DC,
_ => 0x30D0, // FRLG
};
Raw = buffer.AsMemory(offset, SIZE);
IsGlitched = sav.Version != GameVersion.E;
IsGlitched = sav is not SAV3E;
}
public uint IV32

View file

@ -172,6 +172,9 @@ public static class SaveLanguage
if (Contains(name, "geum")) return (Korean, GD);
if (Contains(name, "eun")) return (Korean, SI);
// Codes
if (Contains(name, "gd")) return (OverrideLanguageGen2, GD);
if (Contains(name, "si")) return (OverrideLanguageGen2, SI);
return default;
}