From da959aca28d6e69766b61eda1b7c6ae0846d4e1b Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 26 Dec 2013 21:31:55 +0100 Subject: [PATCH] Support for protocol 7.7/7.72 / Tiny fix --- init.lua | 2 +- modules/client/client.lua | 2 +- modules/gamelib/game.lua | 11 ++++++----- modules/gamelib/protocollogin.lua | 6 +++--- src/client/game.cpp | 8 ++++---- src/client/protocolgameparse.cpp | 11 +++++++++-- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/init.lua b/init.lua index 59798fda..5ef3a990 100644 --- a/init.lua +++ b/init.lua @@ -48,7 +48,7 @@ g_modules.ensureModuleLoaded("game_interface") -- mods 1000-9999 g_modules.autoLoadModules(9999) -local script = '/' .. g_app.getCompactName() .. 'rc' +local script = '/' .. g_app.getCompactName() .. 'rc.lua' if g_resources.fileExists(script) then dofile(script) diff --git a/modules/client/client.lua b/modules/client/client.lua index 99787b22..155f24f6 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -14,7 +14,7 @@ function reloadScripts() g_textures.clearCache() g_modules.reloadModules() - local script = '/' .. g_app.getCompactName() .. 'rc' + local script = '/' .. g_app.getCompactName() .. 'rc.lua' if g_resources.fileExists(script) then dofile(script) end diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index 4c407963..8d524be4 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -48,11 +48,12 @@ end function g_game.getSupportedClients() return { - 760, 810, 811, 840, 842, 850, 853, - 854, 860, 861, 862, 870, 910, 940, - 944, 953, 954, 960, 961, 963, 970, - 980, 981, 982, 983, 984, 985, 986, - 1001, 1002, 1010, 1020, 1021, 1022, + 760, 770, 772, 810, 811, 840, 842, + 850, 853, 854, 860, 861, 862, 870, + 910, 940, 944, 953, 954, 960, 961, + 963, 970, 980, 981, 982, 983, 984, + 985, 986, 1001, 1002, 1010, 1020, + 1021, 1022 } end diff --git a/modules/gamelib/protocollogin.lua b/modules/gamelib/protocollogin.lua index 30d3d11d..043b39b7 100644 --- a/modules/gamelib/protocollogin.lua +++ b/modules/gamelib/protocollogin.lua @@ -46,7 +46,7 @@ function ProtocolLogin:sendLoginPacket() local offset = msg:getMessageSize() - if g_game.getProtocolVersion() >= 800 then + if g_game.getProtocolVersion() >= 770 then -- first RSA byte must be 0 msg:addU8(0) -- xtea key @@ -74,7 +74,7 @@ function ProtocolLogin:sendLoginPacket() local paddingBytes = g_crypt.rsaGetSize() - (msg:getMessageSize() - offset) assert(paddingBytes >= 0) msg:addPaddingBytes(paddingBytes, 0) - if g_game.getProtocolVersion() >= 800 then + if g_game.getProtocolVersion() >= 770 then msg:encryptRsa() end @@ -83,7 +83,7 @@ function ProtocolLogin:sendLoginPacket() end self:send(msg) - if g_game.getProtocolVersion() >= 800 then + if g_game.getProtocolVersion() >= 770 then self:enableXteaEncryption() end self:recv() diff --git a/src/client/game.cpp b/src/client/game.cpp index 5bdf7ded..0008eb2a 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1445,7 +1445,7 @@ void Game::setProtocolVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change protocol version while online"); - if(version != 0 && version != 760 && (version < 810 || version > 1022)) + if(version != 0 && (version < 760 || (version > 772 && version < 810) || version > 1022)) stdext::throw_exception(stdext::format("Protocol version %d not supported", version)); m_features.reset(); @@ -1453,6 +1453,8 @@ void Game::setProtocolVersion(int version) if(version >= 770) { + enableFeature(Otc::GameLooktypeU16); + enableFeature(Otc::GameMessageStatements); enableFeature(Otc::GameWritableDate); // might not be since 770 } @@ -1462,9 +1464,7 @@ void Game::setProtocolVersion(int version) enableFeature(Otc::GamePlayerStamina); enableFeature(Otc::GameNewFluids); enableFeature(Otc::GameMessageLevel); - enableFeature(Otc::GameMessageStatements); enableFeature(Otc::GamePlayerStateU16); - enableFeature(Otc::GameLooktypeU16); enableFeature(Otc::GameNewOutfitProtocol); } @@ -1553,7 +1553,7 @@ void Game::setClientVersion(int version) if(isOnline()) stdext::throw_exception("Unable to change client version while online"); - if(version != 0 && version != 760 && (version < 810 || version > 1022)) + if(version != 0 && (version < 760 || (version > 772 && version < 810) || version > 1022)) stdext::throw_exception(stdext::format("Client version %d not supported", version)); m_clientVersion = version; diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 45936e83..094a8e43 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -1462,8 +1462,15 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg) outfitList.push_back(std::make_tuple(outfitId, outfitName, outfitAddons)); } } else { - int outfitStart = msg->getU8(); - int outfitEnd = msg->getU8(); + int outfitStart, outfitEnd; + if(g_game.getFeature(Otc::GameLooktypeU16)) { + outfitStart = msg->getU16(); + outfitEnd = msg->getU16(); + } else { + outfitStart = msg->getU8(); + outfitEnd = msg->getU8(); + } + for(int i = outfitStart; i <= outfitEnd; i++) outfitList.push_back(std::make_tuple(i, "", 0)); }