summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-12 23:59:10 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-13 00:04:53 +0300
commit0a7725600eecd8491f3c814110bb434824e71252 (patch)
tree05df7742a9697f394a9478082fdeb15a46d4bbb4 /src/resources
parent9e53440cb2dbcfd4311ce2566eb98839383738c7 (diff)
downloadmanaverse-0a7725600eecd8491f3c814110bb434824e71252.tar.gz
manaverse-0a7725600eecd8491f3c814110bb434824e71252.tar.bz2
manaverse-0a7725600eecd8491f3c814110bb434824e71252.tar.xz
manaverse-0a7725600eecd8491f3c814110bb434824e71252.zip
Use per race equipment sprites.
Example: <sprite gender="male" race="4">...</sprite>
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/itemdb.cpp13
-rw-r--r--src/resources/iteminfo.cpp24
-rw-r--r--src/resources/iteminfo.h6
3 files changed, 30 insertions, 13 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index e81700ecc..3aadc662e 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -167,8 +167,8 @@ void ItemDB::load()
mUnknown->setName(_("Unknown item"));
mUnknown->setDisplay(SpriteDisplay());
std::string errFile = paths.getStringValue("spriteErrorFile");
- mUnknown->setSprite(errFile, GENDER_MALE);
- mUnknown->setSprite(errFile, GENDER_FEMALE);
+ mUnknown->setSprite(errFile, GENDER_MALE, 0);
+ mUnknown->setSprite(errFile, GENDER_FEMALE, 0);
mUnknown->addTag(mTags["All"]);
XML::Document doc("items.xml");
@@ -595,14 +595,15 @@ int parseDirectionName(std::string name)
void loadSpriteRef(ItemInfo *itemInfo, XmlNodePtr node)
{
- std::string gender = XML::getProperty(node, "gender", "unisex");
- std::string filename = reinterpret_cast<const char*>(
+ const std::string gender = XML::getProperty(node, "gender", "unisex");
+ const std::string filename = reinterpret_cast<const char*>(
node->xmlChildrenNode->content);
+ const int race = XML::getProperty(node, "race", 0);
if (gender == "male" || gender == "unisex")
- itemInfo->setSprite(filename, GENDER_MALE);
+ itemInfo->setSprite(filename, GENDER_MALE, race);
if (gender == "female" || gender == "unisex")
- itemInfo->setSprite(filename, GENDER_FEMALE);
+ itemInfo->setSprite(filename, GENDER_FEMALE, race);
}
void loadSoundRef(ItemInfo *itemInfo, XmlNodePtr node)
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index f163fc590..15454dccd 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -32,6 +32,8 @@
#include "debug.h"
+extern int serverVersion;
+
/*
ItemInfo::ItemInfo(ItemInfo &info)
{
@@ -99,20 +101,28 @@ ItemInfo::~ItemInfo()
mSpriteToItemReplaceMap[f] = nullptr;
}
-const std::string &ItemInfo::getSprite(Gender gender) const
+const std::string &ItemInfo::getSprite(Gender gender, int race) const
{
if (mView)
{
// Forward the request to the item defining how to view this item
- return ItemDB::get(mView).getSprite(gender);
+ return ItemDB::get(mView).getSprite(gender, race);
}
else
{
static const std::string empty("");
std::map<int, std::string>::const_iterator i =
- mAnimationFiles.find(gender);
+ mAnimationFiles.find(static_cast<int>(gender) * 2 + race);
- return (i != mAnimationFiles.end()) ? i->second : empty;
+ if (i != mAnimationFiles.end())
+ return i->second;
+ if (serverVersion > 0)
+ {
+ i = mAnimationFiles.find(static_cast<int>(gender) * 2);
+ if (i != mAnimationFiles.end())
+ return i->second;
+ }
+ return empty;
}
}
@@ -311,3 +321,9 @@ int ItemInfo::getDrawPriority(int direction) const
return 0;
return mDrawPriority[direction];
}
+
+void ItemInfo::setSprite(const std::string &animationFile,
+ Gender gender, int race)
+{
+ mAnimationFiles[static_cast<int>(gender) * 2 + race] = animationFile;
+}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 5f789663f..cd406003d 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -169,10 +169,10 @@ class ItemInfo
void setView(int view)
{ mView = view; }
- void setSprite(const std::string &animationFile, Gender gender)
- { mAnimationFiles[gender] = animationFile; }
+ void setSprite(const std::string &animationFile,
+ Gender gender, int race);
- const std::string &getSprite(Gender gender) const;
+ const std::string &getSprite(Gender gender, int race) const;
void setAttackAction(std::string attackAction);