Skip to content

Commit

Permalink
Dex: Don't deepClone Pokedex during load (#10611)
Browse files Browse the repository at this point in the history
The only issue came from gen1 not using modData. After fixing that, everything just works.
You can test this by deepFreezing dataCache right after running Scripts.init and
then loading all the species for all the mods and running the test suite.
  • Loading branch information
larry-the-table-guy authored Oct 13, 2024
1 parent 101f6bc commit 196b72a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 3 additions & 2 deletions data/mods/gen1/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export const Scripts: ModdedBattleScriptsData = {
gen: 1,
init() {
for (const i in this.data.Pokedex) {
(this.data.Pokedex[i] as any).gender = 'N';
(this.data.Pokedex[i] as any).eggGroups = null;
const poke = this.modData('Pokedex', i);
poke.gender = 'N';
poke.eggGroups = null;
}
},
// BattlePokemon scripts.
Expand Down
8 changes: 1 addition & 7 deletions sim/dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,7 @@ export class ModdedDex {
delete childTypedData[entryId];
} else if (!(entryId in childTypedData)) {
// If it doesn't exist it's inherited from the parent data
if (dataType === 'Pokedex') {
// Pokedex entries can be modified too many different ways
// e.g. inheriting different formats-data/learnsets
childTypedData[entryId] = this.deepClone(parentTypedData[entryId]);
} else {
childTypedData[entryId] = parentTypedData[entryId];
}
childTypedData[entryId] = parentTypedData[entryId];
} else if (childTypedData[entryId] && childTypedData[entryId].inherit) {
// {inherit: true} can be used to modify only parts of the parent data,
// instead of overwriting entirely
Expand Down

0 comments on commit 196b72a

Please sign in to comment.