diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-20 20:56:59 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-20 20:56:59 +0000 |
commit | 7ce021a8e4fce72af6e79cad22243bdd50bb8656 (patch) | |
tree | 06f9eadde06667d640f94e8ecc8b526a45af402d /src/resources/mapreader.cpp | |
parent | 368c9002365118212d9ef9b6bb00f9148522770f (diff) | |
download | mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.tar.gz mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.tar.bz2 mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.tar.xz mana-7ce021a8e4fce72af6e79cad22243bdd50bb8656.zip |
Reverted changes to skill dialog, a new one will be developed alongside it so
that the current one remains working for now. Also XML maps now can load but
not the base64 or gzip kind yet.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r-- | src/resources/mapreader.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 98160ff8..32b71d9c 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -47,9 +47,11 @@ int Tileset::getFirstGid() Map *MapReader::readMap(const std::string &filename) { - std::cout << "Attempting to parse XML map data"; + log("Attempting to parse XML map data"); - FILE* f = fopen(filename.c_str(), "rb"); + std::string name = std::string("data/") + filename; + + FILE* f = fopen(name.c_str(), "rb"); char *map_string; if (!f) { @@ -72,7 +74,7 @@ Map *MapReader::readMap(const std::string &filename) delete[] map_string; if (doc) { - std::cout << "Looking for root node"; + log("Looking for root node"); xmlNodePtr node = xmlDocGetRootElement(doc); if (!node || !xmlStrEqual(node->name, BAD_CAST "map")) { @@ -80,7 +82,7 @@ Map *MapReader::readMap(const std::string &filename) return NULL; } - std::cout << "Loading map from XML tree"; + log("Loading map from XML tree"); return readMap(node, filename); xmlFreeDoc(doc); } else { @@ -93,6 +95,9 @@ Map *MapReader::readMap(const std::string &filename) Map* MapReader::readMap(xmlNodePtr node, const std::string &path) { xmlChar *prop; + + // Take the filename off the path + std::string pathDir = path.substr(0, path.rfind("/") + 1); prop = xmlGetProp(node, BAD_CAST "version"); #ifndef WIN32 @@ -111,7 +116,7 @@ Map* MapReader::readMap(xmlNodePtr node, const std::string &path) { if (xmlStrEqual(node->name, BAD_CAST "tileset")) { - Tileset *tileset = readTileset(node, path, map); + Tileset *tileset = readTileset(node, pathDir, map); if (tileset) { tilesets.push_back(tileset); } @@ -162,6 +167,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map, int layer) } } + if (layer == 0) map->setWalk(x, y, true); map->setTile(x, y, layer, img); x++; |