diff options
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/gamehandler.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/loginhandler.cpp | 24 | ||||
-rw-r--r-- | src/net/ea/loginhandler.h | 2 | ||||
-rw-r--r-- | src/net/ea/network.cpp | 4 |
4 files changed, 32 insertions, 1 deletions
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index de1d6f151..b0be76ac6 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -62,6 +62,9 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) const msg.skip(2); // 0x0505 logger->log("Protocol: Player start position: (%d, %d)," " Direction: %d", x, y, direction); + + mLastHost &= 0xffffff; + // Switch now or we'll have problems client->setState(STATE_GAME); if (player_node) diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 44d834b94..df1516b8b 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -291,6 +291,30 @@ void LoginHandler::processLoginError(Net::MessageIn &msg) const client->setState(STATE_ERROR); } +void LoginHandler::loginOrRegister(LoginData *const data) +{ + if (!data) + return; + + logger->log("Username is %s", data->username.c_str()); + + // Send login infos + if (data->registerLogin) + registerAccount(data); + else + loginAccount(data); + + // Clear the password, avoids auto login when returning to login + data->password.clear(); + + const bool remember = data->remember; + if (remember) + serverConfig.setValue("username", data->username); + else + serverConfig.setValue("username", ""); + serverConfig.setValue("remember", remember); +} + void LoginHandler::logout() const { } diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index f539176f5..ec1610013 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -96,6 +96,8 @@ class LoginHandler : public Net::LoginHandler virtual void processServerVersion(Net::MessageIn &msg) = 0; + void loginOrRegister(LoginData *const data) override final; + protected: LoginHandler(); diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index c5ed9de57..128ca2996 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -32,6 +32,8 @@ #include "debug.h" +extern unsigned int mLastHost; + namespace Ea { @@ -89,7 +91,6 @@ bool Network::connect(ServerInfo server) if (mState != IDLE && mState != NET_ERROR) { logger->log1("Tried to connect an already connected socket!"); -// assert(false); return false; } @@ -217,6 +218,7 @@ bool Network::realConnect() return false; } + mLastHost = ipAddress.host; logger->log_r("Network::Started session with %s:%i", ipToString(ipAddress.host), ipAddress.port); |