diff options
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/itemdb.cpp | 13 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 24 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 6 |
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); |