From f53e2491bfe41cea6e912bef1692c2961927ef23 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 1 Jun 2020 10:23:12 -0400 Subject: Document union_room_player_avatar.c --- src/fieldmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/fieldmap.c') diff --git a/src/fieldmap.c b/src/fieldmap.c index 21bbaa8f8..753f4451f 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -917,11 +917,11 @@ void GetCameraCoords(u16 *x, u16 *y) *y = gSaveBlock1Ptr->pos.y; } -void sub_8088B94(int x, int y, int a2) +void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable) { if (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height) { - if (a2 != 0) + if (impassable) gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK; else gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK; -- cgit v1.2.3 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/fieldmap.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/fieldmap.c') diff --git a/src/fieldmap.c b/src/fieldmap.c index e953e0f93..25157ebb1 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -533,9 +533,16 @@ static bool32 SavedMapViewIsEmpty(void) u16 i; u32 marker = 0; +#ifndef UBFIX // BUG: This loop extends past the bounds of the mapView array. Its size is only 0x100. for (i = 0; i < 0x200; i++) marker |= gSaveBlock1Ptr->mapView[i]; +#else + // UBFIX: Only iterate over 0x100 + for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->mapView); i++) + marker |= gSaveBlock1Ptr->mapView[i]; +#endif + if (marker == 0) return TRUE; -- cgit v1.2.3