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.
This commit is contained in:
Michael Panzlaff
2020-05-09 14:49:51 +02:00
parent 46f4a4bbf7
commit 3264cf697f
10 changed files with 79 additions and 45 deletions

View File

@@ -764,11 +764,11 @@ void ClearTVShowData(void)
for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows); i ++)
{
gSaveBlock1Ptr->tvShows[i].common.kind = 0;
gSaveBlock1Ptr->tvShows[i].common.active = 0;
for (j = 0; j < sizeof(TVShow) - 2; j ++)
gSaveBlock1Ptr->tvShows[i].commonInit.kind = 0;
gSaveBlock1Ptr->tvShows[i].commonInit.active = 0;
for (j = 0; j < ARRAY_COUNT(gSaveBlock1Ptr->tvShows[i].commonInit.pad02); j ++)
{
gSaveBlock1Ptr->tvShows[i].common.pad02[j] = 0;
gSaveBlock1Ptr->tvShows[i].commonInit.pad02[j] = 0;
}
}
ClearPokemonNews();
@@ -3167,11 +3167,11 @@ void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx)
{
u8 i;
shows[idx].common.kind = TVSHOW_OFF_AIR;
shows[idx].common.active = FALSE;
for (i = 0; i < 34; i ++)
shows[idx].commonInit.kind = TVSHOW_OFF_AIR;
shows[idx].commonInit.active = FALSE;
for (i = 0; i < ARRAY_COUNT(shows[idx].commonInit.pad02); i++)
{
shows[idx].common.pad02[i] = 0;
shows[idx].commonInit.pad02[i] = 0;
}
}