Let pkmdb fetch from save backups

Only if compiled in debug; bumps my searchables to 6 figures lol

bulk legality scan yielded one exception (bad CXD pidiv for starters)
bullk sav fetch yielded one exception (unknown type didn't define
SeenFlagOffsets)
This commit is contained in:
Kurt 2017-06-09 23:13:41 -07:00
parent 1e9f5261b7
commit 8a1691eb91
3 changed files with 34 additions and 2 deletions

View file

@ -824,6 +824,9 @@ namespace PKHeX.Core
}
private void verifyCXDStarterCorrelation(PIDIV pidiv)
{
if (pidiv.Type != PIDType.CXD)
return;
var spec = EncounterMatch.Species;
int rev; // pidiv reversed 2x yields SID, 3x yields TID. shift by 7 if another PKM is generated prior
switch (spec)

View file

@ -148,7 +148,7 @@ namespace PKHeX.Core
HeldItems = Legal.HeldItems_RS;
// Sanity Check SeenFlagOffsets -- early saves may not have block 4 initialized yet
SeenFlagOffsets = SeenFlagOffsets.Where(z => z >= 0).ToArray();
SeenFlagOffsets = SeenFlagOffsets?.Where(z => z >= 0).ToArray();
if (!Exportable)
resetBoxes();

View file

@ -100,6 +100,26 @@ namespace PKHeX.WinForms
dbTemp.Add(pk);
});
#if DEBUG
if (SaveUtil.getSavesFromFolder(Main.BackupPath, false, out IEnumerable<string> result))
{
Parallel.ForEach(result, file =>
{
var sav = SaveUtil.getVariantSAV(File.ReadAllBytes(file));
var path = EXTERNAL_SAV + new FileInfo(file).Name;
if (sav.HasBox)
foreach (var pk in sav.BoxData)
addPKM(pk);
void addPKM(PKM pk)
{
pk.Identifier = Path.Combine(path, pk.Identifier);
dbTemp.Add(pk);
}
});
}
#endif
// Prepare Database
RawDB = new List<PKM>(dbTemp.OrderBy(pk => pk.Identifier)
.Concat(SAV.BoxData.Where(pk => pk.Species != 0)) // Fetch from save file
@ -126,6 +146,7 @@ namespace PKHeX.WinForms
private readonly string Counter;
private readonly string Viewed;
private const int MAXFORMAT = 7;
private readonly string EXTERNAL_SAV = new DirectoryInfo(Main.BackupPath).Name + Path.DirectorySeparatorChar;
private static string hash(PKM pk)
{
switch (pk.Format)
@ -178,10 +199,18 @@ namespace PKHeX.WinForms
var pk = Results[index];
string path = pk.Identifier;
#if DEBUG
if (path.StartsWith(EXTERNAL_SAV))
{
WinFormsUtil.Alert("Can't delete from a backup save.");
return;
}
#endif
if (path.Contains(Path.DirectorySeparatorChar))
{
// Data from Database: Delete file from disk
File.Delete(path);
if (File.Exists(path))
File.Delete(path);
}
else
{