From 3b91735e63409f4c5fd88d9984b036a6304952f9 Mon Sep 17 00:00:00 2001 From: MCboy Date: Fri, 6 Nov 2020 22:59:46 +0330 Subject: [PATCH 1/2] use constants for ball throw count --- include/battle.h | 4 +++- src/tv.c | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/battle.h b/include/battle.h index 8dad6bc251..a58f69cda7 100644 --- a/include/battle.h +++ b/include/battle.h @@ -12,6 +12,8 @@ #include "battle_util2.h" #include "battle_bg.h" +#include "pokeball.h" // i'm not sure about this one + #define GET_BATTLER_POSITION(battler) (gBattlerPositions[battler]) #define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE) #define GET_BATTLER_SIDE2(battler) (GET_BATTLER_POSITION(battler) & BIT_SIDE) @@ -255,7 +257,7 @@ struct BattleResults u16 caughtMonSpecies; // 0x28 u8 caughtMonNick[POKEMON_NAME_LENGTH + 1]; // 0x2A u8 filler35; // 0x35 - u8 catchAttempts[11]; // 0x36 + u8 catchAttempts[POKEBALL_COUNT-1]; // 0x36 Doesn't include Master ball }; struct BattleTv_Side diff --git a/src/tv.c b/src/tv.c index 17af3edff4..b401de06f3 100644 --- a/src/tv.c +++ b/src/tv.c @@ -32,6 +32,7 @@ #include "decoration.h" #include "secret_base.h" #include "tv.h" +#include "pokeball.h" #include "data.h" #include "constants/battle_frontier.h" #include "constants/contest.h" @@ -963,7 +964,7 @@ void GabbyAndTyBeforeInterview(void) } if (!gBattleResults.usedMasterBall) { - for (i = 0; i < 11; i ++) + for (i = 0; i < POKEBALL_COUNT-1; i ++) { if (gBattleResults.catchAttempts[i]) { @@ -1135,7 +1136,7 @@ void PutPokemonTodayCaughtOnAir(void) sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_CAUGHT, FALSE) != TRUE) { - for (i = 0; i < 11; i ++) + for (i = 0; i < POKEBALL_COUNT-1; i ++) { ct += gBattleResults.catchAttempts[i]; } @@ -1152,7 +1153,7 @@ void PutPokemonTodayCaughtOnAir(void) } else { - for (i = 0; i < 11; i ++) + for (i = 0; i < POKEBALL_COUNT-1; i ++) { ct += gBattleResults.catchAttempts[i]; } @@ -1203,7 +1204,7 @@ void PutPokemonTodayFailedOnTheAir(void) if (!rbernoulli(1, 1)) { - for (i = 0, ct = 0; i < 11; i ++) + for (i = 0, ct = 0; i < POKEBALL_COUNT-1; i ++) { ct += gBattleResults.catchAttempts[i]; } @@ -2228,7 +2229,7 @@ void sub_80EE184(void) show->breakingNews.kind = TVSHOW_BREAKING_NEWS; show->breakingNews.active = FALSE; balls = 0; - for (i = 0; i < 11; i ++) + for (i = 0; i < POKEBALL_COUNT-1; i ++) { balls += gBattleResults.catchAttempts[i]; } From e31158d017c71110d421864beee166d1facbebd9 Mon Sep 17 00:00:00 2001 From: MCboy Date: Fri, 6 Nov 2020 23:29:52 +0330 Subject: [PATCH 2/2] add spaces around - and remove comment from include in battle.h --- include/battle.h | 5 ++--- src/tv.c | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/battle.h b/include/battle.h index a58f69cda7..820684a699 100644 --- a/include/battle.h +++ b/include/battle.h @@ -11,8 +11,7 @@ #include "battle_gfx_sfx_util.h" #include "battle_util2.h" #include "battle_bg.h" - -#include "pokeball.h" // i'm not sure about this one +#include "pokeball.h" #define GET_BATTLER_POSITION(battler) (gBattlerPositions[battler]) #define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE) @@ -257,7 +256,7 @@ struct BattleResults u16 caughtMonSpecies; // 0x28 u8 caughtMonNick[POKEMON_NAME_LENGTH + 1]; // 0x2A u8 filler35; // 0x35 - u8 catchAttempts[POKEBALL_COUNT-1]; // 0x36 Doesn't include Master ball + u8 catchAttempts[POKEBALL_COUNT - 1]; // 0x36 Doesn't include Master ball }; struct BattleTv_Side diff --git a/src/tv.c b/src/tv.c index b401de06f3..748915c7a4 100644 --- a/src/tv.c +++ b/src/tv.c @@ -964,7 +964,7 @@ void GabbyAndTyBeforeInterview(void) } if (!gBattleResults.usedMasterBall) { - for (i = 0; i < POKEBALL_COUNT-1; i ++) + for (i = 0; i < POKEBALL_COUNT - 1; i ++) { if (gBattleResults.catchAttempts[i]) { @@ -1136,7 +1136,7 @@ void PutPokemonTodayCaughtOnAir(void) sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_CAUGHT, FALSE) != TRUE) { - for (i = 0; i < POKEBALL_COUNT-1; i ++) + for (i = 0; i < POKEBALL_COUNT - 1; i ++) { ct += gBattleResults.catchAttempts[i]; } @@ -1153,7 +1153,7 @@ void PutPokemonTodayCaughtOnAir(void) } else { - for (i = 0; i < POKEBALL_COUNT-1; i ++) + for (i = 0; i < POKEBALL_COUNT - 1; i ++) { ct += gBattleResults.catchAttempts[i]; } @@ -1204,7 +1204,7 @@ void PutPokemonTodayFailedOnTheAir(void) if (!rbernoulli(1, 1)) { - for (i = 0, ct = 0; i < POKEBALL_COUNT-1; i ++) + for (i = 0, ct = 0; i < POKEBALL_COUNT - 1; i ++) { ct += gBattleResults.catchAttempts[i]; } @@ -2229,7 +2229,7 @@ void sub_80EE184(void) show->breakingNews.kind = TVSHOW_BREAKING_NEWS; show->breakingNews.active = FALSE; balls = 0; - for (i = 0; i < POKEBALL_COUNT-1; i ++) + for (i = 0; i < POKEBALL_COUNT - 1; i ++) { balls += gBattleResults.catchAttempts[i]; }