summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-09 23:02:28 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-09 23:02:28 +0300
commit94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd (patch)
treea5fd9ec3c5844ce9b8d6b4c63c25c9ded803a6a0 /src/resources/mapreader.cpp
parent51169702a6fba4626eeae44faa35ebcbf40e5fed (diff)
downloadplus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.tar.gz
plus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.tar.bz2
plus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.tar.xz
plus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.zip
Impliment air and water block types.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 818968621..7fa088326 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -288,6 +288,8 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
else if (xmlStrEqual(childNode->name, BAD_CAST "properties"))
{
readProperties(childNode, map);
+ map->setVersion(atoi(map->getProperty(
+ "manaplus version").c_str()));
}
else if (xmlStrEqual(childNode->name, BAD_CAST "objectgroup"))
{
@@ -407,8 +409,33 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
{
// Set collision tile
// if (set && (gid - set->getFirstGid() == 1)) buggy update
- if (set && (gid - set->getFirstGid() != 0))
- map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ if (set)
+ {
+ if (map->getVersion() >= 1)
+ {
+ switch (gid - set->getFirstGid())
+ {
+ case Map::COLLISION_WALL:
+ map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ break;
+ case Map::COLLISION_AIR:
+ logger->log("air: %d, %d", x, y);
+ map->blockTile(x, y, Map::BLOCKTYPE_AIR);
+ break;
+ case Map::COLLISION_WATER:
+ logger->log("water: %d, %d", x, y);
+ map->blockTile(x, y, Map::BLOCKTYPE_WATER);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if (gid - set->getFirstGid() != 0)
+ map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ }
+ }
}
}