From ca46b5033e98836da78ffc4e57193e1fe958c032 Mon Sep 17 00:00:00 2001 From: BeniS Date: Fri, 4 Jan 2013 11:42:02 +1300 Subject: [PATCH] More progress on cipserver login for pv973 and a few fixes. * Fixed the "options" module hotkey (changed boost walker to Ctrl+Shift+D). * Fixed a small issue with UIMiniWindow:setup() function (was setting parent before its pos). * Pic signature has changed for cipsoft client. * Fixed 'client type' byte position in the login packet. * Changed the ping function to execute every 4 seconds rather than 2. * Changed some protocolgame for pv973 support. --- .gitignore | 1 + modules/client_options/options.lua | 3 ++- modules/corelib/ui/uiminiwindow.lua | 2 +- modules/gamelib/const.lua | 5 ++++- modules/gamelib/protocollogin.lua | 5 ++++- src/otclient/game.cpp | 4 +++- src/otclient/protocolcodes.h | 3 ++- src/otclient/protocolgame.h | 1 + src/otclient/protocolgameparse.cpp | 13 ++++++++++--- src/otclient/protocolgamesend.cpp | 11 +++++++++-- 10 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index ef197501..c83ecaee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/modules/.project build* CMakeCache.txt CMakeFiles diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 99836cd5..badd2685 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -90,8 +90,9 @@ function Options.init() end end + g_keyboard.bindKeyDown('Ctrl+D', function() Options.toggle() end) g_keyboard.bindKeyDown('Ctrl+F', function() Options.toggleOption('fullscreen') end) - g_keyboard.bindKeyDown('Ctrl+D', function() Options.toggleOption('walkBooster') end) + g_keyboard.bindKeyDown('Ctrl+Shift+D', function() Options.toggleOption('walkBooster') end) optionsWindow = g_ui.displayUI('options.otui') optionsWindow:hide() diff --git a/modules/corelib/ui/uiminiwindow.lua b/modules/corelib/ui/uiminiwindow.lua index 4894d03d..e0b4ddb4 100644 --- a/modules/corelib/ui/uiminiwindow.lua +++ b/modules/corelib/ui/uiminiwindow.lua @@ -95,8 +95,8 @@ function UIMiniWindow:setup() self.miniIndex = selfSettings.index parent:scheduleInsert(self, selfSettings.index) elseif selfSettings.position then - self:setParent(parent) self:setPosition(topoint(selfSettings.position)) + self:setParent(parent) addEvent(function() self:bindRectToParent() end) end end diff --git a/modules/gamelib/const.lua b/modules/gamelib/const.lua index 8c742f1b..6a5e70e4 100644 --- a/modules/gamelib/const.lua +++ b/modules/gamelib/const.lua @@ -149,6 +149,9 @@ CIPSOFT_RSA = "1321277432058722840622950990822933849527763264961655079678763618" -- set to the latest Tibia.pic signature to make otclient compatible with official tibia PIC_SIGNATURE = 1337606793 +if g_game.getClientVersion() < 970 then + PIC_SIGNATURE = 1353074333 +end OsTypes = { Linux = 1, @@ -162,7 +165,7 @@ OsTypes = { PathFindResults = { Ok = 0, Position = 1, - Impossipble = 2, + Impossible = 2, TooFar = 3, NoWay = 4 } diff --git a/modules/gamelib/protocollogin.lua b/modules/gamelib/protocollogin.lua index 1532f731..416dfa84 100644 --- a/modules/gamelib/protocollogin.lua +++ b/modules/gamelib/protocollogin.lua @@ -32,13 +32,16 @@ function ProtocolLogin:sendLoginPacket() if g_game.getProtocolVersion() >= 971 then msg:addU32(g_game.getClientVersion()) - msg:addU8(182) -- clientType end msg:addU32(g_things.getDatSignature()) msg:addU32(g_sprites.getSprSignature()) msg:addU32(PIC_SIGNATURE) + if g_game.getProtocolVersion() >= 971 then + msg:addU8(0) -- clientType + end + local paddingBytes = 128 msg:addU8(0) -- first RSA byte must be 0 paddingBytes = paddingBytes - 1 diff --git a/src/otclient/game.cpp b/src/otclient/game.cpp index 4597b4bd..06e89ca3 100644 --- a/src/otclient/game.cpp +++ b/src/otclient/game.cpp @@ -133,6 +133,8 @@ void Game::processPendingGame() void Game::processEnterGame() { m_localPlayer->setPendingGame(false); + m_protocolGame->sendEnterGame(); + g_lua.callGlobalField("g_game", "onEnterGame"); } @@ -156,7 +158,7 @@ void Game::processGameStart() m_protocolGame->sendPing(); disableBotCall(); } - }, 2000); + }, 4000); } } diff --git a/src/otclient/protocolcodes.h b/src/otclient/protocolcodes.h index 0c95c3ac..5441ad0e 100644 --- a/src/otclient/protocolcodes.h +++ b/src/otclient/protocolcodes.h @@ -145,7 +145,8 @@ namespace Proto { enum ClientOpcodes : uint8 { ClientEnterAccount = 1, - ClientEnterGame = 10, + ClientPendingGame = 10, + ClientEnterGame = 15, ClientLeaveGame = 20, ClientPing = 29, ClientPingBack = 30, diff --git a/src/otclient/protocolgame.h b/src/otclient/protocolgame.h index 7e5b0f9e..8e8f8aac 100644 --- a/src/otclient/protocolgame.h +++ b/src/otclient/protocolgame.h @@ -36,6 +36,7 @@ public: void sendExtendedOpcode(uint8 opcode, const std::string& buffer); void sendLoginPacket(uint challangeTimestamp, uint8 challangeRandom); + void sendEnterGame(); void sendLogout(); void sendPing(); void sendPingBack(); diff --git a/src/otclient/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp index 84b2b22c..fd460818 100644 --- a/src/otclient/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -43,9 +43,11 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg) opcode = msg->getU8(); // must be > so extended will be enabled before GameStart. - if(!m_gameInitialized && opcode > Proto::GameServerFirstGameOpcode) { - g_game.processGameStart(); - m_gameInitialized = true; + if(!g_game.getFeature(Otc::GameLoginPending)) { + if(!m_gameInitialized && opcode > Proto::GameServerFirstGameOpcode) { + g_game.processGameStart(); + m_gameInitialized = true; + } } // try to parse in lua first @@ -361,6 +363,11 @@ void ProtocolGame::parseEnterGame(const InputMessagePtr& msg) { //set player to entered game state g_game.processEnterGame(); + + if(!m_gameInitialized) { + g_game.processGameStart(); + m_gameInitialized = true; + } } void ProtocolGame::parseGMActions(const InputMessagePtr& msg) diff --git a/src/otclient/protocolgamesend.cpp b/src/otclient/protocolgamesend.cpp index b9fa6025..c48401ba 100644 --- a/src/otclient/protocolgamesend.cpp +++ b/src/otclient/protocolgamesend.cpp @@ -48,7 +48,7 @@ void ProtocolGame::sendLoginPacket(uint challangeTimestamp, uint8 challangeRando { OutputMessagePtr msg(new OutputMessage); - msg->addU8(Proto::ClientEnterGame); + msg->addU8(Proto::ClientPendingGame); msg->addU16(g_lua.callGlobalField("g_game", "getOsType")); msg->addU16(g_game.getProtocolVersion()); @@ -103,6 +103,13 @@ void ProtocolGame::sendLoginPacket(uint challangeTimestamp, uint8 challangeRando enableXteaEncryption(); } +void ProtocolGame::sendEnterGame() +{ + OutputMessagePtr msg(new OutputMessage); + msg->addU8(Proto::ClientEnterGame); + send(msg); +} + void ProtocolGame::sendLogout() { OutputMessagePtr msg(new OutputMessage); @@ -444,7 +451,7 @@ void ProtocolGame::sendLook(const Position& position, int thingId, int stackpos) void ProtocolGame::sendLookCreature(uint32 creatureId) { OutputMessagePtr msg(new OutputMessage); - msg->addU8(0x8D); + msg->addU8(Proto::ClientLookCreature); msg->addU32(creatureId); send(msg); }