diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-07 20:34:29 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-07 20:34:29 +0100 |
commit | b119923b4bb90d9ed3bb3a7550401b274d3ef0ad (patch) | |
tree | 4a092eb5d1dcabe6340f4c12a294599e276a95aa /src/resources | |
parent | 98e0c2435bd69d6dd78fb0f84389a81b56278958 (diff) | |
download | mana-b119923b4bb90d9ed3bb3a7550401b274d3ef0ad.tar.gz mana-b119923b4bb90d9ed3bb3a7550401b274d3ef0ad.tar.bz2 mana-b119923b4bb90d9ed3bb3a7550401b274d3ef0ad.tar.xz mana-b119923b4bb90d9ed3bb3a7550401b274d3ef0ad.zip |
Some code simplifications in ResourceManager::loadFile
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/resourcemanager.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index dd9aaebb..65cc4d50 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -465,31 +465,24 @@ void *ResourceManager::loadFile(const std::string &filename, int &filesize, // Close the file and let the user deallocate the memory PHYSFS_close(file); - unsigned char *inflated; - unsigned int inflatedSize; - if (inflate && filename.find(".gz", filename.length() - 3) != std::string::npos) { + unsigned char *inflated; + // Inflate the gzipped map data - inflatedSize = - inflateMemory((unsigned char*) buffer, filesize, inflated); + filesize = inflateMemory((unsigned char*) buffer, filesize, inflated); free(buffer); - if (inflated == nullptr) + buffer = inflated; + + if (!buffer) { - logger->log("Could not decompress file: %s", - filename.c_str()); - return nullptr; + logger->log("Could not decompress file: %s", filename.c_str()); } - - filesize = inflatedSize; - return inflated; - } - else - { - return buffer; } + + return buffer; } bool ResourceManager::copyFile(const std::string &src, const std::string &dst) |