From 4de25cd2eab810aae981bf86f380f52952dc2a2d Mon Sep 17 00:00:00 2001 From: obligaron Date: Sat, 15 May 2021 21:16:40 +0200 Subject: [PATCH] Introduce PlayerStruct.IsWalking() --- Source/player.cpp | 13 +++++++++++++ Source/player.h | 5 +++++ Source/track.cpp | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/player.cpp b/Source/player.cpp index 19d7e710a..68d419b8e 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -355,6 +355,19 @@ void PlayerStruct::Stop() destAction = ACTION_NONE; } +bool PlayerStruct::IsWalking() const +{ + switch (_pmode) + { + case PM_WALK: + case PM_WALK2: + case PM_WALK3: + return true; + default: + return false; + } +} + void SetPlayerGPtrs(byte *pData, byte **pAnim) { int i; diff --git a/Source/player.h b/Source/player.h index 8540748a5..ae25c704f 100644 --- a/Source/player.h +++ b/Source/player.h @@ -390,6 +390,11 @@ struct PlayerStruct { * opening a chest, picking an item up, etc) this action will also be cancelled. */ void Stop(); + + /** + * @brief Is the player currently walking? + */ + bool IsWalking() const; }; extern int myplr; diff --git a/Source/track.cpp b/Source/track.cpp index bde59f086..e9ecfbe6e 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -26,7 +26,7 @@ void track_process() if (cursmx < 0 || cursmx >= MAXDUNX - 1 || cursmy < 0 || cursmy >= MAXDUNY - 1) return; - if (plr[myplr].AnimInfo.GetFrameToUseForRendering() <= 6 || (plr[myplr]._pmode != PM_WALK && plr[myplr]._pmode != PM_WALK2 && plr[myplr]._pmode != PM_WALK3 && plr[myplr]._pmode != PM_STAND)) + if (plr[myplr].AnimInfo.GetFrameToUseForRendering() <= 6 || (!plr[myplr].IsWalking() && plr[myplr]._pmode != PM_STAND)) return; const Point target = plr[myplr].GetTargetPosition();