diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-08-27 20:47:31 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-08-27 20:47:31 +0000 |
commit | 76291862ce0e26040f251bc4764539d8ff6634a0 (patch) | |
tree | 6d89b1816081da7338e8571be7165ffe8138cfb6 /src/resources | |
parent | ce0ccc904a899e3aa8e719d2407391433b3b4be5 (diff) | |
download | Mana-76291862ce0e26040f251bc4764539d8ff6634a0.tar.gz Mana-76291862ce0e26040f251bc4764539d8ff6634a0.tar.bz2 Mana-76291862ce0e26040f251bc4764539d8ff6634a0.tar.xz Mana-76291862ce0e26040f251bc4764539d8ff6634a0.zip |
Made client search for both compressed and non-compressed map files.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/mapreader.cpp | 25 |
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); |