summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/download.cpp4
-rw-r--r--src/net/download.h2
-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
-rw-r--r--src/net/loginhandler.h2
-rw-r--r--src/net/pethandler.h2
-rw-r--r--src/net/serverinfo.h7
-rw-r--r--src/net/tmwa/pethandler.cpp13
-rw-r--r--src/net/tmwa/pethandler.h5
11 files changed, 54 insertions, 14 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 141a7772f..6d127d0a4 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -148,11 +148,11 @@ unsigned long Download::fadler32(FILE *const file)
return adler;
}
-unsigned long Download::adlerBuffer(char *buffer, int size)
+unsigned long Download::adlerBuffer(char *const buffer, int size)
{
unsigned long adler = adler32(0L, Z_NULL, 0);
return adler32(static_cast<uInt>(adler),
- reinterpret_cast<Bytef*>(buffer), size);
+ reinterpret_cast<const Bytef*>(buffer), size);
}
void Download::addHeader(const std::string &header)
diff --git a/src/net/download.h b/src/net/download.h
index bc06f1974..7dae8913f 100644
--- a/src/net/download.h
+++ b/src/net/download.h
@@ -104,7 +104,7 @@ class Download final
static void secureCurl(CURL *const curl);
- static unsigned long adlerBuffer(char *buffer, int size);
+ static unsigned long adlerBuffer(char *const buffer, int size);
static std::string getUploadResponse()
{ return mUploadResponse; }
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..174263dcd 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) const
+{
+ 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..a6e7160cb 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) const 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);
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
index 91c2e4603..6e832aeda 100644
--- a/src/net/loginhandler.h
+++ b/src/net/loginhandler.h
@@ -99,6 +99,8 @@ class LoginHandler
virtual void clearWorlds() = 0;
+ virtual void loginOrRegister(LoginData *const data) const = 0;
+
virtual ~LoginHandler()
{ }
diff --git a/src/net/pethandler.h b/src/net/pethandler.h
index 7b5666396..688eb3034 100644
--- a/src/net/pethandler.h
+++ b/src/net/pethandler.h
@@ -41,7 +41,7 @@ class PetHandler
const int petId,
const int x, const int y) const = 0;
- virtual void emote(const uint8_t emoteId, const int petId) const = 0;
+ virtual void emote(const uint8_t emoteId, const int petId) = 0;
};
} // namespace Net
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 48f216855..899400598 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -49,12 +49,11 @@ public:
std::string name;
std::string hostname;
std::string althostname;
- uint16_t port;
-
std::string description;
std::string registerUrl;
std::string onlineListUrl;
std::string supportUrl;
+ uint16_t port;
VersionString version;
bool save;
@@ -64,11 +63,11 @@ public:
name(),
hostname(),
althostname(),
- port(6901),
description(),
registerUrl(),
onlineListUrl(),
supportUrl(),
+ port(6901),
version(),
save(false)
{
@@ -80,11 +79,11 @@ public:
name(info.name),
hostname(info.hostname),
althostname(info.althostname),
- port(info.port),
description(info.description),
registerUrl(info.registerUrl),
onlineListUrl(info.onlineListUrl),
supportUrl(info.supportUrl),
+ port(info.port),
version(),
save(info.save)
{
diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp
index 3293b7edd..77317a077 100644
--- a/src/net/tmwa/pethandler.cpp
+++ b/src/net/tmwa/pethandler.cpp
@@ -34,7 +34,8 @@ namespace TmwAthena
{
PetHandler::PetHandler() :
- MessageHandler()
+ MessageHandler(),
+ mRandCounter(1000)
{
static const uint16_t _messages[] =
{
@@ -63,10 +64,14 @@ void PetHandler::spawn(const Being *const being A_UNUSED,
{
}
-void PetHandler::emote(const uint8_t emoteId, const int petId A_UNUSED) const
+void PetHandler::emote(const uint8_t emoteId, const int petId A_UNUSED)
{
- Net::getChatHandler()->talk("\302\202\302e" + toString(
- static_cast<int>(emoteId)), GENERAL_CHANNEL);
+ mRandCounter ++;
+ if (mRandCounter > 10000)
+ mRandCounter = 1000;
+
+ Net::getChatHandler()->talk(strprintf("\302\202\302e%dz%d",
+ static_cast<int>(emoteId), mRandCounter), GENERAL_CHANNEL);
}
} // namespace TmwAthena
diff --git a/src/net/tmwa/pethandler.h b/src/net/tmwa/pethandler.h
index 30eff59b8..bcfa6b1a6 100644
--- a/src/net/tmwa/pethandler.h
+++ b/src/net/tmwa/pethandler.h
@@ -47,7 +47,10 @@ class PetHandler final : public MessageHandler, public Net::PetHandler
const int x, const int y) const override final;
void emote(const uint8_t emoteId,
- const int petId) const override final;
+ const int petId) override final;
+
+ protected:
+ int mRandCounter;
};
} // namespace TmwAthena