summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/eathena/loginhandler.cpp47
-rw-r--r--src/net/eathena/loginhandler.h8
-rw-r--r--src/net/eathena/network.cpp7
-rw-r--r--src/net/eathena/protocol.h4
-rw-r--r--src/net/tmwa/loginhandler.cpp3
5 files changed, 54 insertions, 15 deletions
diff --git a/src/net/eathena/loginhandler.cpp b/src/net/eathena/loginhandler.cpp
index 763baeccd..3332091d1 100644
--- a/src/net/eathena/loginhandler.cpp
+++ b/src/net/eathena/loginhandler.cpp
@@ -27,6 +27,8 @@
#include "gui/windows/logindialog.h"
+#include "net/serverfeatures.h"
+
#include "net/eathena/messageout.h"
#include "net/eathena/network.h"
#include "net/eathena/protocol.h"
@@ -52,6 +54,7 @@ LoginHandler::LoginHandler() :
SMSG_LOGIN_ERROR,
SMSG_LOGIN_ERROR2,
SMSG_CHAR_PASSWORD_RESPONSE,
+ SMSG_SERVER_VERSION_RESPONSE,
0
};
handledMessages = _messages;
@@ -82,6 +85,10 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
processLoginError2(msg);
break;
+ case SMSG_SERVER_VERSION_RESPONSE:
+ processServerVersion(msg);
+ break;
+
default:
break;
}
@@ -93,8 +100,15 @@ void LoginHandler::connect()
return;
mNetwork->connect(mServer);
- if (client->getState() != STATE_LOGIN)
- client->setState(STATE_LOGIN);
+ if (serverFeatures->haveServerVersion())
+ {
+ sendVersion();
+ }
+ else
+ {
+ if (client->getState() != STATE_LOGIN)
+ client->setState(STATE_LOGIN);
+ }
}
bool LoginHandler::isConnected() const
@@ -131,13 +145,6 @@ void LoginHandler::sendLoginRegister(const std::string &restrict username,
outMsg.writeInt32(20, "client version");
outMsg.writeString(username, 24, "login");
outMsg.writeStringNoLog(password, 24, "password");
-
- /*
- * eAthena calls the last byte "client version 2", but it isn't used at
- * at all. We're retasking it, as a bit mask:
- * 0 - can handle the 0x63 "update host" packet
- * 1 - defaults to the first char-server (instead of the last)
- */
outMsg.writeInt8(0x03, "client type");
}
@@ -224,4 +231,26 @@ void LoginHandler::processUpdateHost2(Net::MessageIn &msg A_UNUSED)
{
}
+void LoginHandler::sendVersion() const
+{
+ createOutPacket(CMSG_SERVER_VERSION_REQUEST);
+ outMsg.writeInt32(CLIENT_PROTOCOL_VERSION, "protocol version");
+ outMsg.writeInt32(0, "unused");
+ outMsg.writeInt32(0, "unused");
+ outMsg.writeInt32(0, "unused");
+ outMsg.writeInt32(0, "unused");
+}
+
+void LoginHandler::processServerVersion(Net::MessageIn &msg)
+{
+ msg.readInt16("len");
+ msg.readInt32("unused");
+ serverVersion = msg.readInt32("server version");
+ if (serverVersion > 0)
+ logger->log("Evol2 server version: %d", serverVersion);
+ else
+ logger->log("Hercules without version");
+ client->setState(STATE_LOGIN);
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/loginhandler.h b/src/net/eathena/loginhandler.h
index eda2c809a..8e30e908a 100644
--- a/src/net/eathena/loginhandler.h
+++ b/src/net/eathena/loginhandler.h
@@ -60,21 +60,21 @@ class LoginHandler final : public MessageHandler, public Ea::LoginHandler
const std::string &restrict newPassword)
const override final;
+ void sendVersion() const;
+
ServerInfo *getCharServer() const override final A_WARN_UNUSED;
static void processLoginError2(Net::MessageIn &msg);
static void processUpdateHost2(Net::MessageIn &msg);
+ static void processServerVersion(Net::MessageIn &msg);
+
private:
void sendLoginRegister(const std::string &restrict username,
const std::string &restrict password,
const std::string &restrict email)
const override final;
-
- // unused
- void processServerVersion(Net::MessageIn &msg A_UNUSED)
- { }
};
} // namespace EAthena
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index ff4bfce14..f0f727462 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -27,6 +27,7 @@
#include "net/eathena/messagehandler.h"
#include "net/eathena/messagein.h"
#include "net/eathena/packets.h"
+#include "net/eathena/protocol.h"
#include "utils/delete2.h"
@@ -139,7 +140,11 @@ bool Network::messageReady()
if (mInSize >= 2)
{
const int msgId = readWord(0);
- if (msgId >= 0 && static_cast<unsigned int>(msgId)
+ if (msgId == SMSG_SERVER_VERSION_RESPONSE)
+ {
+ len = 10;
+ }
+ else if (msgId >= 0 && static_cast<unsigned int>(msgId)
< packet_lengths_size)
{
len = packet_lengths[msgId];
diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h
index 4328941be..4645389ff 100644
--- a/src/net/eathena/protocol.h
+++ b/src/net/eathena/protocol.h
@@ -26,6 +26,8 @@
/*********************************
* Packets from server to client *
*********************************/
+#define SMSG_SERVER_VERSION_RESPONSE 0x7531
+
#define SMSG_SERVER_PING 0x007f /**< Contains server tick */
#define SMSG_CONNECTION_PROBLEM 0x0081
#define SMSG_MAP_NOT_FOUND 0x0840
@@ -308,6 +310,8 @@
* Packets from client to server *
**********************************/
+#define CMSG_SERVER_VERSION_REQUEST 0x7530
+
#define CMSG_LOGIN_REGISTER 0x0064
#define CMSG_NAME_REQUEST 0x088a
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index b0e381407..c4fe39e64 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -110,7 +110,8 @@ void LoginHandler::connect()
return;
mNetwork->connect(mServer);
- createOutPacket(CMSG_SERVER_VERSION_REQUEST);
+ if (serverFeatures->haveServerVersion())
+ createOutPacket(CMSG_SERVER_VERSION_REQUEST);
}
bool LoginHandler::isConnected() const