summaryrefslogtreecommitdiff
path: root/src/resources/map/map.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-16 00:32:58 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-16 00:32:58 +0300
commitf672c7242dfa8d278d826f1e460af96265ca307c (patch)
tree623589aa9a104febeac4147ea349e05c76fb8c77 /src/resources/map/map.cpp
parent6d44c69cb0cc9c2ac8a94c56c07ed45f63ab9726 (diff)
downloadplus-f672c7242dfa8d278d826f1e460af96265ca307c.tar.gz
plus-f672c7242dfa8d278d826f1e460af96265ca307c.tar.bz2
plus-f672c7242dfa8d278d826f1e460af96265ca307c.tar.xz
plus-f672c7242dfa8d278d826f1e460af96265ca307c.zip
Impliment packet SMSG_MAP_SET_TILES_TYPE (hercules)
This allow change collision types from server.
Diffstat (limited to 'src/resources/map/map.cpp')
-rw-r--r--src/resources/map/map.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 097a7a11d..de6090dc2 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -680,7 +680,7 @@ const Tileset *Map::getTilesetWithGid(const int gid) const
}
void Map::addBlockMask(const int x, const int y,
- const BlockTypeT type)
+ const BlockTypeT type)
{
if (type == BlockType::NONE || !contains(x, y))
return;
@@ -712,6 +712,39 @@ void Map::addBlockMask(const int x, const int y,
}
}
+void Map::setBlockMask(const int x, const int y,
+ const BlockTypeT type)
+{
+ if (type == BlockType::NONE || !contains(x, y))
+ return;
+
+ const int tileNum = x + y * mWidth;
+
+ switch (type)
+ {
+ case BlockType::WALL:
+ mMetaTiles[tileNum].blockmask = BlockMask::WALL;
+ break;
+ case BlockType::AIR:
+ mMetaTiles[tileNum].blockmask = BlockMask::AIR;
+ break;
+ case BlockType::WATER:
+ mMetaTiles[tileNum].blockmask = BlockMask::WATER;
+ break;
+ case BlockType::GROUND:
+ mMetaTiles[tileNum].blockmask = BlockMask::GROUND;
+ break;
+ case BlockType::GROUNDTOP:
+ mMetaTiles[tileNum].blockmask = BlockMask::GROUNDTOP;
+ break;
+ default:
+ case BlockType::NONE:
+ case BlockType::NB_BLOCKTYPES:
+ // Do nothing.
+ break;
+ }
+}
+
bool Map::getWalk(const int x, const int y,
const unsigned char blockWalkMask) const
{
@@ -781,6 +814,14 @@ const std::string Map::getFilename() const
return fileName.substr(lastSlash, fileName.rfind(".") - lastSlash);
}
+const std::string Map::getGatName() const
+{
+ const std::string fileName = getProperty("_filename");
+ const size_t lastSlash = fileName.rfind("/") + 1;
+ return fileName.substr(lastSlash,
+ fileName.rfind(".") - lastSlash).append(".gat");
+}
+
Path Map::findPath(const int startX, const int startY,
const int destX, const int destY,
const unsigned char blockWalkMask,