summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog31
-rw-r--r--src/engine.cpp12
-rw-r--r--src/resources/mapreader.cpp25
3 files changed, 46 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 4ce8afc0..a9f3c416 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
-2007-08-27 Eugenio Favalli <elvenprogrammer@gmail.com>
+2007-08-27 Bjørn Lindeijer <bjorn@lindeijer.nl>
- * src/game.cpp: Assigned unused emotions to Alt +/-. (Applyed a patch by
- Quiche_on_a_leash).
+ * src/engine.cpp, src/resources/mapreader.cpp: Made client search for
+ both compressed and non-compressed map files.
+
+2007-08-27 Eugenio Favalli <elvenprogrammer@gmail.com>
+
+ * src/game.cpp: Assigned unused emotions to Alt +/-. (applied a patch
+ by Quiche_on_a_leash).
* data/maps/new_1-1.tmx, data/maps/new_1-1.tmx.gz,
data/maps/new_10-1.tmx, data/maps/new_10-1.tmx.gz,
data/maps/new_11-1.tmx, data/maps/new_11-1.tmx.gz,
@@ -15,14 +20,14 @@
data/maps/new_19-1.tmx, data/maps/new_19-1.tmx.gz,
data/maps/new_2-1.tmx, data/maps/new_2-1.tmx.gz,
data/maps/new_20-1.tmx, data/maps/new_20-1.tmx.gz,
- data/maps/new_3-1.tmx, data/maps/new_3-1.tmx.gz, data/maps/new_4-1.tmx,
- data/maps/new_4-1.tmx.gz, data/maps/new_5-1.tmx,
- data/maps/new_5-1.tmx.gz, data/maps/new_6-1.tmx,
- data/maps/new_6-1.tmx.gz, data/maps/new_7-1.tmx,
- data/maps/new_7-1.tmx.gz, data/maps/new_8-1.tmx,
- data/maps/new_8-1.tmx.gz, data/maps/new_9-1.tmx,
- data/maps/new_9-1.tmx.gz: Replaced compressed maps with layer
- compressed maps.
+ data/maps/new_3-1.tmx, data/maps/new_3-1.tmx.gz,
+ data/maps/new_4-1.tmx, data/maps/new_4-1.tmx.gz,
+ data/maps/new_5-1.tmx, data/maps/new_5-1.tmx.gz,
+ data/maps/new_6-1.tmx, data/maps/new_6-1.tmx.gz,
+ data/maps/new_7-1.tmx, data/maps/new_7-1.tmx.gz,
+ data/maps/new_8-1.tmx, data/maps/new_8-1.tmx.gz,
+ data/maps/new_9-1.tmx, data/maps/new_9-1.tmx.gz: Replaced compressed
+ maps with layer compressed maps.
2007-08-26 Eugenio Favalli <elvenprogrammer@gmail.com>
@@ -123,8 +128,8 @@
* src/keyboardconfig.cpp, src/keyboardconfig.h: Minor cleanup.
* src/gui/buy.cpp, src/gui/sell.cpp: Buy/sell fixed minimum quantity.
- * src/gui/setup_keyboard.cpp, src/gui/setup_keyboard.h: fixed bug - reverts
- unassigned key.
+ * src/gui/setup_keyboard.cpp, src/gui/setup_keyboard.h: Fixed bug -
+ reverts unassigned key.
2007-08-17 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/src/engine.cpp b/src/engine.cpp
index fb6b6048..4a0f2f1f 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -72,7 +72,16 @@ void Engine::changeMap(const std::string &mapPath)
particleEngine->clear();
// Store full map path in global var
- map_path = "maps/" + mapPath.substr(0, mapPath.rfind(".")) + ".tmx.gz";
+ const std::string base = "maps/" + mapPath.substr(0, mapPath.rfind("."));
+ ResourceManager *resman = ResourceManager::getInstance();
+ if (resman->exists(base + ".tmx"))
+ {
+ map_path = base + ".tmx";
+ }
+ else
+ {
+ map_path = base + ".tmx.gz";
+ }
// Attempt to load the new map
Map *newMap = MapReader::readMap(map_path);
@@ -85,7 +94,6 @@ void Engine::changeMap(const std::string &mapPath)
Image *mapImage = NULL;
if (newMap->hasProperty("minimap"))
{
- ResourceManager *resman = ResourceManager::getInstance();
mapImage = resman->getImage(newMap->getProperty("minimap"));
}
minimap->setMapImage(mapImage);
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 2230cb6a..260d5aa9 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -160,16 +160,27 @@ MapReader::readMap(const std::string &filename)
return NULL;
}
- // Inflate the gzipped map data
unsigned char *inflated;
- unsigned int inflatedSize = inflateMemory((unsigned char*) buffer,
- fileSize, inflated);
- free(buffer);
+ unsigned int inflatedSize;
- if (inflated == NULL)
+ if (filename.find(".gz", filename.length() - 3) != std::string::npos)
{
- logger->log("Could not decompress map file (%s)\n", filename.c_str());
- return NULL;
+ // Inflate the gzipped map data
+ inflatedSize =
+ inflateMemory((unsigned char*) buffer, fileSize, inflated);
+ free(buffer);
+
+ if (inflated == NULL)
+ {
+ logger->log("Could not decompress map file (%s)",
+ filename.c_str());
+ return NULL;
+ }
+ }
+ else
+ {
+ inflated = (unsigned char*) buffer;
+ inflatedSize = fileSize;
}
xmlDocPtr doc = xmlParseMemory((char*) inflated, inflatedSize);