From 1b0cfb075723af7b457ec118eca2888df449bf9e Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 18 Nov 2018 20:00:36 +0100 Subject: [PATCH 1/2] Party Size and Num Stats --- include/constants/pokemon.h | 7 +++++-- include/pokemon.h | 5 +---- src/battle_ai_switch_items.c | 2 +- src/battle_controller_link_opponent.c | 4 ++-- src/battle_controller_link_partner.c | 4 ++-- src/battle_controller_opponent.c | 4 ++-- src/battle_controller_player.c | 4 ++-- src/battle_controller_player_partner.c | 4 ++-- src/battle_controller_recorded_opponent.c | 4 ++-- src/battle_controller_recorded_player.c | 4 ++-- src/battle_controller_wally.c | 4 ++-- src/battle_dome.c | 10 +++++----- src/battle_main.c | 6 +++--- src/battle_script_commands.c | 16 ++++++++-------- src/battle_util.c | 6 +++--- src/egg_hatch.c | 6 +++--- src/field_player_avatar.c | 2 +- src/field_specials.c | 22 +++++++++++----------- src/hall_of_fame.c | 20 ++++++++++---------- src/lottery_corner.c | 21 ++++++++++----------- src/pokemon_size_record.c | 8 ++++---- src/post_battle_event_funcs.c | 2 +- src/scrcmd.c | 4 ++-- 23 files changed, 84 insertions(+), 85 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 78c1583b4..1a4741574 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -74,7 +74,10 @@ #define STAT_SPEED 3 #define STAT_SPATK 4 #define STAT_SPDEF 5 -#define STAT_ACC 6 // only in battles -#define STAT_EVASION 7 // only in battles +#define STAT_ACC 6 // Only in battles. +#define STAT_EVASION 7 // Only in battles. + +#define NUM_STATS 6 +#define NUM_BATTLE_STATS 8 #endif // GUARD_CONSTANTS_POKEMON_H diff --git a/include/pokemon.h b/include/pokemon.h index 7cf043ba3..3e69845e6 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -151,7 +151,6 @@ #define STATUS_PRIMARY_FAINTED 0x7 #define MAX_TOTAL_EVS 510 -#define NUM_STATS 6 #define UNOWN_FORM_COUNT 28 struct PokemonSubstruct0 @@ -293,8 +292,6 @@ struct Unknown_806F160_Struct struct SpriteFrameImage *frameImages; }; -#define BATTLE_STATS_NO 8 - struct BattlePokemon { /*0x00*/ u16 species; @@ -312,7 +309,7 @@ struct BattlePokemon /*0x17*/ u32 spDefenseIV:5; /*0x17*/ u32 isEgg:1; /*0x17*/ u32 altAbility:1; - /*0x18*/ s8 statStages[BATTLE_STATS_NO]; + /*0x18*/ s8 statStages[NUM_BATTLE_STATS]; /*0x20*/ u8 ability; /*0x21*/ u8 type1; /*0x22*/ u8 type2; diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 71d0e8381..ad25b483c 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -310,7 +310,7 @@ static bool8 AreStatsRaised(void) u8 buffedStatsValue = 0; s32 i; - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { if (gBattleMons[gActiveBattler].statStages[i] > 6) buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - 6; diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 2b6a356dd..0bf531c49 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -558,7 +558,7 @@ static void LinkOpponentHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += CopyLinkOpponentMonData(i, monData + size); @@ -892,7 +892,7 @@ static void LinkOpponentHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetLinkOpponentMonData(i); diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 203883c27..d84c1d296 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -444,7 +444,7 @@ static void LinkPartnerHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += CopyLinkPartnerMonData(i, monData + size); @@ -778,7 +778,7 @@ static void LinkPartnerHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetLinkPartnerMonData(i); diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 54726229d..2daee71db 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -541,7 +541,7 @@ static void OpponentHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += GetOpponentMonData(i, monData + size); @@ -884,7 +884,7 @@ static void OpponentHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetOpponentMonData(i); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index ad5ae2059..28657901f 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -1589,7 +1589,7 @@ static void PlayerHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += CopyPlayerMonData(i, monData + size); @@ -1932,7 +1932,7 @@ static void PlayerHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetPlayerMonData(i); diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 3572c1c69..26eb16ed5 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -632,7 +632,7 @@ static void PlayerPartnerHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += CopyPlayerPartnerMonData(i, monData + size); @@ -966,7 +966,7 @@ static void PlayerPartnerHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetPlayerPartnerMonData(i); diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 72667649f..3de09bb81 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -542,7 +542,7 @@ static void RecordedOpponentHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += CopyRecordedOpponentMonData(i, monData + size); @@ -876,7 +876,7 @@ static void RecordedOpponentHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetRecordedOpponentMonData(i); diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index b74d55cc8..108542269 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -527,7 +527,7 @@ static void RecordedPlayerHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += CopyRecordedPlayerMonData(i, monData + size); @@ -861,7 +861,7 @@ static void RecordedPlayerHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetRecordedPlayerMonData(i); diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index f7e9831a7..a82d45fc4 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -442,7 +442,7 @@ static void WallyHandleGetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) size += CopyWallyMonData(i, monData + size); @@ -776,7 +776,7 @@ static void WallyHandleSetMonData(void) else { monToCheck = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) SetWallyMonData(i); diff --git a/src/battle_dome.c b/src/battle_dome.c index 2a77da180..f0627e48d 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2756,17 +2756,17 @@ static void CalcDomeMonStats(u16 species, s32 level, s32 ivs, u8 evBits, u8 natu s32 i, count; u8 bits; u16 resultingEvs; - s32 evs[6]; + s32 evs[NUM_STATS]; count = 0, bits = evBits; - for (i = 0; i < 6; bits >>= 1, i++) + for (i = 0; i < NUM_STATS; bits >>= 1, i++) { if (bits & 1) count++; } resultingEvs = MAX_TOTAL_EVS / count; - for (i = 0; i < 6; bits <<= 1, i++) + for (i = 0; i < NUM_STATS; bits <<= 1, i++) { evs[i] = 0; if (evBits & bits) @@ -4953,7 +4953,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) for (i = 0; i < 3; i++) { s32 evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread; - for (k = 0, j = 0; j < 6; j++) + for (k = 0, j = 0; j < NUM_STATS; j++) { allocatedArray[j] = 0; if (evBits & 1) @@ -4962,7 +4962,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId) } k = MAX_TOTAL_EVS / k; evBits = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[trainerTournamentId][i]].evSpread; - for (j = 0; j < 6; j++) + for (j = 0; j < NUM_STATS; j++) { if (evBits & 1) allocatedArray[j] = k; diff --git a/src/battle_main.c b/src/battle_main.c index f6c01aee2..4f5540616 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3095,7 +3095,7 @@ void SwitchInClearSetData(void) if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) { - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) gBattleMons[gActiveBattler].statStages[i] = 6; for (i = 0; i < gBattlersCount; i++) { @@ -3204,7 +3204,7 @@ void FaintClearSetData(void) s32 i; u8 *ptr; - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) gBattleMons[gActiveBattler].statStages[i] = 6; gBattleMons[gActiveBattler].status2 = 0; @@ -3358,7 +3358,7 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].altAbility); hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)]; *hpOnSwitchout = gBattleMons[gActiveBattler].hp; - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) gBattleMons[gActiveBattler].statStages[i] = 6; gBattleMons[gActiveBattler].status2 = 0; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 665ee3750..8e084a46c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3285,7 +3285,7 @@ static void atk23_getexp(void) u16 calculatedExp; s32 viaSentIn; - for (viaSentIn = 0, i = 0; i < 6; i++) + for (viaSentIn = 0, i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) continue; @@ -3543,7 +3543,7 @@ static void atk24(void) } else { - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i]))) @@ -3556,7 +3556,7 @@ static void atk24(void) if (HP_count == 0) gBattleOutcome |= B_OUTCOME_LOST; - for (HP_count = 0, i = 0; i < 6; i++) + for (HP_count = 0, i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostOpponentMons & gBitTable[i]))) @@ -4952,7 +4952,7 @@ static void atk4D_switchindataupdate(void) if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { gBattleMons[gActiveBattler].statStages[i] = oldData.statStages[i]; } @@ -7406,7 +7406,7 @@ static void atk8A_normalisebuffs(void) // haze for (i = 0; i < gBattlersCount; i++) { - for (j = 0; j < BATTLE_STATS_NO; j++) + for (j = 0; j < NUM_BATTLE_STATS; j++) gBattleMons[i].statStages[j] = 6; } @@ -9034,7 +9034,7 @@ static void atkBD_copyfoestats(void) // psych up { s32 i; - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { gBattleMons[gBattlerAttacker].statStages[i] = gBattleMons[gBattlerTarget].statStages[i]; } @@ -9868,7 +9868,7 @@ static void atkE5_pickup(void) if (InBattlePyramid()) { - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); @@ -9891,7 +9891,7 @@ static void atkE5_pickup(void) } else { - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); diff --git a/src/battle_util.c b/src/battle_util.c index 6fb5f4bdc..251a545c9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2616,7 +2616,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gBattleStruct->moneyMultiplier = 2; break; case HOLD_EFFECT_RESTORE_STATS: - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { if (gBattleMons[battlerId].statStages[i] < 6) { @@ -2687,7 +2687,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_RESTORE_STATS: - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { if (gBattleMons[battlerId].statStages[i] < 6) { @@ -3163,7 +3163,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_RESTORE_STATS: - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { if (gBattleMons[battlerId].statStages[i] < 6) { diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 43beef442..4b7ee9a61 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -305,7 +305,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp) u32 personality, pokerus; u8 i, friendship, language, gameMet, markings, obedience; u16 moves[4]; - u32 ivs[6]; + u32 ivs[NUM_STATS]; species = GetMonData(egg, MON_DATA_SPECIES); @@ -317,7 +317,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp) personality = GetMonData(egg, MON_DATA_PERSONALITY); - for (i = 0; i < 6; i++) + for (i = 0; i < NUM_STATS; i++) { ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i); } @@ -335,7 +335,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp) SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]); } - for (i = 0; i < 6; i++) + for (i = 0; i < NUM_STATS; i++) { SetMonData(temp, MON_DATA_HP_IV + i, &ivs[i]); } diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index f0a8da7d7..a5aa23e32 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -1306,7 +1306,7 @@ bool8 PartyHasMonWithSurf(void) if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) { - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE) break; diff --git a/src/field_specials.c b/src/field_specials.c index 113f46922..562127890 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -2052,26 +2052,26 @@ _08139D7C:\n\ void sub_8139D98(void) { u8 i; - u32 ivStorage[6]; + u32 ivStorage[NUM_STATS]; - ivStorage[0] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_HP_IV); - ivStorage[1] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ATK_IV); - ivStorage[2] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_DEF_IV); - ivStorage[3] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPEED_IV); - ivStorage[4] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPATK_IV); - ivStorage[5] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPDEF_IV); + ivStorage[STAT_HP] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_HP_IV); + ivStorage[STAT_ATK] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ATK_IV); + ivStorage[STAT_DEF] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_DEF_IV); + ivStorage[STAT_SPEED] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPEED_IV); + ivStorage[STAT_SPATK] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPATK_IV); + ivStorage[STAT_SPDEF] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPDEF_IV); gSpecialVar_0x8005 = 0; - for (i = 0; i < ARRAY_COUNT(ivStorage); i++) + for (i = 0; i < NUM_STATS; i++) { gSpecialVar_0x8005 += ivStorage[i]; } gSpecialVar_0x8006 = 0; - gSpecialVar_0x8007 = ivStorage[0]; // HP IV + gSpecialVar_0x8007 = ivStorage[STAT_HP]; - for (i = 1; i < 6; i++) + for (i = 1; i < NUM_STATS; i++) { if (ivStorage[gSpecialVar_0x8006] < ivStorage[i]) { @@ -2081,7 +2081,7 @@ void sub_8139D98(void) else if (ivStorage[gSpecialVar_0x8006] == ivStorage[i]) { u16 randomNumber = Random(); - if ((randomNumber & 1) != 0) + if (randomNumber & 1) { gSpecialVar_0x8006 = i; gSpecialVar_0x8007 = ivStorage[i]; diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 22206405b..12f04092b 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -438,7 +438,7 @@ static void Task_Hof_InitMonData(u8 taskId) gTasks[taskId].tMonNumber = 0; // valid pokes - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { u8 nick[POKEMON_NAME_LENGTH + 2]; if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)) @@ -468,7 +468,7 @@ static void Task_Hof_InitMonData(u8 taskId) gTasks[taskId].tDisplayedMonId = 0; gTasks[taskId].tPlayerSpriteID = 0xFF; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { gTasks[taskId].tMonSpriteId(i) = 0xFF; } @@ -642,7 +642,7 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId) u16 i; BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, 0); - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (gTasks[taskId].tMonSpriteId(i) != 0xFF) gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 0; @@ -665,7 +665,7 @@ static void sub_8173DC0(u8 taskId) else { u16 i; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (gTasks[taskId].tMonSpriteId(i) != 0xFF) gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1; @@ -748,7 +748,7 @@ static void Task_Hof_HandleExit(u8 taskId) { s32 i; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { u8 spriteId = gTasks[taskId].tMonSpriteId(i); if (spriteId != 0xFF) @@ -844,7 +844,7 @@ void CB2_DoHallOfFamePC(void) SetGpuReg(REG_OFFSET_BLDY, 0); taskId = CreateTask(Task_HofPC_CopySaveData, 0); - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { gTasks[taskId].tMonSpriteId(i) = 0xFF; } @@ -901,7 +901,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId) gTasks[taskId].tCurrMonId = 0; gTasks[taskId].tMonNo = 0; - for (i = 0; i < 6; i++, currMon++) + for (i = 0; i < PARTY_SIZE; i++, currMon++) { if (currMon->species != 0) gTasks[taskId].tMonNo++; @@ -909,7 +909,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId) currMon = &savedTeams->mon[0]; - for (i = 0; i < 6; i++, currMon++) + for (i = 0; i < PARTY_SIZE; i++, currMon++) { if (currMon->species != 0) { @@ -963,7 +963,7 @@ static void Task_HofPC_PrintMonInfo(u8 taskId) for (i = 0; i < gTasks[taskId].tCurrTeamNo; i++) savedTeams++; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { u16 spriteId = gTasks[taskId].tMonSpriteId(i); if (spriteId != 0xFF) @@ -1056,7 +1056,7 @@ static void Task_HofPC_HandleExit(u8 taskId) { u8 i; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { u16 spriteId = gTasks[taskId].tMonSpriteId(i); if (spriteId != 0xFF) diff --git a/src/lottery_corner.c b/src/lottery_corner.c index 2ded9c943..f04fd0bdd 100644 --- a/src/lottery_corner.c +++ b/src/lottery_corner.c @@ -7,6 +7,7 @@ #include "constants/species.h" #include "string_util.h" #include "text.h" +#include "pokemon_storage_system.h" static EWRAM_DATA u16 sWinNumberDigit = 0; static EWRAM_DATA u16 sOtIdDigit = 0; @@ -55,23 +56,23 @@ void PickLotteryCornerTicket(void) gSpecialVar_0x8004 = 0; slot = 0; box = 0; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { - struct Pokemon *pkmn = &gPlayerParty[i]; + struct Pokemon *mon = &gPlayerParty[i]; // UB: Too few arguments for function GetMonData - if (GetMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE) + if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { // do not calculate ticket values for eggs. - if (!GetMonData(pkmn, MON_DATA_IS_EGG)) + if (!GetMonData(mon, MON_DATA_IS_EGG)) { - u32 otId = GetMonData(pkmn, MON_DATA_OT_ID); + u32 otId = GetMonData(mon, MON_DATA_OT_ID); u8 numMatchingDigits = GetMatchingDigits(gSpecialVar_Result, otId); if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { gSpecialVar_0x8004 = numMatchingDigits - 1; - box = 14; + box = TOTAL_BOXES_COUNT; slot = i; } } @@ -80,11 +81,9 @@ void PickLotteryCornerTicket(void) break; } - // player has 14 boxes. - for (i = 0; i < 14; i++) + for (i = 0; i < TOTAL_BOXES_COUNT; i++) { - // player has 30 slots per box. - for (j = 0; j < 30; j++) + for (j = 0; j < IN_BOX_COUNT; j++) { if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SPECIES) != SPECIES_NONE && !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_IS_EGG)) @@ -106,7 +105,7 @@ void PickLotteryCornerTicket(void) { gSpecialVar_0x8005 = sLotteryPrizes[gSpecialVar_0x8004 - 1]; - if (box == 14) + if (box == TOTAL_BOXES_COUNT) { gSpecialVar_0x8006 = 0; GetMonData(&gPlayerParty[slot], MON_DATA_NICKNAME, gStringVar1); diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index 473bbee03..2d9a2f08f 100644 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -206,13 +206,13 @@ void GiveGiftRibbonToParty(u8 index, u8 ribbonId) if (index < 11 && ribbonId < 65) { gSaveBlock1Ptr->giftRibbons[index] = ribbonId; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { - struct Pokemon *pkmn = &gPlayerParty[i]; + struct Pokemon *mon = &gPlayerParty[i]; - if (GetMonData(pkmn, MON_DATA_SPECIES) != 0 && GetMonData(pkmn, MON_DATA_SANITY_BIT3) == 0) + if (GetMonData(mon, MON_DATA_SPECIES) != 0 && GetMonData(mon, MON_DATA_SANITY_BIT3) == 0) { - SetMonData(pkmn, array[index], &data); + SetMonData(mon, array[index], &data); gotRibbon = TRUE; } } diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c index 9765ef5b6..934972b7c 100644 --- a/src/post_battle_event_funcs.c +++ b/src/post_battle_event_funcs.c @@ -43,7 +43,7 @@ int GameClear(void) ribbonGet = FALSE; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { struct Pokemon *mon = &gPlayerParty[i]; diff --git a/src/scrcmd.c b/src/scrcmd.c index 127a5ecaa..d2a6c2a17 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1713,8 +1713,8 @@ bool8 ScrCmd_checkpartymove(struct ScriptContext *ctx) u8 i; u16 moveId = ScriptReadHalfword(ctx); - gSpecialVar_Result = 6; - for (i = 0; i < 6; i++) + gSpecialVar_Result = PARTY_SIZE; + for (i = 0; i < PARTY_SIZE; i++) { u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); if (!species) From f58cc47e173900537200c796501386f4e3a1f0d6 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 18 Nov 2018 20:32:27 +0100 Subject: [PATCH 2/2] USE RGB constants in hall of fame --- src/hall_of_fame.c | 15 ++++++++------- src/lottery_corner.c | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 514eb365d..315990256 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -31,6 +31,7 @@ #include "trainer_pokemon_sprites.h" #include "data2.h" #include "rom_81520A8.h" +#include "constants/rgb.h" struct HallofFameMon { @@ -388,7 +389,7 @@ static bool8 InitHallOfFameScreen(void) if (!sub_8175024()) { SetVBlankCallback(VBlankCB_HallOfFame); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); gMain.state++; } break; @@ -626,7 +627,7 @@ static void Task_Hof_TryDisplayAnotherMon(u8 taskId) if (gTasks[taskId].tDisplayedMonId <= 4 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display { gTasks[taskId].tDisplayedMonId++; - BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, 0x63B0); + BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24)); gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.priority = 1; gTasks[taskId].func = Task_Hof_DisplayMon; } @@ -641,7 +642,7 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId) { u16 i; - BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, 0); + BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, RGB_BLACK); for (i = 0; i < PARTY_SIZE; i++) { if (gTasks[taskId].tMonSpriteId(i) != 0xFF) @@ -670,7 +671,7 @@ static void sub_8173DC0(u8 taskId) if (gTasks[taskId].tMonSpriteId(i) != 0xFF) gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1; } - BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, 0x63B0); + BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24)); FillWindowPixelBuffer(0, 0); CopyWindowToVram(0, 3); gTasks[taskId].tFrameCount = 7; @@ -738,7 +739,7 @@ static void Task_Hof_ExitOnKeyPressed(u8 taskId) static void Task_Hof_HandlePaletteOnExit(u8 taskId) { CpuCopy16(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); - BeginNormalPaletteFade(0xFFFFFFFF, 8, 0, 0x10, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 8, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_Hof_HandleExit; } @@ -940,7 +941,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId) } } - BlendPalettes(0xFFFF0000, 0xC, 0x63B0); + BlendPalettes(0xFFFF0000, 0xC, RGB(16, 29, 24)); ConvertIntToDecimalStringN(gStringVar1, gTasks[taskId].tCurrPageNo, STR_CONV_MODE_RIGHT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_HOFNumber); @@ -973,7 +974,7 @@ static void Task_HofPC_PrintMonInfo(u8 taskId) currMonID = gTasks[taskId].tMonSpriteId(gTasks[taskId].tCurrMonId); gSprites[currMonID].oam.priority = 0; sUnknown_0203BCD4 = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000; - BlendPalettesUnfaded(sUnknown_0203BCD4, 0xC, 0x63B0); + BlendPalettesUnfaded(sUnknown_0203BCD4, 0xC, RGB(16, 29, 24)); currMon = &savedTeams->mon[gTasks[taskId].tCurrMonId]; if (currMon->species != SPECIES_EGG) diff --git a/src/lottery_corner.c b/src/lottery_corner.c index f04fd0bdd..bd7d17ef7 100644 --- a/src/lottery_corner.c +++ b/src/lottery_corner.c @@ -60,7 +60,6 @@ void PickLotteryCornerTicket(void) { struct Pokemon *mon = &gPlayerParty[i]; - // UB: Too few arguments for function GetMonData if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { // do not calculate ticket values for eggs.