diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-08-29 16:10:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-08-29 16:10:10 +0300 |
commit | 71addab362fe436cfc32c77d437df6d662ef1630 (patch) | |
tree | fcb6ab62371521f4cc0d6046511e66bea0c2f77c /src/resources/itemdb.cpp | |
parent | 552781d7e35fd773ae08e9d1c0cc12c1f245d4ed (diff) | |
download | manaplus-71addab362fe436cfc32c77d437df6d662ef1630.tar.gz manaplus-71addab362fe436cfc32c77d437df6d662ef1630.tar.bz2 manaplus-71addab362fe436cfc32c77d437df6d662ef1630.tar.xz manaplus-71addab362fe436cfc32c77d437df6d662ef1630.zip |
Add pseudo directions upall, downall for sprites replacement logic.
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r-- | src/resources/itemdb.cpp | 106 |
1 files changed, 85 insertions, 21 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 60fe51443..9fba69461 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -560,6 +560,10 @@ int parseDirectionName(std::string name) id = DIRECTION_RIGHT; else if (name == "downright" || name == "rightdown") id = DIRECTION_DOWNRIGHT; + else if (name == "downall") + id = -2; + else if (name == "upall") + id = -3; return id; } @@ -627,39 +631,99 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) itemInfo->setRemoveSprites(); - if (direction != -1) + switch (direction) { - std::map<int, int> *mapList = itemInfo->addReplaceSprite( - parseSpriteName(removeSprite), direction); - if (!mapList) - return; - for_each_xml_child_node(itemNode, replaceNode) + case -1: { - if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + 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); + for (int f = 0; f < 9; f ++) + { + std::map<int, int> *mapList + = itemInfo->addReplaceSprite( + parseSpriteName(removeSprite), f); + if (!mapList) + continue; + (*mapList)[from] = to; + } + } } + break; } - } - else - { - for_each_xml_child_node(itemNode, replaceNode) + case -2: + { + logger->log("parse -2"); + 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); + std::map<int, int> *mapList = itemInfo->addReplaceSprite( + parseSpriteName(removeSprite), DIRECTION_DOWN); + if (mapList) + (*mapList)[from] = to; + + mapList = itemInfo->addReplaceSprite(parseSpriteName( + removeSprite), DIRECTION_DOWNLEFT); + if (mapList) + (*mapList)[from] = to; + + mapList = itemInfo->addReplaceSprite(parseSpriteName( + removeSprite), DIRECTION_DOWNRIGHT); + if (mapList) + (*mapList)[from] = to; + } + } + break; + } + case -3: { - if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + logger->log("parse -3"); + for_each_xml_child_node(itemNode, replaceNode) { - int from = XML::getProperty(itemNode, "from", 0); - int to = XML::getProperty(itemNode, "to", 1); - for (int f = 0; f < 9; f ++) + if (xmlStrEqual(itemNode->name, BAD_CAST "item")) { + int from = XML::getProperty(itemNode, "from", 0); + int to = XML::getProperty(itemNode, "to", 1); std::map<int, int> *mapList = itemInfo->addReplaceSprite( - parseSpriteName(removeSprite), f); - if (!mapList) - continue; + parseSpriteName(removeSprite), DIRECTION_UP); + if (mapList) + (*mapList)[from] = to; + + mapList = itemInfo->addReplaceSprite(parseSpriteName( + removeSprite), DIRECTION_UPLEFT); + if (mapList) + (*mapList)[from] = to; + + mapList = itemInfo->addReplaceSprite(parseSpriteName( + removeSprite), DIRECTION_UPRIGHT); + if (mapList) + (*mapList)[from] = to; + } + } + break; + } + default: + { + std::map<int, int> *mapList = itemInfo->addReplaceSprite( + parseSpriteName(removeSprite), direction); + if (!mapList) + return; + 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; } } + break; } } } |