Fix battle filter, fix walk issue, try logout when force exit

This commit is contained in:
Henrique Santiago 2012-08-08 16:49:02 -03:00
parent 56817a8678
commit b5cb4e2c93
5 changed files with 13 additions and 11 deletions

View File

@ -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

View File

@ -131,6 +131,7 @@ function tryExit()
local cancelButton = exitWindow:getChildById('buttonCancel')
local exitFunc = function()
logout() -- try logout anyway
forceExit()
end
local logoutFunc = function()

View File

@ -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();
}

View File

@ -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;

View File

@ -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();
}