diff --git a/TODO b/TODO index 866dbd5c..471104d7 100644 --- a/TODO +++ b/TODO @@ -46,7 +46,6 @@ Low priority TODO == Platform [bart] port to MacOs and iphone -[bart] KeyDown, KeyText events change win32 mouse cursor icon == UI diff --git a/modules/addon_pingbar/pingbar.lua b/modules/addon_pingbar/pingbar.lua deleted file mode 100644 index 18eef16b..00000000 --- a/modules/addon_pingbar/pingbar.lua +++ /dev/null @@ -1,27 +0,0 @@ -PingBar = {} - -local pingLabel - --- public functions -function PingBar.init() - pingLabel = createWidget('UILabel', rootWidget:recursiveGetChildById('leftButtonsPanel')) - pingLabel:applyStyle({ ['anchors.left'] = 'prev.right', - ['anchors.top'] = 'parent.top', - ['margin-top'] = 12, - ['margin-left'] = 20, - font = 'verdana-11px-rounded', - color = '#FE6500', - width = 120, - height = 16}) -end - -function PingBar.terminate() - pingLabel:destroy() -end - --- hooked events -local function onGamePingUpdate(ping) - pingLabel:setText('Ping: ' .. ping .. ' ms') -end - -connect(Game, { onWalkPingUpdate = onGamePingUpdate }) \ No newline at end of file diff --git a/modules/addon_pingbar/pingbar.otmod b/modules/addon_pingbar/pingbar.otmod deleted file mode 100644 index f55172ca..00000000 --- a/modules/addon_pingbar/pingbar.otmod +++ /dev/null @@ -1,15 +0,0 @@ -Module - name: pingbar - description: Show ping in game - author: OTClient team - website: https://github.com/edubart/otclient - - autoLoad: true - autoLoadAntecedence: 1000 - - onLoad: | - require 'pingbar' - PingBar.init() - - onUnload: | - PingBar.terminate() diff --git a/src/framework/platform/platformwindow.cpp b/src/framework/platform/platformwindow.cpp index 8e9e4856..9cb35ee0 100644 --- a/src/framework/platform/platformwindow.cpp +++ b/src/framework/platform/platformwindow.cpp @@ -91,6 +91,19 @@ void PlatformWindow::processKeyRelease(Fw::Key keyCode) } } +void PlatformWindow::releaseAllKeys() +{ + for(auto it : m_keysState) { + Fw::Key keyCode = it.first; + bool pressed = it.second; + + if(!pressed) + continue; + + processKeyRelease(keyCode); + } +} + void PlatformWindow::fireKeysPress() { // avoid massive checks @@ -119,4 +132,3 @@ void PlatformWindow::fireKeysPress() } } } - diff --git a/src/framework/platform/platformwindow.h b/src/framework/platform/platformwindow.h index 0a53a04c..a65d8c41 100644 --- a/src/framework/platform/platformwindow.h +++ b/src/framework/platform/platformwindow.h @@ -94,6 +94,7 @@ protected: void processKeyDown(Fw::Key keyCode); void processKeyRelease(Fw::Key keyCode); + void releaseAllKeys(); void fireKeysPress(); std::map m_keyMap; diff --git a/src/framework/platform/x11window.cpp b/src/framework/platform/x11window.cpp index 800cddcc..d528ee32 100644 --- a/src/framework/platform/x11window.cpp +++ b/src/framework/platform/x11window.cpp @@ -710,6 +710,7 @@ void X11Window::poll() break; case FocusOut: m_focused = false; + releaseAllKeys(); break; case Expose: // window needs redraw diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index be678c95..a862dd39 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -117,8 +117,6 @@ void Creature::draw(const Point& p, const Rect&) if(m_type->dimensions[ThingType::Layers] > 1) { int maskId = m_type->getSpriteId(w, h, 1, m_xPattern, m_yPattern, m_zPattern, m_animation); - if(!maskId) - continue; TexturePtr maskTex = g_sprites.getSpriteTexture(maskId); outfitProgram->setUniformTexture(MASK_TEXTURE_UNIFORM, maskTex, 1); } @@ -292,8 +290,7 @@ void Creature::cancelWalk(Otc::Direction direction, bool force) if(direction != Otc::InvalidDirection) setDirection(direction); - if(m_outfit.getCategory() == ThingsType::Creature) - m_animation = 0; + m_animation = 0; } void Creature::setName(const std::string& name) diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index e24c3c3c..016a1f9c 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -36,9 +36,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c { m_online = false; m_dead = false; - m_walkFeedback = true; m_selectedThing = nullptr; - m_walkPing = 0; m_protocolGame = ProtocolGamePtr(new ProtocolGame); m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName); } @@ -146,16 +144,9 @@ void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldP // teleport } else { // stop walking on teleport - if(creature->isWalking()) + if(creature->isWalking() || creature->isPreWalking()) creature->cancelWalk(); } - - if(creature == m_localPlayer) { - if(!m_walkFeedback) { - updateWalkPing(); - m_walkFeedback = true; - } - } } void Game::processAttackCancel() @@ -166,10 +157,6 @@ void Game::processAttackCancel() void Game::processWalkCancel(Otc::Direction direction) { - if(!m_walkFeedback) { - updateWalkPing(); - m_walkFeedback = true; - } m_localPlayer->cancelWalk(direction, true); } @@ -190,9 +177,6 @@ void Game::walk(Otc::Direction direction) void Game::forceWalk(Otc::Direction direction) { - m_walkPingTimer.restart(); - m_walkFeedback = false; - switch(direction) { case Otc::North: m_protocolGame->sendWalkNorth(); @@ -478,9 +462,3 @@ bool Game::checkBotProtection() #endif return true; } - -void Game::updateWalkPing() -{ - m_walkPing = m_walkPingTimer.ticksElapsed(); - g_lua.callGlobalField("Game", "onWalkPingUpdate", m_walkPing); -} diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index bcd6a34f..878fc222 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -114,18 +114,12 @@ public: LocalPlayerPtr getLocalPlayer() { return m_localPlayer; } ProtocolGamePtr getProtocolGame() { return m_protocolGame; } int getProtocolVersion() { return PROTOCOL; } - int getWalkPing() { return m_walkPing; } private: - void updateWalkPing(); - LocalPlayerPtr m_localPlayer; ProtocolGamePtr m_protocolGame; bool m_online; bool m_dead; - bool m_walkFeedback; - Timer m_walkPingTimer; - int m_walkPing; int m_serverBeat; ThingPtr m_selectedThing; }; diff --git a/src/otclient/core/tile.cpp b/src/otclient/core/tile.cpp index 5cdd6c64..45b245f6 100644 --- a/src/otclient/core/tile.cpp +++ b/src/otclient/core/tile.cpp @@ -65,6 +65,7 @@ void Tile::draw(const Point& p, const Rect& visibleRect) // we can render creatures in 3x3 range //TODO: this algorithm is slowing down render too much, but it could be cached to improve framerate + //NOTE: looping for 9 tiles is a dirty way to render walking creatures, must change this later for(int xi = -1; xi <= 1; ++xi) { for(int yi = -1; yi <= 1; ++yi) { for(CreaturePtr creature : g_map.getTile(m_pos + Position(xi, yi, 0))->getCreatures()) { diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index 3cb1fddb..ba0d8a3b 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -1124,7 +1124,7 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg) int skull = msg.getU8(); int shield = msg.getU8(); - int emblem = 0; + int emblem = -1; if(thingId == 0x0061) // emblem is sent only in packet type 0x61 emblem = msg.getU8(); @@ -1138,7 +1138,8 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg) creature->setSpeed(speed); creature->setSkull(skull); creature->setShield(shield); - creature->setEmblem(emblem); + if(emblem != -1) + creature->setEmblem(emblem); creature->setPassable(passable); creature->cancelWalk(direction); }