From 3805d1384894a33ecb09e4852d47afb04ddb0687 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 14 Feb 2011 03:54:55 +0200 Subject: Replace sprites functionality (need support in client data). --- src/resources/itemdb.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/resources/itemdb.cpp') 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 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 &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; + } + } +} -- cgit v1.2.3-70-g09d2