summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-03 21:04:14 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-03 21:05:20 +0300
commita2100778f2930042fea64cd3edc86b986da5d5da (patch)
tree6439e65f991e28ead3c497d6882b95b5bbba645f /src
parent8700635293ff1d39266f0c1a8a77d2d28ba4a241 (diff)
downloadplus-a2100778f2930042fea64cd3edc86b986da5d5da.tar.gz
plus-a2100778f2930042fea64cd3edc86b986da5d5da.tar.bz2
plus-a2100778f2930042fea64cd3edc86b986da5d5da.tar.xz
plus-a2100778f2930042fea64cd3edc86b986da5d5da.zip
Extend walkMask being xml attribute.
Now it also support 'all' and 'wall' attributes. Also allow set walk mask by complex values like this: walkMask="water,wall"
Diffstat (limited to 'src')
-rw-r--r--src/resources/beingcommon.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp
index b37a6e879..78c55853e 100644
--- a/src/resources/beingcommon.cpp
+++ b/src/resources/beingcommon.cpp
@@ -53,20 +53,32 @@ void BeingCommon::readBasicAttributes(BeingInfo *const info,
info->setHpBarOffsetX(XML::getProperty(node, "hpBarOffsetX", 0));
info->setHpBarOffsetY(XML::getProperty(node, "hpBarOffsetY", 0));
- unsigned char block = 0;
+ unsigned char block = BlockMask::WALL;
std::string walkStr = XML::getProperty(
node, "walkType", "walk");
- if (walkStr == "walk")
- block = BlockMask::WATER | BlockMask::AIR;
- else if (walkStr == "fly")
- block = 0;
- else if (walkStr == "swim")
- block = BlockMask::GROUND | BlockMask::AIR;
- else if (walkStr == "walkswim" || walkStr == "swimwalk")
- block = BlockMask::AIR;
-
- info->setBlockWalkMask(static_cast<unsigned char>(
- BlockMask::WALL | block));
+
+ const int allFlags = BlockMask::GROUND |
+ BlockMask::WALL |
+ BlockMask::WATER |
+ BlockMask::AIR;
+ StringVect tokens;
+ splitToStringVector(tokens, walkStr, ',');
+ FOR_EACH(StringVectCIter, it, tokens)
+ {
+ if (walkStr == "walk" || walkStr == "ground")
+ block |= BlockMask::GROUND;
+ else if (walkStr == "fly" || walkStr == "air")
+ block |= BlockMask::GROUND | BlockMask::WATER | BlockMask::AIR;
+ else if (walkStr == "all")
+ block |= allFlags;
+ else if (walkStr == "wall")
+ block |= BlockMask::WALL;
+ else if (walkStr == "swim" || walkStr == "water")
+ block |= BlockMask::WATER;
+ else if (walkStr == "walkswim" || walkStr == "swimwalk") // legacy
+ block |= BlockMask::GROUND | BlockMask::WATER;
+ }
+ info->setBlockWalkMask(static_cast<unsigned char>(block ^ allFlags));
}
void BeingCommon::getIncludeFiles(const std::string &dir,