From 4247e05ae8ee9e14323629701c3a11e5c2fac674 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 10 Nov 2014 22:02:37 +0300 Subject: eathnea; add support for update hosts. --- src/net/ea/loginhandler.cpp | 23 +++++++++++++++++++++++ src/net/ea/loginhandler.h | 2 ++ src/net/eathena/loginhandler.cpp | 5 +++++ src/net/eathena/network.h | 2 +- src/net/eathena/protocol.h | 2 ++ src/net/tmwa/loginhandler.cpp | 23 ----------------------- src/net/tmwa/loginhandler.h | 2 -- 7 files changed, 33 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 11fe197c2..8b2ec1ed1 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -323,6 +323,29 @@ void LoginHandler::loginOrRegister(LoginData *const data) const serverConfig.setValue("remember", remember); } +void LoginHandler::processUpdateHost2(Net::MessageIn &msg) +{ + const int len = msg.readInt16("len") - 4; + const std::string updateHost = msg.readString(len, "host"); + + splitToStringVector(loginData.updateHosts, updateHost, '|'); + FOR_EACH (StringVectIter, it, loginData.updateHosts) + { + if (!checkPath(*it)) + { + logger->log1("Warning: incorrect update server name"); + loginData.updateHosts.clear(); + break; + } + } + + logger->log("Received update hosts \"%s\" from login server.", + updateHost.c_str()); + + if (client->getState() == STATE_PRE_LOGIN) + client->setState(STATE_LOGIN); +} + void LoginHandler::logout() const { } diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index 845e11f50..93fe3fb2d 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -95,6 +95,8 @@ class LoginHandler notfinal : public Net::LoginHandler static void processLoginError(Net::MessageIn &msg); + static void processUpdateHost2(Net::MessageIn &msg); + void loginOrRegister(LoginData *const data) const override final; protected: diff --git a/src/net/eathena/loginhandler.cpp b/src/net/eathena/loginhandler.cpp index 3332091d1..c36b6a1d1 100644 --- a/src/net/eathena/loginhandler.cpp +++ b/src/net/eathena/loginhandler.cpp @@ -55,6 +55,7 @@ LoginHandler::LoginHandler() : SMSG_LOGIN_ERROR2, SMSG_CHAR_PASSWORD_RESPONSE, SMSG_SERVER_VERSION_RESPONSE, + SMSG_UPDATE_HOST, 0 }; handledMessages = _messages; @@ -89,6 +90,10 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) processServerVersion(msg); break; + case SMSG_UPDATE_HOST: + processUpdateHost(msg); + break; + default: break; } diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h index fae4f06d5..81e2131e0 100644 --- a/src/net/eathena/network.h +++ b/src/net/eathena/network.h @@ -29,7 +29,7 @@ * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. */ -#define CLIENT_PROTOCOL_VERSION 1 +#define CLIENT_PROTOCOL_VERSION 2 namespace EAthena { diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index 4645389ff..7a83d5c84 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -306,6 +306,8 @@ #define SMSG_ELEMENTAL_UPDATE_STATUS 0x081e #define SMSG_ELEMENTAL_INFO 0x081d +#define SMSG_UPDATE_HOST 0x0063 + /********************************** * Packets from client to server * **********************************/ diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 42ea0101b..ee0381475 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -242,29 +242,6 @@ void LoginHandler::processServerVersion(Net::MessageIn &msg) mVersionResponse = true; } -void LoginHandler::processUpdateHost2(Net::MessageIn &msg) -{ - const int len = msg.readInt16("len") - 4; - const std::string updateHost = msg.readString(len, "host"); - - splitToStringVector(loginData.updateHosts, updateHost, '|'); - FOR_EACH (StringVectIter, it, loginData.updateHosts) - { - if (!checkPath(*it)) - { - logger->log1("Warning: incorrect update server name"); - loginData.updateHosts.clear(); - break; - } - } - - logger->log("Received update hosts \"%s\" from login server.", - updateHost.c_str()); - - if (client->getState() == STATE_PRE_LOGIN) - client->setState(STATE_LOGIN); -} - int LoginHandler::supportedOptionalActions() const { return serverFeatures->haveEmailOnRegister() diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h index 03f2c22b4..f6565d3e3 100644 --- a/src/net/tmwa/loginhandler.h +++ b/src/net/tmwa/loginhandler.h @@ -67,8 +67,6 @@ class LoginHandler final : public MessageHandler, public Ea::LoginHandler static void requestUpdateHosts(); - static void processUpdateHost2(Net::MessageIn &msg); - private: void sendLoginRegister(const std::string &restrict username, const std::string &restrict password, -- cgit v1.2.3-70-g09d2