summaryrefslogtreecommitdiff
path: root/src/battle_controller_player.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle_controller_player.c')
-rw-r--r--src/battle_controller_player.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index 2d8fba63a..12ffca381 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -34,9 +34,6 @@
#include "constants/songs.h"
#include "constants/trainers.h"
-extern u8 gUnknown_0203CEE8;
-extern u8 gUnknown_0203CEE9;
-extern u8 gUnknown_0203CF00[];
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
@@ -406,7 +403,7 @@ static void HandleInputChooseTarget(void)
do
{
if (--i < 0)
- i = 4; // UB: array out of range
+ i = MAX_BATTLERS_COUNT; // UB: array out of range
gMultiUsePlayerCursor = GetBattlerAtPosition(identities[i]);
} while (gMultiUsePlayerCursor == gBattlersCount);
@@ -707,7 +704,7 @@ static void HandleMoveSwitching(void)
MoveSelectionDisplayMoveNames();
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
perMovePPBonuses[i] = (gBattleMons[gActiveBattler].ppBonuses & (3 << (i * 2))) >> (i * 2);
totalPPBonuses = perMovePPBonuses[gMoveSelectionCursor[gActiveBattler]];
@@ -715,12 +712,12 @@ static void HandleMoveSwitching(void)
perMovePPBonuses[gMultiUsePlayerCursor] = totalPPBonuses;
totalPPBonuses = 0;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
totalPPBonuses |= perMovePPBonuses[i] << (i * 2);
gBattleMons[gActiveBattler].ppBonuses = totalPPBonuses;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
gBattleMons[gActiveBattler].moves[i] = moveInfo->moves[i];
gBattleMons[gActiveBattler].pp[i] = moveInfo->currentPp[i];
@@ -728,14 +725,14 @@ static void HandleMoveSwitching(void)
if (!(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED))
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
moveStruct.moves[i] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MOVE1 + i);
moveStruct.currentPp[i] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_PP1 + i);
}
totalPPBonuses = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_PP_BONUSES);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
perMovePPBonuses[i] = (totalPPBonuses & (3 << (i * 2))) >> (i * 2);
i = moveStruct.moves[gMoveSelectionCursor[gActiveBattler]];
@@ -751,10 +748,10 @@ static void HandleMoveSwitching(void)
perMovePPBonuses[gMultiUsePlayerCursor] = totalPPBonuses;
totalPPBonuses = 0;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
totalPPBonuses |= perMovePPBonuses[i] << (i * 2);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
SetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MOVE1 + i, &moveStruct.moves[i]);
SetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_PP1 + i, &moveStruct.currentPp[i]);
@@ -872,7 +869,7 @@ static void sub_80586F8(void)
}
else
{
- if (sub_800A520())
+ if (IsLinkTaskFinished())
{
m4aSongNumStop(SE_HINSI);
gMain.inBattle = 0;
@@ -891,7 +888,7 @@ void sub_80587B0(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
- if (sub_800A520())
+ if (IsLinkTaskFinished())
{
if (gWirelessCommType == 0)
sub_800AC34();
@@ -1449,7 +1446,7 @@ static void MoveSelectionDisplayMoveNames(void)
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
gNumberOfMovesToChoose = 0;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
MoveSelectionDestroyCursorAt(i);
StringCopy(gDisplayedStringBattle, gMoveNames[moveInfo->moves[i]]);
@@ -1612,7 +1609,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst)
case REQUEST_ALL_BATTLE:
battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES);
battleMon.item = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM);
- for (size = 0; size < 4; size++)
+ for (size = 0; size < MAX_MON_MOVES; size++)
{
battleMon.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size);
battleMon.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
@@ -1659,7 +1656,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst)
size = 2;
break;
case REQUEST_MOVES_PP_BATTLE:
- for (size = 0; size < 4; size++)
+ for (size = 0; size < MAX_MON_MOVES; size++)
{
moveData.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size);
moveData.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
@@ -1679,7 +1676,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst)
size = 2;
break;
case REQUEST_PP_DATA_BATTLE:
- for (size = 0; size < 4; size++)
+ for (size = 0; size < MAX_MON_MOVES; size++)
dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES);
size++;
@@ -1953,7 +1950,7 @@ static void SetPlayerMonData(u8 monId)
SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &battlePokemon->species);
SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &battlePokemon->item);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &battlePokemon->moves[i]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &battlePokemon->pp[i]);
@@ -1992,7 +1989,7 @@ static void SetPlayerMonData(u8 monId)
SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_MOVES_PP_BATTLE:
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
{
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &moveData->moves[i]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &moveData->pp[i]);