mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-25 13:30:20 +00:00
parent
2c687e48fb
commit
06b8ec03ae
3 changed files with 14 additions and 6 deletions
|
@ -15,7 +15,6 @@ public sealed class StartupArguments
|
|||
|
||||
// ReSharper disable once UnassignedGetOnlyAutoProperty
|
||||
public Exception? Error { get; }
|
||||
// ReSharper disable once CollectionNeverQueried.Global
|
||||
public readonly List<object> Extra = [];
|
||||
|
||||
/// <summary>
|
||||
|
@ -52,6 +51,8 @@ public sealed class StartupArguments
|
|||
|
||||
if (Entity is { } x)
|
||||
SAV = ReadSettingsDefinedPKM(startup, x) ?? GetBlank(x);
|
||||
else if (Extra.OfType<SAV3GCMemoryCard>().FirstOrDefault() is { } mc && SaveUtil.GetVariantSAV(mc) is { } mcSav)
|
||||
SAV = mcSav;
|
||||
else
|
||||
SAV = ReadSettingsAnyPKM(startup) ?? GetBlankSaveFile(startup.DefaultSaveVersion, SAV);
|
||||
}
|
||||
|
@ -104,7 +105,7 @@ public sealed class StartupArguments
|
|||
var sav = SaveUtil.GetBlankSAV(version, tr, lang);
|
||||
if (sav.Version == GameVersion.Invalid) // will fail to load
|
||||
{
|
||||
var max = GameInfo.VersionDataSource.MaxBy(z => z.Value) ?? throw new Exception();
|
||||
var max = GameInfo.VersionDataSource.MaxBy(z => z.Value)!;
|
||||
var maxVer = (GameVersion)max.Value;
|
||||
sav = SaveUtil.GetBlankSAV(maxVer, tr, lang);
|
||||
}
|
||||
|
|
|
@ -142,10 +142,11 @@ public sealed class SAV3GCMemoryCard(Memory<byte> Raw)
|
|||
|
||||
private int DirectoryBlock_Used;
|
||||
|
||||
private int EntryCOLO = -1;
|
||||
private int EntryXD = -1;
|
||||
private int EntryRSBOX = -1;
|
||||
private int EntrySelected = -1;
|
||||
private const int NotPresent = -1;
|
||||
private int EntryCOLO = NotPresent;
|
||||
private int EntryXD = NotPresent;
|
||||
private int EntryRSBOX = NotPresent;
|
||||
private int EntrySelected = NotPresent;
|
||||
public bool HasCOLO => EntryCOLO >= 0;
|
||||
public bool HasXD => EntryXD >= 0;
|
||||
public bool HasRSBOX => EntryRSBOX >= 0;
|
||||
|
@ -251,10 +252,14 @@ public sealed class SAV3GCMemoryCard(Memory<byte> Raw)
|
|||
return MemoryCardSaveStatus.SaveGameRSBOX;
|
||||
}
|
||||
|
||||
public bool IsNoGameSelected => SelectedGameVersion == GameVersion.Any;
|
||||
|
||||
public GameVersion SelectedGameVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EntrySelected < 0)
|
||||
return GameVersion.Any;
|
||||
if (EntrySelected == EntryCOLO)
|
||||
return GameVersion.COLO;
|
||||
if (EntrySelected == EntryXD)
|
||||
|
|
|
@ -765,6 +765,8 @@ public static class SaveUtil
|
|||
public static SaveFile? GetVariantSAV(SAV3GCMemoryCard memCard)
|
||||
{
|
||||
// Pre-check for header/footer signatures
|
||||
if (memCard.IsNoGameSelected)
|
||||
memCard.GetMemoryCardState();
|
||||
var memory = memCard.ReadSaveGameData();
|
||||
if (memory.Length == 0)
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue