summaryrefslogtreecommitdiff
path: root/src/net/ea
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-06 00:39:58 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-06 23:06:15 +0300
commit6b291b6515825f4ce0e09df5dec7ea1b619b63a7 (patch)
treef26a35a21cde34f45538a191b2196bf7c81d2693 /src/net/ea
parent833e498f54c1d33be94c09214315b368cccaec06 (diff)
downloadplus-6b291b6515825f4ce0e09df5dec7ea1b619b63a7.tar.gz
plus-6b291b6515825f4ce0e09df5dec7ea1b619b63a7.tar.bz2
plus-6b291b6515825f4ce0e09df5dec7ea1b619b63a7.tar.xz
plus-6b291b6515825f4ce0e09df5dec7ea1b619b63a7.zip
improve a bit different code.
Diffstat (limited to 'src/net/ea')
-rw-r--r--src/net/ea/gamehandler.cpp3
-rw-r--r--src/net/ea/loginhandler.cpp24
-rw-r--r--src/net/ea/loginhandler.h2
-rw-r--r--src/net/ea/network.cpp4
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);