diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/mapmanager.cpp | 9 | ||||
-rw-r--r-- | src/resourcemanager.cpp | 8 | ||||
-rw-r--r-- | src/resourcemanager.h | 5 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/game-server/mapmanager.cpp b/src/game-server/mapmanager.cpp index ab0d0fec..713bd2cf 100644 --- a/src/game-server/mapmanager.cpp +++ b/src/game-server/mapmanager.cpp @@ -116,8 +116,13 @@ void MapManager::raiseActive(int mapId) return; } - std::string const &file = composite->getName(); - MapReader::readMap("maps/" + file, composite); + std::string file = "maps/" + composite->getName() + ".tmx"; + ResourceManager *resman = ResourceManager::getInstance(); + if (!resman->exists(file)) + { + file += ".gz"; + } + MapReader::readMap(file, composite); LOG_INFO("Activated map \"" << file << "\" (id " << mapId << ")"); // Add some testing stuff diff --git a/src/resourcemanager.cpp b/src/resourcemanager.cpp index d45e96e4..f40fc232 100644 --- a/src/resourcemanager.cpp +++ b/src/resourcemanager.cpp @@ -139,11 +139,17 @@ ResourceManager::searchAndAddZipFiles() #endif } +bool ResourceManager::exists(std::string const &path) +{ + return PHYSFS_exists(path.c_str()); +} + void* ResourceManager::loadFile(const std::string &fileName, int &fileSize) { // If the file doesn't exist indicate failure - if (!PHYSFS_exists(fileName.c_str())) { + if (!exists(fileName)) + { LOG_WARN("Warning: " << fileName << " not found!"); return NULL; } diff --git a/src/resourcemanager.h b/src/resourcemanager.h index 97fb9956..0eb79c8d 100644 --- a/src/resourcemanager.h +++ b/src/resourcemanager.h @@ -44,6 +44,11 @@ class ResourceManager ~ResourceManager(); /** + * Checks whether the given file or directory exists in the search path + */ + bool exists(std::string const &path); + + /** * Allocates data into a buffer pointer for raw data loading. The * returned data is expected to be freed using <code>free()</code>. * |