Compress PLA wild bin resource

Change the data structure so that different locations are tied to the table, rather than separate usages of the table.

This de-bloats from 344KB->85KB and has less runtime memory consumption.
This commit is contained in:
Kurt 2022-02-27 15:08:53 -08:00
parent c2f7003f38
commit 85e422c225
4 changed files with 17 additions and 17 deletions

View file

@ -11,20 +11,13 @@ namespace PKHeX.Core;
public sealed record EncounterArea8a : EncounterArea
{
public readonly EncounterSlot8a[] Slots;
public readonly int ParentLocation;
private readonly byte[] Locations;
protected override IReadOnlyList<EncounterSlot> Raw => Slots;
public override bool IsMatchLocation(int location)
{
if (base.IsMatchLocation(location))
return true;
return CanCrossoverTo(location);
}
private bool CanCrossoverTo(int location)
{
return location == ParentLocation;
return Array.IndexOf(Locations, (byte)location) != -1;
}
public override IEnumerable<EncounterSlot> GetMatchingSlots(PKM pkm, IReadOnlyList<EvoCriteria> chain) => GetMatches(chain, pkm.Met_Level);
@ -61,12 +54,18 @@ public sealed record EncounterArea8a : EncounterArea
private EncounterArea8a(ReadOnlySpan<byte> areaData, GameVersion game) : base(game)
{
// Area Metadata
Location = areaData[0];
ParentLocation = areaData[1];
Type = areaData[2] + SlotType.Overworld;
var count = areaData[3];
int locationCount = areaData[0];
Locations = areaData.Slice(1, locationCount).ToArray();
Location = Locations[0];
var slots = areaData[4..];
int align = (locationCount + 1);
if ((align & 1) == 1)
align++;
areaData = areaData[align..];
Type = areaData[0] + SlotType.Overworld;
var count = areaData[1];
var slots = areaData[2..];
Slots = ReadSlots(slots, count);
}

View file

@ -37,9 +37,9 @@ internal static class Encounters8a
new(077,000,15 ) { Location = 014, Shiny = Always}, // Ponyta*
new(442,000,60,M,M) { Location = 043, FlawlessIVCount = 3 }, // Spiritomb
new(570,001,27 ) { Location = 027, FlawlessIVCount = 3 }, // Zorua
new(570,001,28 ) { Location = 027, FlawlessIVCount = 3 }, // Zorua
new(570,001,29 ) { Location = 027, FlawlessIVCount = 3 }, // Zorua
new(570,001,27 ) { Location = 027 }, // Zorua
new(570,001,28 ) { Location = 027 }, // Zorua
new(570,001,29 ) { Location = 027 }, // Zorua
new(489,000,33 ) { Location = 064, Fateful = true }, // Phione
new(489,000,34 ) { Location = 064, Fateful = true }, // Phione

View file

@ -88,6 +88,7 @@ namespace PKHeX.Core
Overworld = 16,
Distortion = 17,
Landmark = 18,
OverworldMMO = 19,
// Modifiers