Merge pull request #479 from Kurausukun/ubfix
Some checks failed
GithubCI / build (push) Has been cancelled

Add UBFIX Define and Standardize #ifdef vs #ifndef
This commit is contained in:
AnonymousRandomPerson
2026-04-30 01:01:05 -04:00
committed by GitHub
4 changed files with 15 additions and 9 deletions

View File

@@ -60,8 +60,14 @@ static inline bool8 AreStringsDifferent(const u8 *str1, const u8 *str2)
return strcmp(str1, str2) != 0;
}
#ifdef BUGFIX
#ifndef UBFIX
#define UBFIX
#endif
#endif
#ifdef MODERN
#define BUGFIX
#define UBFIX
#define NONMATCHING
#include "mini_printf.h"

View File

@@ -572,7 +572,7 @@ void TryResetDungeonMapTilesScheduledForCopy(void)
s32 x, y;
Dungeon *dungeon = gDungeon;
if (dungeon->dungeonMap.resetTilesScheduledForCopy) {
#ifdef BUGFIX
#ifdef UBFIX
for (y = 0; y < DUNGEON_MAP_MAX_Y; y++) {
for (x = 0; x < DUNGEON_MAP_MAX_X; x++) {
dungeon->dungeonMap.tileScheduledForCopy[y][x] = FALSE;
@@ -584,7 +584,7 @@ void TryResetDungeonMapTilesScheduledForCopy(void)
dungeon->dungeonMap.tileScheduledForCopy[y][x] = FALSE;
}
}
#endif // BUGFIX
#endif // UBFIX
dungeon->dungeonMap.resetTilesScheduledForCopy = FALSE;
}
}

View File

@@ -2480,17 +2480,17 @@ static s32 ExecuteScriptCommand(Action *action)
// making the target position nonsense. But even if they were correct,
// the way the cap is calculated would make the random offset biased off-center.
// This doesn't affect the released version because these script commands are never used.
#ifndef BUGFIX
#ifdef BUGFIX
action->callbacks->getHitboxCenter(action->parentObject, &scriptData->pos1);
scriptData->pos2.x = scriptData->pos1.x + ((OtherRandInt(curCmd.arg1 * 2 + 1) - curCmd.arg1) << 8);
scriptData->pos2.y = scriptData->pos1.y + ((OtherRandInt(curCmd.arg2 * 2 + 1) - curCmd.arg2) << 8);
#else
s32 cap1 = curCmd.arg1 * 2 - 1;
s32 cap2 = curCmd.arg2 * 2 - 1;
action->callbacks->getHitboxCenter(action->parentObject, &scriptData->pos1);
scriptData->pos2.x = scriptData->pos1.x + ((OtherRandInt(cap1) - curCmd.argShort) << 8);
scriptData->pos2.y = scriptData->pos1.y + ((OtherRandInt(cap2) - curCmd.arg1) << 8);
#else
action->callbacks->getHitboxCenter(action->parentObject, &scriptData->pos1);
scriptData->pos2.x = scriptData->pos1.x + ((OtherRandInt(curCmd.arg1 * 2 + 1) - curCmd.arg1) << 8);
scriptData->pos2.y = scriptData->pos1.y + ((OtherRandInt(curCmd.arg2 * 2 + 1) - curCmd.arg2) << 8);
#endif
if (curCmd.op == CMD_BYTE_7F || curCmd.op == CMD_BYTE_85) {
scriptData->unk2A = HYPOT;

View File

@@ -1177,7 +1177,7 @@ void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str)
// BUG: The background array is 161 entries long, but this function will potentially write
// up to index 160 + 12 = 172, overflowing the array.
#ifdef BUGFIX
#ifdef UBFIX
if (r5 > 160 - 12) {
r5 = 160 - 12;
}