summaryrefslogtreecommitdiff
path: root/src
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
parent2f6f5950605e3ffe8054f3a2675f10032ca0aaf6 (diff)
downloadmanaverse-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.tar.gz
manaverse-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.tar.bz2
manaverse-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.tar.xz
manaverse-1eea3f1102b7d8f87b076a5a8380fd71fc00d773.zip
improve inventoryhandler class.
Diffstat (limited to 'src')
-rw-r--r--src/equipment.h3
-rw-r--r--src/net/ea/inventoryhandler.cpp142
-rw-r--r--src/net/ea/inventoryhandler.h50
-rw-r--r--src/net/eathena/inventoryhandler.cpp14
-rw-r--r--src/net/eathena/inventoryhandler.h15
-rw-r--r--src/net/inventoryhandler.h30
-rw-r--r--src/net/tmwa/inventoryhandler.cpp14
-rw-r--r--src/net/tmwa/inventoryhandler.h15
8 files changed, 139 insertions, 144 deletions
diff --git a/src/equipment.h b/src/equipment.h
index 2666f45ab..42c1dc680 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -67,7 +67,8 @@ class Equipment
class Backend
{
public:
- virtual Item *getEquipment(int index) const A_WARN_UNUSED = 0;
+ virtual Item *getEquipment(const int index)
+ const A_WARN_UNUSED = 0;
virtual void clear() = 0;
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index df0b5c824..6f5da6106 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -53,21 +53,21 @@ const Equipment::Slot EQUIP_POINTS[Equipment::EQUIP_VECTOREND] =
// missing EQUIP_RING1_SLOT
const Equipment::Slot EQUIP_CONVERT[] =
{
- Equipment::EQUIP_PROJECTILE_SLOT, // 0
- Equipment::EQUIP_FEET_SLOT, // SPRITE_SHOE
- Equipment::EQUIP_LEGS_SLOT, // SPRITE_BOTTOMCLOTHES
- Equipment::EQUIP_TORSO_SLOT, // SPRITE_TOPCLOTHES
- Equipment::EQUIP_PROJECTILE_SLOT, // 0
- Equipment::EQUIP_NECK_SLOT, // SPRITE_RING
- Equipment::EQUIP_PROJECTILE_SLOT, // 0
- Equipment::EQUIP_HEAD_SLOT, // SPRITE_HAT
- Equipment::EQUIP_RING2_SLOT, // 0
- Equipment::EQUIP_GLOVES_SLOT, // SPRITE_GLOVES
- Equipment::EQUIP_FIGHT1_SLOT, // SPRITE_WEAPON
- Equipment::EQUIP_FIGHT2_SLOT, // SPRITE_SHIELD
- Equipment::EQUIP_EVOL_RING1_SLOT, // SPRITE_EVOL1
- Equipment::EQUIP_EVOL_RING2_SLOT, // SPRITE_EVOL2
- Equipment::EQUIP_PROJECTILE_SLOT, // 0
+ Equipment::EQUIP_PROJECTILE_SLOT, // 0
+ Equipment::EQUIP_FEET_SLOT, // SPRITE_SHOE
+ Equipment::EQUIP_LEGS_SLOT, // SPRITE_BOTTOMCLOTHES
+ Equipment::EQUIP_TORSO_SLOT, // SPRITE_TOPCLOTHES
+ Equipment::EQUIP_PROJECTILE_SLOT, // 0
+ Equipment::EQUIP_NECK_SLOT, // SPRITE_RING
+ Equipment::EQUIP_PROJECTILE_SLOT, // 0
+ Equipment::EQUIP_HEAD_SLOT, // SPRITE_HAT
+ Equipment::EQUIP_RING2_SLOT, // 0
+ Equipment::EQUIP_GLOVES_SLOT, // SPRITE_GLOVES
+ Equipment::EQUIP_FIGHT1_SLOT, // SPRITE_WEAPON
+ Equipment::EQUIP_FIGHT2_SLOT, // SPRITE_SHIELD
+ Equipment::EQUIP_EVOL_RING1_SLOT, // SPRITE_EVOL1
+ Equipment::EQUIP_EVOL_RING2_SLOT, // SPRITE_EVOL2
+ Equipment::EQUIP_PROJECTILE_SLOT, // 0
};
namespace Ea
@@ -92,28 +92,29 @@ InventoryHandler::~InventoryHandler()
mStorage = nullptr;
}
-bool InventoryHandler::canSplit(const Item *item A_UNUSED) const
+bool InventoryHandler::canSplit(const Item *const item A_UNUSED) const
{
return false;
}
-void InventoryHandler::splitItem(const Item *item A_UNUSED,
- int amount A_UNUSED)
+void InventoryHandler::splitItem(const Item *const item A_UNUSED,
+ const int amount A_UNUSED) const
{
// Not implemented for eAthena (possible?)
}
-void InventoryHandler::moveItem(int oldIndex A_UNUSED, int newIndex A_UNUSED)
+void InventoryHandler::moveItem(const int oldIndex A_UNUSED,
+ const int newIndex A_UNUSED) const
{
// Not implemented for eAthena (possible?)
}
-void InventoryHandler::openStorage(int type A_UNUSED)
+void InventoryHandler::openStorage(const int type A_UNUSED) const
{
// Doesn't apply to eAthena, since opening happens through NPCs?
}
-size_t InventoryHandler::getSize(int type) const
+size_t InventoryHandler::getSize(const int type) const
{
switch (type)
{
@@ -129,7 +130,7 @@ size_t InventoryHandler::getSize(int type) const
return 0;
}
}
-int InventoryHandler::convertFromServerSlot(int serverSlot) const
+int InventoryHandler::convertFromServerSlot(const int serverSlot) const
{
if (serverSlot < 0 || serverSlot > 13)
return 0;
@@ -137,7 +138,7 @@ int InventoryHandler::convertFromServerSlot(int serverSlot) const
return EQUIP_CONVERT[serverSlot];
}
-int InventoryHandler::getSlot(int eAthenaSlot)
+int InventoryHandler::getSlot(const int eAthenaSlot) const
{
if (eAthenaSlot == 0)
return Equipment::EQUIP_VECTOREND;
@@ -156,7 +157,7 @@ int InventoryHandler::getSlot(int eAthenaSlot)
}
void InventoryHandler::processPlayerInventory(Net::MessageIn &msg,
- bool playerInvintory)
+ const bool playerInvintory)
{
Inventory *const inventory = player_node
? PlayerInfo::getInventory() : nullptr;
@@ -262,14 +263,8 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
{
- int index, amount, itemId, equipType, refine;
-// int cards[4], itemType;
- unsigned char identified;
- int floorId;
-
- Inventory *inventory = nullptr;
- if (player_node)
- inventory = PlayerInfo::getInventory();
+ Inventory *const inventory = player_node
+ ? PlayerInfo::getInventory() : nullptr;
if (PlayerInfo::getEquipment()
&& !PlayerInfo::getEquipment()->getBackend())
@@ -277,20 +272,20 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
mEquips.clear();
PlayerInfo::getEquipment()->setBackend(&mEquips);
}
- index = msg.readInt16() - INVENTORY_OFFSET;
- amount = msg.readInt16();
- itemId = msg.readInt16();
- identified = msg.readInt8();
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ int amount = msg.readInt16();
+ const int itemId = msg.readInt16();
+ unsigned char identified = msg.readInt8();
msg.readInt8(); // attribute
- refine = msg.readInt8();
+ const int refine = msg.readInt8();
for (int i = 0; i < 4; i++)
msg.readInt16(); // cards[i]
- equipType = msg.readInt16();
+ const int equipType = msg.readInt16();
msg.readInt8(); // itemType
const ItemInfo &itemInfo = ItemDB::get(itemId);
-
const unsigned char err = msg.readInt8();
+ int floorId;
if (mSentPickups.empty())
{
floorId = 0;
@@ -330,15 +325,13 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
}
}
-void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg)
+void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) const
{
- int index, amount;
- Inventory *inventory = nullptr;
- if (player_node)
- inventory = PlayerInfo::getInventory();
+ Inventory *const inventory = player_node
+ ? PlayerInfo::getInventory() : nullptr;
- index = msg.readInt16() - INVENTORY_OFFSET;
- amount = msg.readInt16();
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ const int amount = msg.readInt16();
if (inventory)
{
if (Item *const item = inventory->getItem(index))
@@ -352,17 +345,15 @@ void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg)
}
}
-void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg)
+void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) const
{
- int index, amount;
- Inventory *inventory = nullptr;
- if (player_node)
- inventory = PlayerInfo::getInventory();
+ Inventory *const inventory = player_node
+ ? PlayerInfo::getInventory() : nullptr;
- index = msg.readInt16() - INVENTORY_OFFSET;
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
msg.readInt16(); // item id
msg.readInt32(); // id
- amount = msg.readInt16();
+ const int amount = msg.readInt16();
msg.readInt8(); // type
if (inventory)
@@ -377,15 +368,13 @@ void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg)
}
}
-void InventoryHandler::processItemUseResponse(Net::MessageIn &msg)
+void InventoryHandler::processItemUseResponse(Net::MessageIn &msg) const
{
- int index, amount;
- Inventory *inventory = nullptr;
- if (player_node)
- inventory = PlayerInfo::getInventory();
+ Inventory *const inventory = player_node
+ ? PlayerInfo::getInventory() : nullptr;
- index = msg.readInt16() - INVENTORY_OFFSET;
- amount = msg.readInt16();
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ const int amount = msg.readInt16();
if (msg.readInt8() == 0)
{
@@ -432,16 +421,13 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg)
void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
{
- int index, amount, itemId, refine;
- unsigned char identified;
-
// Move an item into storage
- index = msg.readInt16() - STORAGE_OFFSET;
- amount = msg.readInt32();
- itemId = msg.readInt16();
- identified = msg.readInt8();
+ const int index = msg.readInt16() - STORAGE_OFFSET;
+ const int amount = msg.readInt32();
+ const int itemId = msg.readInt16();
+ unsigned char identified = msg.readInt8();
msg.readInt8(); // attribute
- refine = msg.readInt8();
+ const int refine = msg.readInt8();
for (int i = 0; i < 4; i++)
msg.readInt16(); // card i
@@ -465,11 +451,9 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
void InventoryHandler::processPlayerStorageRemove(Net::MessageIn &msg)
{
- int index, amount;
-
// Move an item out of storage
- index = msg.readInt16() - STORAGE_OFFSET;
- amount = msg.readInt16();
+ const int index = msg.readInt16() - STORAGE_OFFSET;
+ const int amount = msg.readInt16();
if (mStorage)
{
if (Item *const item = mStorage->getItem(index))
@@ -496,16 +480,15 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
{
- Inventory *inventory = nullptr;
- if (player_node)
- inventory = PlayerInfo::getInventory();
+ Inventory *const inventory = player_node
+ ? PlayerInfo::getInventory() : nullptr;
msg.readInt16(); // length
- if (PlayerInfo::getEquipment()
- && !PlayerInfo::getEquipment()->getBackend())
+ Equipment *const equipment = PlayerInfo::getEquipment();
+ if (equipment && !equipment->getBackend())
{ // look like SMSG_PLAYER_INVENTORY was not received
mEquips.clear();
- PlayerInfo::getEquipment()->setBackend(&mEquips);
+ equipment->setBackend(&mEquips);
}
const int number = (msg.getLength() - 4) / 20;
@@ -567,7 +550,7 @@ void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg)
miniStatusWindow->updateArrows();
}
-void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg)
+void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) const
{
const int range = msg.readInt16();
if (player_node)
@@ -579,7 +562,6 @@ void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg)
void InventoryHandler::processPlayerArrowEquip(Net::MessageIn &msg)
{
int index = msg.readInt16();
-
if (index <= 1)
return;
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);
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 80b8ed73c..79219cb42 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -135,7 +135,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
}
}
-void InventoryHandler::equipItem(const Item *item)
+void InventoryHandler::equipItem(const Item *const item) const
{
if (!item)
return;
@@ -146,7 +146,7 @@ void InventoryHandler::equipItem(const Item *item)
outMsg.writeInt16(0);
}
-void InventoryHandler::unequipItem(const Item *item)
+void InventoryHandler::unequipItem(const Item *const item) const
{
if (!item)
return;
@@ -156,7 +156,7 @@ void InventoryHandler::unequipItem(const Item *item)
item->getInvIndex() + INVENTORY_OFFSET));
}
-void InventoryHandler::useItem(const Item *item)
+void InventoryHandler::useItem(const Item *const item) const
{
if (!item)
return;
@@ -167,7 +167,7 @@ void InventoryHandler::useItem(const Item *item)
outMsg.writeInt32(item->getId()); // unused
}
-void InventoryHandler::dropItem(const Item *item, int amount)
+void InventoryHandler::dropItem(const Item *const item, const int amount) const
{
if (!item)
return;
@@ -179,13 +179,13 @@ void InventoryHandler::dropItem(const Item *item, int amount)
outMsg.writeInt16(static_cast<int16_t>(amount));
}
-void InventoryHandler::closeStorage(int type A_UNUSED)
+void InventoryHandler::closeStorage(const int type A_UNUSED) const
{
MessageOut outMsg(CMSG_CLOSE_STORAGE);
}
-void InventoryHandler::moveItem2(int source, int slot, int amount,
- int destination)
+void InventoryHandler::moveItem2(const int source, const int slot,
+ const int amount, const int destination) const
{
if (source == Inventory::INVENTORY && destination == Inventory::STORAGE)
{
diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h
index 77f128838..f6e87fd2a 100644
--- a/src/net/eathena/inventoryhandler.h
+++ b/src/net/eathena/inventoryhandler.h
@@ -44,19 +44,20 @@ class InventoryHandler final : public MessageHandler,
~InventoryHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg) override;
- void equipItem(const Item *item);
+ void equipItem(const Item *const item) const override;
- void unequipItem(const Item *item);
+ void unequipItem(const Item *const item) const override;
- void useItem(const Item *item);
+ void useItem(const Item *const item) const override;
- void dropItem(const Item *item, int amount);
+ void dropItem(const Item *const item, const int amount) const override;
- void closeStorage(int type);
+ void closeStorage(const int type) const override;
- void moveItem2(int source, int slot, int amount, int destination);
+ void moveItem2(const int source, const int slot,
+ const int amount, const int destination) const override;
};
} // namespace EAthena
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index 5cf6bc5db..3b8a24aa5 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -36,33 +36,37 @@ class InventoryHandler
virtual ~InventoryHandler()
{ }
- virtual void equipItem(const Item *item) = 0;
+ virtual void equipItem(const Item *const item) const = 0;
- virtual void unequipItem(const Item *item) = 0;
+ virtual void unequipItem(const Item *const item) const = 0;
- virtual void useItem(const Item *item) = 0;
+ virtual void useItem(const Item *const item) const = 0;
- virtual void dropItem(const Item *item, int amount) = 0;
+ virtual void dropItem(const Item *const item,
+ const int amount) const = 0;
- virtual bool canSplit(const Item *item) const = 0;
+ virtual bool canSplit(const Item *const item) const = 0;
- virtual void splitItem(const Item *item, int amount) = 0;
+ virtual void splitItem(const Item *const item,
+ const int amount) const = 0;
- virtual void moveItem(int oldIndex, int newIndex) = 0;
+ virtual void moveItem(const int oldIndex,
+ const int newIndex) const = 0;
- virtual void openStorage(int type) = 0;
+ virtual void openStorage(const int type) const = 0;
- virtual void closeStorage(int type) = 0;
+ virtual void closeStorage(const int type) const = 0;
//void changeCart() = 0;
- virtual void moveItem2(int source, int slot, int amount,
- int destination) = 0;
+ virtual void moveItem2(const int source, const int slot,
+ const int amount,
+ const int destination) const = 0;
// TODO: fix/remove me
- virtual size_t getSize(int type) const A_WARN_UNUSED = 0;
+ virtual size_t getSize(const int type) const A_WARN_UNUSED = 0;
- virtual int convertFromServerSlot(int eAthenaSlot) const = 0;
+ virtual int convertFromServerSlot(const int eAthenaSlot) const = 0;
};
} // namespace Net
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 42e6ee9d2..59aa6f69a 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -137,7 +137,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
BLOCK_END("InventoryHandler::handleMessage")
}
-void InventoryHandler::equipItem(const Item *item)
+void InventoryHandler::equipItem(const Item *const item) const
{
if (!item)
return;
@@ -148,7 +148,7 @@ void InventoryHandler::equipItem(const Item *item)
outMsg.writeInt16(0);
}
-void InventoryHandler::unequipItem(const Item *item)
+void InventoryHandler::unequipItem(const Item *const item) const
{
if (!item)
return;
@@ -158,7 +158,7 @@ void InventoryHandler::unequipItem(const Item *item)
item->getInvIndex() + INVENTORY_OFFSET));
}
-void InventoryHandler::useItem(const Item *item)
+void InventoryHandler::useItem(const Item *const item) const
{
if (!item)
return;
@@ -169,7 +169,7 @@ void InventoryHandler::useItem(const Item *item)
outMsg.writeInt32(item->getId()); // unused
}
-void InventoryHandler::dropItem(const Item *item, int amount)
+void InventoryHandler::dropItem(const Item *const item, const int amount) const
{
if (!item)
return;
@@ -181,13 +181,13 @@ void InventoryHandler::dropItem(const Item *item, int amount)
outMsg.writeInt16(static_cast<int16_t>(amount));
}
-void InventoryHandler::closeStorage(int type A_UNUSED)
+void InventoryHandler::closeStorage(const int type A_UNUSED) const
{
MessageOut outMsg(CMSG_CLOSE_STORAGE);
}
-void InventoryHandler::moveItem2(int source, int slot, int amount,
- int destination)
+void InventoryHandler::moveItem2(const int source, const int slot,
+ const int amount, const int destination) const
{
if (source == Inventory::INVENTORY && destination == Inventory::STORAGE)
{
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index b112776ba..707a9169c 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -44,19 +44,20 @@ class InventoryHandler final : public MessageHandler,
~InventoryHandler();
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg) override;
- void equipItem(const Item *item);
+ void equipItem(const Item *const item) const override;
- void unequipItem(const Item *item);
+ void unequipItem(const Item *const item) const override;
- void useItem(const Item *item);
+ void useItem(const Item *const item) const override;
- void dropItem(const Item *item, int amount);
+ void dropItem(const Item *const item, const int amount) const override;
- void closeStorage(int type);
+ void closeStorage(const int type) const override;
- void moveItem2(int source, int slot, int amount, int destination);
+ void moveItem2(const int source, const int slot,
+ const int amount, const int destination) const override;
};
} // namespace TmwAthena