Improve gen3 sav detection

better detect RSE collisions
add auto-detection for japanese games
Closes #1172
This commit is contained in:
Kurt
2017-05-29 10:33:27 -07:00
parent 82750de1b8
commit 550153e3bc
4 changed files with 9 additions and 17 deletions

View File

@@ -99,6 +99,11 @@ public SAV3(byte[] data = null, GameVersion versionOverride = GameVersion.Any)
Array.Copy(Data, blockIndex * SIZE_BLOCK + ABO, Data, Box + (i - 5)*0xF80, chunkLength[i]);
}
// 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
// OT name is stored at the top of the first block.
Japanese = BitConverter.ToInt16(data, BlockOfs[0] + 0x6) == 0;
switch (Version)
{
case GameVersion.RS:
@@ -173,7 +178,6 @@ public override byte[] Write(bool DSV)
// Configuration
public override SaveFile Clone() { return new SAV3(Write(DSV:false), Version) {Japanese = Japanese}; }
public override bool IndeterminateGame => Version == GameVersion.Unknown;
public override bool IndeterminateLanguage => true; // Unknown JP/International
public override bool IndeterminateSubVersion => Version == GameVersion.FRLG;
public override int SIZE_STORED => PKX.SIZE_3STORED;

View File

@@ -23,7 +23,6 @@ public abstract class SaveFile
public bool Japanese { get; set; }
public string PlayTimeString => $"{PlayedHours}ː{PlayedMinutes:00}ː{PlayedSeconds:00}"; // not :
public virtual bool IndeterminateGame => false;
public virtual bool IndeterminateLanguage => false;
public virtual bool IndeterminateSubVersion => false;
public abstract string Extension { get; }
public virtual string[] PKMExtensions => PKM.Extensions.Where(f =>

View File

@@ -209,14 +209,14 @@ public static GameVersion getIsG3SAV(byte[] data)
if (BlockOrder.Count(v => v == 0) == BlockOrder.Length)
continue;
uint GameCode = BitConverter.ToUInt32(data, Block0 * 0x1000 + 0xAC + ofs);
if (GameCode == uint.MaxValue)
return GameVersion.Unknown; // what a hack
switch (GameCode)
{
case 0: return GameVersion.RS;
case 1: return GameVersion.FRLG;
default: return GameVersion.E;
case uint.MaxValue: return GameVersion.Unknown; // what a hack
default: return BitConverter.ToUInt32(data, Block0 * 0x1000 + 0x1F4 + ofs) == 0
? GameVersion.RS
: GameVersion.E;
}
}
return GameVersion.Invalid;

View File

@@ -887,17 +887,6 @@ private static bool sanityCheckSAV(ref SaveFile sav, string path)
sav.Personal = dialog.Result == GameVersion.FR ? PersonalTable.FR : PersonalTable.LG;
}
if (sav.IndeterminateLanguage)
{
// Japanese Save files are different. Get isJapanese
var drJP = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel,
$"{sav.Version} Save File detected. Select language...",
"Yes: International" + Environment.NewLine + "No: Japanese");
if (drJP == DialogResult.Cancel)
return false;
sav.Japanese = drJP == DialogResult.No;
}
return true;
}