summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-08 01:48:08 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-08 01:48:08 +0000
commitd9db81d03e979028c5e0b9eac1ae951499b776a3 (patch)
treedc9458133e8e1815ccdb9d77953b6e0bb2cba6c8
parentdaa73fee2b89f16c42a05a7ab081699e024fab23 (diff)
downloadmana-d9db81d03e979028c5e0b9eac1ae951499b776a3.tar.gz
mana-d9db81d03e979028c5e0b9eac1ae951499b776a3.tar.bz2
mana-d9db81d03e979028c5e0b9eac1ae951499b776a3.tar.xz
mana-d9db81d03e979028c5e0b9eac1ae951499b776a3.zip
Use STL algorithms and make destructor inline.
-rw-r--r--ChangeLog2
-rw-r--r--src/equipment.cpp22
-rw-r--r--src/equipment.h5
3 files changed, 10 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 221c7c4e..44c3dc39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2006-03-08 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/equipment.cpp, src/equipment.h: Use STL algorithms and make
+ destructor inline.
* src/localplayer.cpp, src/gui/gui.cpp: Let the LocalPlayer decide
whether it can walk to a destination.
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;
}
}
diff --git a/src/equipment.h b/src/equipment.h
index cc805004..db9cf27d 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -37,11 +37,6 @@ class Equipment
Equipment();
/**
- * Destructor.
- */
- ~Equipment();
-
- /**
* Get equipment at the given slot.
*/
Item*