From 0c53148a96413eec254a6b3ba49d52fb7f48e24f Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Wed, 7 Jun 2023 12:39:59 +0200 Subject: Decompression refactoring --- src/SFileReadFile.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/SFileReadFile.cpp') diff --git a/src/SFileReadFile.cpp b/src/SFileReadFile.cpp index 39f794e..b0698c1 100644 --- a/src/SFileReadFile.cpp +++ b/src/SFileReadFile.cpp @@ -13,6 +13,11 @@ #include "StormLib.h" #include "StormCommon.h" +//----------------------------------------------------------------------------- +// External references (not public functions) + +int WINAPI SCompDecompressX(TMPQArchive * ha, void * pvOutBuffer, int * pcbOutBuffer, void * pbInBuffer, int cbInBuffer); + //----------------------------------------------------------------------------- // Local functions @@ -171,18 +176,10 @@ static DWORD ReadMpqSectors(TMPQFile * hf, LPBYTE pbBuffer, DWORD dwByteOffset, // Remember the last used compression hf->dwCompression0 = pbInSector[0]; - // Decompress the data - if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) - { - nResult = SCompDecompress2(pbOutSector, &cbOutSector, pbInSector, cbInSector); - } - else - { - if(ha->dwFlags & MPQ_FLAG_STARCRAFT_BETA) - nResult = SCompDecompress_SC1B(pbOutSector, &cbOutSector, pbInSector, cbInSector); - else - nResult = SCompDecompress(pbOutSector, &cbOutSector, pbInSector, cbInSector); - } + // Decompress the data. We need to perform MPQ-specific decompression, + // as multiple Blizzard games may have their own decompression tables + // and even decompression methods. + nResult = SCompDecompressX(ha, pbOutSector, &cbOutSector, pbInSector, cbInSector); } // Is the file compressed by PKWARE Data Compression Library ? -- cgit v1.2.3