From b119923b4bb90d9ed3bb3a7550401b274d3ef0ad Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 7 Mar 2024 20:34:29 +0100 Subject: Some code simplifications in ResourceManager::loadFile --- src/resources/resourcemanager.cpp | 25 +++++++++---------------- 1 file 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) -- cgit v1.2.3-70-g09d2