diff options
author | Ira Rice <irarice@gmail.com> | 2008-12-02 18:08:12 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-12-02 18:08:12 -0700 |
commit | 7882d3dfcac6b2894d33947d4dca5df375712646 (patch) | |
tree | 1d401017d1d43420819398cd4f0004b9de278117 /src/resources/mapreader.cpp | |
parent | 84164bd6cb597fe45f54e97cf9c8991e93e9a803 (diff) | |
download | mana-7882d3dfcac6b2894d33947d4dca5df375712646.tar.gz mana-7882d3dfcac6b2894d33947d4dca5df375712646.tar.bz2 mana-7882d3dfcac6b2894d33947d4dca5df375712646.tar.xz mana-7882d3dfcac6b2894d33947d4dca5df375712646.zip |
Added the ability to use external tilesets in the client.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r-- | src/resources/mapreader.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index d6154ee0..b1068510 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -446,13 +446,17 @@ MapReader::readTileset(xmlNodePtr node, const std::string &path, Map *map) { + int firstGid = XML::getProperty(node, "firstgid", 0); + XML::Document* doc = NULL; + if (xmlHasProp(node, BAD_CAST "source")) { - logger->log("Warning: External tilesets not supported yet."); - return NULL; + std::string filename = XML::getProperty(node, "source", ""); + doc = new XML::Document(filename); + node = doc->rootNode(); + firstGid += XML::getProperty(node, "firstgid", 0); } - const int firstGid = XML::getProperty(node, "firstgid", 0); const int tw = XML::getProperty(node, "tilewidth", map->getTileWidth()); const int th = XML::getProperty(node, "tileheight", map->getTileHeight()); @@ -475,6 +479,8 @@ MapReader::readTileset(xmlNodePtr node, { Tileset *set = new Tileset(tilebmp, tw, th, firstGid); tilebmp->decRef(); + if (doc) + delete doc; return set; } else { @@ -486,5 +492,8 @@ MapReader::readTileset(xmlNodePtr node, break; } + if (doc) + delete doc; + return NULL; } |