fix ub for forced link movement (#732)
This commit is contained in:
+28
-26
@@ -59,15 +59,20 @@
|
|||||||
#define PLAYER_LINK_STATE_READY 0x82
|
#define PLAYER_LINK_STATE_READY 0x82
|
||||||
#define PLAYER_LINK_STATE_EXITING_ROOM 0x83
|
#define PLAYER_LINK_STATE_EXITING_ROOM 0x83
|
||||||
|
|
||||||
#define FACING_NONE 0
|
enum LinkFacing
|
||||||
#define FACING_UP 1
|
{
|
||||||
#define FACING_DOWN 2
|
FACING_NONE,
|
||||||
#define FACING_LEFT 3
|
FACING_UP,
|
||||||
#define FACING_RIGHT 4
|
FACING_DOWN,
|
||||||
#define FACING_FORCED_UP 7
|
FACING_LEFT,
|
||||||
#define FACING_FORCED_DOWN 8
|
FACING_RIGHT,
|
||||||
#define FACING_FORCED_LEFT 9
|
FACING_UNUSED1,
|
||||||
#define FACING_FORCED_RIGHT 10
|
FACING_UNUSED2,
|
||||||
|
FACING_FORCED_UP,
|
||||||
|
FACING_FORCED_DOWN,
|
||||||
|
FACING_FORCED_LEFT,
|
||||||
|
FACING_FORCED_RIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
typedef u16 (*KeyInterCB)(u32 key);
|
typedef u16 (*KeyInterCB)(u32 key);
|
||||||
|
|
||||||
@@ -2552,21 +2557,17 @@ static u8 (*const sLinkPlayerMovementModes[])(struct LinkPlayerObjectEvent *, st
|
|||||||
// These handlers return TRUE if the movement was scripted and successful, and FALSE otherwise.
|
// These handlers return TRUE if the movement was scripted and successful, and FALSE otherwise.
|
||||||
static bool8 (*const sLinkPlayerFacingHandlers[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) =
|
static bool8 (*const sLinkPlayerFacingHandlers[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) =
|
||||||
{
|
{
|
||||||
[DIR_NONE] = FacingHandler_DoNothing,
|
[FACING_NONE] = FacingHandler_DoNothing,
|
||||||
[DIR_SOUTH] = FacingHandler_DpadMovement,
|
[FACING_UP] = FacingHandler_DpadMovement,
|
||||||
[DIR_NORTH] = FacingHandler_DpadMovement,
|
[FACING_DOWN] = FacingHandler_DpadMovement,
|
||||||
[DIR_WEST] = FacingHandler_DpadMovement,
|
[FACING_LEFT] = FacingHandler_DpadMovement,
|
||||||
[DIR_EAST] = FacingHandler_DpadMovement,
|
[FACING_RIGHT] = FacingHandler_DpadMovement,
|
||||||
};
|
[FACING_UNUSED1] = FacingHandler_DoNothing,
|
||||||
|
[FACING_UNUSED2] = FacingHandler_DoNothing,
|
||||||
static bool8 (*const sUnusedLinkPlayerFacingHandlers[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) =
|
[FACING_FORCED_UP] = FacingHandler_ForcedFacingChange,
|
||||||
{
|
[FACING_FORCED_DOWN] = FacingHandler_ForcedFacingChange,
|
||||||
FacingHandler_DoNothing,
|
[FACING_FORCED_LEFT] = FacingHandler_ForcedFacingChange,
|
||||||
FacingHandler_DoNothing,
|
[FACING_FORCED_RIGHT] = FacingHandler_ForcedFacingChange,
|
||||||
FacingHandler_ForcedFacingChange,
|
|
||||||
FacingHandler_ForcedFacingChange,
|
|
||||||
FacingHandler_ForcedFacingChange,
|
|
||||||
FacingHandler_ForcedFacingChange,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// These handlers are run after an attempted movement.
|
// These handlers are run after an attempted movement.
|
||||||
@@ -3066,7 +3067,8 @@ static bool32 CanCableClubPlayerPressStart(struct CableClubPlayer *player)
|
|||||||
static const u8 *TryGetTileEventScript(struct CableClubPlayer *player)
|
static const u8 *TryGetTileEventScript(struct CableClubPlayer *player)
|
||||||
{
|
{
|
||||||
if (player->movementMode != MOVEMENT_MODE_SCRIPTED)
|
if (player->movementMode != MOVEMENT_MODE_SCRIPTED)
|
||||||
return FACING_NONE;
|
return NULL;
|
||||||
|
|
||||||
return GetCoordEventScriptAtMapPosition(&player->pos);
|
return GetCoordEventScriptAtMapPosition(&player->pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3088,7 +3090,7 @@ static const u8 *TryInteractWithPlayer(struct CableClubPlayer *player)
|
|||||||
u8 linkPlayerId;
|
u8 linkPlayerId;
|
||||||
|
|
||||||
if (player->movementMode != MOVEMENT_MODE_FREE && player->movementMode != MOVEMENT_MODE_SCRIPTED)
|
if (player->movementMode != MOVEMENT_MODE_FREE && player->movementMode != MOVEMENT_MODE_SCRIPTED)
|
||||||
return FACING_NONE;
|
return NULL;
|
||||||
|
|
||||||
otherPlayerPos = player->pos;
|
otherPlayerPos = player->pos;
|
||||||
otherPlayerPos.x += gDirectionToVectors[player->facing].x;
|
otherPlayerPos.x += gDirectionToVectors[player->facing].x;
|
||||||
|
|||||||
Reference in New Issue
Block a user