summaryrefslogtreecommitdiff
path: root/src/net
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
parentb384454131c7bd50ba171b1fdbad64cfc83d1ffb (diff)
downloadmv-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')
-rw-r--r--src/net/ea/loginhandler.cpp1
-rw-r--r--src/net/ea/loginhandler.h2
-rw-r--r--src/net/logindata.h2
-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
7 files changed, 62 insertions, 0 deletions
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 39a920f03..560893a4f 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -151,6 +151,7 @@ void LoginHandler::processUpdateHost(Net::MessageIn &msg)
len = msg.readInt16() - 4;
mUpdateHost = msg.readString(len);
+
if (!checkPath(mUpdateHost))
{
mUpdateHost = "";
diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h
index 555de6385..c3bd2a4e8 100644
--- a/src/net/ea/loginhandler.h
+++ b/src/net/ea/loginhandler.h
@@ -79,6 +79,8 @@ class LoginHandler : public Net::LoginHandler
virtual void processUpdateHost(Net::MessageIn &msg);
+ virtual void processUpdateHost2(Net::MessageIn &msg) = 0;
+
virtual void processLoginData(Net::MessageIn &msg);
virtual void processLoginError(Net::MessageIn &msg);
diff --git a/src/net/logindata.h b/src/net/logindata.h
index e5d3fc97a..0f41b02ae 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -59,6 +59,7 @@ class LoginData
std::string password;
std::string newPassword;
std::string updateHost;
+ std::vector<std::string> updateHosts;
std::string lastLogin;
int updateType;
@@ -79,6 +80,7 @@ class LoginData
password.clear();
newPassword.clear();
updateHost.clear();
+ updateHosts.clear();
updateType = Upd_Normal;
email.clear();
captchaResponse.clear();
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