summaryrefslogtreecommitdiff
path: root/src/net/tmwa/inventoryhandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/tmwa/inventoryhandler.h')
-rw-r--r--src/net/tmwa/inventoryhandler.h21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 315be16c..218723e6 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -49,10 +49,6 @@ class EquipBackend : public Equipment::Backend
Item *getEquipment(int index) const
{
int invyIndex = mEquipment[index];
- if (invyIndex == -1)
- {
- return NULL;
- }
return PlayerInfo::getInventory()->getItem(invyIndex);
}
@@ -62,11 +58,8 @@ class EquipBackend : public Equipment::Backend
{
if (mEquipment[i] != -1)
{
- Item* item = PlayerInfo::getInventory()->getItem(i);
- if (item)
- {
+ if (Item *item = PlayerInfo::getInventory()->getItem(i))
item->setEquipped(false);
- }
}
mEquipment[i] = -1;
@@ -75,20 +68,16 @@ class EquipBackend : public Equipment::Backend
void setEquipment(int index, int inventoryIndex)
{
+ Inventory *inventory = PlayerInfo::getInventory();
+
// Unequip existing item
- Item* item = PlayerInfo::getInventory()->getItem(mEquipment[index]);
- if (item)
- {
+ if (Item *item = inventory->getItem(mEquipment[index]))
item->setEquipped(false);
- }
mEquipment[index] = inventoryIndex;
- item = PlayerInfo::getInventory()->getItem(inventoryIndex);
- if (item)
- {
+ if (Item *item = inventory->getItem(inventoryIndex))
item->setEquipped(true);
- }
inventoryWindow->updateButtons();
}