diff --git a/modules/client_locales/locales.lua b/modules/client_locales/locales.lua index 71a9873c..52e4c1e7 100644 --- a/modules/client_locales/locales.lua +++ b/modules/client_locales/locales.lua @@ -13,7 +13,7 @@ local localeComboBox local function sendLocale(localeName) local protocolGame = g_game.getProtocolGame() if protocolGame then - protocolGame:sendExtendedOpcode(0, localeName) + protocolGame:sendExtendedOpcode(1, localeName) return true end return false @@ -63,7 +63,7 @@ function Locales.init() localeComboBox.onOptionChange = onLocaleComboBoxOptionChange end, false) - Extended.register(0, onServerSetLocale) + Extended.register(1, onServerSetLocale) connect(g_game, { onGameStart = onGameStart }) end @@ -71,7 +71,7 @@ function Locales.terminate() installedLocales = nil currentLocale = nil localeComboBox = nil - Extended.unregister(0) + Extended.unregister(1) disconnect(g_game, { onGameStart = onGameStart }) end diff --git a/src/otclient/CMakeLists.txt b/src/otclient/CMakeLists.txt index a1a5a40c..1a83cd55 100644 --- a/src/otclient/CMakeLists.txt +++ b/src/otclient/CMakeLists.txt @@ -5,7 +5,6 @@ ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) # otclient options OPTION(BOT_PROTECTION "Enable bot protection" ON) -OPTION(EXTENDED_OPCODE "Enable extended opcode" OFF) SET(PROTOCOL 860 CACHE "Protocol version" STRING) OPTION(CIPSOFT_RSA "Use cipsoft RSA to login into original tibia" OFF) ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL}) @@ -25,13 +24,6 @@ ELSE(BOT_PROTECTION) MESSAGE(STATUS "Bot protection: OFF") ENDIF(BOT_PROTECTION) -IF(EXTENDED_OPCODE) - ADD_DEFINITIONS(-DEXTENDED_OPCODE) - MESSAGE(STATUS "Extended opcode: ON") -ELSE(EXTENDED_OPCODE) - MESSAGE(STATUS "Extended opcode: OFF") -ENDIF(EXTENDED_OPCODE) - SET(otclient_SOURCES ${otclient_SOURCES} # otclient ${CMAKE_CURRENT_LIST_DIR}/otclient.cpp diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h index dad57f19..b63c0b31 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/net/protocolcodes.h @@ -105,7 +105,7 @@ namespace Proto { GameServerChallange = 31, GameServerDeath = 40, - // all in game opcodes must be equal or greater than 50 + // all in game opcodes must be greater than 50 GameServerFirstGameOpcode = 50, // otclient ONLY diff --git a/src/otclient/net/protocolgame.h b/src/otclient/net/protocolgame.h index cfd3d1f7..9ba96e1f 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/net/protocolgame.h @@ -213,6 +213,7 @@ public: Position getPosition(const InputMessagePtr& msg); private: + Boolean m_enableSendExtendedOpcode; Boolean m_gameInitialized; std::string m_accountName; std::string m_accountPassword; diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index dad75c61..280ac6d9 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -46,7 +46,7 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg) if(callLuaField("onOpcode", opcode, msg)) continue; - if(!m_gameInitialized && opcode >= Proto::GameServerFirstGameOpcode) + if(!m_gameInitialized && opcode > Proto::GameServerFirstGameOpcode) logWarning("received a game opcode from the server, but the game is not initialized yet, this is a server side bug"); switch(opcode) { @@ -1212,13 +1212,16 @@ void ProtocolGame::parseExtendedOpcode(const InputMessagePtr& msg) int opcode = msg->getU8(); std::string buffer = msg->getString(); -#ifdef EXTENDED_OPCODE - try { - callLuaField("onExtendedOpcode", opcode, buffer); - } catch(Exception& e) { - logError("Network exception in extended opcode ", opcode, ": ", e.what()); + if(opcode == 0) { + m_enableSendExtendedOpcode = true; + } + else { + try { + callLuaField("onExtendedOpcode", opcode, buffer); + } catch(Exception& e) { + logError("Network exception in extended opcode ", opcode, ": ", e.what()); + } } -#endif } void ProtocolGame::setMapDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height) diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index 6dd512b2..690fd3d5 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -33,13 +33,13 @@ void ProtocolGame::safeSend(const OutputMessagePtr& outputMessage) void ProtocolGame::sendExtendedOpcode(uint8 opcode, const std::string& buffer) { -#ifdef EXTENDED_OPCODE - OutputMessagePtr msg(new OutputMessage); - msg->addU8(Proto::ClientExtendedOpcode); - msg->addU8(opcode); - msg->addString(buffer); - safeSend(msg); -#endif + if(m_enableSendExtendedOpcode) { + OutputMessagePtr msg(new OutputMessage); + msg->addU8(Proto::ClientExtendedOpcode); + msg->addU8(opcode); + msg->addString(buffer); + safeSend(msg); + } } void ProtocolGame::sendLoginPacket(uint challangeTimestamp, uint8 challangeRandom)