summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/manaserv/charhandler.cpp7
-rw-r--r--src/net/manaserv/inventoryhandler.cpp23
-rw-r--r--src/net/tmwa/inventoryhandler.cpp16
-rw-r--r--src/net/tmwa/network.cpp2
4 files changed, 22 insertions, 26 deletions
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index d5a5497e..c8c23c7f 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -397,11 +397,10 @@ void CharHandler::updateCharacters()
character->data.mAttributes[CHAR_POINTS] = info.characterPoints;
character->data.mAttributes[CORR_POINTS] = info.correctionPoints;
- for (auto it = info.attribute.begin(),
- it_end = info.attribute.end(); it != it_end; it++)
+ for (const auto &it : info.attribute)
{
- character->data.mStats[i].base = it->second.base;
- character->data.mStats[i].mod = it->second.mod;
+ character->data.mStats[i].base = it.second.base;
+ character->data.mStats[i].mod = it.second.mod;
}
mCharacters.push_back(character);
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index af482400..8898db55 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -99,13 +99,12 @@ void EquipBackend::triggerUnequip(int slotIndex) const
void EquipBackend::clear()
{
- for (auto i = mSlots.begin(), i_end = mSlots.end();
- i != i_end; ++i)
+ for (auto &slot : mSlots)
{
- if (i->second.item)
+ if (slot.second.item)
{
- delete i->second.item;
- i->second.item = nullptr;
+ delete slot.second.item;
+ slot.second.item = nullptr;
}
}
mSlots.clear();
@@ -280,22 +279,20 @@ void EquipBackend::readBoxNode(xmlNodePtr slotNode)
bool EquipBackend::isWeaponSlot(int slotTypeId) const
{
- for (auto it = mSlots.begin(), it_end = mSlots.end();
- it != it_end; ++it)
+ for (const auto &slot : mSlots)
{
- if (it->second.slotTypeId == (unsigned)slotTypeId)
- return it->second.weaponSlot;
+ if (slot.second.slotTypeId == (unsigned)slotTypeId)
+ return slot.second.weaponSlot;
}
return false;
}
bool EquipBackend::isAmmoSlot(int slotTypeId) const
{
- for (auto it = mSlots.begin(), it_end = mSlots.end();
- it != it_end; ++it)
+ for (const auto &slot : mSlots)
{
- if (it->second.slotTypeId == (unsigned)slotTypeId)
- return it->second.ammoSlot;
+ if (slot.second.slotTypeId == (unsigned)slotTypeId)
+ return slot.second.ammoSlot;
}
return false;
}
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 6f32fb3d..7b08d83c 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -158,8 +158,8 @@ void InventoryHandler::handleMessage(MessageIn &msg)
identified = msg.readInt8();
amount = msg.readInt16();
msg.readInt16(); // Arrow
- for (int i = 0; i < 4; i++)
- cards[i] = msg.readInt16();
+ for (int &card : cards)
+ card = msg.readInt16();
index -= (msg.getId() == SMSG_PLAYER_INVENTORY) ?
INVENTORY_OFFSET : STORAGE_OFFSET;
@@ -195,8 +195,8 @@ void InventoryHandler::handleMessage(MessageIn &msg)
msg.readInt16(); // Another Equip Point?
msg.readInt8(); // Attribute (broken)
msg.readInt8(); // Refine level
- for (int i = 0; i < 4; i++)
- cards[i] = msg.readInt16();
+ for (int &card : cards)
+ card = msg.readInt16();
if (debugInventory)
{
@@ -218,8 +218,8 @@ void InventoryHandler::handleMessage(MessageIn &msg)
identified = msg.readInt8();
msg.readInt8(); // attribute
msg.readInt8(); // refine
- for (int i = 0; i < 4; i++)
- cards[i] = msg.readInt16();
+ for (int &card : cards)
+ card = msg.readInt16();
msg.readInt16(); // EquipType
itemType = msg.readInt8();
@@ -331,8 +331,8 @@ void InventoryHandler::handleMessage(MessageIn &msg)
identified = msg.readInt8();
msg.readInt8(); // attribute
msg.readInt8(); // refine
- for (int i = 0; i < 4; i++)
- cards[i] = msg.readInt16();
+ for (int &card : cards)
+ card = msg.readInt16();
if (Item *item = mStorage->getItem(index))
{
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index d0a5dc62..c1862f00 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -31,7 +31,7 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <assert.h>
+#include <cassert>
#include <sstream>
/** Warning: buffers and other variables are shared,