From 94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 9 May 2011 23:02:28 +0300 Subject: Impliment air and water block types. --- src/resources/mapreader.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/resources/mapreader.cpp') 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); + } + } } } -- cgit v1.2.3-70-g09d2