diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-02-14 03:54:55 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-02-14 23:52:45 +0200 |
commit | 3805d1384894a33ecb09e4852d47afb04ddb0687 (patch) | |
tree | 840b5920d912576554e0e11e67794a726d4a9c4f /src/resources/itemdb.cpp | |
parent | 36ccecd553539955929f1ce535b8925533922e4e (diff) | |
download | manaplus-3805d1384894a33ecb09e4852d47afb04ddb0687.tar.gz manaplus-3805d1384894a33ecb09e4852d47afb04ddb0687.tar.bz2 manaplus-3805d1384894a33ecb09e4852d47afb04ddb0687.tar.xz manaplus-3805d1384894a33ecb09e4852d47afb04ddb0687.zip |
Replace sprites functionality (need support in client data).
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r-- | src/resources/itemdb.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 00987ff9d..ce2ec40a2 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -50,6 +50,7 @@ namespace static void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node); static void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node); static void loadFloorSprite(SpriteDisplay *display, xmlNodePtr node); +static void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode); static int parseSpriteName(std::string &name); static char const *const fields[][2] = @@ -205,8 +206,6 @@ void ItemDB::load() std::string drawBefore = XML::getProperty(node, "drawBefore", ""); std::string drawAfter = XML::getProperty(node, "drawAfter", ""); std::string removeSprite = XML::getProperty(node, "removeSprite", ""); - std::string removeSpriteIds = XML::getProperty(node, "removeSpriteIds", ""); - std::set<int> rSprites = splitToIntSet(removeSpriteIds, ','); std::string tags[3]; tags[0] = XML::getProperty(node, "tag", @@ -266,8 +265,6 @@ void ItemDB::load() itemInfo->setDrawBefore(parseSpriteName(drawBefore)); itemInfo->setDrawAfter(parseSpriteName(drawAfter)); itemInfo->setDrawPriority(drawPriority); - itemInfo->setRemoveSprite(parseSpriteName(removeSprite)); - itemInfo->setRemoveSpriteIds(rSprites); std::string effect; for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i) @@ -313,6 +310,10 @@ void ItemDB::load() { loadFloorSprite(&display, itemChild); } + else if (xmlStrEqual(itemChild->name, BAD_CAST "replace")) + { + loadReplaceSprite(itemInfo, itemChild); + } } itemInfo->setDisplay(display); @@ -554,3 +555,20 @@ void loadFloorSprite(SpriteDisplay *display, xmlNodePtr floorNode) } } } + +void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) +{ + std::string removeSprite = XML::getProperty(replaceNode, "sprite", ""); + std::map<int,int> &mapList = itemInfo->addReplaceSprite(parseSpriteName(removeSprite)); + itemInfo->setRemoveSprites(); + + 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); + mapList[from] = to; + } + } +} |