summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_ai_script_commands.c7
-rw-r--r--src/battle_anim_sound_tasks.c8
-rw-r--r--src/battle_dome.c11
-rw-r--r--src/battle_factory_screen.c5
-rw-r--r--src/battle_pyramid.c6
-rw-r--r--src/egg_hatch.c3
-rw-r--r--src/item.c1
-rw-r--r--src/roulette.c4
-rw-r--r--src/siirtc.c5
-rw-r--r--src/union_room.c7
10 files changed, 48 insertions, 9 deletions
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index 9fdd4d0c3..81e7c15cc 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -1877,9 +1877,14 @@ static void Cmd_if_has_move_with_effect(void)
case AI_TARGET_PARTNER:
for (i = 0; i < MAX_MON_MOVES; i++)
{
- // UB: checks sBattler_AI instead of gBattlerTarget.
+ // BUG: checks sBattler_AI instead of gBattlerTarget.
+ #ifndef BUGFIX
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
break;
+ #else
+ if (gBattleMons[gBattlerTarget].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
+ break;
+ #endif
}
if (i == MAX_MON_MOVES)
gAIScriptPtr += 7;
diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c
index 8fc93c3aa..39d6729e8 100644
--- a/src/battle_anim_sound_tasks.c
+++ b/src/battle_anim_sound_tasks.c
@@ -135,8 +135,10 @@ void SoundTask_PlayCryHighPitch(u8 taskId)
{
if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species;
+ #ifndef UBFIX
else
- DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task.
+ DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice.
+ #endif
}
else
{
@@ -179,8 +181,10 @@ void SoundTask_PlayDoubleCry(u8 taskId)
{
if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species;
+ #ifndef UBFIX
else
- DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task.
+ DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice.
+ #endif
}
else
{
diff --git a/src/battle_dome.c b/src/battle_dome.c
index a3bf3dadf..59e418a06 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -2766,13 +2766,22 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
}
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
- // BUG: TYPE_x2 is not necessary and makes the condition always false if the ability is wonder guard.
+ // BUG: the value of TYPE_x2 does not exist in gTypeEffectiveness, so if defAbility is ABILITY_WONDER_GUARD, the conditional always fails
+ #ifndef BUGFIX
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ #else
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ #endif
}
i += 3;
}
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index 680c6e81c..db810e965 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -4221,12 +4221,17 @@ static void Task_OpenMonPic(u8 taskId)
return;
break;
default:
+ #ifndef UBFIX
DestroyTask(taskId);
+ #endif
// UB: Should not use the task after it has been deleted.
if (gTasks[taskId].tIsSwapScreen == TRUE)
Swap_CreateMonSprite();
else
Select_CreateMonSprite();
+ #ifdef UBFIX
+ DestroyTask(taskId);
+ #endif
return;
}
task->tState++;
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index a41a80bbb..8eb09bb8d 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -1399,8 +1399,12 @@ void GenerateBattlePyramidWildMon(void)
for (i = 0; i < MAX_MON_MOVES; i++)
SetMonMoveSlot(&gEnemyParty[0], wildMons[id].moves[i], i);
- // BUG: Reading outside the array as lvl was used for mon level instead of frontier lvl mode.
+ // UB: Reading outside the array as lvl was used for mon level instead of frontier lvl mode.
+ #ifndef UBFIX
if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] >= 140)
+ #else
+ if (gSaveBlock2Ptr->frontier.pyramidWinStreas[gSaveBlock2Ptr->frontier.lvlMode] >= 140)
+ #endif
{
id = (Random() % 17) + 15;
for (i = 0; i < NUM_STATS; i++)
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index 7a3019f56..576e5c0d9 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -584,6 +584,9 @@ static void Task_EggHatchPlayBGM(u8 taskID)
PlayBGM(MUS_EVOLUTION);
DestroyTask(taskID);
// UB: task is destroyed, yet the value is incremented
+ #ifdef UBFIX
+ return;
+ #endif
}
gTasks[taskID].data[0]++;
}
diff --git a/src/item.c b/src/item.c
index 68907b02c..156034262 100644
--- a/src/item.c
+++ b/src/item.c
@@ -548,7 +548,6 @@ bool8 AddPCItem(u16 itemId, u16 count)
void RemovePCItem(u8 index, u16 count)
{
- // UB: should use GetPCItemQuantity and SetPCItemQuantity functions
gSaveBlock1Ptr->pcItems[index].quantity -= count;
if (gSaveBlock1Ptr->pcItems[index].quantity == 0)
{
diff --git a/src/roulette.c b/src/roulette.c
index 1ea69dc2e..adde16199 100644
--- a/src/roulette.c
+++ b/src/roulette.c
@@ -2896,7 +2896,9 @@ static const union AnimCmd sAnim_CreditDigit[] =
ANIMCMD_FRAME(18, 0), // 9
// BUG: Animation not terminated properly
// Doesn't matter in practice, the frames are set directly and not looped
- //ANIMCMD_END
+#ifdef BUGFIX
+ ANIMCMD_END
+#endif
};
static const union AnimCmd *const sAnims_CreditDigit[] =
diff --git a/src/siirtc.c b/src/siirtc.c
index 5c153a841..01d2e0e72 100644
--- a/src/siirtc.c
+++ b/src/siirtc.c
@@ -417,6 +417,9 @@ static u8 ReadData()
u8 i;
u8 temp;
u8 value;
+ #ifdef UBFIX
+ value = 0;
+ #endif
for (i = 0; i < 8; i++)
{
@@ -428,7 +431,7 @@ static u8 ReadData()
GPIO_PORT_DATA = SCK_HI | CS_HI;
temp = ((GPIO_PORT_DATA & SIO_HI) >> 1);
- value = (value >> 1) | (temp << 7); // UB: accessing uninitialized var
+ value = (value >> 1) | (temp << 7); // UB: value is uninitialized on first iteration
}
return value;
diff --git a/src/union_room.c b/src/union_room.c
index f41cfd45f..bd6b303b9 100644
--- a/src/union_room.c
+++ b/src/union_room.c
@@ -319,8 +319,13 @@ static void StringExpandPlaceholders_AwaitingCommFromAnother(u8 *dst, u8 caseId)
case ACTIVITY_CONTEST_CUTE:
case ACTIVITY_CONTEST_SMART:
case ACTIVITY_CONTEST_TOUGH:
- // UB: argument *dst isn't used, instead it always prints to gStringVar4
+ // BUG: argument *dst isn't used, instead it always prints to gStringVar4
+ // not an issue in practice since Gamefreak never used any other arguments here besides gStringVar4
+ #ifndef BUGFIX
StringExpandPlaceholders(gStringVar4, sText_AwaitingCommunication);
+ #else
+ StringExpandPlaceholders(dst, sText_AwaitingCommunication);
+ #endif
break;
}
}