From 9909ffed35b591b3dc880c19cf00d9bd41fc9aac Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Fri, 6 Jan 2012 15:29:18 -0200 Subject: [PATCH] fix walk --- src/otclient/core/creature.h | 4 ++-- src/otclient/core/game.cpp | 16 ++++++++-------- src/otclient/core/localplayer.h | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/otclient/core/creature.h b/src/otclient/core/creature.h index 00ad7c6b..18dfa80a 100644 --- a/src/otclient/core/creature.h +++ b/src/otclient/core/creature.h @@ -54,8 +54,8 @@ public: void addVolatileSquare(uint8 color); void removeVolatileSquare() { m_showVolatileSquare = false; } - void activateStaticSquare(const Color& color) { m_showStaticSquare = true; m_staticSquareColor = color; } - void deactivateStaticSquare() { m_showStaticSquare = false; } + void showStaticSquare(const Color& color) { m_showStaticSquare = true; m_staticSquareColor = color; } + void hideStaticSquare() { m_showStaticSquare = false; } std::string getName() { return m_name; } uint8 getHealthPercent() { return m_healthPercent; } diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 74750464..68a1cb4c 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -106,7 +106,7 @@ void Game::processInventoryChange(int slot, const ItemPtr& item) void Game::walk(Otc::Direction direction) { - if(!m_online || !m_localPlayer->canWalk(direction) || !g_ui.isOnInputEvent()) + if(!m_online || !m_localPlayer->canWalk(direction) || (!g_ui.isOnInputEvent() && m_localPlayer->getNextWalkDirection() == Otc::InvalidDirection)) return; cancelFollow(); @@ -188,9 +188,9 @@ void Game::attack(const CreaturePtr& creature) return; if(m_attackingCreature) - m_attackingCreature->deactivateStaticSquare(); + m_attackingCreature->hideStaticSquare(); - creature->activateStaticSquare(Fw::red); + creature->showStaticSquare(Fw::red); m_attackingCreature = creature; m_protocolGame->sendAttack(creature->getId()); @@ -200,7 +200,7 @@ void Game::cancelAttack() { if(m_attackingCreature) { m_protocolGame->sendAttack(0); - m_attackingCreature->deactivateStaticSquare(); + m_attackingCreature->hideStaticSquare(); m_attackingCreature = nullptr; } } @@ -208,7 +208,7 @@ void Game::cancelAttack() void Game::onAttackCancelled() { if(m_attackingCreature) { - m_attackingCreature->deactivateStaticSquare(); + m_attackingCreature->hideStaticSquare(); m_attackingCreature = nullptr; } } @@ -219,9 +219,9 @@ void Game::follow(const CreaturePtr& creature) return; if(m_followingCreature) - m_followingCreature->deactivateStaticSquare(); + m_followingCreature->hideStaticSquare(); - creature->activateStaticSquare(Fw::green); + creature->showStaticSquare(Fw::green); m_followingCreature = creature; m_protocolGame->sendFollow(creature->getId()); @@ -231,7 +231,7 @@ void Game::cancelFollow() { if(m_followingCreature) { m_protocolGame->sendFollow(0); - m_followingCreature->deactivateStaticSquare(); + m_followingCreature->hideStaticSquare(); m_followingCreature = nullptr; } } diff --git a/src/otclient/core/localplayer.h b/src/otclient/core/localplayer.h index e5cc2f1b..543dd96c 100644 --- a/src/otclient/core/localplayer.h +++ b/src/otclient/core/localplayer.h @@ -46,6 +46,7 @@ public: void walk(const Position& position, bool inverse); void cancelWalk(Otc::Direction direction, bool force = false); bool canWalk(Otc::Direction direction); + Otc::Direction getNextWalkDirection() { return m_nextWalkDirection; } LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast(shared_from_this()); }