diff --git a/include/global.h b/include/global.h index c9c6cd845..7692df9ac 100644 --- a/include/global.h +++ b/include/global.h @@ -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" diff --git a/src/ground_script.c b/src/ground_script.c index b2d69d997..874317148 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -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; diff --git a/src/text_2.c b/src/text_2.c index 6b472f670..097dcb814 100644 --- a/src/text_2.c +++ b/src/text_2.c @@ -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; }