diff --git a/include/fieldmap.h b/include/fieldmap.h index a166e785a..7caadfcaa 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -26,7 +26,7 @@ u32 MapGridGetMetatileBehaviorAt(int, int); void MapGridSetMetatileIdAt(int, int, u16); void MapGridSetMetatileEntryAt(int, int, u16); void GetCameraCoords(u16 *, u16 *); -bool8 MapGridIsImpassableAt(int, int); +u8 MapGridGetCollisionAt(int, int); int GetMapBorderIdAt(int x, int y); bool32 CanCameraMoveInDirection(int direction); u16 GetMetatileAttributesById(u16 metatileId); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 7ea712be6..69377cac6 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4630,7 +4630,7 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir) u8 direction = dir; if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) return COLLISION_OUTSIDE_RANGE; - else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction)) + else if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction)) return COLLISION_IMPASSABLE; else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)) return COLLISION_IMPASSABLE; @@ -4647,7 +4647,7 @@ u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 d if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) flags |= 1 << (COLLISION_OUTSIDE_RANGE - 1); - if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))) + if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))) flags |= 1 << (COLLISION_IMPASSABLE - 1); if (IsElevationMismatchAt(objectEvent->currentElevation, x, y)) flags |= 1 << (COLLISION_ELEVATION_MISMATCH - 1); diff --git a/src/fieldmap.c b/src/fieldmap.c index 581005af0..2b981dc6e 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -352,7 +352,7 @@ u8 MapGridGetElevationAt(int x, int y) return block >> MAPGRID_ELEVATION_SHIFT; } -bool8 MapGridIsImpassableAt(int x, int y) +u8 MapGridGetCollisionAt(int x, int y) { u16 block = GetMapGridBlockAt(x, y); diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 9129c5208..689958ca2 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -191,7 +191,12 @@ bool8 SetUpFieldMove_Cut(void) sHyperCutTiles[6 + (i * 5) + j] = TRUE; ret = TRUE; } - if (MapGridIsImpassableAt(x, y) == TRUE) + #ifdef BUGFIX + // Collision has a range 0-3, any value != 0 is impassable + if (MapGridGetCollisionAt(x, y)) + #else + if (MapGridGetCollisionAt(x, y) == 1) + #endif { cutTiles[i * 3 + j] = FALSE; } diff --git a/src/item_use.c b/src/item_use.c index e3604b064..4d0919dac 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -247,7 +247,7 @@ static bool32 CanFish(void) } else { - if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior) && !MapGridIsImpassableAt(x, y)) + if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior) && MapGridGetCollisionAt(x, y) == 0) return TRUE; if (MetatileBehavior_IsBridgeOverWaterNoEdge(tileBehavior) == TRUE) return TRUE; diff --git a/src/overworld.c b/src/overworld.c index 812568d01..66d7be99b 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -129,7 +129,7 @@ static void ResetAllPlayerLinkStates(void); static void UpdateHeldKeyCode(u16); static void UpdateAllLinkPlayers(u16 *, s32); static u8 FlipVerticalAndClearForced(u8, u8); -static u8 LinkPlayerDetectCollision(u8, u8, s16, s16); +static u8 LinkPlayerGetCollision(u8, u8, s16, s16); static void CreateLinkPlayerSprite(u8, u8); static void GetLinkPlayerCoords(u8, u16 *, u16 *); static u8 GetLinkPlayerFacingDirection(u8); @@ -3087,7 +3087,7 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer linkDirection(objEvent) = FlipVerticalAndClearForced(dir, linkDirection(objEvent)); ObjectEventMoveDestCoords(objEvent, linkDirection(objEvent), &x, &y); - if (LinkPlayerDetectCollision(linkPlayerObjEvent->objEventId, linkDirection(objEvent), x, y)) + if (LinkPlayerGetCollision(linkPlayerObjEvent->objEventId, linkDirection(objEvent), x, y)) { return FALSE; } @@ -3147,7 +3147,7 @@ static u8 FlipVerticalAndClearForced(u8 newFacing, u8 oldFacing) return oldFacing; } -static bool8 LinkPlayerDetectCollision(u8 selfObjEventId, u8 direction, s16 x, s16 y) +static u8 LinkPlayerGetCollision(u8 selfObjEventId, u8 direction, s16 x, s16 y) { u8 i; for (i = 0; i < OBJECT_EVENTS_COUNT; i++) @@ -3157,11 +3157,11 @@ static bool8 LinkPlayerDetectCollision(u8 selfObjEventId, u8 direction, s16 x, s if ((gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y) || (gObjectEvents[i].previousCoords.x == x && gObjectEvents[i].previousCoords.y == y)) { - return TRUE; + return 1; } } } - return MapGridIsImpassableAt(x, y); + return MapGridGetCollisionAt(x, y); } static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion) diff --git a/src/rotating_gate.c b/src/rotating_gate.c index e2fd575a1..1db3ad4ec 100644 --- a/src/rotating_gate.c +++ b/src/rotating_gate.c @@ -874,7 +874,12 @@ static s32 RotatingGate_CanRotate(u8 gateId, s32 rotationDirection) if (sRotatingGate_ArmLayout[shape][2 * i + j]) { - if (MapGridIsImpassableAt(x + armPos[armIndex].x, y + armPos[armIndex].y) == TRUE) + #ifdef BUGFIX + // Collision has a range 0-3, any value != 0 is impassable + if (MapGridGetCollisionAt(x + armPos[armIndex].x, y + armPos[armIndex].y)) + #else + if (MapGridGetCollisionAt(x + armPos[armIndex].x, y + armPos[armIndex].y) == 1) + #endif return FALSE; } }