summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-07 22:56:05 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-09 00:29:40 +0300
commiteacf63c7a4c660b38329325c3958bbc63d10ee5c (patch)
treea06eb415526220ce0911c686dd69e9adcf848dd3 /src/net/tmwa
parentb384454131c7bd50ba171b1fdbad64cfc83d1ffb (diff)
downloadmanaplus-eacf63c7a4c660b38329325c3958bbc63d10ee5c.tar.gz
manaplus-eacf63c7a4c660b38329325c3958bbc63d10ee5c.tar.bz2
manaplus-eacf63c7a4c660b38329325c3958bbc63d10ee5c.tar.xz
manaplus-eacf63c7a4c660b38329325c3958bbc63d10ee5c.zip
Add support for many update hosts (evol server only).
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/loginhandler.cpp48
-rw-r--r--src/net/tmwa/loginhandler.h4
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/protocol.h3
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