Skip to content

Commit

Permalink
Ignore empty slots in pre-filter
Browse files Browse the repository at this point in the history
Add Palma property to PK8 per bdsp disassembly
  • Loading branch information
kwsch committed Feb 22, 2022
1 parent 75bd26d commit 2753927
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 12 additions & 8 deletions PKHeX.Core/Legality/BulkAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@ public BulkAnalysis(SaveFile sav)
Trainer = sav;
var list = new List<SlotCache>(sav.BoxSlotCount + (sav.HasParty ? 6 : 0) + 5);
SlotInfoLoader.AddFromSaveFile(sav, list);
list.RemoveAll(IsEmptyData);
AllData = list;
AllAnalysis = GetIndividualAnalysis(AllData);
CloneFlags = new bool[AllData.Count];

Valid = ScanAll();
}

// Remove things that aren't actual stored data, or already flagged by legality checks.
private static bool IsEmptyData(SlotCache obj)
{
var pkm = obj.Entity;
if ((uint)(pkm.Species - 1) >= pkm.MaxSpeciesID)
return true;
if (!pkm.ChecksumValid)
return true;
return false;
}

private bool ScanAll()
{
CheckClones();
Expand Down Expand Up @@ -74,8 +86,6 @@ private void CheckClones()
for (int i = 0; i < AllData.Count; i++)
{
var cs = AllData[i];
if (cs.Entity.Species == 0)
continue;
var ca = AllAnalysis[i];
Debug.Assert(cs.Entity.Format == Trainer.Generation);

Expand Down Expand Up @@ -142,9 +152,6 @@ private void CheckECReuse()
if (CloneFlags[i])
continue; // already flagged
var cp = AllData[i];
if (cp.Entity.Species == 0)
continue;

var ca = AllAnalysis[i];
Debug.Assert(cp.Entity.Format >= 6);
var id = cp.Entity.EncryptionConstant;
Expand Down Expand Up @@ -282,9 +289,6 @@ private void VerifyPIDShare(CombinedReference pr, CombinedReference cr)
var ps = pr.Slot;
var pa = pr.Analysis;
var cs = cr.Slot;
if (cs.Entity.Species == 0)
return;

var ca = cr.Analysis;
const CheckIdentifier ident = PID;
int gen = pa.Info.Generation;
Expand Down
4 changes: 2 additions & 2 deletions PKHeX.Core/PKM/G8PKM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,10 @@ public override string Nickname

public byte DynamaxLevel { get => Data[0x90]; set => Data[0x90] = value; }

// 0x90-0x93 unused
// 0x91-0x93 unused

public override int Status_Condition { get => ReadInt32LittleEndian(Data.AsSpan(0x94)); set => WriteInt32LittleEndian(Data.AsSpan(0x94), value); }
public int Unk98 { get => ReadInt32LittleEndian(Data.AsSpan(0x98)); set => WriteInt32LittleEndian(Data.AsSpan(0x98), value); }
public int Palma { get => ReadInt32LittleEndian(Data.AsSpan(0x98)); set => WriteInt32LittleEndian(Data.AsSpan(0x98), value); }

// 0x9C-0xA7 unused

Expand Down

0 comments on commit 2753927

Please sign in to comment.