diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-11-25 13:08:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-11-25 13:08:23 +0300 |
commit | 5600eb502f0c7238ab7ab83e12ea92f69c9811c1 (patch) | |
tree | 423120c75391ae01e0f2a6cedcbd49598837c581 /src/resources | |
parent | 4d6c6999c7c0097fc9ad73fe0b5e2f6cefc47aa6 (diff) | |
download | mv-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.tar.gz mv-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.tar.bz2 mv-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.tar.xz mv-5600eb502f0c7238ab7ab83e12ea92f69c9811c1.zip |
add ability to replace body/race sprite by equipped item.
add support for empty replace tag to remove all sprites.
Example: <replace />
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/db/itemdb.cpp | 44 |
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; + } } } } |