summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2020-12-12 23:28:01 -0500
committerGriffinR <griffin.g.richards@gmail.com>2020-12-12 23:30:51 -0500
commit81d95b9325ed2526ce638744408f453a8169abb4 (patch)
treee0f7100b6b35156f0868df537b2e3a149061dd52 /src
parentba3021db64bd9518f324c1ad89e63e90278f0eb4 (diff)
Use BUGFIX for some inline fixes
Diffstat (limited to 'src')
-rw-r--r--src/battle_ai_script_commands.c6
-rw-r--r--src/battle_dome.c14
-rw-r--r--src/battle_factory_screen.c6
-rw-r--r--src/battle_pyramid.c8
-rw-r--r--src/battle_tower.c28
-rw-r--r--src/battle_util.c7
-rw-r--r--src/berry_blender.c10
-rw-r--r--src/contest_ai.c10
-rw-r--r--src/daycare.c12
-rw-r--r--src/field_effect.c13
-rw-r--r--src/frontier_pass.c3
-rw-r--r--src/frontier_util.c14
-rw-r--r--src/match_call.c10
-rw-r--r--src/metatile_behavior.c9
-rw-r--r--src/pokemon.c5
-rw-r--r--src/pokemon_storage_system.c5
-rw-r--r--src/region_map.c4
-rw-r--r--src/roulette.c5
-rw-r--r--src/union_room.c10
19 files changed, 139 insertions, 40 deletions
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index 2423cfe37..651f9da2a 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -1613,8 +1613,10 @@ static void Cmd_if_status_not_in_party(void)
if (species != SPECIES_NONE && species != SPECIES_EGG && hp != 0 && status == statusToCompareTo)
{
- gAIScriptPtr += 10; // UB: Still bugged in Emerald. Uncomment the return statement to fix.
- // return;
+ gAIScriptPtr += 10;
+ #ifdef BUGFIX
+ return;
+ #endif
}
}
diff --git a/src/battle_dome.c b/src/battle_dome.c
index ce2f3cde6..0d1bee8cf 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -863,7 +863,9 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 372,
},
- // UB: No DUMMY_WIN_TEMPLATE at the array's end.
+ #ifdef UBFIX
+ DUMMY_WIN_TEMPLATE,
+ #endif
};
static const struct ScanlineEffectParams sTourneyTreeScanlineEffectParams =
@@ -2526,7 +2528,11 @@ static void CreateDomeOpponentMon(u8 monPartyId, u16 tournamentTrainerId, u8 tou
{
int i;
u8 friendship = MAX_FRIENDSHIP;
- u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Should be using (DOME_TRAINERS[tournamentTrainerId].trainerId) instead of (tournamentTrainerId). As a result, all Pokemon have ivs of 3.
+ #ifdef BUGFIX
+ u8 fixedIv = GetDomeTrainerMonIvs(DOME_TRAINERS[tournamentTrainerId].trainerId);
+ #else
+ u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Using the wrong ID. As a result, all Pokemon have ivs of 3.
+ #endif
u8 level = SetFacilityPtrsGetLevel();
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[monPartyId],
gFacilityTrainerMons[DOME_MONS[tournamentTrainerId][tournamentMonId]].species,
@@ -5964,6 +5970,10 @@ static void DecideRoundWinners(u8 roundId)
else if (tournamentId2 != 0xFF)
{
// BUG: points1 and points2 are not cleared at the beginning of the loop resulting in not fair results.
+ #ifdef BUGFIX
+ points1 = 0;
+ points2 = 0;
+ #endif
// Calculate points for both trainers.
for (monId1 = 0; monId1 < FRONTIER_PARTY_SIZE; monId1++)
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index c10bbc5e4..ba1e39006 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -3905,7 +3905,11 @@ static void Swap_ShowSummaryMonSprite(void)
personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL);
otId = GetMonData(mon, MON_DATA_OT_ID, NULL);
- sFactorySwapScreen->unk2C.field0 = CreateMonPicSprite_HandleDeoxys(species, personality, otId, TRUE, 88, 32, 15, 0xFFFF); // BUG: otId and personality should be switched.
+ #ifdef BUGFIX
+ sFactorySwapScreen->unk2C.field0 = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF);
+ #else
+ sFactorySwapScreen->unk2C.field0 = CreateMonPicSprite_HandleDeoxys(species, personality, otId, TRUE, 88, 32, 15, 0xFFFF);
+ #endif
gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecY = 0;
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index 1b220f145..ac6d95338 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -1757,7 +1757,9 @@ static bool8 SetPyramidObjectPositionsInAndNearSquare(u8 objType, u8 squareId)
r7 &= 1;
}
- // free(floorLayoutOffsets); BUG: floorLayoutOffsets memory not freed
+ #ifdef BUGFIX
+ free(floorLayoutOffsets);
+ #endif
return (numObjects / 2) > numPlacedObjects;
}
@@ -1809,7 +1811,9 @@ static bool8 SetPyramidObjectPositionsNearSquare(u8 objType, u8 squareId)
if (r8 == 4)
break;
}
- // free(floorLayoutOffsets); BUG: floorLayoutOffsets memory not freed
+ #ifdef BUGFIX
+ free(floorLayoutOffsets);
+ #endif
return (numObjects / 2) > numPlacedObjects;
}
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;
diff --git a/src/battle_util.c b/src/battle_util.c
index a30145ea4..e929de091 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -536,9 +536,12 @@ void HandleAction_ThrowPokeblock(void)
gBattleStruct->safariPkblThrowCounter++;
if (gBattleStruct->safariEscapeFactor > 1)
{
- // BUG: The safariEscapeFactor is unintetionally able to become 0 (but it can not become negative!). This causes the pokeblock throw glitch.
- // To fix that change the < in the if statement below to <=.
+ // BUG: safariEscapeFactor can become 0 below. This causes the pokeblock throw glitch.
+ #ifdef BUGFIX
+ if (gBattleStruct->safariEscapeFactor <= sPkblToEscapeFactor[gBattleStruct->safariPkblThrowCounter][gBattleCommunication[MULTISTRING_CHOOSER]])
+ #else
if (gBattleStruct->safariEscapeFactor < sPkblToEscapeFactor[gBattleStruct->safariPkblThrowCounter][gBattleCommunication[MULTISTRING_CHOOSER]])
+ #endif
gBattleStruct->safariEscapeFactor = 1;
else
gBattleStruct->safariEscapeFactor -= sPkblToEscapeFactor[gBattleStruct->safariPkblThrowCounter][gBattleCommunication[MULTISTRING_CHOOSER]];
diff --git a/src/berry_blender.c b/src/berry_blender.c
index 16ba42bd7..573affbd5 100644
--- a/src/berry_blender.c
+++ b/src/berry_blender.c
@@ -1852,7 +1852,9 @@ static void Task_HandleOpponent1(u8 taskId)
gRecvCmds[1][BLENDER_COMM_SCORE] = LINKCMD_BLENDER_SCORE_GOOD;
// BUG: Overrwrote above assignment. Opponent 1 can't get Best at low speed
+ #ifndef BUGFIX
gRecvCmds[1][BLENDER_COMM_SCORE] = LINKCMD_BLENDER_SCORE_GOOD;
+ #endif
}
else if (sBerryBlender->speed < 1500)
{
@@ -2131,11 +2133,17 @@ static void UpdateOpponentScores(void)
sBerryBlender->scores[i][SCORE_MISS]++;
}
- // BUG: Should [i][BLENDER_COMM_SCORE] below, not [BLENDER_COMM_SCORE][i]
+ // BUG: Should be [i][BLENDER_COMM_SCORE] below, not [BLENDER_COMM_SCORE][i]
// As a result the music tempo updates if any player misses, but only if 1 specific player hits
+ #ifdef BUGFIX
+ if (gRecvCmds[i][BLENDER_COMM_SCORE] == LINKCMD_BLENDER_SCORE_MISS
+ || gRecvCmds[i][BLENDER_COMM_SCORE] == LINKCMD_BLENDER_SCORE_BEST
+ || gRecvCmds[i][BLENDER_COMM_SCORE] == LINKCMD_BLENDER_SCORE_GOOD)
+ #else
if (gRecvCmds[i][BLENDER_COMM_SCORE] == LINKCMD_BLENDER_SCORE_MISS
|| gRecvCmds[BLENDER_COMM_SCORE][i] == LINKCMD_BLENDER_SCORE_BEST
|| gRecvCmds[BLENDER_COMM_SCORE][i] == LINKCMD_BLENDER_SCORE_GOOD)
+ #endif
{
if (sBerryBlender->speed > 1500)
m4aMPlayTempoControl(&gMPlayInfo_BGM, ((sBerryBlender->speed - 750) / 20) + 256);
diff --git a/src/contest_ai.c b/src/contest_ai.c
index 2f048718f..8fe339790 100644
--- a/src/contest_ai.c
+++ b/src/contest_ai.c
@@ -1734,8 +1734,9 @@ static void ContestAICmd_if_user_doesnt_have_exciting_move(void)
// they're checking for an effect. Checking for a specific effect would make more sense,
// but given that effects are normally read as a single byte and this reads 2 bytes, it
// seems reading a move was intended and the AI script is using it incorrectly.
-// In any case, to fix it to correctly check for effects replace the u16 move assignment with
-// u16 move = gContestMoves[gContestMons[eContestAI.contestantId].moves[i]].effect;
+// The fix below aligns the function with how it's used by the script, rather than the apparent
+// intention of its usage
+
static void ContestAICmd_check_user_has_move(void)
{
int hasMove = FALSE;
@@ -1744,7 +1745,12 @@ static void ContestAICmd_check_user_has_move(void)
for (i = 0; i < MAX_MON_MOVES; i++)
{
+ #ifdef BUGFIX
+ u16 move = gContestMoves[gContestMons[eContestAI.contestantId].moves[i]].effect;
+ #else
u16 move = gContestMons[eContestAI.contestantId].moves[i];
+ #endif
+
if (move == targetMove)
{
hasMove = TRUE;
diff --git a/src/daycare.c b/src/daycare.c
index d849b39f3..96f62d5bf 100644
--- a/src/daycare.c
+++ b/src/daycare.c
@@ -551,13 +551,15 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
// removes position 0 (HP) then position 1 (DEF), then position 2. This is why HP and DEF
// have a lower chance to be inherited in Emerald and why the IV picked for inheritance can
// be repeated. Amusingly, FRLG and RS also got this wrong. They remove selectedIvs[i], which
- // is not an index! This means that it can sometimes remove the wrong stat. To fix, delete
- // the following two lines and uncomment the rest of the block.
+ // is not an index! This means that it can sometimes remove the wrong stat.
+ #ifndef BUGFIX
selectedIvs[i] = availableIVs[Random() % (NUM_STATS - i)];
RemoveIVIndexFromList(availableIVs, i);
- // u8 index = Random() % (NUM_STATS - i);
- // selectedIvs[i] = availableIVs[index];
- // RemoveIVIndexFromList(availableIVs, index);
+ #else
+ u8 index = Random() % (NUM_STATS - i);
+ selectedIvs[i] = availableIVs[index];
+ RemoveIVIndexFromList(availableIVs, index);
+ #endif
}
// Determine which parent each of the selected IVs should inherit from.
diff --git a/src/field_effect.c b/src/field_effect.c
index 41f1a899c..5a18557eb 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -3846,7 +3846,6 @@ bool8 FldEff_MoveDeoxysRock(struct Sprite* sprite)
static void Task_MoveDeoxysRock(u8 taskId)
{
- // BUG: Possible divide by zero
s16 *data = gTasks[taskId].data;
struct Sprite *sprite = &gSprites[data[1]];
switch (data[0])
@@ -3854,8 +3853,16 @@ static void Task_MoveDeoxysRock(u8 taskId)
case 0:
data[4] = sprite->pos1.x << 4;
data[5] = sprite->pos1.y << 4;
- data[6] = (data[2] * 16 - data[4]) / data[8];
- data[7] = (data[3] * 16 - data[5]) / data[8];
+
+ // UB: Possible divide by zero
+ #ifdef UBFIX
+ #define DIVISOR (data[8] ? data[8] : 1);
+ #else
+ #define DIVISOR (data[8])
+ #endif
+
+ data[6] = (data[2] * 16 - data[4]) / DIVISOR;
+ data[7] = (data[3] * 16 - data[5]) / DIVISOR;
data[0]++;
case 1:
if (data[8] != 0)
diff --git a/src/frontier_pass.c b/src/frontier_pass.c
index 1b8030149..cf170b350 100644
--- a/src/frontier_pass.c
+++ b/src/frontier_pass.c
@@ -983,6 +983,9 @@ static void Task_HandleFrontierPassInput(u8 taskId)
SetMainCallback2(CB2_HideFrontierPass);
DestroyTask(taskId);
// BUG. The function should return here. Otherwise, it can play the same sound twice and destroy the same task twice.
+ #ifdef BUGFIX
+ return;
+ #endif
}
}
diff --git a/src/frontier_util.c b/src/frontier_util.c
index 83c9341d5..5955d9bf7 100644
--- a/src/frontier_util.c
+++ b/src/frontier_util.c
@@ -2383,13 +2383,21 @@ void ClearRankingHallRecords(void)
{
s32 i, j, k;
+ // BUG: Passing 0 as a pointer instead of a pointer holding a value of 0.
+ #ifdef BUGFIX
+ u8 zero = 0;
+ #define ZERO (&zero)
+ #else
+ #define ZERO 0
+ #endif
+
for (i = 0; i < HALL_FACILITIES_COUNT; i++)
{
for (j = 0; j < 2; j++)
{
for (k = 0; k < 3; k++)
{
- CopyTrainerId(gSaveBlock2Ptr->hallRecords1P[i][j][k].id, 0); // BUG: Passing 0 as a pointer instead of a pointer holding a value of 0.
+ CopyTrainerId(gSaveBlock2Ptr->hallRecords1P[i][j][k].id, ZERO);
gSaveBlock2Ptr->hallRecords1P[i][j][k].name[0] = EOS;
gSaveBlock2Ptr->hallRecords1P[i][j][k].winStreak = 0;
}
@@ -2400,8 +2408,8 @@ void ClearRankingHallRecords(void)
{
for (k = 0; k < 3; k++)
{
- CopyTrainerId(gSaveBlock2Ptr->hallRecords2P[j][k].id1, 0); // BUG: Passing 0 as a pointer instead of a pointer holding a value of 0.
- CopyTrainerId(gSaveBlock2Ptr->hallRecords2P[j][k].id2, 0); // BUG: Passing 0 as a pointer instead of a pointer holding a value of 0.
+ CopyTrainerId(gSaveBlock2Ptr->hallRecords2P[j][k].id1, ZERO);
+ CopyTrainerId(gSaveBlock2Ptr->hallRecords2P[j][k].id2, ZERO);
gSaveBlock2Ptr->hallRecords2P[j][k].name1[0] = EOS;
gSaveBlock2Ptr->hallRecords2P[j][k].name2[0] = EOS;
gSaveBlock2Ptr->hallRecords2P[j][k].winStreak = 0;
diff --git a/src/match_call.c b/src/match_call.c
index a39739f76..723562ade 100644
--- a/src/match_call.c
+++ b/src/match_call.c
@@ -1817,10 +1817,13 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
}
*topicTextId = 3;
break;
+ #ifdef BUGFIX
+ case FRONTIER_FACILITY_PIKE:
+ #else
case FRONTIER_FACILITY_FACTORY:
+ #endif
for (i = 0; i < 2; i++)
{
- // BUG: should be looking at battle factory records.
if (streak < gSaveBlock2Ptr->frontier.pikeRecordStreaks[i])
streak = gSaveBlock2Ptr->frontier.pikeRecordStreaks[i];
}
@@ -1848,12 +1851,15 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
}
*topicTextId = 2;
break;
+ #ifdef BUGFIX
+ case FRONTIER_FACILITY_FACTORY:
+ #else
case FRONTIER_FACILITY_PIKE:
+ #endif
for (i = 0; i < 2; i++)
{
for (j = 0; j < 2; j++)
{
- // BUG: should be looking at battle pike records.
if (streak < gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[i][j])
streak = gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[i][j];
}
diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c
index 51cc65c22..2a9304a4d 100644
--- a/src/metatile_behavior.c
+++ b/src/metatile_behavior.c
@@ -970,10 +970,13 @@ bool8 MetatileBehavior_IsUnableToEmerge(u8 metatileBehavior)
{
// BUG: The player is unintentionally able to emerge on water doors.
// Also the narrower underwater door in the underwater tileset has the wrong metatile behavior. This causes the dive glitch.
- // To fix that add || metatileBehavior == MB_WATER_DOOR to the if statement below and
- // change the metatile behavior of the narrower water door with porymaps tileset editor.
+ // To fix change the metatile behavior of the narrower water door with porymap's tileset editor.
if (metatileBehavior == MB_NO_SURFACING
- || metatileBehavior == MB_SEAWEED_NO_SURFACING)
+ || metatileBehavior == MB_SEAWEED_NO_SURFACING
+ #ifdef BUGFIX
+ || metatileBehavior == MB_WATER_DOOR
+ #endif
+ )
return TRUE;
else
return FALSE;
diff --git a/src/pokemon.c b/src/pokemon.c
index 3621284d6..7c546fcd5 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -2861,8 +2861,11 @@ void CalculateMonStats(struct Pokemon *mon)
currentHP = newMaxHP;
else if (currentHP != 0)
// BUG: currentHP is unintentionally able to become <= 0 after the instruction below. This causes the pomeg berry glitch.
- // To fix that set currentHP = 1 if currentHP <= 0.
currentHP += newMaxHP - oldMaxHP;
+ #ifdef BUGFIX
+ if (currentHP <= 0)
+ currentHP = 1;
+ #endif
else
return;
}
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index eb288c978..db8f3d2bb 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -9329,10 +9329,11 @@ u32 GetBoxMonLevelAt(u8 boxId, u8 boxPosition)
{
u32 lvl;
- // BUG: Missed 'else' statement.
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES))
lvl = GetLevelFromBoxMonExp(&gPokemonStoragePtr->boxes[boxId][boxPosition]);
- // else
+ #ifdef BUGFIX
+ else
+ #endif
lvl = 0;
return lvl;
diff --git a/src/region_map.c b/src/region_map.c
index 49b21be07..c2a5b4e9c 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -131,7 +131,11 @@ static const u16 sRegionMap_SpecialPlaceLocations[][2] =
{
{MAPSEC_UNDERWATER_105, MAPSEC_ROUTE_105},
{MAPSEC_UNDERWATER_124, MAPSEC_ROUTE_124},
+ #ifdef BUGFIX
+ {MAPSEC_UNDERWATER_125, MAPSEC_ROUTE_125},
+ #else
{MAPSEC_UNDERWATER_125, MAPSEC_ROUTE_129}, // BUG: Map will incorrectly display the name of Route 129 when diving on Route 125 (for Marine Cave only)
+ #endif
{MAPSEC_UNDERWATER_126, MAPSEC_ROUTE_126},
{MAPSEC_UNDERWATER_127, MAPSEC_ROUTE_127},
{MAPSEC_UNDERWATER_128, MAPSEC_ROUTE_128},
diff --git a/src/roulette.c b/src/roulette.c
index b4d1c4463..4173edcdb 100644
--- a/src/roulette.c
+++ b/src/roulette.c
@@ -463,8 +463,9 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0xC5
},
- // BUG: Array not terminated properly
- //DUMMY_WIN_TEMPLATE
+ #ifdef UBFIX
+ DUMMY_WIN_TEMPLATE,
+ #endif
};
static const struct GridSelection sGridSelections[NUM_GRID_SELECTIONS + 1] =
diff --git a/src/union_room.c b/src/union_room.c
index 3e80ffe37..479792a7c 100644
--- a/src/union_room.c
+++ b/src/union_room.c
@@ -478,7 +478,11 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
// BUG: sPlayerActivityGroupSize was meant below, not gPlayerCurrActivity
// This will be false for all but ACTIVITY_BATTLE_DOUBLE and ACTIVITY_DECLINE
// All this changes is which of two texts gets printed
+ #ifdef BUGFIX
+ id = (GROUP_MAX(sPlayerActivityGroupSize) == 2) ? 0 : 1;
+ #else
id = (GROUP_MAX(gPlayerCurrActivity) == 2) ? 1 : 0;
+ #endif
if (PrintOnTextbox(&data->textState, sPlayerUnavailableTexts[id]))
{
data->playerCount = sub_8013398(data->field_0);
@@ -1320,7 +1324,11 @@ static bool32 IsPartnerActivityAcceptable(u32 activity, u32 linkGroup)
if (linkGroup == 0xFF)
return TRUE;
- if (linkGroup <= ARRAY_COUNT(sAcceptedActivityIds)) // UB: <= may access data outside the array
+ #ifdef UBFIX
+ if (linkGroup < ARRAY_COUNT(sAcceptedActivityIds))
+ #else
+ if (linkGroup <= ARRAY_COUNT(sAcceptedActivityIds))
+ #endif
{
const u8 *bytes = sAcceptedActivityIds[linkGroup];