From 7880e6f7612b70a50d6bef9fc404fd43decff49e Mon Sep 17 00:00:00 2001 From: Azdul Date: Sat, 19 Jan 2019 14:41:17 +0100 Subject: [PATCH] CompressedBSAFile::FileRecord::isCompressed implementation simplified. Double space in CompressedBSAFile::FileRecord::getSizeWithoutCompressionFlag removed. --- components/bsa/compressedbsafile.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/components/bsa/compressedbsafile.cpp b/components/bsa/compressedbsafile.cpp index 598f65250..9ff0b67ce 100644 --- a/components/bsa/compressedbsafile.cpp +++ b/components/bsa/compressedbsafile.cpp @@ -61,16 +61,19 @@ bool CompressedBSAFile::FileRecord::isValid() const bool CompressedBSAFile::FileRecord::isCompressed(bool bsaCompressedByDefault) const { - bool compressionFlagEnabled = ((size & sCompressedFlag) == sCompressedFlag); - - if (bsaCompressedByDefault) { - return !compressionFlagEnabled; - } - return compressionFlagEnabled; + bool recordCompressionFlagEnabled = ((size & sCompressedFlag) == sCompressedFlag); + + //record is compressed when: + //- bsaCompressedByDefault flag is set and 30th bit is NOT set, or + //- bsaCompressedByDefault flag is NOT set and 30th bit is set + //record is NOT compressed when: + //- bsaCompressedByDefault flag is NOT set and 30th bit is NOT set, or + //- bsaCompressedByDefault flag is set and 30th bit is set + return (bsaCompressedByDefault != recordCompressionFlagEnabled); } std::uint32_t CompressedBSAFile::FileRecord::getSizeWithoutCompressionFlag() const { - return size & (~sCompressedFlag); + return size & (~sCompressedFlag); } void CompressedBSAFile::getBZString(std::string& str, std::istream& filestream)