summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-09 09:47:21 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-13 12:57:16 +0100
commitc70be70cab3615cb36cc5f244671cf5d39f1fda8 (patch)
treeb15e68552ffd6adda832a9ae5d38160ef8299d7f /src/net
parent717eb07c0d51098e319059883b11ba6e2bf4cbb8 (diff)
downloadmana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.tar.gz
mana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.tar.bz2
mana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.tar.xz
mana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.zip
General code cleanups
* Removing unused includes * Use member initialization * Use range-based for loops * Use nullptr * Removed no longer used aliases * Use override * Don't use else after return * Use '= delete' to remove implicit members * Use std::string::empty instead of comparing to ""
Diffstat (limited to 'src/net')
-rw-r--r--src/net/logindata.h7
-rw-r--r--src/net/manaserv/network.cpp4
-rw-r--r--src/net/tmwa/inventoryhandler.h22
-rw-r--r--src/net/tmwa/loginhandler.h2
-rw-r--r--src/net/tmwa/messageout.cpp7
-rw-r--r--src/net/tmwa/messageout.h6
-rw-r--r--src/net/tmwa/network.cpp2
7 files changed, 17 insertions, 33 deletions
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 162ba1fa..380f9061 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -29,10 +29,7 @@
class LoginData
{
public:
- LoginData()
- {
- characterSlots = 3;
- }
+ LoginData() = default;
std::string username;
std::string password;
@@ -48,7 +45,7 @@ public:
bool remember; /**< Whether to store the username. */
bool registerLogin; /**< Whether an account is being registered. */
- unsigned short characterSlots; /**< The number of character slots */
+ unsigned short characterSlots = 3; /**< The number of character slots */
/**
* Initialize character slots to 3 for backwards compatibility
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index 7f354fa1..b8d3fa93 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -42,9 +42,7 @@ namespace {
namespace ManaServ
{
-using MessageHandlers = std::map<unsigned short, MessageHandler *>;
-using MessageHandlerIterator = MessageHandlers::iterator;
-static MessageHandlers mMessageHandlers;
+static std::map<unsigned short, MessageHandler *> mMessageHandlers;
void initialize()
{
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 6224b572..6bf11f54 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -136,18 +136,6 @@ class EquipBackend : public Equipment::Backend
int getSlotNumber() const override
{ return EQUIP_VECTOR_END; }
- // Note the slot type id is equal to the slot Index for tA.
- bool isWeaponSlot(unsigned int slotTypeId) const
- {
- return (slotTypeId == EQUIP_FIGHT1_SLOT
- || slotTypeId == EQUIP_FIGHT1_SLOT);
- }
-
- bool isAmmoSlot(unsigned int slotTypeId) const
- {
- return (slotTypeId == EQUIP_PROJECTILE_SLOT);
- }
-
private:
int mEquipment[EQUIP_VECTOR_END];
};
@@ -195,11 +183,17 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
size_t getSize(int type) const override;
+ // Note the slot type id is equal to the slot Index for tA.
bool isWeaponSlot(unsigned int slotTypeId) const override
- { return mEquips.isWeaponSlot(slotTypeId); }
+ {
+ return (slotTypeId == EQUIP_FIGHT1_SLOT
+ || slotTypeId == EQUIP_FIGHT1_SLOT);
+ }
bool isAmmoSlot(unsigned int slotTypeId) const override
- { return mEquips.isAmmoSlot(slotTypeId); }
+ {
+ return (slotTypeId == EQUIP_PROJECTILE_SLOT);
+ }
private:
EquipBackend mEquips;
diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h
index 92a268f1..3ff33e83 100644
--- a/src/net/tmwa/loginhandler.h
+++ b/src/net/tmwa/loginhandler.h
@@ -29,7 +29,7 @@
#include <string>
-struct LoginData;
+class LoginData;
namespace TmwAthena {
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index ae5f6dba..19f5ee49 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -31,12 +31,9 @@
namespace TmwAthena {
MessageOut::MessageOut(uint16_t id):
- mDataSize(0),
- mPos(0)
+ mNetwork(TmwAthena::Network::instance()),
+ mData(mNetwork->mOutBuffer + mNetwork->mOutSize)
{
- mNetwork = TmwAthena::Network::instance();
- mData = mNetwork->mOutBuffer + mNetwork->mOutSize;
-
writeInt16(id);
}
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index dd2b84cc..4f1faa9d 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/messageout.h
@@ -88,9 +88,9 @@ class MessageOut
Network *mNetwork;
- char *mData; /**< Data building up. */
- unsigned int mDataSize; /**< Size of data. */
- unsigned int mPos; /**< Position in the data. */
+ char *mData; /**< Data building up. */
+ unsigned int mDataSize = 0; /**< Size of data. */
+ unsigned int mPos = 0; /**< Position in the data. */
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index c1862f00..f5aeaf91 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -23,8 +23,6 @@
#include "log.h"
-#include "net/messagehandler.h"
-
#include "net/tmwa/messagein.h"
#include "net/tmwa/protocol.h"