Use MAX_MON_MOVES constants

This commit is contained in:
GriffinR 2019-09-08 11:53:48 -04:00 committed by huderlem
parent 258784f263
commit 85d97542cd
24 changed files with 81 additions and 81 deletions

View file

@ -37,7 +37,6 @@
#define B_ACTION_NONE 0xFF
#define MAX_TRAINER_ITEMS 4
#define MAX_MON_MOVES 4
// array entries for battle communication
#define MULTIUSE_STATE 0x0
@ -180,19 +179,19 @@ struct AI_ThinkingStruct
u8 aiState;
u8 movesetIndex;
u16 moveConsidered;
s8 score[4];
s8 score[MAX_MON_MOVES];
u32 funcResult;
u32 aiFlags;
u8 aiAction;
u8 aiLogicId;
u8 filler12[6];
u8 simulatedRNG[4];
u8 simulatedRNG[MAX_MON_MOVES];
};
struct UsedMoves
{
u16 moves[MAX_BATTLERS_COUNT];
u16 unknown[MAX_BATTLERS_COUNT];
u16 moves[MAX_MON_MOVES];
u16 unknown[MAX_MON_MOVES];
};
struct BattleHistory

View file

@ -97,16 +97,16 @@ struct HpAndStatus
struct MovePpInfo
{
u16 moves[4];
u8 pp[4];
u16 moves[MAX_MON_MOVES];
u8 pp[MAX_MON_MOVES];
u8 ppBonuses;
};
struct ChooseMoveStruct
{
u16 moves[4];
u8 currentPp[4];
u8 maxPp[4];
u16 moves[MAX_MON_MOVES];
u8 currentPp[MAX_MON_MOVES];
u8 maxPp[MAX_MON_MOVES];
u16 species;
u8 monType1;
u8 monType2;

View file

@ -7,7 +7,7 @@ struct RSBattleTowerRecord
/*0x01*/ u8 facilityClass;
/*0x02*/ u16 winStreak;
/*0x04*/ u8 name[PLAYER_NAME_LENGTH + 1];
/*0x0C*/ u8 trainerId[4];
/*0x0C*/ u8 trainerId[TRAINER_ID_LENGTH];
/*0x10*/ u16 greeting[6];
/*0x1C*/ struct BattleTowerPokemon party[3];
/*0xA0*/ u32 checksum;
@ -27,7 +27,7 @@ struct BattleFrontierTrainer
struct FacilityMon
{
u16 species;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
u8 itemTableId;
u8 evSpread;
u8 nature;

View file

@ -51,6 +51,7 @@
#define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode.
#define TRAINER_ID_LENGTH 4
#define MAX_MON_MOVES 4
// string lengths
#define ITEM_NAME_LENGTH 14

View file

@ -227,7 +227,7 @@ struct ContestPokemon
u8 aiPool_Cute:1; // 0x10
u8 aiPool_Smart:1; // 0x20
u8 aiPool_Tough:1; // 0x40
/*0x1E*/ u16 moves[4]; // moves
/*0x1E*/ u16 moves[MAX_MON_MOVES]; // moves
/*0x26*/ u8 cool; // cool
/*0x27*/ u8 beauty; // beauty
/*0x28*/ u8 cute; // cute

View file

@ -34,7 +34,7 @@ struct TrainerMonNoItemCustomMoves
u16 iv;
u8 lvl;
u16 species;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
};
struct TrainerMonItemCustomMoves
@ -43,7 +43,7 @@ struct TrainerMonItemCustomMoves
u8 lvl;
u16 species;
u16 heldItem;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
};
union TrainerMonPtr

View file

@ -212,7 +212,7 @@ struct BerryCrush
struct ApprenticeMon
{
u16 species;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
u16 item;
};
@ -234,7 +234,7 @@ struct BattleTowerPokemon
{
u16 species;
u16 heldItem;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
u8 level;
u8 ppBonuses;
u8 hpEV;
@ -290,7 +290,7 @@ struct BattleTowerEReaderTrainer
struct FrontierMonData
{
u16 moves[4];
u16 moves[MAX_MON_MOVES];
u8 evs[6];
u8 nature;
};
@ -946,7 +946,7 @@ struct SaveBlock1
/*0x2B94*/ u8 outbreakPokemonLevel;
/*0x2B95*/ u8 outbreakUnk1;
/*0x2B96*/ u16 outbreakUnk2;
/*0x2B98*/ u16 outbreakPokemonMoves[4];
/*0x2B98*/ u16 outbreakPokemonMoves[MAX_MON_MOVES];
/*0x2BA0*/ u8 outbreakUnk4;
/*0x2BA1*/ u8 outbreakPokemonProbability;
/*0x2BA2*/ u16 outbreakDaysLeft;

View file

@ -482,7 +482,7 @@ typedef union // size = 0x24
/*0x01*/ bool8 active;
/*0x02*/ u8 var02;
/*0x03*/ u8 var03;
/*0x04*/ u16 moves[4];
/*0x04*/ u16 moves[MAX_MON_MOVES];
/*0x0C*/ u16 species;
/*0x0E*/ u16 var0E;
/*0x10*/ u8 locationMapNum;

View file

@ -145,8 +145,8 @@ struct PokemonSubstruct0
struct PokemonSubstruct1
{
u16 moves[4];
u8 pp[4];
u16 moves[MAX_MON_MOVES];
u8 pp[MAX_MON_MOVES];
};
struct PokemonSubstruct2
@ -273,7 +273,7 @@ struct BattlePokemon
/*0x06*/ u16 speed;
/*0x08*/ u16 spAttack;
/*0x0A*/ u16 spDefense;
/*0x0C*/ u16 moves[4];
/*0x0C*/ u16 moves[MAX_MON_MOVES];
/*0x14*/ u32 hpIV:5;
/*0x14*/ u32 attackIV:5;
/*0x15*/ u32 defenseIV:5;
@ -287,7 +287,7 @@ struct BattlePokemon
/*0x21*/ u8 type1;
/*0x22*/ u8 type2;
/*0x23*/ u8 unknown;
/*0x24*/ u8 pp[4];
/*0x24*/ u8 pp[MAX_MON_MOVES];
/*0x28*/ u16 hp;
/*0x2A*/ u8 level;
/*0x2B*/ u8 friendship;

View file

@ -1100,7 +1100,7 @@ void ResetAllApprenticeData(void)
gSaveBlock2Ptr->apprentices[i].lvlMode = 0;
gSaveBlock2Ptr->apprentices[i].number = 0;
gSaveBlock2Ptr->apprentices[i].field_1 = 0;
for (j = 0; j < 4; j++)
for (j = 0; j < TRAINER_ID_LENGTH; j++)
gSaveBlock2Ptr->apprentices[i].playerId[j] = 0;
gSaveBlock2Ptr->apprentices[i].language = gGameLanguage;
gSaveBlock2Ptr->apprentices[i].checksum = 0;
@ -1410,7 +1410,7 @@ static void GetLatestLearnedMoves(u16 species, u16 *moves)
static u16 sub_81A0284(u8 arg0, u8 speciesTableId, u8 arg2)
{
u16 moves[4];
u16 moves[MAX_MON_MOVES];
u8 i, count;
if (PLAYER_APPRENTICE.field_B1_1 < 3)
@ -2063,7 +2063,7 @@ static void sub_81A1370(void)
r10 = 0xFFFF;
r9 = -1;
for (i = 1; i < 4; i++)
for (i = 1; i < TRAINER_ID_LENGTH; i++)
{
if (GetTrainerId(gSaveBlock2Ptr->apprentices[i].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId)
&& gSaveBlock2Ptr->apprentices[i].number < r10)
@ -2092,7 +2092,7 @@ static void sub_81A1438(void)
gSaveBlock2Ptr->apprentices[0].number++;
sub_81A0390(gSaveBlock2Ptr->apprentices[0].field_1);
for (i = 0; i < 4; i++)
for (i = 0; i < TRAINER_ID_LENGTH; i++)
gSaveBlock2Ptr->apprentices[0].playerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
StringCopy(gSaveBlock2Ptr->apprentices[0].playerName, gSaveBlock2Ptr->playerName);

View file

@ -397,8 +397,8 @@ u8 BattleAI_ChooseMoveOrAction(void)
static u8 ChooseMoveOrAction_Singles(void)
{
u8 currentMoveArray[4];
u8 consideredMoveArray[4];
u8 currentMoveArray[MAX_MON_MOVES];
u8 consideredMoveArray[MAX_MON_MOVES];
u8 numOfBestMoves;
s32 i;
@ -452,11 +452,11 @@ static u8 ChooseMoveOrAction_Doubles(void)
s32 i;
s32 j;
s32 scriptsToRun;
s16 bestMovePointsForTarget[4];
s8 mostViableTargetsArray[4];
u8 actionOrMoveIndex[4];
u8 mostViableMovesScores[4];
u8 mostViableMovesIndices[4];
s16 bestMovePointsForTarget[MAX_BATTLERS_COUNT];
s8 mostViableTargetsArray[MAX_BATTLERS_COUNT];
u8 actionOrMoveIndex[MAX_BATTLERS_COUNT];
u8 mostViableMovesScores[MAX_MON_MOVES];
u8 mostViableMovesIndices[MAX_MON_MOVES];
s32 mostViableTargetsNo;
s32 mostViableMovesNo;
s16 mostMovePoints;
@ -543,7 +543,7 @@ static u8 ChooseMoveOrAction_Doubles(void)
mostViableTargetsArray[0] = 0;
mostViableTargetsNo = 1;
for (i = 1; i < MAX_MON_MOVES; i++)
for (i = 1; i < MAX_BATTLERS_COUNT; i++)
{
if (mostMovePoints == bestMovePointsForTarget[i])
{
@ -1167,7 +1167,7 @@ static void BattleAICmd_get_considered_move_power(void)
static void BattleAICmd_get_how_powerful_move_is(void)
{
s32 i, checkedMove;
s32 moveDmgs[4];
s32 moveDmgs[MAX_MON_MOVES];
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++)
{

View file

@ -664,7 +664,7 @@ u32 sub_8057FBC(void) // unused
static void HandleMoveSwitching(void)
{
u8 perMovePPBonuses[4];
u8 perMovePPBonuses[MAX_MON_MOVES];
struct ChooseMoveStruct moveStruct;
u8 totalPPBonuses;

View file

@ -49,7 +49,7 @@ struct PikeWildMon
{
u16 species;
u8 levelDelta;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
};
// IWRAM bss

View file

@ -77,7 +77,7 @@ struct PyramidWildMon
u16 species;
u8 lvl;
u8 abilityNum;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
};
struct PyramidFloorTemplate

View file

@ -1019,7 +1019,7 @@ struct
u8 level;
u8 nature;
u8 evs[6];
u16 moves[4];
u16 moves[MAX_MON_MOVES];
} const sStevenMons[3] =
{
{
@ -1561,7 +1561,7 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm)
for (i = 0; i < 5; i++)
{
k = 0;
for (j = 0; j < 4; j++)
for (j = 0; j < TRAINER_ID_LENGTH; j++)
{
if (gSaveBlock2Ptr->frontier.towerRecords[i].trainerId[j] != newRecord->trainerId[j])
break;
@ -3308,7 +3308,7 @@ bool32 RubyBattleTowerRecordToEmerald(struct RSBattleTowerRecord *src, struct Em
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
dst->name[i] = src->name[i];
for (i = 0; i < 4; i++)
for (i = 0; i < TRAINER_ID_LENGTH; i++)
dst->trainerId[i] = src->trainerId[i];
for (i = 0; i < 6; i++)
dst->greeting[i] = src->greeting[i];
@ -3357,7 +3357,7 @@ bool32 EmeraldBattleTowerRecordToRuby(struct EmeraldBattleTowerRecord *src, stru
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
dst->name[i] = src->name[i];
for (i = 0; i < 4; i++)
for (i = 0; i < TRAINER_ID_LENGTH; i++)
dst->trainerId[i] = src->trainerId[i];
for (i = 0; i < 6; i++)
dst->greeting[i] = src->greeting[i];

View file

@ -34,10 +34,10 @@ static void DaycarePrintMonInfo(u8 windowId, s32 daycareSlotId, u8 y);
// RAM buffers used to assist with BuildEggMoveset()
EWRAM_DATA static u16 sHatchedEggLevelUpMoves[EGG_LVL_UP_MOVES_ARRAY_COUNT] = {0};
EWRAM_DATA static u16 sHatchedEggFatherMoves[4] = {0};
EWRAM_DATA static u16 sHatchedEggFinalMoves[4] = {0};
EWRAM_DATA static u16 sHatchedEggFatherMoves[MAX_MON_MOVES] = {0};
EWRAM_DATA static u16 sHatchedEggFinalMoves[MAX_MON_MOVES] = {0};
EWRAM_DATA static u16 sHatchedEggEggMoves[EGG_MOVES_ARRAY_COUNT] = {0};
EWRAM_DATA static u16 sHatchedEggMotherMoves[4] = {0};
EWRAM_DATA static u16 sHatchedEggMotherMoves[MAX_MON_MOVES] = {0};
#include "data/pokemon/egg_moves.h"

View file

@ -298,13 +298,13 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
u16 species;
u32 personality, pokerus;
u8 i, friendship, language, gameMet, markings, obedience;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
u32 ivs[NUM_STATS];
species = GetMonData(egg, MON_DATA_SPECIES);
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_MON_MOVES; i++)
{
moves[i] = GetMonData(egg, MON_DATA_MOVE1 + i);
}
@ -324,7 +324,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
CreateMon(temp, species, EGG_HATCH_LEVEL, 32, TRUE, personality, OT_ID_PLAYER_ID, 0);
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_MON_MOVES; i++)
{
SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]);
}

View file

@ -154,7 +154,7 @@ static EWRAM_DATA struct
{
u8 state;
u8 heartSpriteIds[16]; /*0x001*/
u16 movesToLearn[4]; /*0x012*/
u16 movesToLearn[MAX_MON_MOVES]; /*0x012*/
u8 filler1A[0x44 - 0x1A]; /*0x01A*/
u8 partyMon; /*0x044*/
u8 moveSlot; /*0x045*/

View file

@ -2989,11 +2989,11 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove)
void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move)
{
s32 i;
u16 moves[4];
u8 pp[4];
u16 moves[MAX_MON_MOVES];
u8 pp[MAX_MON_MOVES];
u8 ppBonuses;
for (i = 0; i < 3; i++)
for (i = 0; i < MAX_MON_MOVES - 1; i++)
{
moves[i] = GetMonData(mon, MON_DATA_MOVE2 + i, NULL);
pp[i] = GetMonData(mon, MON_DATA_PP2 + i, NULL);
@ -3016,11 +3016,11 @@ void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move)
void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move)
{
s32 i;
u16 moves[4];
u8 pp[4];
u16 moves[MAX_MON_MOVES];
u8 pp[MAX_MON_MOVES];
u8 ppBonuses;
for (i = 0; i < 3; i++)
for (i = 0; i < MAX_MON_MOVES - 1; i++)
{
moves[i] = GetBoxMonData(boxMon, MON_DATA_MOVE2 + i, NULL);
pp[i] = GetBoxMonData(boxMon, MON_DATA_PP2 + i, NULL);
@ -3304,21 +3304,21 @@ u8 CountAliveMonsInBattle(u8 caseId)
switch (caseId)
{
case BATTLE_ALIVE_EXCEPT_ACTIVE:
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
case BATTLE_ALIVE_ATK_SIDE:
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBattlerSide(i) == GetBattlerSide(gBattlerAttacker) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
case BATTLE_ALIVE_DEF_SIDE:
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
@ -6096,7 +6096,7 @@ u32 CanSpeciesLearnTMHM(u16 species, u8 tm)
u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves)
{
u16 learnedMoves[4];
u16 learnedMoves[MAX_MON_MOVES];
u8 numMoves = 0;
u16 species = GetMonData(mon, MON_DATA_SPECIES, 0);
u8 level = GetMonData(mon, MON_DATA_LEVEL, 0);
@ -6146,7 +6146,7 @@ u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves)
u8 GetNumberOfRelearnableMoves(struct Pokemon *mon)
{
u16 learnedMoves[4];
u16 learnedMoves[MAX_MON_MOVES];
u16 moves[20];
u8 numMoves = 0;
u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0);

View file

@ -121,8 +121,8 @@ static EWRAM_DATA struct PokemonSummaryScreenData
u8 metGame; // 0xB
u32 pid; // 0xC
u32 exp; // 0x10
u16 moves[4]; // 0x14
u8 pp[4]; // 0x1C
u16 moves[MAX_MON_MOVES]; // 0x14
u8 pp[MAX_MON_MOVES]; // 0x1C
u16 currentHP; // 0x20
u16 maxHP; // 0x22
u16 atk; // 0x24

View file

@ -37,8 +37,8 @@ struct PlayerInfo
struct MovePp
{
u16 moves[4];
u8 pp[4];
u16 moves[MAX_MON_MOVES];
u8 pp[MAX_MON_MOVES];
};
struct RecordedBattleSave
@ -91,7 +91,7 @@ EWRAM_DATA static u32 sBattleFlags = 0;
EWRAM_DATA static u32 sAI_Scripts = 0;
EWRAM_DATA static struct Pokemon sSavedPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0};
EWRAM_DATA static u16 sPlayerMonMoves[2][4] = {0};
EWRAM_DATA static u16 sPlayerMonMoves[2][MAX_MON_MOVES] = {0};
EWRAM_DATA static struct PlayerInfo sPlayers[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u8 sUnknown_0203CCD0 = 0;
EWRAM_DATA static u8 sRecordMixFriendName[PLAYER_NAME_LENGTH + 1] = {0};
@ -766,11 +766,11 @@ void sub_818603C(u8 arg0)
{
if (sBattleRecords[battlerId][sRecordedBytesNo[battlerId]] == ACTION_MOVE_CHANGE)
{
u8 ppBonuses[4];
u8 array1[4];
u8 array2[4];
u8 ppBonuses[MAX_MON_MOVES];
u8 array1[MAX_MON_MOVES];
u8 array2[MAX_MON_MOVES];
struct MovePp movePp;
u8 array3[8];
u8 array3[(MAX_MON_MOVES * 2)];
u8 var;
RecordedBattle_GetBattlerAction(battlerId);

View file

@ -349,7 +349,7 @@ void SetPlayerSecretBase(void)
u16 i;
gSaveBlock1Ptr->secretBases[0].secretBaseId = sCurSecretBaseId;
for (i = 0; i < 4; i++)
for (i = 0; i < TRAINER_ID_LENGTH; i++)
gSaveBlock1Ptr->secretBases[0].trainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
VarSet(VAR_CURRENT_SECRET_BASE, 0);
@ -1291,7 +1291,7 @@ static void SetSecretBaseDataAndLanguage(u8 secretBaseId, struct SecretBase *sec
static bool8 SecretBasesHaveSameTrainerId(struct SecretBase *secretBase1, struct SecretBase *secretBase2)
{
u8 i;
for (i = 0; i < 4; i++)
for (i = 0; i < TRAINER_ID_LENGTH; i++)
{
if (secretBase1->trainerId[i] != secretBase2->trainerId[i])
return FALSE;
@ -1445,7 +1445,7 @@ bool8 SecretBaseBelongsToPlayer(struct SecretBase *secretBase)
return FALSE;
// Check if the player's trainer Id matches the secret base's id.
for (i = 0; i < 4; i++)
for (i = 0; i < TRAINER_ID_LENGTH; i++)
{
if (secretBase->trainerId[i] != gSaveBlock2Ptr->playerTrainerId[i])
return FALSE;

View file

@ -3032,7 +3032,7 @@ static u8 sub_8079A3C(u8 *str, u8 whichParty, u8 monIdx)
static void sub_8079AA4(u8 *a0, u8 a1, u8 a2)
{
u16 arr[4];
u16 moves[MAX_MON_MOVES];
u16 i;
if (!gUnknown_0203229C->unk_51[a1][a2])
@ -3041,11 +3041,11 @@ static void sub_8079AA4(u8 *a0, u8 a1, u8 a2)
{
if (!a1)
{
arr[i] = GetMonData(&gPlayerParty[a2], i + MON_DATA_MOVE1, NULL);
moves[i] = GetMonData(&gPlayerParty[a2], i + MON_DATA_MOVE1, NULL);
}
else
{
arr[i] = GetMonData(&gEnemyParty[a2], i + MON_DATA_MOVE1, NULL);
moves[i] = GetMonData(&gEnemyParty[a2], i + MON_DATA_MOVE1, NULL);
}
}
@ -3053,9 +3053,9 @@ static void sub_8079AA4(u8 *a0, u8 a1, u8 a2)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (arr[i] != MOVE_NONE)
if (moves[i] != MOVE_NONE)
{
StringAppend(a0, gMoveNames[arr[i]]);
StringAppend(a0, gMoveNames[moves[i]]);
}
StringAppend(a0, gText_NewLine3);

View file

@ -182,7 +182,7 @@ static void DoTVShowPokemonContestLiveUpdates2(void);
static const struct {
u16 species;
u16 moves[4];
u16 moves[MAX_MON_MOVES];
u8 level;
u8 location;
} sPokeOutbreakSpeciesList[] = {
@ -2329,7 +2329,7 @@ void sub_80EE35C(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u1
show->battleSeminar.foeSpecies = foeSpecies;
show->battleSeminar.species = species;
show->battleSeminar.move = movePtr[moveIdx];
for (i = 0, j = 0; i < 4; i ++)
for (i = 0, j = 0; i < MAX_MON_MOVES; i ++)
{
if (i != moveIdx && movePtr[i])
{