diff options
Diffstat (limited to 'src/net/tmwa')
-rw-r--r-- | src/net/tmwa/loginhandler.cpp | 48 | ||||
-rw-r--r-- | src/net/tmwa/loginhandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/network.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/protocol.h | 3 |
4 files changed, 57 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 diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h index e2b8beec7..b27b0af77 100644 --- a/src/net/tmwa/loginhandler.h +++ b/src/net/tmwa/loginhandler.h @@ -67,6 +67,10 @@ class LoginHandler : public MessageHandler, public Ea::LoginHandler void processServerVersion(Net::MessageIn &msg); + void requestUpdateHosts(); + + void processUpdateHost2(Net::MessageIn &msg); + private: void sendLoginRegister(const std::string &username, const std::string &password); diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 5d5a84a64..0e0c09d5f 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -331,6 +331,8 @@ MessageIn Network::getNextMessage() int len; if (msgId == SMSG_SERVER_VERSION_RESPONSE) len = 10; + else if (msgId == SMSG_UPDATE_HOST2) + len = -1; else len = packet_lengths[msgId]; diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h index 256f1dce4..130268b82 100644 --- a/src/net/tmwa/protocol.h +++ b/src/net/tmwa/protocol.h @@ -338,4 +338,7 @@ enum #define SMSG_NPC_COMMAND 0x0212 #define CMSG_SET_STATUS 0x0213 +#define CMSG_SEND_CLIENT_INFO 0x7533 +#define SMSG_UPDATE_HOST2 0x7534 + #endif |