diff --git a/include/mon_markings.h b/include/mon_markings.h index 8e4ec58bd..241b31e01 100644 --- a/include/mon_markings.h +++ b/include/mon_markings.h @@ -1,17 +1,19 @@ #ifndef POKEEMERALD_MON_MARKINGS_H #define POKEEMERALD_MON_MARKINGS_H +#define NUM_MON_MARKINGS 4 + struct PokemonMarkMenu { /*0x0000*/ u16 baseTileTag; /*0x0002*/ u16 basePaletteTag; /*0x0004*/ u8 markings; // bit flags /*0x0005*/ s8 cursorPos; - /*0x0006*/ bool8 markingsArray[4]; + /*0x0006*/ bool8 markingsArray[NUM_MON_MARKINGS]; /*0x000A*/ u8 cursorBaseY; /*0x000B*/ bool8 spriteSheetLoadRequired; /*0x000C*/ struct Sprite *menuWindowSprites[2]; // upper and lower halves of menu window - /*0x0014*/ struct Sprite *menuMarkingSprites[4]; + /*0x0014*/ struct Sprite *menuMarkingSprites[NUM_MON_MARKINGS]; /*0x0024*/ struct Sprite *unkSprite; /*0x0028*/ struct Sprite *menuTextSprite; /*0x002C*/ const u8 *frameTiles; diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 6a8163b96..b581a8bbc 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -298,7 +298,7 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves) ) ) { - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_TRAINER_ITEMS; i++) { if (gTrainers[gTrainerBattleOpponent_A].items[i] != 0) { diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index cd31293f8..6ef359150 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -820,7 +820,7 @@ static bool8 ShouldUseItem(void) } } - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_TRAINER_ITEMS; i++) { u16 item; const u8 *itemEffects; diff --git a/src/battle_main.c b/src/battle_main.c index 87e29dd57..27889e81e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -1790,9 +1790,9 @@ static void CB2_HandleStartMultiBattle(void) gBattleCommunication[SPRITES_INIT_STATE2] = 0; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - for (id = 0; id < 4 && (gLinkPlayers[id].version & 0xFF) == 3; id++); + for (id = 0; id < MAX_LINK_PLAYERS && (gLinkPlayers[id].version & 0xFF) == VERSION_EMERALD; id++); - if (id == 4) + if (id == MAX_LINK_PLAYERS) gBattleCommunication[MULTIUSE_STATE] = 8; else gBattleCommunication[MULTIUSE_STATE] = 10; @@ -4244,7 +4244,7 @@ static void HandleTurnActionSelectionState(void) moveInfo.monType1 = gBattleMons[gActiveBattler].type1; moveInfo.monType2 = gBattleMons[gActiveBattler].type2; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MON_MOVES; i++) { moveInfo.moves[i] = gBattleMons[gActiveBattler].moves[i]; moveInfo.currentPp[i] = gBattleMons[gActiveBattler].pp[i]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5016a3a58..6f1b43240 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10184,7 +10184,7 @@ static void atkEF_handleballthrow(void) gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); - if (CalculatePlayerPartyCount() == 6) + if (CalculatePlayerPartyCount() == PARTY_SIZE) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -10196,7 +10196,7 @@ static void atkEF_handleballthrow(void) odds = Sqrt(Sqrt(16711680 / odds)); odds = 1048560 / odds; - for (shakes = 0; shakes < 4 && Random() < odds; shakes++); + for (shakes = 0; shakes < BALL_3_SHAKES_SUCCESS && Random() < odds; shakes++); if (gLastUsedItem == ITEM_MASTER_BALL) shakes = BALL_3_SHAKES_SUCCESS; // why calculate the shakes before that check? @@ -10209,7 +10209,7 @@ static void atkEF_handleballthrow(void) gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); - if (CalculatePlayerPartyCount() == 6) + if (CalculatePlayerPartyCount() == PARTY_SIZE) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; diff --git a/src/mon_markings.c b/src/mon_markings.c index f8b128045..f4d6b3818 100644 --- a/src/mon_markings.c +++ b/src/mon_markings.c @@ -350,7 +350,7 @@ void sub_811FAA4(u8 markings, s16 x, s16 y) u16 i; sMenu->cursorPos = 0; sMenu->markings = markings; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_MON_MARKINGS; i++) sMenu->markingsArray[i] = (sMenu->markings >> i) & 1; sub_811FC80(x, y, sMenu->baseTileTag, sMenu->basePaletteTag); } @@ -371,7 +371,7 @@ void sub_811FAF8(void) DestroySprite(sMenu->menuWindowSprites[i]); sMenu->menuWindowSprites[i] = NULL; } - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_MON_MARKINGS; i++) { if (!sMenu->menuMarkingSprites[i]) return; @@ -422,7 +422,7 @@ bool8 sub_811FBA4(void) { case 4: sMenu->markings = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_MON_MARKINGS; i++) sMenu->markings |= sMenu->markingsArray[i] << i; return FALSE; case 5: @@ -498,7 +498,7 @@ static void sub_811FC80(s16 x, s16 y, u16 baseTileTag, u16 basePaletteTag) sprTemplate.callback = sub_811FF40; sprTemplate.oam = &gUnknown_0859EE84; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_MON_MARKINGS; i++) { spriteId = CreateSprite(&sprTemplate, x + 32, y + 16 + 16 * i, 0); if (spriteId != MAX_SPRITES) diff --git a/src/new_game.c b/src/new_game.c index b4d9ba9b3..1021ea96c 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -81,7 +81,7 @@ u32 GetTrainerId(u8 *trainerId) void CopyTrainerId(u8 *dst, u8 *src) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < TRAINER_ID_LENGTH; i++) dst[i] = src[i]; } diff --git a/src/overworld.c b/src/overworld.c index cefbd8159..51d9ad9b5 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -2435,7 +2435,7 @@ static void UpdateAllLinkPlayers(u16 *keys, s32 selfId) struct TradeRoomPlayer trainer; s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_LINK_PLAYERS; i++) { u8 key = keys[i]; u16 setFacing = FACING_NONE; @@ -3026,7 +3026,7 @@ static s32 sub_80878E4(u8 linkPlayerId) static u8 GetLinkPlayerIdAt(s16 x, s16 y) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_LINK_PLAYERS; i++) { if (gLinkPlayerEventObjects[i].active && (gLinkPlayerEventObjects[i].movementMode == 0 || gLinkPlayerEventObjects[i].movementMode == 2)) diff --git a/src/pokemon.c b/src/pokemon.c index a393759d3..4833f2db6 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6683,7 +6683,7 @@ u8 sub_806EF08(u8 arg0) var = (arg0 != 0) ? 2 : 0; break; } - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_LINK_PLAYERS; i++) { if (gLinkPlayers[i].id == (s16)(var)) break; @@ -6706,7 +6706,7 @@ u8 sub_806EF84(u8 arg0, u8 arg1) var = (arg0 != 0) ? 2 : 0; break; } - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_LINK_PLAYERS; i++) { if (gLinkPlayers[i].id == (s16)(var)) break;