From f2286853ea4322c980b05577bbc04ed2c211997b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 29 Aug 2011 02:04:52 +0300 Subject: Fix item sprites replacment issue if mixed directional and non directional replacement rules. --- src/resources/itemdb.cpp | 41 +++++++++++++++++++++++++++++++---------- src/resources/iteminfo.cpp | 19 ------------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index e60127997..60fe51443 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -624,21 +624,42 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) std::string removeSprite = XML::getProperty(replaceNode, "sprite", ""); int direction = parseDirectionName(XML::getProperty( replaceNode, "direction", "all")); - std::map *mapList = itemInfo->addReplaceSprite( - parseSpriteName(removeSprite), direction); - - if (!mapList) - return; itemInfo->setRemoveSprites(); - for_each_xml_child_node(itemNode, replaceNode) + if (direction != -1) { - if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + std::map *mapList = itemInfo->addReplaceSprite( + parseSpriteName(removeSprite), direction); + if (!mapList) + return; + for_each_xml_child_node(itemNode, replaceNode) { - int from = XML::getProperty(itemNode, "from", 0); - int to = XML::getProperty(itemNode, "to", 1); - (*mapList)[from] = to; + if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + { + int from = XML::getProperty(itemNode, "from", 0); + int to = XML::getProperty(itemNode, "to", 1); + (*mapList)[from] = to; + } + } + } + else + { + for_each_xml_child_node(itemNode, replaceNode) + { + if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + { + int from = XML::getProperty(itemNode, "from", 0); + int to = XML::getProperty(itemNode, "to", 1); + for (int f = 0; f < 9; f ++) + { + std::map *mapList = itemInfo->addReplaceSprite( + parseSpriteName(removeSprite), f); + if (!mapList) + continue; + (*mapList)[from] = to; + } + } } } } diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 56cfc01f6..fb4b8ed5e 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -144,25 +144,6 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const std::map *ItemInfo::addReplaceSprite(int sprite, int direction) { - if (direction == -1) - { - SpriteToItemMap *spMap = new SpriteToItemMap(); - for (int f = 0; f < 9; f ++) - { - if (!mSpriteToItemReplaceMap[f]) - { - mSpriteToItemReplaceMap[f] = spMap; - direction = f; - } - } - if (direction >= 0) - mSpriteToItemReplaceList.push_back(spMap); - else - delete spMap; - if (direction == -1) - direction = 1; - } - if (direction < 0 || direction >= 9) return 0; -- cgit v1.2.3-70-g09d2