diff --git a/src/client/creature.cpp b/src/client/creature.cpp index c40cdba319..749e578374 100644 --- a/src/client/creature.cpp +++ b/src/client/creature.cpp @@ -695,7 +695,7 @@ void Creature::terminateWalk() m_walkOffset = {}; m_walking = false; - if (isLocalPlayer() && !static_self_cast()->isAutoWalking() && getWalkSteps() > 1) { + if (isLocalPlayer() && !static_self_cast()->isAutoWalking()) { g_dispatcher.addEvent([] { g_dispatcher.deferEvent([] { if (g_game.getLocalPlayer()) diff --git a/src/client/game.cpp b/src/client/game.cpp index eec8ec2598..7da1f899e4 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -642,28 +642,31 @@ bool Game::walk(const Otc::Direction direction, bool force) return false; } - if (!canPerformGameAction() || nextWalkSchedule) + if (!canPerformGameAction()) return false; - if (!force && m_localPlayer->getWalkSteps() > 0) { - auto delay = 0; - auto steps = m_localPlayer->getWalkSteps(); - - if (m_localPlayer->getWalkSteps() == 1) { - delay = m_walkFirstStepDelay; - steps = 2; - } else if (direction != m_localPlayer->getDirection()) - delay = m_walkTurnDelay; - - if (delay > 0) { - nextWalkSchedule = g_dispatcher.scheduleEvent([this, steps, direction] { - nextWalkSchedule = nullptr; - if (m_localPlayer) { - m_localPlayer->setWalkSteps(steps); - walk(direction, true); - } - }, delay); + if (!force) { + if (nextWalkSchedule) return false; + + if (m_localPlayer->getWalkSteps() > 0) { + uint16_t delay = 0; + if (m_localPlayer->getWalkSteps() == 1) { + delay = m_walkFirstStepDelay; + } else if (direction != m_localPlayer->getDirection()) + delay = m_walkTurnDelay; + + if (delay > 0) { + nextWalkSchedule = g_dispatcher.scheduleEvent([this, direction] { + if (m_localPlayer && m_localPlayer->getNextWalkDir() != Otc::InvalidDirection) { + m_localPlayer->setWalkSteps(1); + walk(direction, true); + } + + nextWalkSchedule = nullptr; + }, delay); + return false; + } } }