summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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*