diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-09 03:34:45 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-09 03:34:45 +0000 |
commit | 8bde9095c5840b8d62ebafe11beaed98877d6ac2 (patch) | |
tree | 537f717a339d1247cae222eb7a354ea5dbe8babf /src/equipment.h | |
parent | a246c08cef5e4d598fc07a681eb971bfbcf01519 (diff) | |
download | mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.gz mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.bz2 mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.xz mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.zip |
* Made Sprite into an interface implemented by both FloorItem and Being, which
hook themselves into the map on construction. The improved fringe layer is
working as expected now.
* Made sure TMW compiles without warnings even when using "-Wconversion
-Wshadow -Wcast-qual -Wwrite-strings -ansi -pedantic", lots of cleanups.
* Added two new small tilesets that contain the desert tiles that are twice and
three times the height of a normal tile. One well in new_3-1 has been
converted to use the new double tiles for testing purposes.
Diffstat (limited to 'src/equipment.h')
-rw-r--r-- | src/equipment.h | 94 |
1 files changed, 41 insertions, 53 deletions
diff --git a/src/equipment.h b/src/equipment.h index 4e6cd705..2bb53e42 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -21,8 +21,10 @@ * $Id$ */ -#ifndef _EQUIPMENT_H -#define _EQUIPMENT_H +#ifndef _TMW_EQUIPMENT_H_ +#define _TMW_EQUIPMENT_H_ + +#include <stdlib.h> class Item; @@ -31,16 +33,45 @@ class Item; class Equipment { public: + /** + * Retrieve an instance of the equipment class. + */ static Equipment* getInstance(); - Item* getEquipment(int index); - void setEquipment(int index, Item *item); + /** + * Get equipment at the given slot. + */ + Item* + getEquipment(int index) { return mEquipment[index]; } + + /** + * Set equipment at the given slot. + */ + void + setEquipment(int index, Item *item) { mEquipment[index] = item; } + + /** + * Remove equipment from the given slot. + */ + void + removeEquipment(int index) { mEquipment[index] = NULL; } - void removeEquipment(int index); + /** + * Remove the given item from equipment. + */ void removeEquipment(Item *item); - Item* getArrows(); - void setArrows(Item *arrows); + /** + * Get the item used in the arrow slot. + */ + Item* + getArrows() { return mArrows; } + + /** + * Set the item used in the arrow slot. + */ + void + setArrows(Item *arrows) { mArrows = arrows; } protected: /** @@ -53,54 +84,11 @@ class Equipment */ ~Equipment(); - Item *equipment[EQUIPMENT_SIZE]; - Item *arrows; + Item *mEquipment[EQUIPMENT_SIZE]; + Item *mArrows; private: - static Equipment *instance; + static Equipment *mInstance; }; -inline Equipment *Equipment::getInstance() -{ - if (!instance) - instance = new Equipment(); - - return instance; -} - -inline Item* Equipment::getEquipment(int index) -{ - return equipment[index]; -} - -inline void Equipment::setEquipment(int index, Item *item) -{ - equipment[index] = item; -} - -inline void Equipment::removeEquipment(int index) -{ - equipment[index] = 0; -} - -inline void Equipment::removeEquipment(Item *item) -{ - for (int i = 0; i < EQUIPMENT_SIZE; i++) { - if (equipment[i] == item) { - equipment[i] = 0; - break; - } - } -} - -inline Item* Equipment::getArrows() -{ - return arrows; -} - -inline void Equipment::setArrows(Item *arrows) -{ - this->arrows = arrows; -} - #endif |