diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-06 17:42:17 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-06 17:42:17 +0000 |
commit | 5dc6243dfc06924d9206b2987bb7ededaa87f8f1 (patch) | |
tree | 565b4c983e53eba75801a0bfc5a77264627527a7 /src/resources/mapreader.cpp | |
parent | 000bbf497024f5d9c9c7521c0a423f458641a32e (diff) | |
download | mana-client-5dc6243dfc06924d9206b2987bb7ededaa87f8f1.tar.gz mana-client-5dc6243dfc06924d9206b2987bb7ededaa87f8f1.tar.bz2 mana-client-5dc6243dfc06924d9206b2987bb7ededaa87f8f1.tar.xz mana-client-5dc6243dfc06924d9206b2987bb7ededaa87f8f1.zip |
Added collision tileset... last commit missed there files.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r-- | src/resources/mapreader.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index b28515c1..20438c9d 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -176,8 +176,15 @@ void MapReader::readLayer(xmlNodePtr node, Map *map, int layer) if (xmlStrEqual(n2->name, BAD_CAST "tile") && y < h) { int gid = getProperty(n2, "gid", -1); - if (layer == 0) map->setWalk(x, y, true); - map->setTile(x, y, layer, getTileWithGid(gid)); + if (layer == 3) + { + Tileset *set = getTilesetWithGid(gid); + map->setWalk(x, y, + !set || (gid - set->getFirstGid() == 0)); + } + else if (layer < 3) { + map->setTile(x, y, layer, getTileWithGid(gid)); + } x++; if (x == w) {x = 0; y++;} @@ -257,6 +264,18 @@ int MapReader::getProperty(xmlNodePtr node, const char* name, int def) Image *MapReader::getTileWithGid(int gid) { std::vector<Tileset*>::iterator i; + Tileset *set = getTilesetWithGid(gid); + + if (set) { + return set->spriteset[gid - set->getFirstGid()]; + } + + return NULL; +} + +Tileset *MapReader::getTilesetWithGid(int gid) +{ + std::vector<Tileset*>::iterator i; Tileset *set = NULL; // Find the tileset with the highest firstGid below/eq to gid @@ -272,7 +291,7 @@ Image *MapReader::getTileWithGid(int gid) if (set && (gid - set->getFirstGid()) < (int)set->spriteset.size()) { - return set->spriteset[gid - set->getFirstGid()]; + return set; } return NULL; |