From 3264cf697f5fe996c2a79c6c34181c186fe2f96e Mon Sep 17 00:00:00 2001 From: Michael Panzlaff Date: Sat, 9 May 2020 14:49:51 +0200 Subject: fix aggressive loop optimizations Previously, aggressive loop optimizations with a new compiler were not possible due to undefined behaviour at end of arrays. A macro "UBFIX" is added to allow ifdefs for fixes which resolve undefined behavior. For example newer GCC versions will detect various bugs in the original game code and will otherwise not compile with -Werror. --- src/easy_chat.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/easy_chat.c') diff --git a/src/easy_chat.c b/src/easy_chat.c index 1bdb3fdc0..2a4c49213 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -5273,12 +5273,17 @@ void InitEasyChatPhrases(void) gSaveBlock1Ptr->mail[i].words[j] = 0xFFFF; } +#ifndef UBFIX // BUG: This is supposed to clear 64 bits, but this loop is clearing 64 bytes. // However, this bug has no resulting effect on gameplay because only the // Mauville old man data is corrupted, which is initialized directly after // this function is called when starting a new game. for (i = 0; i < 64; i++) gSaveBlock1Ptr->additionalPhrases[i] = 0; +#else + for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->additionalPhrases); i++) + gSaveBlock1Ptr->additionalPhrases[i] = 0; +#endif } static bool8 sub_811F28C(void) -- cgit v1.2.3