From 4bac617fd9fb104e68a17622a6985fda0742181b Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 18 Mar 2012 17:59:00 -0300 Subject: [PATCH] some protocol 870 support --- BUGS | 2 ++ modules/client_entergame/characterlist.lua | 14 ++++++--- src/otclient/core/game.cpp | 7 +++-- src/otclient/net/protocolcodes.h | 18 ++++++----- src/otclient/net/protocolgameparse.cpp | 35 +++++++++++++++++++--- 5 files changed, 59 insertions(+), 17 deletions(-) diff --git a/BUGS b/BUGS index 84fce01c..93fcca5d 100644 --- a/BUGS +++ b/BUGS @@ -5,3 +5,5 @@ some animated hits are displayed as 2 hits instead of one skulls is rendering outside map bounds paste on x11 platform does not work correctly when doing ctrl+c in google chrome party options does not work when relogging inside a party + +when the player gets disconnected it isn't removed from the map diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index a5762102..d867cf35 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -55,13 +55,13 @@ end function onGameLoginError(message) CharacterList.destroyLoadBox() local errorBox = displayErrorBox("Login Error", "Login error: " .. message) - errorBox.onOk = CharacterList.show + errorBox.onOk = CharacterList.showAgain end function onGameConnectionError(message) CharacterList.destroyLoadBox() local errorBox = displayErrorBox("Login Error", "Connection error: " .. message) - errorBox.onOk = CharacterList.show + errorBox.onOk = CharacterList.showAgain end -- public functions @@ -73,14 +73,14 @@ function CharacterList.init() connect(g_game, { onLoginError = onGameLoginError }) connect(g_game, { onConnectionError = onGameConnectionError }) connect(g_game, { onGameStart = CharacterList.destroyLoadBox }) - connect(g_game, { onGameEnd = CharacterList.show }) + connect(g_game, { onGameEnd = CharacterList.showAgain }) end function CharacterList.terminate() disconnect(g_game, { onLoginError = onGameLoginError }) disconnect(g_game, { onConnectionError = onGameConnectionError }) disconnect(g_game, { onGameStart = CharacterList.destroyLoadBox }) - disconnect(g_game, { onGameEnd = CharacterList.show }) + disconnect(g_game, { onGameEnd = CharacterList.showAgain }) characterList = nil charactersWindow:destroy() charactersWindow = nil @@ -144,6 +144,12 @@ function CharacterList.show() end end +function CharacterList.showAgain() + if characterList:hasChildren() then + CharacterList.show() + end +end + function CharacterList.isVisible() if charactersWindow and charactersWindow:isVisible() then return true diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index d49bd4fb..0a98bb8e 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -142,7 +142,6 @@ void Game::processDeath(int penality) void Game::processPing() { - m_protocolGame->sendPingResponse(); g_lua.callGlobalField("g_game", "onPing"); } @@ -315,6 +314,10 @@ void Game::processWalkCancel(Otc::Direction direction) void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldHost, int worldPort, const std::string& characterName) { + if(m_protocolGame || isOnline()) { + logTraceError("unable to login into a world while already online or logging"); + return; + } m_protocolGame = ProtocolGamePtr(new ProtocolGame); m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName); } @@ -333,7 +336,7 @@ void Game::forceLogout() if(!isOnline()) return; - m_protocolGame->sendLogout(); + //m_protocolGame->sendLogout(); processDisconnect(); } diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h index 9120481d..a0d9ce06 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/net/protocolcodes.h @@ -25,7 +25,7 @@ #include -#if PROTOCOL < 860 || PROTOCOL > 862 +#if PROTOCOL != 860 && PROTOCOL != 870 && PROTOCOL != 862 && PROTOCOL != 870 #error "the supplied protocol version is not supported" #endif @@ -47,10 +47,10 @@ namespace Proto { constexpr int ClientVersion = PROTOCOL; constexpr int PicSignature = 0x4E119CBF; -#if PROTOCOL==860 - constexpr int NumViolationReasons = 20; -#elif PROTOCOL==861 || PROTOCOL==862 +#if PROTOCOL>=861 constexpr int NumViolationReasons = 19; +#elif PROTOCOL==860 + constexpr int NumViolationReasons = 20; #endif enum OsTypes { @@ -118,8 +118,10 @@ namespace Proto { GameServerPlayerSkills = 161, GameServerPlayerState = 162, GameServerClearTarget = 163, +#if PROTOCOL>=870 GameServerSpellDelay = 164, GameServerSpellGroupDelay = 165, +#endif GameServerTalk = 170, GameServerChannels = 171, GameServerOpenChannel = 172, @@ -209,7 +211,9 @@ namespace Proto { ClientRefreshContainer = 202, ClientRequestOutfit = 210, ClientChangeOutfit = 211, - //ClientMount = 212, +#if PROTOCOL>=870 + ClientMount = 212, +#endif ClientAddVip = 220, ClientRemoveVip = 221, //ClientBugReport = 230, @@ -221,7 +225,7 @@ namespace Proto { }; enum ServerSpeakType { -#if PROTOCOL==861 || PROTOCOL==862 +#if PROTOCOL>=861 ServerSpeakSay = 1, ServerSpeakWhisper, ServerSpeakYell, @@ -265,7 +269,7 @@ namespace Proto { }; enum MessageTypes { -#if PROTOCOL==862 || PROTOCOL==861 +#if PROTOCOL>=862 MessageConsoleOrange = 13, MessageConsoleOrange2, MessageWarning, diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index 198a271b..d9c75d9d 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -165,7 +165,12 @@ void ProtocolGame::parseMessage(InputMessage& msg) case Proto::GameServerCreatureParty: parseCreatureShields(msg); break; - // case Proto::GameServerCreatureUnpass +#if PROTOCOL>=870 + case Proto::GameServerCreatureUnpass: + msg.getU32(); // creature id + msg.getU8(); // unpassable boolean + break; +#endif case Proto::GameServerEditText: parseEditText(msg); break; @@ -184,8 +189,14 @@ void ProtocolGame::parseMessage(InputMessage& msg) case Proto::GameServerClearTarget: parsePlayerCancelAttack(msg); break; - //case Proto::GameServerSpellDelay: - //case Proto::GameServerSpellGroupDelay: +#if PROTOCOL>=870 + case Proto::GameServerSpellDelay: + case Proto::GameServerSpellGroupDelay: + msg.getU16(); // spell id + msg.getU16(); // cooldown + msg.getU8(); // unknown + break; +#endif case Proto::GameServerTalk: parseCreatureSpeak(msg); break; @@ -309,12 +320,13 @@ void ProtocolGame::parseLoginWait(InputMessage& msg) void ProtocolGame::parsePing(InputMessage&) { g_game.processPing(); + sendPingResponse(); } void ProtocolGame::parseDeath(InputMessage& msg) { int penality = 100; -#if PROTOCOL==862 +#if PROTOCOL>=862 penality = msg.getU8(); #endif g_game.processDeath(penality); @@ -721,7 +733,11 @@ void ProtocolGame::parsePlayerStats(InputMessage& msg) double health = msg.getU16(); double maxHealth = msg.getU16(); double freeCapacity = msg.getU32() / 100.0; +#if PROTOCOL >= 870 + double experience = msg.getU64(); +#else double experience = msg.getU32(); +#endif double level = msg.getU16(); double levelPercent = msg.getU8(); double mana = msg.getU16(); @@ -917,6 +933,14 @@ void ProtocolGame::parseOpenOutfitWindow(InputMessage& msg) outfitList.push_back(std::make_tuple(outfitId, outfitName, outfitAddons)); } +#if PROTOCOL>=870 + int mountCount = msg.getU8(); + for(int i=0;i=870 + msg.getU16(); // mount +#endif outfit.setId(id); outfit.setHead(head);