diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-06 17:19:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-06 17:29:51 +0300 |
commit | 208da05ae612c118f1f6d91dca7bbd8670cf2897 (patch) | |
tree | f6e4395b08cce28ac52a20ba3dbe2b78322c652b /src/net/eathena/loginhandler.cpp | |
parent | 4a688fa73264495d6f0db661e6d3d5c4630ed6df (diff) | |
download | mv-208da05ae612c118f1f6d91dca7bbd8670cf2897.tar.gz mv-208da05ae612c118f1f6d91dca7bbd8670cf2897.tar.bz2 mv-208da05ae612c118f1f6d91dca7bbd8670cf2897.tar.xz mv-208da05ae612c118f1f6d91dca7bbd8670cf2897.zip |
eathena: add packets SMSG_SERVER_VERSION_RESPONSE 0x7531
and CMSG_SERVER_VERSION_REQUEST 0x7530
Diffstat (limited to 'src/net/eathena/loginhandler.cpp')
-rw-r--r-- | src/net/eathena/loginhandler.cpp | 47 |
1 files changed, 38 insertions, 9 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 |