diff options
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 35 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.h | 4 | ||||
-rw-r--r-- | src/net/eathena/charserverhandler.cpp | 39 | ||||
-rw-r--r-- | src/net/eathena/charserverhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 39 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.h | 2 |
6 files changed, 80 insertions, 41 deletions
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 9b747ed49..90b1cfba9 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -248,41 +248,6 @@ void CharServerHandler::clear() mCharacters.clear(); } -void CharServerHandler::processCharMapInfo(Net::MessageIn &restrict msg, - Network *restrict const network, - ServerInfo &restrict server) -{ - BLOCK_START("CharServerHandler::processCharMapInfo") -// msg.skip(4); // CharID, must be the same as localPlayer->charID - PlayerInfo::setCharId(msg.readInt32()); - GameHandler *const gh = static_cast<GameHandler*>(Net::getGameHandler()); - gh->setMap(msg.readString(16)); - if (config.getBoolValue("usePersistentIP") || settings.persistentIp) - { - msg.readInt32(); - server.hostname = settings.serverName; - } - else - { - server.hostname = ipToString(msg.readInt32()); - } - server.port = msg.readInt16(); - - // Prevent the selected local player from being deleted - localPlayer = mSelectedCharacter->dummy; - PlayerInfo::setBackend(mSelectedCharacter->data); - - mSelectedCharacter->dummy = nullptr; - - Net::getCharServerHandler()->clear(); - updateCharSelectDialog(); - - if (network) - network->disconnect(); - client->setState(STATE_CONNECT_GAME); - BLOCK_END("CharServerHandler::processCharMapInfo") -} - void CharServerHandler::processChangeMapServer(Net::MessageIn &restrict msg, Network *restrict const network, ServerInfo &restrict server) diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index e86965f6b..ebafea22c 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -76,10 +76,6 @@ class CharServerHandler notfinal : public Net::CharServerHandler virtual void processCharDeleteFailed(Net::MessageIn &msg); - virtual void processCharMapInfo(Net::MessageIn &restrict msg, - Network *restrict const network, - ServerInfo &restrict mapServer); - virtual void processChangeMapServer(Net::MessageIn &restrict msg, Network *restrict const network, ServerInfo &restrict mapServer) diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp index 58b757e3f..d46728fac 100644 --- a/src/net/eathena/charserverhandler.cpp +++ b/src/net/eathena/charserverhandler.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "configuration.h" +#include "settings.h" #include "being/attributes.h" @@ -32,6 +33,7 @@ #include "net/net.h" #include "net/eathena/attrs.h" +#include "net/eathena/gamehandler.h" #include "net/eathena/loginhandler.h" #include "net/eathena/messageout.h" #include "net/eathena/network.h" @@ -105,7 +107,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_CHAR_MAP_INFO: - processCharMapInfo(msg, mNetwork, mapServer); + processCharMapInfo(msg); break; case SMSG_CHANGE_MAP_SERVER: @@ -298,4 +300,39 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg) client->setState(STATE_CHAR_SELECT); } +void CharServerHandler::processCharMapInfo(Net::MessageIn &restrict msg) +{ + Network *const network = mNetwork; + ServerInfo &server = mapServer; + BLOCK_START("CharServerHandler::processCharMapInfo") +// msg.skip(4); // CharID, must be the same as localPlayer->charID + PlayerInfo::setCharId(msg.readInt32()); + GameHandler *const gh = static_cast<GameHandler*>(Net::getGameHandler()); + gh->setMap(msg.readString(16)); + if (config.getBoolValue("usePersistentIP") || settings.persistentIp) + { + msg.readInt32(); + server.hostname = settings.serverName; + } + else + { + server.hostname = ipToString(msg.readInt32()); + } + server.port = msg.readInt16(); + + // Prevent the selected local player from being deleted + localPlayer = mSelectedCharacter->dummy; + PlayerInfo::setBackend(mSelectedCharacter->data); + + mSelectedCharacter->dummy = nullptr; + + Net::getCharServerHandler()->clear(); + updateCharSelectDialog(); + + if (network) + network->disconnect(); + client->setState(STATE_CONNECT_GAME); + BLOCK_END("CharServerHandler::processCharMapInfo") +} + } // namespace EAthena diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h index 326921a99..e5618ab35 100644 --- a/src/net/eathena/charserverhandler.h +++ b/src/net/eathena/charserverhandler.h @@ -59,6 +59,8 @@ class CharServerHandler final : public MessageHandler, void processCharLogin(Net::MessageIn &msg); + void processCharMapInfo(Net::MessageIn &restrict msg); + protected: void readPlayerData(Net::MessageIn &msg, Net::Character *const character, diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index ba90556fa..b8bdf4842 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "configuration.h" +#include "settings.h" #include "being/attributes.h" @@ -32,6 +33,7 @@ #include "net/net.h" #include "net/tmwa/attrs.h" +#include "net/tmwa/gamehandler.h" #include "net/tmwa/loginhandler.h" #include "net/tmwa/messageout.h" #include "net/tmwa/network.h" @@ -107,7 +109,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_CHAR_MAP_INFO: - processCharMapInfo(msg, mNetwork, mapServer); + processCharMapInfo(msg); break; case SMSG_CHANGE_MAP_SERVER: @@ -350,4 +352,39 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg) BLOCK_END("CharServerHandler::processCharLogin") } +void CharServerHandler::processCharMapInfo(Net::MessageIn &restrict msg) +{ + Network *const network = mNetwork; + ServerInfo &server = mapServer; + BLOCK_START("CharServerHandler::processCharMapInfo") +// msg.skip(4); // CharID, must be the same as localPlayer->charID + PlayerInfo::setCharId(msg.readInt32()); + GameHandler *const gh = static_cast<GameHandler*>(Net::getGameHandler()); + gh->setMap(msg.readString(16)); + if (config.getBoolValue("usePersistentIP") || settings.persistentIp) + { + msg.readInt32(); + server.hostname = settings.serverName; + } + else + { + server.hostname = ipToString(msg.readInt32()); + } + server.port = msg.readInt16(); + + // Prevent the selected local player from being deleted + localPlayer = mSelectedCharacter->dummy; + PlayerInfo::setBackend(mSelectedCharacter->data); + + mSelectedCharacter->dummy = nullptr; + + Net::getCharServerHandler()->clear(); + updateCharSelectDialog(); + + if (network) + network->disconnect(); + client->setState(STATE_CONNECT_GAME); + BLOCK_END("CharServerHandler::processCharMapInfo") +} + } // namespace TmwAthena diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index c2f6596be..8910b784c 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -59,6 +59,8 @@ class CharServerHandler final : public MessageHandler, void processCharLogin(Net::MessageIn &msg); + void processCharMapInfo(Net::MessageIn &restrict msg); + protected: void readPlayerData(Net::MessageIn &msg, Net::Character *const character, |