diff --git a/modules/game_battle/battle.lua b/modules/game_battle/battle.lua index 417d7d6e..e15546eb 100644 --- a/modules/game_battle/battle.lua +++ b/modules/game_battle/battle.lua @@ -170,7 +170,7 @@ end function onCreatureAppear(creature) local player = g_game.getLocalPlayer() - if creature ~= player and creature:getPosition().z == player:getPosition().z then + if creature ~= player and creature:getPosition().z == player:getPosition().z and doCreatureFitFilters(creature) then addCreature(creature) end end diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index fafcc814..68d4f3c3 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -131,6 +131,7 @@ function tryExit() local cancelButton = exitWindow:getChildById('buttonCancel') local exitFunc = function() + logout() -- try logout anyway forceExit() end local logoutFunc = function() diff --git a/src/otclient/creature.cpp b/src/otclient/creature.cpp index 0598f26c..56391501 100644 --- a/src/otclient/creature.cpp +++ b/src/otclient/creature.cpp @@ -48,6 +48,7 @@ Creature::Creature() : Thing() m_direction = Otc::South; m_walkAnimationPhase = 0; m_walkedPixels = 0; + m_walkStepDuration = 0; m_walkTurnDirection = Otc::InvalidDirection; m_skull = Otc::SkullNone; m_shield = Otc::ShieldNone; @@ -265,6 +266,7 @@ void Creature::walk(const Position& oldPos, const Position& newPos) m_walking = true; m_walkTimer.restart(); m_walkedPixels = 0; + m_walkStepDuration = getStepDuration(); // no direction need to be changed when the walk ends m_walkTurnDirection = Otc::InvalidDirection; @@ -349,7 +351,7 @@ void Creature::updateWalkAnimation(int totalPixelsWalked) int footAnimPhases = getAnimationPhases() - 1; if(totalPixelsWalked == 32 || footAnimPhases == 0) m_walkAnimationPhase = 0; - else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= getStepDuration() / 4 ) { + else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= m_walkStepDuration / 4 ) { m_footStep++; m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases); m_footStepDrawn = false; @@ -413,14 +415,13 @@ void Creature::nextWalkUpdate() m_walkUpdateEvent = g_dispatcher.scheduleEvent([self] { self->m_walkUpdateEvent = nullptr; self->nextWalkUpdate(); - }, getStepDuration() / 32); + }, m_walkStepDuration / 32); } } void Creature::updateWalk() { - int stepDuration = getStepDuration(); - float walkTicksPerPixel = stepDuration / 32; + float walkTicksPerPixel = m_walkStepDuration / 32; int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f); // needed for paralyze effect @@ -432,7 +433,7 @@ void Creature::updateWalk() updateWalkingTile(); // terminate walk - if(m_walking && m_walkTimer.ticksElapsed() >= stepDuration) + if(m_walking && m_walkTimer.ticksElapsed() >= m_walkStepDuration) terminateWalk(); } diff --git a/src/otclient/creature.h b/src/otclient/creature.h index 284bdbeb..02eee099 100644 --- a/src/otclient/creature.h +++ b/src/otclient/creature.h @@ -139,6 +139,7 @@ protected: // walk related int m_walkAnimationPhase; int m_walkedPixels; + int m_walkStepDuration; uint m_footStep; Timer m_walkTimer; Timer m_footTimer; diff --git a/src/otclient/localplayer.cpp b/src/otclient/localplayer.cpp index 044b205e..8dbbc574 100644 --- a/src/otclient/localplayer.cpp +++ b/src/otclient/localplayer.cpp @@ -67,11 +67,11 @@ bool LocalPlayer::canWalk(Otc::Direction direction) return false; // last walk is not done yet - if(m_walkTimer.ticksElapsed() < getStepDuration()) + if(m_walkTimer.ticksElapsed() < m_walkStepDuration) return false; // prewalk has a timeout, because for some reason that I don't know yet the server sometimes doesn't answer the prewalk - bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= getStepDuration() + PREWALK_TIMEOUT; + bool prewalkTimeouted = m_walking && m_preWalking && m_walkTimer.ticksElapsed() >= m_walkStepDuration + PREWALK_TIMEOUT; // avoid doing more walks than wanted when receiving a lot of walks from server if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted) @@ -178,8 +178,7 @@ void LocalPlayer::updateWalkOffset(int totalPixelsWalked) void LocalPlayer::updateWalk() { - int stepDuration = getStepDuration(); - float walkTicksPerPixel = stepDuration / 32.0f; + float walkTicksPerPixel = m_walkStepDuration / 32.0f; int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f); // update walk animation and offsets @@ -188,7 +187,7 @@ void LocalPlayer::updateWalk() updateWalkingTile(); // terminate walk only when client and server side walk are complated - if(m_walking && !m_preWalking && m_walkTimer.ticksElapsed() >= stepDuration) + if(m_walking && !m_preWalking && m_walkTimer.ticksElapsed() >= m_walkStepDuration) terminateWalk(); }