summaryrefslogtreecommitdiff
path: root/src/net/ea/inventoryhandler.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-03 00:01:34 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-03 00:01:34 +0300
commit1eea3f1102b7d8f87b076a5a8380fd71fc00d773 (patch)
treec6c993c12631ff2e9f9d9784e83497caf87edbf6 /src/net/ea/inventoryhandler.h
parent2f6f5950605e3ffe8054f3a2675f10032ca0aaf6 (diff)
downloadplus-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.tar.gz
plus-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.tar.bz2
plus-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.tar.xz
plus-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.zip
improve inventoryhandler class.
Diffstat (limited to 'src/net/ea/inventoryhandler.h')
-rw-r--r--src/net/ea/inventoryhandler.h50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 9cd484856..2d47853f6 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -48,21 +48,22 @@ class EquipBackend : public Equipment::Backend
A_DELETE_COPY(EquipBackend)
- Item *getEquipment(int index) const A_WARN_UNUSED
+ Item *getEquipment(const int index) const A_WARN_UNUSED
{
int invyIndex = mEquipment[index];
if (invyIndex == -1)
return nullptr;
- if (PlayerInfo::getInventory())
- return PlayerInfo::getInventory()->getItem(invyIndex);
+ const Inventory *const inv = PlayerInfo::getInventory();
+ if (inv)
+ return inv->getItem(invyIndex);
else
return nullptr;
}
void clear()
{
- Inventory *inv = PlayerInfo::getInventory();
+ Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
for (int i = 0; i < EQUIPMENT_SIZE; i++)
@@ -78,18 +79,19 @@ class EquipBackend : public Equipment::Backend
}
}
- void setEquipment(int index, int inventoryIndex)
+ void setEquipment(const int index, const int inventoryIndex)
{
- Inventory *inv = PlayerInfo::getInventory();
+ Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
// Unequip existing item
- Item* item = inv->getItem(mEquipment[index]);
+ Item *item = inv->getItem(mEquipment[index]);
if (item)
item->setEquipped(false);
+ // not checking index because it must be safe
mEquipment[index] = inventoryIndex;
item = inv->getItem(inventoryIndex);
@@ -117,8 +119,9 @@ class InventoryItem
unsigned char color;
bool equip;
- InventoryItem(int slot0, int id0, int quantity0, int refine0,
- unsigned char color0, bool equip0) :
+ InventoryItem(const int slot0, const int id0, const int quantity0,
+ const int refine0, const unsigned char color0,
+ const bool equip0) :
slot(slot0),
id(id0),
quantity(quantity0),
@@ -146,34 +149,37 @@ class InventoryHandler : public Net::InventoryHandler
~InventoryHandler();
- bool canSplit(const Item *item) const A_WARN_UNUSED;
+ bool canSplit(const Item *const item) const override A_WARN_UNUSED;
- void splitItem(const Item *item, int amount);
+ void splitItem(const Item *const item,
+ const int amount) const override;
- void moveItem(int oldIndex, int newIndex);
+ void moveItem(const int oldIndex, const int newIndex) const override;
- void openStorage(int type);
+ void openStorage(const int type) const override;
- size_t getSize(int type) const A_WARN_UNUSED;
+ size_t getSize(const int type) const override A_WARN_UNUSED;
- int convertFromServerSlot(int serverSlot) const A_WARN_UNUSED;
+ int convertFromServerSlot(const int serverSlot)
+ const override A_WARN_UNUSED;
- void pushPickup(int floorId)
+ void pushPickup(const int floorId)
{ mSentPickups.push(floorId); }
- int getSlot(int eAthenaSlot) A_WARN_UNUSED;
+ int getSlot(const int eAthenaSlot) const A_WARN_UNUSED;
- void processPlayerInventory(Net::MessageIn &msg, bool playerInvintory);
+ void processPlayerInventory(Net::MessageIn &msg,
+ const bool playerInvintory);
void processPlayerStorageEquip(Net::MessageIn &msg);
void processPlayerInventoryAdd(Net::MessageIn &msg);
- void processPlayerInventoryRemove(Net::MessageIn &msg);
+ void processPlayerInventoryRemove(Net::MessageIn &msg) const;
- void processPlayerInventoryUse(Net::MessageIn &msg);
+ void processPlayerInventoryUse(Net::MessageIn &msg) const;
- void processItemUseResponse(Net::MessageIn &msg);
+ void processItemUseResponse(Net::MessageIn &msg) const;
void processPlayerStorageStatus(Net::MessageIn &msg);
@@ -189,7 +195,7 @@ class InventoryHandler : public Net::InventoryHandler
void processPlayerUnEquip(Net::MessageIn &msg);
- void processPlayerAttackRange(Net::MessageIn &msg);
+ void processPlayerAttackRange(Net::MessageIn &msg) const;
void processPlayerArrowEquip(Net::MessageIn &msg);