summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-02-02 19:54:42 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-02-02 19:54:42 +0000
commitaf6d41608a32266ed0251ba4909daa4fa81baca6 (patch)
tree93e8f90ee849ed21d8cb352ecd38710a4ed48b8d /src/being.cpp
parent63dcf62ec17992b8993dcab5ace8f3af5c7f8277 (diff)
downloadmana-af6d41608a32266ed0251ba4909daa4fa81baca6.tar.gz
mana-af6d41608a32266ed0251ba4909daa4fa81baca6.tar.bz2
mana-af6d41608a32266ed0251ba4909daa4fa81baca6.tar.xz
mana-af6d41608a32266ed0251ba4909daa4fa81baca6.zip
Made Engine class even more useless by moving emoticon loading into Being.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp27
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