From af6d41608a32266ed0251ba4909daa4fa81baca6 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 2 Feb 2007 19:54:42 +0000 Subject: Made Engine class even more useless by moving emoticon loading into Being. --- src/being.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/being.cpp') 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 -- cgit v1.2.3-70-g09d2