From 971d90a596650e021d51c8deb83bf4a51ad786e3 Mon Sep 17 00:00:00 2001 From: Joao Pasqualini Costa Date: Sun, 20 Oct 2013 18:31:20 -0200 Subject: [PATCH] Fix protocol error #362 TODO: Handle the helpers in LUA, it could be added into Battle Window i think, if someone know where should this be comment here ! --- src/client/game.cpp | 6 ++++++ src/client/game.h | 2 ++ src/client/protocolcodes.h | 1 + src/client/protocolgame.h | 1 + src/client/protocolgameparse.cpp | 16 ++++++++++++++++ 5 files changed, 26 insertions(+) diff --git a/src/client/game.cpp b/src/client/game.cpp index 9087a441..2a26c54b 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -171,6 +171,7 @@ void Game::processEnterGame() g_lua.callGlobalField("g_game", "onEnterGame"); } + void Game::processGameStart() { m_online = true; @@ -234,6 +235,11 @@ void Game::processGMActions(const std::vector& actions) g_lua.callGlobalField("g_game", "onGMActions", actions); } +void Game::processPlayerHelpers(int helpers) +{ + g_lua.callGlobalField("g_game", "onPlayerHelpersUpdate", helpers); +} + void Game::processPing() { g_lua.callGlobalField("g_game", "onPing"); diff --git a/src/client/game.h b/src/client/game.h index e76d6c4d..3fdf85fa 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -73,6 +73,8 @@ protected: void processAttackCancel(uint seq); void processWalkCancel(Otc::Direction direction); + void processPlayerHelpers(int helpers); + // message related void processTextMessage(Otc::MessageMode mode, const std::string& text); void processTalk(const std::string& name, int level, Otc::MessageMode mode, const std::string& text, int channelId, const Position& pos); diff --git a/src/client/protocolcodes.h b/src/client/protocolcodes.h index 4a2e4adc..524ed97d 100644 --- a/src/client/protocolcodes.h +++ b/src/client/protocolcodes.h @@ -102,6 +102,7 @@ namespace Proto { GameServerCreatureSkull = 144, GameServerCreatureParty = 145, GameServerCreatureUnpass = 146, + GameServerPlayerHelpers = 148, GameServerEditText = 150, GameServerEditList = 151, GameServerPlayerDataBasic = 159, // 950 diff --git a/src/client/protocolgame.h b/src/client/protocolgame.h index 99c5973a..e42eb4f8 100644 --- a/src/client/protocolgame.h +++ b/src/client/protocolgame.h @@ -125,6 +125,7 @@ public: void addPosition(const OutputMessagePtr& msg, const Position& position); private: + void parsePlayerHelpers(const InputMessagePtr& msg); void parseMessage(const InputMessagePtr& msg); void parsePendingGame(const InputMessagePtr& msg); void parseEnterGame(const InputMessagePtr& msg); diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index aea49247..3a30e29f 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -323,6 +323,10 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg) case Proto::GameServerEnterGame: parseEnterGame(msg); break; + // PROTOCOL>=1010 + case Proto::GameServerPlayerHelpers: + parsePlayerHelpers(msg); + break; // otclient ONLY case Proto::GameServerExtendedOpcode: parseExtendedOpcode(msg); @@ -379,6 +383,18 @@ void ProtocolGame::parseEnterGame(const InputMessagePtr& msg) } } +void ProtocolGame::parsePlayerHelpers(const InputMessagePtr& msg) +{ + uint id = msg->getU32(); + int helpers = msg->getU16(); + + CreaturePtr creature = g_map.getCreatureById(id); + if(creature) + g_game.processPlayerHelpers(helpers); + else + g_logger.traceError("could not get creature"); +} + void ProtocolGame::parseGMActions(const InputMessagePtr& msg) { std::vector actions;