summaryrefslogtreecommitdiff
path: root/src/equipment.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-15 23:44:01 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-15 23:44:01 +0000
commit0e925e97554aae573e895afa4e3d8450f01df342 (patch)
treebbc30319410aecb9fec7c005e667cd7fb628bb17 /src/equipment.cpp
parentffa0fae492d954c0aed35a0acbd7b856778d7328 (diff)
downloadmana-client-0e925e97554aae573e895afa4e3d8450f01df342.tar.gz
mana-client-0e925e97554aae573e895afa4e3d8450f01df342.tar.bz2
mana-client-0e925e97554aae573e895afa4e3d8450f01df342.tar.xz
mana-client-0e925e97554aae573e895afa4e3d8450f01df342.zip
Moved item icon from ItemInfo class to the Item class, so that it can be loaded
on demand. Results in faster startup time and reduced memory usage.
Diffstat (limited to 'src/equipment.cpp')
-rw-r--r--src/equipment.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/equipment.cpp b/src/equipment.cpp
index 9de8c26e..265f230a 100644
--- a/src/equipment.cpp
+++ b/src/equipment.cpp
@@ -24,9 +24,31 @@
#include <algorithm>
#include "equipment.h"
+#include "item.h"
+
+Equipment::Equipment()
+{
+ std::fill_n(mEquipment, EQUIPMENT_SIZE, (Item*) 0);
+}
+
+Equipment::~Equipment()
+{
+ clear();
+}
void Equipment::clear()
{
- std::fill_n(mEquipment, EQUIPMENT_SIZE, 0);
+ for (int i = 0; i < EQUIPMENT_SIZE; ++i)
+ delete mEquipment[i];
+
+ std::fill_n(mEquipment, EQUIPMENT_SIZE, (Item*) 0);
}
+void Equipment::setEquipment(int index, int id)
+{
+ if (mEquipment[index] && mEquipment[index]->getId() == id)
+ return;
+
+ delete mEquipment[index];
+ mEquipment[index] = (id > 0) ? new Item(id) : 0;
+}