diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-03-07 22:56:05 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-03-09 00:29:40 +0300 |
commit | eacf63c7a4c660b38329325c3958bbc63d10ee5c (patch) | |
tree | a06eb415526220ce0911c686dd69e9adcf848dd3 /src/net/tmwa/loginhandler.cpp | |
parent | b384454131c7bd50ba171b1fdbad64cfc83d1ffb (diff) | |
download | mv-eacf63c7a4c660b38329325c3958bbc63d10ee5c.tar.gz mv-eacf63c7a4c660b38329325c3958bbc63d10ee5c.tar.bz2 mv-eacf63c7a4c660b38329325c3958bbc63d10ee5c.tar.xz mv-eacf63c7a4c660b38329325c3958bbc63d10ee5c.zip |
Add support for many update hosts (evol server only).
Diffstat (limited to 'src/net/tmwa/loginhandler.cpp')
-rw-r--r-- | src/net/tmwa/loginhandler.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 3b53bbf7c..a2c5034d6 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -32,6 +32,7 @@ #include "net/tmwa/protocol.h" #include "utils/gettext.h" +#include "utils/paths.h" #include "debug.h" @@ -47,6 +48,7 @@ LoginHandler::LoginHandler() static const Uint16 _messages[] = { SMSG_UPDATE_HOST, + SMSG_UPDATE_HOST2, SMSG_LOGIN_DATA, SMSG_LOGIN_ERROR, SMSG_CHAR_PASSWORD_RESPONSE, @@ -73,6 +75,10 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) processUpdateHost(msg); break; + case SMSG_UPDATE_HOST2: + processUpdateHost2(msg); + break; + case SMSG_LOGIN_DATA: processLoginData(msg); break; @@ -144,6 +150,13 @@ ServerInfo *LoginHandler::getCharServer() return &charServer; } +void LoginHandler::requestUpdateHosts() +{ + MessageOut outMsg(CMSG_SEND_CLIENT_INFO); + outMsg.writeInt8(CLIENT_PROTOCOL_VERSION); + outMsg.writeInt8(0); // unused +} + void LoginHandler::processServerVersion(Net::MessageIn &msg) { char b1 = msg.readInt8(); // -1 @@ -156,6 +169,8 @@ void LoginHandler::processServerVersion(Net::MessageIn &msg) mRegistrationEnabled = options; msg.skip(2); // 0 unused serverVersion = msg.readInt8(); + if (serverVersion >= 5) + requestUpdateHosts(); } else { @@ -163,9 +178,42 @@ void LoginHandler::processServerVersion(Net::MessageIn &msg) mRegistrationEnabled = options; serverVersion = 0; } + logger->log("Server version: %d", serverVersion); + if (serverVersion < 5) + { + if (Client::getState() != STATE_LOGIN) + Client::setState(STATE_LOGIN); + } // Leave this last mVersionResponse = true; } +void LoginHandler::processUpdateHost2(Net::MessageIn &msg) +{ + int len; + + len = msg.readInt16() - 4; + std::string updateHost = msg.readString(len); + + splitToStringVector(loginData.updateHosts, updateHost, '|'); + std::vector<std::string>::iterator it = loginData.updateHosts.begin(); + std::vector<std::string>::iterator it_end = loginData.updateHosts.end(); + for (; it != it_end; ++ it) + { + 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); +} + } // namespace TmwAthena |