summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-27 21:37:15 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-27 21:37:15 +0000
commit1cfedcb3046f4169698256c65b09307d79f363d8 (patch)
treee7baa03ef62ac19329873f32edb944eadeafa1d2 /src/resources/mapreader.cpp
parent11a539a2945f2eabb8e9c179829e0b0dd3c966ff (diff)
downloadmana-1cfedcb3046f4169698256c65b09307d79f363d8.tar.gz
mana-1cfedcb3046f4169698256c65b09307d79f363d8.tar.bz2
mana-1cfedcb3046f4169698256c65b09307d79f363d8.tar.xz
mana-1cfedcb3046f4169698256c65b09307d79f363d8.zip
Ported patch from 0.0, in order to support missing extensions and uncompressed maps.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp25
1 files changed, 18 insertions, 7 deletions
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);