diff options
Diffstat (limited to 'src/battle_tower.c')
-rw-r--r-- | src/battle_tower.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/battle_tower.c b/src/battle_tower.c index 6fc0cd5be..d7123f3d2 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -1336,10 +1336,15 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm) { for (k = 0; k < PLAYER_NAME_LENGTH; k++) { - // BUG: Wrong variable used, 'j' instead of 'k'. + #ifdef BUGFIX + if (gSaveBlock2Ptr->frontier.towerRecords[i].name[k] != newRecord->name[k]) + break; + if (newRecord->name[k] == EOS) + #else if (gSaveBlock2Ptr->frontier.towerRecords[i].name[j] != newRecord->name[j]) break; if (newRecord->name[j] == EOS) + #endif { k = PLAYER_NAME_LENGTH; break; @@ -2956,7 +2961,12 @@ static void FillPartnerParty(u16 trainerId) sStevenMons[i].species, sStevenMons[i].level, sStevenMons[i].fixedIV, - TRUE, i, // BUG: personality was stored in the 'j' variable. As a result, Steven's pokemon do not have the intended natures. + TRUE, + #ifdef BUGFIX + j, + #else + i, // BUG: personality was stored in the 'j' variable. As a result, Steven's pokemon do not have the intended natures. + #endif OT_ID_PRESET, STEVEN_OTID); for (j = 0; j < PARTY_SIZE; j++) SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_HP_EV + j, &sStevenMons[i].evs[j]); @@ -3062,9 +3072,12 @@ bool32 RubyBattleTowerRecordToEmerald(struct RSBattleTowerRecord *src, struct Em { dst->lvlMode = src->lvlMode; dst->winStreak = src->winStreak; - // BUG: Reading outside the array. sRubyFacilityClassToEmerald has less than FACILITY_CLASSES_COUNT entries. - // Fix by using ARRAY_COUNT(sRubyFacilityClassToEmerald) + // UB: Reading outside the array. sRubyFacilityClassToEmerald has less than FACILITY_CLASSES_COUNT entries. + #ifdef UBFIX + for (i = 0; i < ARRAY_COUNT(sRubyFacilityClassToEmerald); i++) + #else for (i = 0; i < FACILITY_CLASSES_COUNT; i++) + #endif { if (sRubyFacilityClassToEmerald[i][0] == src->facilityClass) break; @@ -3112,9 +3125,12 @@ bool32 EmeraldBattleTowerRecordToRuby(struct EmeraldBattleTowerRecord *src, stru { dst->lvlMode = src->lvlMode; dst->winStreak = src->winStreak; - // BUG: Reading outside the array. sRubyFacilityClassToEmerald has less than FACILITY_CLASSES_COUNT entries. - // Fix by using ARRAY_COUNT(sRubyFacilityClassToEmerald) instead + // UB: Reading outside the array. sRubyFacilityClassToEmerald has less than FACILITY_CLASSES_COUNT entries. + #ifdef UBFIX + for (i = 0; i < ARRAY_COUNT(sRubyFacilityClassToEmerald); i++) + #else for (i = 0; i < FACILITY_CLASSES_COUNT; i++) + #endif { if (sRubyFacilityClassToEmerald[i][1] == src->facilityClass) break; |