summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--data/maps.xml38
-rw-r--r--src/game-server/mapmanager.cpp9
-rw-r--r--src/resourcemanager.cpp8
-rw-r--r--src/resourcemanager.h5
5 files changed, 43 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 36b3d658..7d764f08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,11 @@
"drop", and "spawn" remote commands.
* src/game-server/mapreader.cpp: Added support for uncompressed map
files and compressed layers.
+ * src/resourcemanager.cpp, src/resourcemanager.h: Added "exists"
+ function to resource manager.
+ * src/game-server/mapmanager.cpp: Used runtime selection of map
+ filename extensions.
+ * data/maps.xml: Removed extensions from map names.
2007-08-20 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/data/maps.xml b/data/maps.xml
index 3592aa46..768d1da4 100644
--- a/data/maps.xml
+++ b/data/maps.xml
@@ -1,22 +1,22 @@
<?xml version="1.0"?>
<maps>
- <map id="1" name="new_1-1.tmx.gz"/>
- <map id="2" name="new_2-1.tmx.gz"/>
- <map id="3" name="new_3-1.tmx.gz"/>
- <map id="4" name="new_4-1.tmx.gz"/>
- <map id="5" name="new_5-1.tmx.gz"/>
- <map id="6" name="new_6-1.tmx.gz"/>
- <map id="7" name="new_7-1.tmx.gz"/>
- <map id="8" name="new_8-1.tmx.gz"/>
- <map id="9" name="new_9-1.tmx.gz"/>
- <map id="10" name="new_10-1.tmx.gz"/>
- <map id="11" name="new_11-1.tmx.gz"/>
- <map id="12" name="new_12-1.tmx.gz"/>
- <map id="13" name="new_13-1.tmx.gz"/>
- <map id="14" name="new_14-1.tmx.gz"/>
- <map id="15" name="new_15-1.tmx.gz"/>
- <map id="16" name="new_16-1.tmx.gz"/>
- <map id="17" name="new_17-1.tmx.gz"/>
- <map id="18" name="new_18-1.tmx.gz"/>
- <map id="19" name="new_19-1.tmx.gz"/>
+ <map id="1" name="new_1-1"/>
+ <map id="2" name="new_2-1"/>
+ <map id="3" name="new_3-1"/>
+ <map id="4" name="new_4-1"/>
+ <map id="5" name="new_5-1"/>
+ <map id="6" name="new_6-1"/>
+ <map id="7" name="new_7-1"/>
+ <map id="8" name="new_8-1"/>
+ <map id="9" name="new_9-1"/>
+ <map id="10" name="new_10-1"/>
+ <map id="11" name="new_11-1"/>
+ <map id="12" name="new_12-1"/>
+ <map id="13" name="new_13-1"/>
+ <map id="14" name="new_14-1"/>
+ <map id="15" name="new_15-1"/>
+ <map id="16" name="new_16-1"/>
+ <map id="17" name="new_17-1"/>
+ <map id="18" name="new_18-1"/>
+ <map id="19" name="new_19-1"/>
</maps>
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>.
*