diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-03-08 01:48:08 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-03-08 01:48:08 +0000 |
commit | d9db81d03e979028c5e0b9eac1ae951499b776a3 (patch) | |
tree | dc9458133e8e1815ccdb9d77953b6e0bb2cba6c8 /src/equipment.cpp | |
parent | daa73fee2b89f16c42a05a7ab081699e024fab23 (diff) | |
download | mana-d9db81d03e979028c5e0b9eac1ae951499b776a3.tar.gz mana-d9db81d03e979028c5e0b9eac1ae951499b776a3.tar.bz2 mana-d9db81d03e979028c5e0b9eac1ae951499b776a3.tar.xz mana-d9db81d03e979028c5e0b9eac1ae951499b776a3.zip |
Use STL algorithms and make destructor inline.
Diffstat (limited to 'src/equipment.cpp')
-rw-r--r-- | src/equipment.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/equipment.cpp b/src/equipment.cpp index cdbe387c..6cd4d967 100644 --- a/src/equipment.cpp +++ b/src/equipment.cpp @@ -22,29 +22,23 @@ */ #include "equipment.h" + +#include <algorithm> + #include "item.h" Equipment::Equipment(): - mArrows(NULL) -{ - for (int i = 0; i < EQUIPMENT_SIZE; i++) - { - mEquipment[i] = NULL; - } -} - -Equipment::~Equipment() + mArrows(0) { + std::fill_n(mEquipment, EQUIPMENT_SIZE, (Item*)0); } void Equipment::removeEquipment(Item *item) { - for (int i = 0; i < EQUIPMENT_SIZE; i++) { - if (mEquipment[i] == item) { - mEquipment[i] = 0; - break; - } + Item **i = std::find(mEquipment, mEquipment+EQUIPMENT_SIZE, item); + if (i != mEquipment+EQUIPMENT_SIZE) { + *i = 0; } } |