From 3c1a5f24e8e9a259c814d9e485ebff5d0459383e Mon Sep 17 00:00:00 2001 From: Henrique Date: Tue, 31 Jul 2012 14:23:52 -0300 Subject: [PATCH] Fix to protocolgame --- src/framework/net/protocol.cpp | 7 ------- src/otclient/protocolgame.cpp | 11 +++++++++-- src/otclient/protocolgame.h | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/framework/net/protocol.cpp b/src/framework/net/protocol.cpp index 5ff8773f..321fe8ad 100644 --- a/src/framework/net/protocol.cpp +++ b/src/framework/net/protocol.cpp @@ -137,14 +137,7 @@ void Protocol::internalRecvData(uint8* buffer, uint16 size) g_logger.traceError("failed to decrypt message"); return; } - } else { - int size = m_inputMessage->getU16(); - if(size != m_inputMessage->getUnreadSize()) { - g_logger.traceError("invalid message size"); - return; - } } - onRecv(m_inputMessage); } diff --git a/src/otclient/protocolgame.cpp b/src/otclient/protocolgame.cpp index 4befc7a8..417e9849 100644 --- a/src/otclient/protocolgame.cpp +++ b/src/otclient/protocolgame.cpp @@ -42,6 +42,7 @@ void ProtocolGame::login(const std::string& accountName, const std::string& acco void ProtocolGame::onConnect() { + m_firstRecv = true; Protocol::onConnect(); m_localPlayer = g_game.getLocalPlayer(); @@ -57,7 +58,14 @@ void ProtocolGame::onConnect() void ProtocolGame::onRecv(const InputMessagePtr& inputMessage) { - //Protocol::onConnect(inputMessage); + if(m_firstRecv) { + m_firstRecv = false; + int size = inputMessage->getU16(); + if(size != inputMessage->getUnreadSize()) { + g_logger.traceError("invalid message size"); + return; + } + } parseMessage(inputMessage); recv(); @@ -69,4 +77,3 @@ void ProtocolGame::onError(const boost::system::error_code& error) g_game.processConnectionError(error); } - diff --git a/src/otclient/protocolgame.h b/src/otclient/protocolgame.h index dc17f9d1..d96d538b 100644 --- a/src/otclient/protocolgame.h +++ b/src/otclient/protocolgame.h @@ -216,6 +216,7 @@ public: private: stdext::boolean m_enableSendExtendedOpcode; stdext::boolean m_gameInitialized; + stdext::boolean m_firstRecv; std::string m_accountName; std::string m_accountPassword; std::string m_characterName;