summaryrefslogtreecommitdiff
path: root/src
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
parent9e53440cb2dbcfd4311ce2566eb98839383738c7 (diff)
downloadplus-0a7725600eecd8491f3c814110bb434824e71252.tar.gz
plus-0a7725600eecd8491f3c814110bb434824e71252.tar.bz2
plus-0a7725600eecd8491f3c814110bb434824e71252.tar.xz
plus-0a7725600eecd8491f3c814110bb434824e71252.zip
Use per race equipment sprites.
Example: <sprite gender="male" race="4">...</sprite>
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp4
-rw-r--r--src/inventory.cpp5
-rw-r--r--src/inventory.h3
-rw-r--r--src/localplayer.cpp3
-rw-r--r--src/resources/itemdb.cpp13
-rw-r--r--src/resources/iteminfo.cpp24
-rw-r--r--src/resources/iteminfo.h6
7 files changed, 39 insertions, 19 deletions
diff --git a/src/being.cpp b/src/being.cpp
index cbe0a4a5e..db8940662 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -1751,7 +1751,7 @@ void Being::setSprite(unsigned int slot, int id, std::string color,
else
{
const ItemInfo &info = ItemDB::get(id);
- std::string filename = info.getSprite(mGender);
+ std::string filename = info.getSprite(mGender, mSubType);
AnimatedSprite *equipmentSprite = nullptr;
if (!filename.empty())
@@ -1807,7 +1807,7 @@ void Being::load()
// we can go.
int hairstyles = 1;
- while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) !=
+ while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE, 0) !=
paths.getStringValue("spriteErrorFile"))
{
hairstyles ++;
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 47a32bce1..b247b2f63 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -204,7 +204,8 @@ void Inventory::distributeSlotsChangedEvent()
(*i)->slotsChanged(this);
}
-Item *Inventory::findItemBySprite(std::string spritePath, Gender gender)
+Item *Inventory::findItemBySprite(std::string spritePath,
+ Gender gender, int race)
{
spritePath = removeSpriteIndex(spritePath);
// logger->log1("Inventory::FindItemBySprite sprite: " + spritePath);
@@ -217,7 +218,7 @@ Item *Inventory::findItemBySprite(std::string spritePath, Gender gender)
{
if (mItems[i])
{
- std::string path = mItems[i]->getInfo().getSprite(gender);
+ std::string path = mItems[i]->getInfo().getSprite(gender, race);
if (!path.empty())
{
path = removeSpriteIndex(path);
diff --git a/src/inventory.h b/src/inventory.h
index d210c65e2..85756b66f 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -149,7 +149,8 @@ class Inventory
bool isMainInventory() const
{ return mType == INVENTORY; }
- Item *findItemBySprite(std::string spritePath, Gender gender);
+ Item *findItemBySprite(std::string spritePath,
+ Gender gender, int race);
std::string getName();
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index e8c218292..f455cccb2 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -3884,7 +3884,8 @@ void LocalPlayer::imitateOutfit(Being *player, int sprite)
// logger->log("idPath: " + path);
- Item *item = inv->findItemBySprite(path, player->getGender());
+ Item *item = inv->findItemBySprite(path,
+ player->getGender(), player->getSubType());
// if (item)
// {
// logger->log("got item");
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);