From a2100778f2930042fea64cd3edc86b986da5d5da Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 3 Oct 2015 21:04:14 +0300 Subject: 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" --- src/resources/beingcommon.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src/resources') 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( - 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(block ^ allFlags)); } void BeingCommon::getIncludeFiles(const std::string &dir, -- cgit v1.2.3-60-g2f50