summaryrefslogtreecommitdiff
path: root/src/resources/itemdb.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-25 03:42:09 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-25 03:42:09 +0300
commita4252ba2050b16a53247335cdddd7aa13a532239 (patch)
tree19a41cf0b1c546d5b1cc217194a1fe0a477d545d /src/resources/itemdb.cpp
parent4afb49eb81f590c2bce56ed28f237a9bf0e2a093 (diff)
downloadmanaverse-a4252ba2050b16a53247335cdddd7aa13a532239.tar.gz
manaverse-a4252ba2050b16a53247335cdddd7aa13a532239.tar.bz2
manaverse-a4252ba2050b16a53247335cdddd7aa13a532239.tar.xz
manaverse-a4252ba2050b16a53247335cdddd7aa13a532239.zip
Add removing palyers sprite logic depend on players direction.
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r--src/resources/itemdb.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 1260fab58..bee988510 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -56,6 +56,7 @@ 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 int parseDirectionName(std::string name);
static char const *const fields[][2] =
{
@@ -530,6 +531,29 @@ int parseSpriteName(std::string &name)
return id;
}
+int parseDirectionName(std::string name)
+{
+ int id = -1;
+ if (name == "down")
+ id = DIRECTION_DOWN;
+ else if (name == "downleft" || name == "leftdown")
+ id = DIRECTION_DOWNLEFT;
+ else if (name == "left")
+ id = DIRECTION_LEFT;
+ else if (name == "upleft" || name == "leftup")
+ id = DIRECTION_UPLEFT;
+ else if (name == "up")
+ id = DIRECTION_UP;
+ else if (name == "upright" || name == "rightup")
+ id = DIRECTION_UPRIGHT;
+ else if (name == "right")
+ id = DIRECTION_RIGHT;
+ else if (name == "downright" || name == "rightdown")
+ id = DIRECTION_DOWNRIGHT;
+
+ return id;
+}
+
void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node)
{
std::string gender = XML::getProperty(node, "gender", "unisex");
@@ -588,8 +612,10 @@ 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));
+ int direction = parseDirectionName(XML::getProperty(
+ replaceNode, "direction", "all"));
+ std::map<int, int> *mapList = itemInfo->addReplaceSprite(
+ parseSpriteName(removeSprite), direction);
itemInfo->setRemoveSprites();
@@ -599,7 +625,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode)
{
int from = XML::getProperty(itemNode, "from", 0);
int to = XML::getProperty(itemNode, "to", 1);
- mapList[from] = to;
+ (*mapList)[from] = to;
}
}
}