summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-08 22:35:09 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-09 17:14:25 +0100
commit1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7 (patch)
tree74cff7036d1ecfb4df5a79a7ca68bedce5bea47e /src/net
parent0ca05c54dd814f294617eda286ef175f01baa542 (diff)
downloadmana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.tar.gz
mana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.tar.bz2
mana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.tar.xz
mana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.zip
C++11: Use default member initializers
This patch is not exhaustive.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/charhandler.h22
-rw-r--r--src/net/manaserv/connection.cpp3
-rw-r--r--src/net/manaserv/connection.h6
-rw-r--r--src/net/manaserv/inventoryhandler.h21
4 files changed, 16 insertions, 36 deletions
diff --git a/src/net/charhandler.h b/src/net/charhandler.h
index 4b108cac..ee8f2298 100644
--- a/src/net/charhandler.h
+++ b/src/net/charhandler.h
@@ -38,19 +38,13 @@ namespace Net {
*/
struct Character
{
- Character() :
- slot(0),
- dummy(nullptr)
- {
- }
-
~Character()
{
delete dummy;
}
- int slot; /**< The index in the list of characters */
- LocalPlayer *dummy; /**< A dummy representing this character */
+ int slot = 0; /**< The index in the list of characters */
+ LocalPlayer *dummy = nullptr; /**< A dummy representing this character */
PlayerInfoBackend data;
};
@@ -96,11 +90,7 @@ class CharHandler
virtual int getCharCreateMaxHairStyleId() const = 0;
protected:
- CharHandler():
- mSelectedCharacter(nullptr),
- mCharSelectDialog(nullptr),
- mCharCreateDialog(nullptr)
- {}
+ CharHandler() = default;
void updateCharSelectDialog();
void unlockCharSelectDialog();
@@ -109,10 +99,10 @@ class CharHandler
Net::Characters mCharacters;
/** The selected character. */
- Net::Character *mSelectedCharacter;
+ Net::Character *mSelectedCharacter = nullptr;
- CharSelectDialog *mCharSelectDialog;
- CharCreateDialog *mCharCreateDialog;
+ CharSelectDialog *mCharSelectDialog = nullptr;
+ CharCreateDialog *mCharCreateDialog = nullptr;
};
} // namespace Net
diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp
index 4bc57695..d439f964 100644
--- a/src/net/manaserv/connection.cpp
+++ b/src/net/manaserv/connection.cpp
@@ -32,9 +32,8 @@ namespace ManaServ
{
Connection::Connection(ENetHost *client):
- mConnection(nullptr), mClient(client)
+ mClient(client)
{
- mPort = 0;
connections++;
}
diff --git a/src/net/manaserv/connection.h b/src/net/manaserv/connection.h
index 42932c47..e6646e0e 100644
--- a/src/net/manaserv/connection.h
+++ b/src/net/manaserv/connection.h
@@ -72,10 +72,10 @@ namespace ManaServ
friend Connection *ManaServ::getConnection();
Connection(ENetHost *client);
- short mPort;
- ENetPeer *mConnection;
+ short mPort = 0;
+ ENetPeer *mConnection = nullptr;
ENetHost *mClient;
- State mState;
+ State mState = OK;
};
}
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index 3659286b..7ed1b9d5 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -71,43 +71,34 @@ class EquipBackend : public Equipment::Backend, public EventListener
void readBoxNode(xmlNodePtr slotNode);
struct Slot {
- Slot():
- item(nullptr),
- slotTypeId(0),
- subId(0),
- itemInstance(0),
- weaponSlot(false),
- ammoSlot(false)
- {}
-
// Generic info
std::string name;
// The Item reference, used for graphical representation
// and info.
- Item *item;
+ Item *item = nullptr;
// Manaserv specific info
// Used to know which (server-side) slot id it is.
- unsigned int slotTypeId;
+ unsigned int slotTypeId = 0;
// Static part
// The sub id is used to know in which order the slots are
// when the slotType has more than one slot capacity:
// I.e.: capacity = 6, subId will be between 1 and 6
// for each slots in the map.
// This is used to sort the multimap along with the slot id.
- unsigned int subId;
+ unsigned int subId = 0;
// This is the (per character) unique item Id, used especially when
// equipping the same item multiple times on the same slot type.
- unsigned int itemInstance;
+ unsigned int itemInstance = 0;
// Tell whether the slot is a weapon slot
- bool weaponSlot;
+ bool weaponSlot = false;
// Tell whether the slot is an ammo slot
- bool ammoSlot;
+ bool ammoSlot = false;
};
unsigned int mVisibleSlots;