Skip to content

Commit

Permalink
fix: schedule next walk event for smoother turning
Browse files Browse the repository at this point in the history
  • Loading branch information
nekiro committed Jan 9, 2025
1 parent e8a5371 commit afacc0c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,17 @@ bool Game::walk(const Otc::Direction direction)
static Timer timer;

if (nextWalkSchedule) nextWalkSchedule->cancel();
nextWalkSchedule = g_dispatcher.scheduleEvent([this] {
nextWalkSchedule = nullptr;
steps = 0;
}, 150);

// check we can walk and add new walk event if false
if (!m_localPlayer->canWalk(direction)) {
if (m_localPlayer->isWalking()) {
// schedule next walk event for smoother walking
auto delay = std::max<int32_t>(1, m_localPlayer->getStepDuration(true, direction) - m_localPlayer->getWalkTicksElapsed());
nextWalkSchedule = g_dispatcher.scheduleEvent([this, direction] {
walk(direction);
nextWalkSchedule = nullptr;
}, delay);
}
return false;
}

Expand Down

0 comments on commit afacc0c

Please sign in to comment.