From 63f95317a2d3dd29a42ca13368339c088c972e13 Mon Sep 17 00:00:00 2001 From: TheSumm Date: Mon, 19 Jan 2015 01:08:18 +0100 Subject: [PATCH] Fixed baseSpeed not being parsed (10.59+) --- src/client/creature.cpp | 9 +++++++++ src/client/creature.h | 3 +++ src/client/localplayer.cpp | 10 ---------- src/client/localplayer.h | 3 --- src/client/luafunctions.cpp | 4 +--- src/client/protocolgameparse.cpp | 10 +++++++++- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/client/creature.cpp b/src/client/creature.cpp index ac361692..1e646bc6 100644 --- a/src/client/creature.cpp +++ b/src/client/creature.cpp @@ -696,6 +696,15 @@ void Creature::setSpeed(uint16 speed) callLuaField("onSpeedChange", m_speed, oldSpeed); } +void Creature::setBaseSpeed(double baseSpeed) +{ + if(m_baseSpeed != baseSpeed) { + double oldBaseSpeed = m_baseSpeed; + m_baseSpeed = baseSpeed; + + callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed); + } +} void Creature::setSkull(uint8 skull) { m_skull = skull; diff --git a/src/client/creature.h b/src/client/creature.h index 72d35651..606d272e 100644 --- a/src/client/creature.h +++ b/src/client/creature.h @@ -58,6 +58,7 @@ public: void setOutfitColor(const Color& color, int duration); void setLight(const Light& light) { m_light = light; } void setSpeed(uint16 speed); + void setBaseSpeed(double baseSpeed); void setSkull(uint8 skull); void setShield(uint8 shield); void setEmblem(uint8 emblem); @@ -82,6 +83,7 @@ public: Outfit getOutfit() { return m_outfit; } Light getLight() { return m_light; } uint16 getSpeed() { return m_speed; } + double getBaseSpeed() { return m_baseSpeed; } uint8 getSkull() { return m_skull; } uint8 getShield() { return m_shield; } uint8 getEmblem() { return m_emblem; } @@ -147,6 +149,7 @@ protected: Outfit m_outfit; Light m_light; int m_speed; + double m_baseSpeed; uint8 m_skull; uint8 m_shield; uint8 m_emblem; diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index d4cbc898..e137d9dd 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -507,16 +507,6 @@ void LocalPlayer::setPremium(bool premium) } } -void LocalPlayer::setBaseSpeed(double baseSpeed) -{ - if(m_baseSpeed != baseSpeed) { - double oldBaseSpeed = m_baseSpeed; - m_baseSpeed = baseSpeed; - - callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed); - } -} - void LocalPlayer::setRegenerationTime(double regenerationTime) { if(m_regenerationTime != regenerationTime) { diff --git a/src/client/localplayer.h b/src/client/localplayer.h index e839d819..65556334 100644 --- a/src/client/localplayer.h +++ b/src/client/localplayer.h @@ -59,7 +59,6 @@ public: void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item); void setVocation(int vocation); void setPremium(bool premium); - void setBaseSpeed(double baseSpeed); void setRegenerationTime(double regenerationTime); void setOfflineTrainingTime(double offlineTrainingTime); void setSpells(const std::vector& spells); @@ -84,7 +83,6 @@ public: double getBaseMagicLevel() { return m_baseMagicLevel; } double getSoul() { return m_soul; } double getStamina() { return m_stamina; } - double getBaseSpeed() { return m_baseSpeed; } double getRegenerationTime() { return m_regenerationTime; } double getOfflineTrainingTime() { return m_offlineTrainingTime; } std::vector getSpells() { return m_spells; } @@ -162,7 +160,6 @@ private: double m_baseMagicLevel; double m_soul; double m_stamina; - double m_baseSpeed; double m_regenerationTime; double m_offlineTrainingTime; }; diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index e4f8b60f..0fa6794f 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -238,9 +238,7 @@ void Client::registerLuaFunctions() g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game); g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game); g_lua.bindSingletonFunction("g_game", "getPVPMode", &Game::getPVPMode, &g_game); - g_lua.bindSingletonFunction("g_game", "setUnjustifiedPoints", &Game::setUnjustifiedPoints, &g_game); g_lua.bindSingletonFunction("g_game", "getUnjustifiedPoints", &Game::getUnjustifiedPoints, &g_game); - g_lua.bindSingletonFunction("g_game", "setOpenPvpSituations", &Game::setOpenPvpSituations, &g_game); g_lua.bindSingletonFunction("g_game", "getOpenPvpSituations", &Game::getOpenPvpSituations, &g_game); g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game); g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game); @@ -444,6 +442,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("getName", &Creature::getName); g_lua.bindClassMemberFunction("getHealthPercent", &Creature::getHealthPercent); g_lua.bindClassMemberFunction("getSpeed", &Creature::getSpeed); + g_lua.bindClassMemberFunction("getBaseSpeed", &Creature::getBaseSpeed); g_lua.bindClassMemberFunction("getSkull", &Creature::getSkull); g_lua.bindClassMemberFunction("getShield", &Creature::getShield); g_lua.bindClassMemberFunction("getEmblem", &Creature::getEmblem); @@ -630,7 +629,6 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("getStamina", &LocalPlayer::getStamina); g_lua.bindClassMemberFunction("getOfflineTrainingTime", &LocalPlayer::getOfflineTrainingTime); g_lua.bindClassMemberFunction("getRegenerationTime", &LocalPlayer::getRegenerationTime); - g_lua.bindClassMemberFunction("getBaseSpeed", &LocalPlayer::getBaseSpeed); g_lua.bindClassMemberFunction("getBaseMagicLevel", &LocalPlayer::getBaseMagicLevel); g_lua.bindClassMemberFunction("getTotalCapacity", &LocalPlayer::getTotalCapacity); g_lua.bindClassMemberFunction("getInventoryItem", &LocalPlayer::getInventoryItem); diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 8853c150..7744a602 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -1004,11 +1004,19 @@ void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg) void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg) { uint id = msg->getU32(); + + int baseSpeed = -1; + if(g_game.getClientVersion() >= 1059) + baseSpeed = msg->getU16(); + int speed = msg->getU16(); CreaturePtr creature = g_map.getCreatureById(id); - if(creature) + if(creature) { creature->setSpeed(speed); + if(baseSpeed != -1) + creature->setBaseSpeed(baseSpeed); + } // some servers has a bug in get spectators and sends unknown creatures updates // so this code is disabled