summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-31 15:36:56 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-31 21:56:05 +0300
commit3a54cf61c4ea127a16ca11c515906a5f419b97df (patch)
tree7b330747d4357c95791f578eeda0356c8649e614 /src/resources
parent741630d53aa385f192edb40ac27b00844285eac8 (diff)
downloadmanaverse-3a54cf61c4ea127a16ca11c515906a5f419b97df.tar.gz
manaverse-3a54cf61c4ea127a16ca11c515906a5f419b97df.tar.bz2
manaverse-3a54cf61c4ea127a16ca11c515906a5f419b97df.tar.xz
manaverse-3a54cf61c4ea127a16ca11c515906a5f419b97df.zip
Add default avatars support for npcs.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/beinginfo.cpp3
-rw-r--r--src/resources/beinginfo.h7
-rw-r--r--src/resources/npcdb.cpp10
-rw-r--r--src/resources/npcdb.h4
4 files changed, 23 insertions, 1 deletions
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index c5c36b209..905d28921 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -48,7 +48,8 @@ BeingInfo::BeingInfo() :
mStaticMaxHP(false),
mTargetSelection(true),
mSortOffsetY(0),
- mDeadSortOffsetY(31)
+ mDeadSortOffsetY(31),
+ mAvatarId(0)
{
SpriteDisplay display;
display.sprites.push_back(SpriteReference::Empty);
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 0e544a3b6..f1b978543 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -187,6 +187,12 @@ class BeingInfo final
void setDeadSortOffsetY(const int n)
{ mDeadSortOffsetY = n; }
+ uint16_t getAvatarId() const A_WARN_UNUSED
+ { return mAvatarId; }
+
+ void setAvatarId(const uint16_t id)
+ { mAvatarId = id; }
+
static void init();
static void clear();
@@ -207,6 +213,7 @@ class BeingInfo final
bool mTargetSelection;
int mSortOffsetY;
int mDeadSortOffsetY;
+ uint16_t mAvatarId;
};
typedef std::map<int, BeingInfo*> BeingInfos;
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 07549eb03..f8e1e2340 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -95,6 +95,8 @@ void NPCDB::load()
currentInfo->setDeadSortOffsetY(XML::getProperty(npcNode,
"deadSortOffsetY", 31));
+ currentInfo->setAvatarId(XML::getProperty(npcNode, "avatar", 0));
+
SpriteDisplay display;
for_each_xml_child_node(spriteNode, npcNode)
{
@@ -148,3 +150,11 @@ BeingInfo *NPCDB::get(const int id)
return i->second;
}
}
+
+uint16_t NPCDB::getAvatarFor(const int id)
+{
+ BeingInfo *const info = get(id);
+ if (!info)
+ return 0;
+ return info->getAvatarId();
+}
diff --git a/src/resources/npcdb.h b/src/resources/npcdb.h
index 8f3d5650c..61641eaec 100644
--- a/src/resources/npcdb.h
+++ b/src/resources/npcdb.h
@@ -23,6 +23,8 @@
#ifndef NPC_DB_H
#define NPC_DB_H
+#include <stdint.h>
+
#include "localconsts.h"
class BeingInfo;
@@ -37,6 +39,8 @@ namespace NPCDB
void unload();
BeingInfo *get(const int id) A_WARN_UNUSED;
+
+ uint16_t getAvatarFor(const int id);
}
#endif