From 95f075ec905da35ff1bc97f70a92c13a5a218c9a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 13 Jun 2022 15:01:04 -0400 Subject: [PATCH] Remove erroneous bugfix --- src/match_call.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/match_call.c b/src/match_call.c index de7f13416..8b25d5b44 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -33,6 +33,13 @@ #include "constants/songs.h" #include "constants/trainers.h" +// In this file only the values normally associated with Battle Pike and Factory are swapped. +// Note that this is *not* a bug, because they are properly swapped consistently in this file. +// There would only be an issue if anything in this file interacted with something expecting +// the usual value order, or vice versa. +#define MATCH_CALL_FACTORY FRONTIER_FACILITY_PIKE +#define MATCH_CALL_PIKE FRONTIER_FACILITY_FACTORY + // Each match call message has variables that can be populated randomly or // dependent on the trainer. The below are IDs for how to populate the vars // in a given message. @@ -1590,6 +1597,7 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 * rand = Random(); if (!(rand & 1)) { + // Count the number of facilities with a win streak for (count = 0, i = 0; i < NUM_FRONTIER_FACILITIES; i++) { if (GetFrontierStreakInfo(i, &topic) > 1) @@ -1598,6 +1606,8 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 * if (count) { + // At least one facility with a win streak + // Randomly choose one to have a call about count = Random() % count; for (i = 0; i < NUM_FRONTIER_FACILITIES; i++) { @@ -1807,15 +1817,15 @@ static void PopulateSpeciesFromTrainerParty(int matchCallId, u8 *destStr) StringCopy(destStr, speciesName); } -static const u8 *const sBattleFrontierFacilityNames[] = +static const u8 *const sBattleFrontierFacilityNames[NUM_FRONTIER_FACILITIES] = { - gText_BattleTower2, - gText_BattleDome, - gText_BattlePalace, - gText_BattleArena, - gText_BattlePike, - gText_BattleFactory, - gText_BattlePyramid, + [FRONTIER_FACILITY_TOWER] = gText_BattleTower2, + [FRONTIER_FACILITY_DOME] = gText_BattleDome, + [FRONTIER_FACILITY_PALACE] = gText_BattlePalace, + [FRONTIER_FACILITY_ARENA] = gText_BattleArena, + [MATCH_CALL_PIKE] = gText_BattlePike, + [MATCH_CALL_FACTORY] = gText_BattleFactory, + [FRONTIER_FACILITY_PYRAMID] = gText_BattlePyramid, }; static void PopulateBattleFrontierFacilityName(int matchCallId, u8 *destStr) @@ -1899,7 +1909,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) switch (facilityId) { case FRONTIER_FACILITY_DOME: - for (i = 0; i < 2; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.domeRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) { @@ -1909,11 +1919,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) } *topicTextId = GEN_TOPIC_B_DOME - 1; break; - #ifdef BUGFIX - case FRONTIER_FACILITY_PIKE: - #else - case FRONTIER_FACILITY_FACTORY: - #endif + case MATCH_CALL_PIKE: for (i = 0; i < FRONTIER_LVL_MODE_COUNT; i++) { if (streak < gSaveBlock2Ptr->frontier.pikeRecordStreaks[i]) @@ -1922,7 +1928,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) *topicTextId = GEN_TOPIC_B_PIKE - 1; break; case FRONTIER_FACILITY_TOWER: - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.towerRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) { @@ -1933,7 +1939,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; case FRONTIER_FACILITY_PALACE: - for (i = 0; i < 2; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.palaceRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) { @@ -1943,12 +1949,8 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) } *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; - #ifdef BUGFIX - case FRONTIER_FACILITY_FACTORY: - #else - case FRONTIER_FACILITY_PIKE: - #endif - for (i = 0; i < 2; i++) + case MATCH_CALL_FACTORY: + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.factoryRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) {