From b6299ac4cef4a95bb50e982673ebe5a5201416a3 Mon Sep 17 00:00:00 2001 From: psf <77138753+pkmnsnfrn@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:16:56 -0700 Subject: [PATCH] Fix a display issue with B_SHOW_TYPES (#5201) * Moved HandleInputChooseTarget and ShowEntireFieldTargets to non-static and added them as cases to ShouldHideTypeIcon * Made ShouldHideTypeIcon easier to parse * Made ShouldHideTypeIcon a for loop * Fixed identation * Made showTypesControllerFuncs a static const array per https://github.com/rh-hideout/pokeemerald-expansion/pull/5201\#discussion_r1730336265 --- include/battle_controllers.h | 2 ++ src/battle_controller_player.c | 4 ++-- src/type_icons.c | 26 +++++++++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 50860a7285..5e92cac763 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -313,6 +313,8 @@ void MoveSelectionDestroyCursorAt(u8 cursorPosition); void PlayerHandleChooseMove(u32 battler); void HandleInputChooseMove(u32 battler); void HandleInputChooseTarget(u32 battler); +void HandleInputShowEntireFieldTargets(u32 battler); +void HandleInputShowTargets(u32 battler); void HandleMoveSwitching(u32 battler); void HandleChooseMoveAfterDma3(u32 battler); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 61f2b8162d..52507157e7 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -593,7 +593,7 @@ static void HideShownTargets(u32 battler) } } -static void HandleInputShowEntireFieldTargets(u32 battler) +void HandleInputShowEntireFieldTargets(u32 battler) { if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) gPlayerDpadHoldFrames++; @@ -621,7 +621,7 @@ static void HandleInputShowEntireFieldTargets(u32 battler) } } -static void HandleInputShowTargets(u32 battler) +void HandleInputShowTargets(u32 battler) { if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) gPlayerDpadHoldFrames++; diff --git a/src/type_icons.c b/src/type_icons.c index 2877d22071..361312ab91 100644 --- a/src/type_icons.c +++ b/src/type_icons.c @@ -471,15 +471,27 @@ static void FreeAllTypeIconResources(void) } } +static void (* const sShowTypesControllerFuncs[])(u32 battler) = +{ + PlayerHandleChooseMove, + HandleChooseMoveAfterDma3, + HandleInputChooseTarget, + HandleInputShowTargets, + HandleInputShowEntireFieldTargets, + HandleMoveSwitching, + HandleInputChooseMove, +}; + + static bool32 ShouldHideTypeIcon(u32 battlerId) { - return gBattlerControllerFuncs[battlerId] != PlayerHandleChooseMove - && gBattlerControllerFuncs[battlerId] != HandleInputChooseMove - && gBattlerControllerFuncs[battlerId] != HandleChooseMoveAfterDma3 - && gBattlerControllerFuncs[battlerId] != HandleInputChooseMove - && gBattlerControllerFuncs[battlerId] != HandleInputChooseTarget - && gBattlerControllerFuncs[battlerId] != HandleMoveSwitching - && gBattlerControllerFuncs[battlerId] != HandleInputChooseMove; + u32 funcIndex; + + for (funcIndex = 0; funcIndex < ARRAY_COUNT(sShowTypesControllerFuncs); funcIndex++) + if (gBattlerControllerFuncs[battlerId] == sShowTypesControllerFuncs[funcIndex]) + return FALSE; + + return TRUE; } static s32 GetTypeIconHideMovement(bool32 useDoubleBattleCoords, u32 position)