diff options
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/being.cpp b/src/being.cpp index d4f68fac..bfed2d51 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -31,6 +31,7 @@ #include "log.h" #include "map.h" +#include "resources/resourcemanager.h" #include "resources/spriteset.h" #include "gui/gui.h" @@ -38,12 +39,8 @@ #include "utils/dtor.h" #include "utils/tostring.h" -extern Spriteset *emotionset; - -PATH_NODE::PATH_NODE(Uint16 iX, Uint16 iY): - x(iX), y(iY) -{ -} +int Being::instances = 0; +Spriteset *Being::emotionset = NULL; Being::Being(Uint32 id, Uint16 job, Map *map): mJob(job), @@ -67,6 +64,16 @@ Being::Being(Uint32 id, Uint16 job, Map *map): mEquipmentSpriteIDs(VECTOREND_SPRITE, 0) { setMap(map); + + if (instances == 0) + { + // Load the emotion set + ResourceManager *rm = ResourceManager::getInstance(); + emotionset = rm->getSpriteset("graphics/sprites/emotions.png", 30, 32); + if (!emotionset) logger->error("Unable to load emotions spriteset!"); + } + + instances++; } Being::~Being() @@ -74,6 +81,14 @@ Being::~Being() std::for_each(mSprites.begin(), mSprites.end(), make_dtor(mSprites)); clearPath(); setMap(NULL); + + instances--; + + if (instances == 0) + { + emotionset->decRef(); + emotionset = NULL; + } } void |