summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-05 10:13:15 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-06 21:49:14 +0000
commit3ce39d2b497ab5356290a22b324181386af51c51 (patch)
tree1b923b8be7e4d2ce8ff70768dc7fff596487935c /src/net/manaserv
parenta9df89bda908e3b3d443db7f3ca865b6f12c75e5 (diff)
downloadmana-3ce39d2b497ab5356290a22b324181386af51c51.tar.gz
mana-3ce39d2b497ab5356290a22b324181386af51c51.tar.bz2
mana-3ce39d2b497ab5356290a22b324181386af51c51.tar.xz
mana-3ce39d2b497ab5356290a22b324181386af51c51.zip
General code cleanups
* Use final for all message handlers, Client, LocalPlayer, Being::getType, Being::setPosition and Being::setMap. (avoids some warnings about virtual dispatch in constructors) * Use auto in more places * Use emplace_back instead of push_back in some places * Use default member initializers * Less else after return * Removed superfluous .c_str() * Removed type aliases that are only used once * Removed more unused includes
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/adminhandler.cpp2
-rw-r--r--src/net/manaserv/adminhandler.h2
-rw-r--r--src/net/manaserv/beinghandler.h4
-rw-r--r--src/net/manaserv/buysellhandler.h2
-rw-r--r--src/net/manaserv/charhandler.cpp5
-rw-r--r--src/net/manaserv/charhandler.h2
-rw-r--r--src/net/manaserv/chathandler.h2
-rw-r--r--src/net/manaserv/effecthandler.h2
-rw-r--r--src/net/manaserv/gamehandler.h3
-rw-r--r--src/net/manaserv/guildhandler.h2
-rw-r--r--src/net/manaserv/inventoryhandler.h4
-rw-r--r--src/net/manaserv/itemhandler.h2
-rw-r--r--src/net/manaserv/loginhandler.cpp2
-rw-r--r--src/net/manaserv/loginhandler.h3
-rw-r--r--src/net/manaserv/npchandler.h6
-rw-r--r--src/net/manaserv/partyhandler.h5
-rw-r--r--src/net/manaserv/playerhandler.cpp3
-rw-r--r--src/net/manaserv/playerhandler.h4
-rw-r--r--src/net/manaserv/specialhandler.h2
-rw-r--r--src/net/manaserv/tradehandler.h2
20 files changed, 22 insertions, 37 deletions
diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp
index 8ba7c47d..78e6acb2 100644
--- a/src/net/manaserv/adminhandler.cpp
+++ b/src/net/manaserv/adminhandler.cpp
@@ -22,8 +22,6 @@
#include "net/manaserv/adminhandler.h"
#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/manaserv_protocol.h"
extern Net::AdminHandler *adminHandler;
diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h
index e3bd02e0..fd0c7de0 100644
--- a/src/net/manaserv/adminhandler.h
+++ b/src/net/manaserv/adminhandler.h
@@ -28,7 +28,7 @@
namespace ManaServ {
-class AdminHandler : public Net::AdminHandler, public MessageHandler
+class AdminHandler final : public Net::AdminHandler, public MessageHandler
{
public:
AdminHandler();
diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h
index 3d80f45f..63424de9 100644
--- a/src/net/manaserv/beinghandler.h
+++ b/src/net/manaserv/beinghandler.h
@@ -23,8 +23,6 @@
#define NET_MANASERV_BEINGHANDLER_H
#include "net/manaserv/messagehandler.h"
-#include "vector.h"
-#include "map.h"
namespace ManaServ {
@@ -38,7 +36,7 @@ enum SpriteLayer
FIXED_SPRITE_LAYER_SIZE
};
-class BeingHandler : public MessageHandler
+class BeingHandler final : public MessageHandler
{
public:
BeingHandler();
diff --git a/src/net/manaserv/buysellhandler.h b/src/net/manaserv/buysellhandler.h
index f0ae9ab3..0629bd7b 100644
--- a/src/net/manaserv/buysellhandler.h
+++ b/src/net/manaserv/buysellhandler.h
@@ -26,7 +26,7 @@
namespace ManaServ {
-class BuySellHandler : public MessageHandler
+class BuySellHandler final : public MessageHandler
{
public:
BuySellHandler();
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index 83919d4e..e7afa173 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -333,9 +333,8 @@ void CharHandler::newCharacter(const std::string &name,
msg.writeInt8(gender);
msg.writeInt8(slot);
- std::vector<int>::const_iterator it, it_end;
- for (it = stats.begin(), it_end = stats.end(); it != it_end; it++)
- msg.writeInt16((*it));
+ for (int stat : stats)
+ msg.writeInt16(stat);
accountServerConnection->send(msg);
}
diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h
index 262d8a01..9ec5cdbb 100644
--- a/src/net/manaserv/charhandler.h
+++ b/src/net/manaserv/charhandler.h
@@ -37,7 +37,7 @@ namespace ManaServ {
/**
* Deals with incoming messages related to character selection.
*/
-class CharHandler : public MessageHandler, public Net::CharHandler
+class CharHandler final : public MessageHandler, public Net::CharHandler
{
public:
CharHandler();
diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h
index 4ad04a70..c4dc6861 100644
--- a/src/net/manaserv/chathandler.h
+++ b/src/net/manaserv/chathandler.h
@@ -28,7 +28,7 @@
namespace ManaServ {
-class ChatHandler : public MessageHandler, public Net::ChatHandler
+class ChatHandler final : public MessageHandler, public Net::ChatHandler
{
public:
ChatHandler();
diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h
index 268e2725..4ba711d7 100644
--- a/src/net/manaserv/effecthandler.h
+++ b/src/net/manaserv/effecthandler.h
@@ -26,7 +26,7 @@
namespace ManaServ {
-class EffectHandler : public MessageHandler
+class EffectHandler final : public MessageHandler
{
public:
EffectHandler();
diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h
index 01d23b43..019c2dfa 100644
--- a/src/net/manaserv/gamehandler.h
+++ b/src/net/manaserv/gamehandler.h
@@ -23,7 +23,6 @@
#define NET_MANASERV_MAPHANDLER_H
#include "net/gamehandler.h"
-#include "net/serverinfo.h"
#include "net/manaserv/messagehandler.h"
@@ -31,7 +30,7 @@
namespace ManaServ {
-class GameHandler : public MessageHandler, public Net::GameHandler
+class GameHandler final : public MessageHandler, public Net::GameHandler
{
public:
GameHandler();
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index 8fbb15d1..666ae862 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -28,7 +28,7 @@
namespace ManaServ {
-class GuildHandler : public Net::GuildHandler, public MessageHandler
+class GuildHandler final : public Net::GuildHandler, public MessageHandler
{
public:
GuildHandler();
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index 7ed1b9d5..452ccf3e 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -33,7 +33,7 @@
namespace ManaServ {
-class EquipBackend : public Equipment::Backend, public EventListener
+class EquipBackend final : public Equipment::Backend, public EventListener
{
public:
EquipBackend();
@@ -110,7 +110,7 @@ class EquipBackend : public Equipment::Backend, public EventListener
std::vector<std::string> mBoxesBackgroundFile;
};
-class InventoryHandler : public MessageHandler, Net::InventoryHandler,
+class InventoryHandler final : public MessageHandler, Net::InventoryHandler,
public EventListener
{
public:
diff --git a/src/net/manaserv/itemhandler.h b/src/net/manaserv/itemhandler.h
index 4396886f..22adf8fb 100644
--- a/src/net/manaserv/itemhandler.h
+++ b/src/net/manaserv/itemhandler.h
@@ -26,7 +26,7 @@
namespace ManaServ {
-class ItemHandler : public MessageHandler
+class ItemHandler final : public MessageHandler
{
public:
ItemHandler();
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index e10c8a9e..b9a56834 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -345,7 +345,7 @@ void LoginHandler::readServerInfo(MessageIn &msg)
logger->log("Warning: server does not have an update host set!");
// Read the client data folder for dynamic data loading.
- // This is only used by the QT client.
+ // This is only used by the Qt client.
msg.readString();
// Read the number of character slots
diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h
index cdfbe222..87fbe9bc 100644
--- a/src/net/manaserv/loginhandler.h
+++ b/src/net/manaserv/loginhandler.h
@@ -23,7 +23,6 @@
#define NET_MANASERV_LOGINHANDLER_H
#include "net/loginhandler.h"
-#include "net/serverinfo.h"
#include "net/manaserv/messagehandler.h"
@@ -31,7 +30,7 @@ class LoginData;
namespace ManaServ {
-class LoginHandler : public MessageHandler, public Net::LoginHandler
+class LoginHandler final : public MessageHandler, public Net::LoginHandler
{
public:
LoginHandler();
diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h
index 8d397253..ee3a9a12 100644
--- a/src/net/manaserv/npchandler.h
+++ b/src/net/manaserv/npchandler.h
@@ -22,17 +22,13 @@
#ifndef NET_MANASERV_NPCHANDLER_H
#define NET_MANASERV_NPCHANDLER_H
-#include "eventlistener.h"
-
#include "net/npchandler.h"
#include "net/manaserv/messagehandler.h"
-#include <map>
-
namespace ManaServ {
-class NpcHandler : public MessageHandler, public Net::NpcHandler
+class NpcHandler final : public MessageHandler, public Net::NpcHandler
{
public:
NpcHandler();
diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h
index 1462ead8..ac4249a9 100644
--- a/src/net/manaserv/partyhandler.h
+++ b/src/net/manaserv/partyhandler.h
@@ -28,11 +28,9 @@
#include "party.h"
-#include <string>
-
namespace ManaServ {
-class PartyHandler : public MessageHandler, public Net::PartyHandler
+class PartyHandler final : public MessageHandler, public Net::PartyHandler
{
public:
PartyHandler();
@@ -66,6 +64,7 @@ public:
PartyShare getShareItems() override { return PARTY_SHARE_NO; }
void setShareItems(PartyShare share) override {}
+
private:
Party *mParty;
};
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 15b0eb5c..0b098ea8 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -31,14 +31,11 @@
#include "playerinfo.h"
#include "configuration.h"
-#include "gui/gui.h"
-#include "gui/okdialog.h"
#include "gui/viewport.h"
#include "net/net.h"
#include "net/manaserv/connection.h"
-#include "net/manaserv/defines.h"
#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
#include "net/manaserv/manaserv_protocol.h"
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index e2a52d4d..a14e3ed5 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -30,13 +30,13 @@
namespace ManaServ {
-struct RespawnRequestListener : public gcn::ActionListener
+struct RespawnRequestListener final : public gcn::ActionListener
{
void action(const gcn::ActionEvent &event) override;
};
static RespawnRequestListener respawnListener;
-class PlayerHandler : public MessageHandler, public Net::PlayerHandler
+class PlayerHandler final : public MessageHandler, public Net::PlayerHandler
{
public:
PlayerHandler();
diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h
index 55b5225b..dbd203d8 100644
--- a/src/net/manaserv/specialhandler.h
+++ b/src/net/manaserv/specialhandler.h
@@ -28,7 +28,7 @@
namespace ManaServ {
-class SpecialHandler : public MessageHandler, public Net::SpecialHandler
+class SpecialHandler final : public MessageHandler, public Net::SpecialHandler
{
public:
SpecialHandler();
diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h
index 094b3c17..928a62d9 100644
--- a/src/net/manaserv/tradehandler.h
+++ b/src/net/manaserv/tradehandler.h
@@ -28,7 +28,7 @@
namespace ManaServ {
-class TradeHandler : public MessageHandler, public Net::TradeHandler
+class TradeHandler final : public MessageHandler, public Net::TradeHandler
{
public:
TradeHandler();