MapGridIsImpassableAt -> MapGridGetCollisionAt, and add fixes

This commit is contained in:
GriffinR 2022-08-03 14:21:13 -04:00
parent 5101811407
commit e5c36cd745
7 changed files with 22 additions and 12 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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;
}
}