diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-06-24 22:21:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-06-24 22:21:04 +0300 |
commit | 2e655b41861169ee1db19ef59345661b7dc70610 (patch) | |
tree | c2d46433c073a12920232fe94e96995457f5fe4e | |
parent | 3b537e109df901df3da4c706f827c8d3d39a7238 (diff) | |
download | mv-2e655b41861169ee1db19ef59345661b7dc70610.tar.gz mv-2e655b41861169ee1db19ef59345661b7dc70610.tar.bz2 mv-2e655b41861169ee1db19ef59345661b7dc70610.tar.xz mv-2e655b41861169ee1db19ef59345661b7dc70610.zip |
Add basic support for maps without client data (tmx, tiles, etc)
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 18 | ||||
-rw-r--r-- | src/resources/mapreader.h | 3 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp index 4ae5607a0..386e01a3d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -976,10 +976,12 @@ void Game::changeMap(const std::string &mapPath) if (!newMap) { +/* logger->log("Error while loading %s", fullMap.c_str()); new OkDialog(_("Could Not Load Map"), strprintf( _("Error while loading %s"), fullMap.c_str()), DIALOG_ERROR, false); +*/ } if (mCurrentMap) diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index fd04f015f..57524e953 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -192,10 +192,7 @@ Map *MapReader::readMap(const std::string &filename, Map *map = nullptr; if (!buffer) - { - logger->log("Map file not found (%s)", realFilename.c_str()); - return nullptr; - } + return createEmptyMap(filename, realFilename); unsigned char *inflated; unsigned int inflatedSize; @@ -792,3 +789,16 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path, return set; } + +Map *MapReader::createEmptyMap(const std::string &filename, + const std::string &realFilename) +{ + logger->log("Creating empty map"); + Map *map = new Map(300, 300, 32, 32); + MapLayer *layer = new MapLayer(0, 0, 300, 300, false); + map->addLayer(layer); + layer = new MapLayer(0, 0, 300, 300, true); + map->addLayer(layer); + + return map; +} diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index c9c742ecd..28fa628db 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -49,6 +49,9 @@ class MapReader */ static Map *readMap(XmlNodePtr node, const std::string &path); + static Map *createEmptyMap(const std::string &filename, + const std::string &realFilename); + private: /** * Reads the properties element. |