use max mon moves constant where able (#480)

* use max mon moves constant where able

* fix errors in script commands file

* fix more errors
This commit is contained in:
melthelesbian
2018-12-25 12:50:15 -05:00
committed by Marcus Huderle
parent dcbc8db6a3
commit 2dd706ca54
33 changed files with 265 additions and 260 deletions

View File

@@ -403,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);
@@ -704,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]];
@@ -712,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];
@@ -725,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]];
@@ -748,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]);
@@ -1446,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]]);
@@ -1609,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);
@@ -1656,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);
@@ -1676,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++;
@@ -1950,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]);
@@ -1989,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]);