summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-11-25 13:08:23 +0300
committerAndrei Karas <akaras@inbox.ru>2013-11-25 13:08:23 +0300
commit5600eb502f0c7238ab7ab83e12ea92f69c9811c1 (patch)
tree423120c75391ae01e0f2a6cedcbd49598837c581
parent4d6c6999c7c0097fc9ad73fe0b5e2f6cefc47aa6 (diff)
downloadplus-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.tar.gz
plus-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.tar.bz2
plus-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.tar.xz
plus-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.zip
add ability to replace body/race sprite by equipped item.
add support for empty replace tag to remove all sprites. Example: <replace />
-rw-r--r--src/resources/db/itemdb.cpp44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 03b23f01d..62e2789a0 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -604,7 +604,11 @@ const ItemDB::ItemInfos &ItemDB::getItemInfos()
int parseSpriteName(const std::string &name)
{
int id = -1;
- if (name == "shoes" || name == "boot" || name == "boots")
+ if (name == "body" || name == "race")
+ {
+ id = 0;
+ }
+ else if (name == "shoes" || name == "boot" || name == "boots")
{
id = 1;
}
@@ -788,21 +792,33 @@ void loadReplaceSprite(ItemInfo *const itemInfo, const XmlNodePtr replaceNode)
{
case -1:
{
- for (int f = 0; f < 10; f ++)
- {
- std::map<int, int> *const mapList
- = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), f);
- if (!mapList)
- continue;
- for_each_xml_child_node(itemNode, replaceNode)
+ if (removeSprite.empty())
+ { // remove all sprites
+ for (int f = 0; f < 10; f ++)
{
- if (xmlNameEqual(itemNode, "item"))
+ for (int sprite = 0; sprite < 13; sprite ++)
+ itemInfo->addReplaceSprite(sprite, f);
+ }
+ }
+ else
+ { // replace only given sprites
+ for (int f = 0; f < 10; f ++)
+ {
+ std::map<int, int> *const mapList
+ = itemInfo->addReplaceSprite(
+ parseSpriteName(removeSprite), f);
+ if (!mapList)
+ continue;
+ for_each_xml_child_node(itemNode, replaceNode)
{
- const int from = XML::getProperty(itemNode, "from", 0);
- const int to = XML::getProperty(itemNode, "to", 1);
-
- (*mapList)[from] = to;
+ if (xmlNameEqual(itemNode, "item"))
+ {
+ const int from = XML::getProperty(
+ itemNode, "from", 0);
+ const int to = XML::getProperty(
+ itemNode, "to", 1);
+ (*mapList)[from] = to;
+ }
}
}
}