diff --git a/payload/include/global.h b/payload/include/global.h index 9c3df43..77350e6 100644 --- a/payload/include/global.h +++ b/payload/include/global.h @@ -31,7 +31,7 @@ #include "constants/vars.h" #include "constants/flags.h" -#define NELEMS(arr) (sizeof(arr)/sizeof(*(arr))) +#define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) #define MOVE_NAME_LENGTH 12 #define POKEMON_NAME_LENGTH 10 diff --git a/payload/src/pokemon.c b/payload/src/pokemon.c index 7dc0b14..a6c847b 100644 --- a/payload/src/pokemon.c +++ b/payload/src/pokemon.c @@ -102,16 +102,16 @@ static u16 CalculateBoxMonChecksum(struct BoxPokemon *boxMon) union PokemonSubstruct *substruct3 = GetSubstruct(boxMon, boxMon->personality, 3); s32 i; - for (i = 0; i < (s32)NELEMS(substruct0->raw); i++) + for (i = 0; i < (s32)ARRAY_COUNT(substruct0->raw); i++) checksum += substruct0->raw[i]; - for (i = 0; i < (s32)NELEMS(substruct1->raw); i++) + for (i = 0; i < (s32)ARRAY_COUNT(substruct1->raw); i++) checksum += substruct1->raw[i]; - for (i = 0; i < (s32)NELEMS(substruct2->raw); i++) + for (i = 0; i < (s32)ARRAY_COUNT(substruct2->raw); i++) checksum += substruct2->raw[i]; - for (i = 0; i < (s32)NELEMS(substruct3->raw); i++) + for (i = 0; i < (s32)ARRAY_COUNT(substruct3->raw); i++) checksum += substruct3->raw[i]; return checksum; @@ -121,7 +121,7 @@ static inline void EncryptBoxMon(struct BoxPokemon *boxMon) { u32 i; - for (i = 0; i < NELEMS(boxMon->secure.raw); i++) + for (i = 0; i < ARRAY_COUNT(boxMon->secure.raw); i++) { boxMon->secure.raw[i] ^= boxMon->personality; boxMon->secure.raw[i] ^= boxMon->otId; @@ -132,7 +132,7 @@ static inline void DecryptBoxMon(struct BoxPokemon *boxMon) { u32 i; - for (i = 0; i < NELEMS(boxMon->secure.raw); i++) + for (i = 0; i < ARRAY_COUNT(boxMon->secure.raw); i++) { boxMon->secure.raw[i] ^= boxMon->otId; boxMon->secure.raw[i] ^= boxMon->personality; diff --git a/payload/src/unk_200E344.c b/payload/src/unk_200E344.c index 7d14188..bcb69cb 100644 --- a/payload/src/unk_200E344.c +++ b/payload/src/unk_200E344.c @@ -72,7 +72,7 @@ s32 validate_rom_header_internal(void) languageCode = *(const u8 *)0x080000AF; version = *(const u8 *)0x080000BC; sp4 = -1; - for (i = 0; i < NELEMS(gUnknown_0201F298); i++) + for (i = 0; i < ARRAY_COUNT(gUnknown_0201F298); i++) { if (languageCode != gUnknown_0201F298[i][0]) {