From 3d2341674b6693bcddf2492357ab44e0494690d3 Mon Sep 17 00:00:00 2001 From: Adam Heinermann Date: Tue, 9 Jun 2026 01:02:45 -0700 Subject: [PATCH] Add support for ZLIB compression level --- src/SCompression.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SCompression.cpp b/src/SCompression.cpp index 1768452..7bff55a 100644 --- a/src/SCompression.cpp +++ b/src/SCompression.cpp @@ -101,7 +101,14 @@ void Compress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, in // Keep compilers happy STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); + + int level = Z_DEFAULT_COMPRESSION; // ZLIB usually decides this is 6 (Compression level used by WoW MPQs) + if (nCmpLevel == 1) { + level = 9; + } + else if (nCmpLevel == 2) { + level = 1; + } // Fill the stream structure for zlib z.next_in = (Bytef *)pvInBuffer; @@ -134,8 +141,9 @@ void Compress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, in // Initialize the compression. // Storm.dll uses zlib version 1.1.3 // Wow.exe uses zlib version 1.2.3 + // WC3:R, SC:R, and D2:R use zlib version 1.2.11 nResult = deflateInit2(&z, - 6, // Compression level used by WoW MPQs + level, Z_DEFLATED, windowBits, 8,