Update blank sav3 behavior

can now be selected & loaded without exception/hassle
This commit is contained in:
Kurt 2019-01-15 22:14:19 -08:00
parent b6261e57a3
commit 53b2ca93b8
2 changed files with 15 additions and 6 deletions

View file

@ -93,13 +93,23 @@ namespace PKHeX.Core
BlockOfs[i] = index < 0 ? int.MinValue : (index * SIZE_BLOCK) + ABO; BlockOfs[i] = index < 0 ? int.MinValue : (index * SIZE_BLOCK) + ABO;
} }
if (data == null) if (versionOverride != GameVersion.Any)
Version = GameVersion.FRLG;
else if (versionOverride != GameVersion.Any)
Version = versionOverride; Version = versionOverride;
else if (data == null)
Version = GameVersion.FRLG;
else else
Version = GetVersion(Data, BlockOfs[0]); Version = GetVersion(Data, BlockOfs[0]);
Personal = SaveUtil.GetG3Personal(Version);
if (data == null) // spoof block offsets
{
BlockOfs = Enumerable.Range(0, BLOCK_COUNT).ToArray();
if (Version == GameVersion.FR || Version == GameVersion.LG)
Version = GameVersion.FRLG;
else if (Version == GameVersion.R || Version == GameVersion.LG)
Version = GameVersion.RS;
}
// Set up PC data buffer beyond end of save file. // Set up PC data buffer beyond end of save file.
Box = Data.Length; Box = Data.Length;
Array.Resize(ref Data, Data.Length + SIZE_RESERVED); // More than enough empty space. Array.Resize(ref Data, Data.Length + SIZE_RESERVED); // More than enough empty space.
@ -116,7 +126,7 @@ namespace PKHeX.Core
// Japanese games are limited to 5 character OT names; any unused characters are 0xFF. // Japanese games are limited to 5 character OT names; any unused characters are 0xFF.
// 5 for JP, 7 for INT. There's always 1 terminator, thus we can check 0x6-0x7 being 0xFFFF = INT // 5 for JP, 7 for INT. There's always 1 terminator, thus we can check 0x6-0x7 being 0xFFFF = INT
// OT name is stored at the top of the first block. // OT name is stored at the top of the first block.
Japanese = BitConverter.ToInt16(Data, BlockOfs[0] + 0x6) == 0; Japanese = BitConverter.ToInt16(Data, BlockOfs[0] + 0x6) == 0 && Exportable;
PokeDex = BlockOfs[0] + 0x18; PokeDex = BlockOfs[0] + 0x18;
switch (Version) switch (Version)
@ -161,7 +171,6 @@ namespace PKHeX.Core
Daycare = BlockOfs[4] + 0x100; Daycare = BlockOfs[4] + 0x100;
break; break;
} }
Personal = SaveUtil.GetG3Personal(Version);
LoadEReaderBerryData(); LoadEReaderBerryData();
LegalItems = Legal.Pouch_Items_RS; LegalItems = Legal.Pouch_Items_RS;
LegalBalls = Legal.Pouch_Ball_RS; LegalBalls = Legal.Pouch_Ball_RS;

View file

@ -861,7 +861,7 @@ namespace PKHeX.WinForms
if (sav.Version == GameVersion.FRLG) if (sav.Version == GameVersion.FRLG)
sav.Personal = dialog.Result == GameVersion.FR ? PersonalTable.FR : PersonalTable.LG; sav.Personal = dialog.Result == GameVersion.FR ? PersonalTable.FR : PersonalTable.LG;
} }
else if (sav.Version == GameVersion.FRLG) // IndeterminateSubVersion else if (sav.Version == GameVersion.FRLG && sav.Exportable) // IndeterminateSubVersion
{ {
string fr = GameInfo.GetVersionName(GameVersion.FR); string fr = GameInfo.GetVersionName(GameVersion.FR);
string lg = GameInfo.GetVersionName(GameVersion.LG); string lg = GameInfo.GetVersionName(GameVersion.LG);