Increase gen3 sav loading stability

reject if game has only been saved once, the trainer block is
inexplicably not set up to be able to be detected.

#305
Old code would default to RS (reading from any uninitialized 'block0'
yielded 0, gamecode for RS.

#305
This commit is contained in:
Kaphotics 2016-10-05 21:25:36 -07:00
parent 95ca86033a
commit f9a72abb4c

View file

@ -227,8 +227,12 @@ namespace PKHeX
// Detect RS/E/FRLG
// Section 0 stores Game Code @ 0x00AC; 0 for RS, 1 for FRLG, else for Emerald
int Block0 = Array.IndexOf(BlockOrder, 0);
// Sometimes not all blocks are present (start of game), yielding multiple block0's.
// Real 0th block comes before block1.
if (BlockOrder[0] == 1 && Block0 != BlockOrder.Length - 1)
continue;
uint GameCode = BitConverter.ToUInt32(data, Block0 * 0x1000 + 0xAC + ofs);
if (GameCode == uint.MaxValue)
return GameVersion.Unknown; // what a hack