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;