summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/download.cpp8
-rw-r--r--src/net/download.h8
-rw-r--r--src/net/guildhandler.h2
-rw-r--r--src/net/manaserv/charhandler.cpp4
-rw-r--r--src/net/manaserv/chathandler.cpp8
-rw-r--r--src/net/manaserv/generalhandler.cpp10
-rw-r--r--src/net/manaserv/guildhandler.cpp4
-rw-r--r--src/net/manaserv/guildhandler.h2
-rw-r--r--src/net/manaserv/loginhandler.cpp2
-rw-r--r--src/net/manaserv/partyhandler.h2
-rw-r--r--src/net/partyhandler.h4
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp19
-rw-r--r--src/net/tmwa/gui/guildtab.cpp4
-rw-r--r--src/net/tmwa/gui/partytab.cpp3
-rw-r--r--src/net/tmwa/guildhandler.h2
-rw-r--r--src/net/tmwa/network.cpp10
-rw-r--r--src/net/tmwa/partyhandler.cpp1
-rw-r--r--src/net/tmwa/partyhandler.h4
19 files changed, 30 insertions, 69 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 38764d8e..dc928d56 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -63,13 +63,7 @@ Download::Download(void *ptr, const std::string &url,
DownloadUpdate updateFunction):
mPtr(ptr),
mUrl(url),
- mFileName(""),
- mWriteFunction(nullptr),
- mUpdateFunction(updateFunction),
- mThread(nullptr),
- mCurl(nullptr),
- mHeaders(nullptr)
-
+ mUpdateFunction(updateFunction)
{
mError = (char*) malloc(CURL_ERROR_SIZE);
mError[0] = 0;
diff --git a/src/net/download.h b/src/net/download.h
index 3e740b62..500de0b6 100644
--- a/src/net/download.h
+++ b/src/net/download.h
@@ -94,12 +94,12 @@ class Download
unsigned checkAdler: 1;
} mOptions;
std::string mFileName;
- WriteFunction mWriteFunction;
+ WriteFunction mWriteFunction = nullptr;
unsigned long mAdler;
DownloadUpdate mUpdateFunction;
- SDL_Thread *mThread;
- CURL *mCurl;
- curl_slist *mHeaders;
+ SDL_Thread *mThread = nullptr;
+ CURL *mCurl = nullptr;
+ curl_slist *mHeaders = nullptr;
char *mError;
};
diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h
index 11ca93b0..00eae99c 100644
--- a/src/net/guildhandler.h
+++ b/src/net/guildhandler.h
@@ -47,7 +47,7 @@ class GuildHandler
virtual void leave(int guildId) = 0;
- virtual void kick(GuildMember *member, std::string reason = "") = 0;
+ virtual void kick(GuildMember *member, std::string reason = std::string()) = 0;
virtual void chat(int guildId, const std::string &text) = 0;
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index 4665a70d..61e44506 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -132,7 +132,7 @@ void CharHandler::handleCharacterCreateResponse(MessageIn &msg)
if (errMsg != ERRMSG_OK)
{
// Character creation failed
- std::string errorMessage = "";
+ std::string errorMessage;
switch (errMsg)
{
case ERRMSG_NO_LOGIN:
@@ -213,7 +213,7 @@ void CharHandler::handleCharacterDeleteResponse(MessageIn &msg)
else
{
// Character deletion failed
- std::string errorMessage = "";
+ std::string errorMessage;
switch (errMsg)
{
case ERRMSG_NO_LOGIN:
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 6d0b6b4e..ce21eb2f 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -195,7 +195,7 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg)
while (msg.getUnreadLength())
{
user = msg.readString();
- if (user == "")
+ if (user.empty())
return;
userModes = msg.readString();
if (userModes.find('o') != std::string::npos)
@@ -218,7 +218,7 @@ void ChatHandler::handleListChannelsResponse(MessageIn &msg)
while (msg.getUnreadLength())
{
std::string channelName = msg.readString();
- if (channelName == "")
+ if (channelName.empty())
return;
std::ostringstream numUsers;
numUsers << msg.readInt16();
@@ -286,7 +286,7 @@ void ChatHandler::handleListChannelUsersResponse(MessageIn &msg)
while (msg.getUnreadLength())
{
userNick = msg.readString();
- if (userNick == "")
+ if (userNick.empty())
{
break;
}
@@ -360,7 +360,7 @@ void ChatHandler::handleWhoResponse(MessageIn &msg)
while (msg.getUnreadLength())
{
userNick = msg.readString();
- if (userNick == "")
+ if (userNick.empty())
{
break;
}
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index aa62dff1..0692ee82 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -23,12 +23,8 @@
#include "client.h"
-#include "gui/changeemaildialog.h"
-#include "gui/charselectdialog.h"
#include "gui/inventorywindow.h"
-#include "gui/register.h"
#include "gui/skilldialog.h"
-#include "gui/specialswindow.h"
#include "net/manaserv/adminhandler.h"
#include "net/manaserv/beinghandler.h"
@@ -51,10 +47,6 @@
#include "resources/attributes.h"
-#include "utils/gettext.h"
-
-#include <list>
-
extern Net::GeneralHandler *generalHandler;
extern ManaServ::LoginHandler *loginHandler;
@@ -64,7 +56,7 @@ namespace ManaServ {
Connection *accountServerConnection = nullptr;
Connection *chatServerConnection = nullptr;
Connection *gameServerConnection = nullptr;
-std::string netToken = "";
+std::string netToken;
ServerInfo gameServer;
ServerInfo chatServer;
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index be2a5ec8..398e9c62 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -42,8 +42,6 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <iostream>
-
extern Net::GuildHandler *guildHandler;
namespace ManaServ {
@@ -143,7 +141,7 @@ void GuildHandler::handleMessage(MessageIn &msg)
{
name = msg.readString();
online = msg.readInt8();
- if (name != "")
+ if (!name.empty())
{
member = guild->addMember(name);
member->setOnline(online);
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index b14bb203..8fbb15d1 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -47,7 +47,7 @@ public:
void leave(int guildId) override;
- void kick(GuildMember *member, std::string reason = "") override;
+ void kick(GuildMember *member, std::string reason = std::string()) override;
void chat(int guildId, const std::string &text) override;
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index 416e9422..e10c8a9e 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -414,7 +414,7 @@ void LoginHandler::loginAccountContinue()
msg.writeString(sha256(sha256(sha256(mLoginData->username + mTmpPassword)) + mLoginData->randomSeed));
accountServerConnection->send(msg);
- mTmpPassword = "";
+ mTmpPassword.clear();
}
void LoginHandler::logout()
diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h
index ed8a1f25..1462ead8 100644
--- a/src/net/manaserv/partyhandler.h
+++ b/src/net/manaserv/partyhandler.h
@@ -39,7 +39,7 @@ public:
void handleMessage(MessageIn &msg) override;
- void create(const std::string &name = "") override;
+ void create(const std::string &name = std::string()) override;
void join(int partyId) override;
diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h
index d496ffc0..4e14ddbd 100644
--- a/src/net/partyhandler.h
+++ b/src/net/partyhandler.h
@@ -38,9 +38,9 @@ namespace Net {
class PartyHandler
{
public:
- virtual ~PartyHandler() {}
+ virtual ~PartyHandler() = default;
- virtual void create(const std::string &name = "") = 0;
+ virtual void create(const std::string &name = std::string()) = 0;
virtual void join(int partyId) = 0;
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 0d638ac1..de7bf827 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -30,7 +30,7 @@ namespace Net {
class PlayerHandler
{
public:
- virtual ~PlayerHandler() {}
+ virtual ~PlayerHandler() = default;
virtual void attack(int id) = 0;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 4c7e18bb..50585970 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -410,18 +410,6 @@ void BeingHandler::handleMessage(MessageIn &msg)
case SMSG_BEING_CHANGE_LOOKS2:
{
- /*
- * SMSG_BEING_CHANGE_LOOKS (0x00c3) and
- * SMSG_BEING_CHANGE_LOOKS2 (0x01d7) do basically the same
- * thing. The difference is that ...LOOKS carries a single
- * 8 bit value, where ...LOOKS2 carries two 16 bit values.
- *
- * If type = 2, then the first 16 bit value is the weapon ID,
- * and the second 16 bit value is the shield ID. If no
- * shield is equipped, or type is not 2, then the second
- * 16 bit value will be 0.
- */
-
if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
break;
@@ -472,7 +460,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
dstBeing->setSprite(SPRITE_MISC2, id);
break;
default:
- logger->log("SMSG_BEING_CHANGE_LOOKS: unsupported type: "
+ logger->log("SMSG_BEING_CHANGE_LOOKS2: unsupported type: "
"%d, id: %d", type, id);
break;
}
@@ -530,12 +518,9 @@ void BeingHandler::handleMessage(MessageIn &msg)
break;
}
- if (Party *party = local_player->getParty()){
+ if (Party *party = local_player->getParty())
if (party->isMember(id))
- {
dstBeing->setParty(party);
- }
- }
// The original speed is ticks per tile * 10
if (speed)
diff --git a/src/net/tmwa/gui/guildtab.cpp b/src/net/tmwa/gui/guildtab.cpp
index b5a3203b..6014e507 100644
--- a/src/net/tmwa/gui/guildtab.cpp
+++ b/src/net/tmwa/gui/guildtab.cpp
@@ -29,13 +29,9 @@
#include "net/net.h"
#include "net/guildhandler.h"
-#include "resources/iteminfo.h"
-#include "resources/itemdb.h"
#include "resources/theme.h"
-#include "utils/dtor.h"
#include "utils/gettext.h"
-#include "utils/stringutils.h"
namespace TmwAthena {
diff --git a/src/net/tmwa/gui/partytab.cpp b/src/net/tmwa/gui/partytab.cpp
index 19f58777..89f3a769 100644
--- a/src/net/tmwa/gui/partytab.cpp
+++ b/src/net/tmwa/gui/partytab.cpp
@@ -29,11 +29,8 @@
#include "net/net.h"
#include "net/partyhandler.h"
-#include "resources/iteminfo.h"
-#include "resources/itemdb.h"
#include "resources/theme.h"
-#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h
index 5f8c987c..4cbdd286 100644
--- a/src/net/tmwa/guildhandler.h
+++ b/src/net/tmwa/guildhandler.h
@@ -46,7 +46,7 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
void leave(int guildId) override;
- void kick(GuildMember *member, std::string reason = "") override;
+ void kick(GuildMember *member, std::string reason = std::string()) override;
void chat(int guildId, const std::string &text) override;
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 17c6b53e..b4ba0b20 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -402,21 +402,21 @@ void Network::dispatchMessages()
if (mInSize < len)
break;
-#ifdef DEBUG
- logger->log("Received %s (0x%x) of length %d", packetInfo->name, msgId, len);
-#endif
-
MessageIn message(mInBuffer, len);
// Dispatch the message to the appropriate handler
auto iter = mMessageHandlers.find(msgId);
if (iter != mMessageHandlers.end())
{
+#ifdef DEBUG
+ logger->log("Handling %s (0x%x) of length %d", packetInfo->name, msgId, len);
+#endif
+
iter->second->handleMessage(message);
}
else
{
- logger->log("Unhandled packet %s (0x%x)", packetInfo->name, msgId);
+ logger->log("Unhandled %s (0x%x) of length %d", packetInfo->name, msgId, len);
}
skip(len);
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 958c8c14..3b636c71 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -25,6 +25,7 @@
#include "event.h"
#include "localplayer.h"
#include "log.h"
+#include "party.h"
#include "gui/socialwindow.h"
diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h
index 5268f395..7b7e2420 100644
--- a/src/net/tmwa/partyhandler.h
+++ b/src/net/tmwa/partyhandler.h
@@ -27,8 +27,6 @@
#include "net/tmwa/messagehandler.h"
-#include "party.h"
-
namespace TmwAthena {
class PartyHandler : public MessageHandler, public Net::PartyHandler
@@ -40,7 +38,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
void handleMessage(MessageIn &msg) override;
- void create(const std::string &name = "") override;
+ void create(const std::string &name = std::string()) override;
void join(int partyId) override;