diff options
Diffstat (limited to 'src/equipment.cpp')
-rw-r--r-- | src/equipment.cpp | 24 |
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; +} |