diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-06-02 00:32:53 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-06-02 16:41:47 +0200 |
commit | 4e27937924766948d7ff9200f04a37fe4d59018c (patch) | |
tree | c1f5c255192c85a82c77c2f8f916984e2b863c44 /src/net/tmwa/inventoryhandler.h | |
parent | c2eab288ecc7d7c5e26d02ccecf285cbc0c218ed (diff) | |
download | mana-4e27937924766948d7ff9200f04a37fe4d59018c.tar.gz mana-4e27937924766948d7ff9200f04a37fe4d59018c.tar.bz2 mana-4e27937924766948d7ff9200f04a37fe4d59018c.tar.xz mana-4e27937924766948d7ff9200f04a37fe4d59018c.zip |
Arbitrary code cleanups
Just some stuff that piles up while "looking" at the code, which
eventually gets annoying to ignore while staging real changes.
* Replaced a few NULL occurrences with 0
* Rely on default parameter for std::vector::resize.
* Replaced a few "" with std::string()
* Prefer .empty() to == ""
* Removed a few comparisons with NULL
* Don't check pointers before deleting them
* Removed a bunch of redundant semicolons
* Made some global variables static (local to their compilation unit)
* Prefer prefix ++/-- operators to postfix versions when possible
* Corrected location of a comment
Diffstat (limited to 'src/net/tmwa/inventoryhandler.h')
-rw-r--r-- | src/net/tmwa/inventoryhandler.h | 21 |
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(); } |