From 18e7fc5efc5930ea1daac07bd37d43ab6c4e945f Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Thu, 20 Oct 2022 08:41:18 -0300 Subject: [PATCH] Introduce NUM_BATTLE_SIDES --- include/battle.h | 14 +++++++------- include/constants/battle.h | 1 + src/battle_anim_effects_1.c | 10 +++++----- src/battle_main.c | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/battle.h b/include/battle.h index e779dee3d..c1c713691 100644 --- a/include/battle.h +++ b/include/battle.h @@ -164,7 +164,7 @@ struct WishFutureKnock u8 wishCounter[MAX_BATTLERS_COUNT]; u8 wishMonId[MAX_BATTLERS_COUNT]; u8 weatherDuration; - u8 knockedOffMons[2]; // Each battler is represented by a bit. The array entry is dependent on the battler's side. + u8 knockedOffMons[NUM_BATTLE_SIDES]; // Each battler is represented by a bit. }; struct AI_ThinkingStruct @@ -326,9 +326,9 @@ struct BattleTv_Mon struct BattleTv { - struct BattleTv_Mon mon[2][PARTY_SIZE]; // [side][partyId] - struct BattleTv_Position pos[2][2]; // [side][flank] - struct BattleTv_Side side[2]; // [side] + struct BattleTv_Mon mon[NUM_BATTLE_SIDES][PARTY_SIZE]; + struct BattleTv_Position pos[NUM_BATTLE_SIDES][2]; // [side][flank] + struct BattleTv_Side side[NUM_BATTLE_SIDES]; }; struct BattleTvMovePoints @@ -399,7 +399,7 @@ struct BattleStruct u8 wallyWaitFrames; u8 wallyMoveFrames; u8 lastTakenMove[MAX_BATTLERS_COUNT * 2 * 2]; // Last move that a battler was hit with. This field seems to erroneously take 16 bytes instead of 8. - u16 hpOnSwitchout[2]; + u16 hpOnSwitchout[NUM_BATTLE_SIDES]; u32 savedBattleTypeFlags; u8 abilityPreventingSwitchout; u8 hpScale; @@ -670,8 +670,8 @@ extern u8 gMoveResultFlags; extern u32 gHitMarker; extern u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT]; extern u8 gUnusedFirstBattleVar2; -extern u16 gSideStatuses[2]; -extern struct SideTimer gSideTimers[2]; +extern u16 gSideStatuses[NUM_BATTLE_SIDES]; +extern struct SideTimer gSideTimers[NUM_BATTLE_SIDES]; extern u32 gStatuses3[MAX_BATTLERS_COUNT]; extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT]; extern u16 gPauseCounterBattle; diff --git a/include/constants/battle.h b/include/constants/battle.h index b4f3a4d9b..ac83feb3a 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -36,6 +36,7 @@ #define B_SIDE_PLAYER 0 #define B_SIDE_OPPONENT 1 +#define NUM_BATTLE_SIDES 2 #define B_FLANK_LEFT 0 #define B_FLANK_RIGHT 1 diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 757576efa..f6d50b147 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -4561,11 +4561,11 @@ static void AnimTipMon_Step(struct Sprite *sprite) void AnimTask_SkullBashPosition(u8 taskId) { - u8 a; + u8 side; gTasks[taskId].data[0] = gBattlerSpriteIds[gBattleAnimAttacker]; - a = GetBattlerSide(gBattleAnimAttacker); - gTasks[taskId].data[1] = a; + side = GetBattlerSide(gBattleAnimAttacker); + gTasks[taskId].data[1] = side; gTasks[taskId].data[2] = 0; switch (gBattleAnimArgs[0]) { @@ -4577,7 +4577,7 @@ void AnimTask_SkullBashPosition(u8 taskId) gTasks[taskId].data[3] = 8; gTasks[taskId].data[4] = 0; gTasks[taskId].data[5] = 3; - if (a == 0) + if (side == B_SIDE_PLAYER) gTasks[taskId].data[5] *= -1; gTasks[taskId].func = AnimTask_SkullBashPositionSet; @@ -4586,7 +4586,7 @@ void AnimTask_SkullBashPosition(u8 taskId) gTasks[taskId].data[3] = 8; gTasks[taskId].data[4] = 0x600; gTasks[taskId].data[5] = 0xC0; - if (a == 0) + if (side == B_SIDE_PLAYER) { gTasks[taskId].data[4] = -gTasks[taskId].data[4]; gTasks[taskId].data[5] = -gTasks[taskId].data[5]; diff --git a/src/battle_main.c b/src/battle_main.c index 903588fe7..06e458a68 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -199,8 +199,8 @@ EWRAM_DATA u32 gHitMarker = 0; EWRAM_DATA static u8 sUnusedBattlersArray[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u8 gUnusedFirstBattleVar2 = 0; // Never read -EWRAM_DATA u16 gSideStatuses[2] = {0}; -EWRAM_DATA struct SideTimer gSideTimers[2] = {0}; +EWRAM_DATA u16 gSideStatuses[NUM_BATTLE_SIDES] = {0}; +EWRAM_DATA struct SideTimer gSideTimers[NUM_BATTLE_SIDES] = {0}; EWRAM_DATA u32 gStatuses3[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u16 gPauseCounterBattle = 0;