summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-10-27 17:05:14 +0000
committerIra Rice <irarice@gmail.com>2008-10-27 17:05:14 +0000
commit0007b8e9497eacb506c8bfad34aad5adff10ba5a (patch)
tree5c256dac8cd142a762a948ef6a481789e3fbdf2c /src/being.cpp
parentf3beda85b284e57caf6e5c685174bcb2e608d9ce (diff)
downloadmana-0007b8e9497eacb506c8bfad34aad5adff10ba5a.tar.gz
mana-0007b8e9497eacb506c8bfad34aad5adff10ba5a.tar.bz2
mana-0007b8e9497eacb506c8bfad34aad5adff10ba5a.tar.xz
mana-0007b8e9497eacb506c8bfad34aad5adff10ba5a.zip
De-hardcoded the number of hair styles.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/being.cpp b/src/being.cpp
index db8b18e6..7c884218 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -38,6 +38,7 @@
#include "text.h"
#include "resources/resourcemanager.h"
+#include "resources/itemdb.h"
#include "resources/imageset.h"
#include "resources/iteminfo.h"
@@ -52,6 +53,7 @@
#define BEING_EFFECTS_FILE "effects.xml"
int Being::instances = 0;
+int Being::mNumberOfHairstyles = 1;
ImageSet *Being::emotionSet = NULL;
static const int X_SPEECH_OFFSET = 18;
@@ -90,6 +92,17 @@ Being::Being(int id, int job, Map *map):
ResourceManager *rm = ResourceManager::getInstance();
emotionSet = rm->getImageSet("graphics/gui/emotions.png", 30, 32);
if (!emotionSet) logger->error("Unable to load emotions!");
+
+ // Hairstyles are encoded as negative numbers. Count how far negative we can go.
+ int hairstyles = 1;
+ while (ItemDB::get(-hairstyles).getSprite(0) != "error.xml")
+ {
+ hairstyles++;
+ }
+ mNumberOfHairstyles = hairstyles;
+ if (mNumberOfHairstyles == 0)
+ mNumberOfHairstyles = 1; // No hair style -> no hair
+
}
instances++;
@@ -149,7 +162,7 @@ void Being::setPath(const Path &path)
void Being::setHairStyle(int style, int color)
{
- mHairStyle = style < 0 ? mHairStyle : style % NR_HAIR_STYLES;
+ mHairStyle = style < 0 ? mHairStyle : style % mNumberOfHairstyles;
mHairColor = color;
}