pret / pokeemerald

Decompilation of Pokémon Emerald

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing wild encounter constant usage in Match Call

GriffinRichards opened this issue · comments

Currently constants for the distribution of wild Pokémon are generated from data in wild_encounters.json and written by the inja template to wild_encounters.h. Because this file contains data it can't be included elsewhere, and the constants can only be used in wild_encounter.c.

The constants should instead be defined in a separate file that can be included repeatedly so that they can be used in other places the values are referenced (in match call, specifically). If a user changes the encounter chances without the constants there then the distribution of wild Pokémon mentioned in match calls can skew, or it could read out of bounds of the encounter table.

(somewhat related): Also, the constants from include/constants/wild_encounter.h are "missing" (it's not actually required in any vanilla code but would very much be nice to have) something like:

#define FISH_WILD_COUNT_OLD_ROD   2
#define FISH_WILD_COUNT_GOOD_ROD  3
#define FISH_WILD_COUNT_SUPER_ROD 5

They were defined in a .h file before being made into JSON, we'd have to revert that in order to fix this issue
That or we make the modifications to the inja template and JSON

we'd have to revert that in order to fix this issue

um no, obviously we wouldn't have to do that.

That or we make the madifications to the inja template

well yeah that's the point. make the template generate a .c file, drop the static, and have extern ... in a .h file that can be included wherever.

and JSON

nah that's not necessary either.