diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..f804cb6
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "external/zlib"]
+ path = external/zlib
+ url = https://github.com/madler/zlib
diff --git a/Arsenal.vcxproj b/Arsenal.vcxproj
index 6c29f48..1de73e7 100644
--- a/Arsenal.vcxproj
+++ b/Arsenal.vcxproj
@@ -29,26 +29,26 @@
Application
true
- v142
+ v143
Unicode
Application
false
- v142
+ v143
true
Unicode
Application
true
- v142
+ v143
Unicode
Application
false
- v142
+ v143
true
Unicode
@@ -89,12 +89,17 @@
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
stdcpp17
+ $(SolutionDir)external\zlib
+
Console
true
"mgs/3rdparty/zlib/zlib.lib";%(AdditionalDependencies)
+
+ call "build_zlib.bat"
+
@@ -105,6 +110,8 @@
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
stdcpp17
+ $(SolutionDir)external\zlib
+
Console
@@ -114,6 +121,9 @@
"mgs/3rdparty/zlib/zlib.lib";%(AdditionalDependencies)
false
+
+ call "build_zlib.bat"
+
@@ -122,12 +132,17 @@
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
stdcpp17
+ $(SolutionDir)external\zlib
+
Console
true
"mgs/3rdparty/zlib/zlib.lib";%(AdditionalDependencies)
+
+ call "build_zlib.bat"
+
@@ -138,6 +153,8 @@
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
stdcpp17
+ $(SolutionDir)external\zlib
+
Console
@@ -147,6 +164,9 @@
"mgs/3rdparty/zlib/zlib.lib";%(AdditionalDependencies)
false
+
+ call "build_zlib.bat"
+
diff --git a/build_zlib.bat b/build_zlib.bat
new file mode 100644
index 0000000..e1bf0da
--- /dev/null
+++ b/build_zlib.bat
@@ -0,0 +1,61 @@
+@echo off
+setlocal
+
+echo ============================================================
+echo [PreBuild] Auto-build zlib
+echo ============================================================
+
+rem --- Define paths relative to this script (which lives in repo root) ---
+set "ROOT=%~dp0"
+set "SLN=%ROOT%external\zlib\contrib\vstudio\vc17\zlibvc.sln"
+set "OUTDIR=%ROOT%external\zlib\contrib\vstudio\vc17\x64\ZlibStatRelease"
+set "BUILT_LIB=%OUTDIR%\zlibstat.lib"
+set "TARGET_LIB=%ROOT%mgs\3rdparty\zlib\zlib.lib"
+
+echo [PreBuild] Checking for zlib (Release build)...
+echo [PreBuild] Target library: "%TARGET_LIB%"
+
+rem --- If final lib already exists, skip build ---
+if exist "%TARGET_LIB%" (
+ echo [PreBuild] Found existing library: "%TARGET_LIB%"
+ exit /b 0
+)
+
+echo [PreBuild] zlib.lib not found — building static Release library...
+
+rem --- Locate MSBuild using vswhere ---
+set "MSBUILD_EXE="
+for /f "usebackq tokens=*" %%I in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do set "MSBUILD_EXE=%%I"
+
+if "%MSBUILD_EXE%"=="" (
+ echo [PreBuild] ERROR: Could not locate MSBuild.exe via vswhere.
+ exit /b 1
+)
+
+echo [PreBuild] Using MSBuild: "%MSBUILD_EXE%"
+"%MSBUILD_EXE%" "%SLN%" /p:Configuration=Release /p:Platform=x64 /t:Build /nologo /v:minimal
+
+if errorlevel 1 (
+ echo [PreBuild] ERROR: zlib build failed.
+ exit /b 1
+)
+
+if not exist "%BUILT_LIB%" (
+ echo [PreBuild] ERROR: Build completed, but library not found at "%BUILT_LIB%"
+ exit /b 1
+)
+
+echo [PreBuild] Successfully built zlib: "%BUILT_LIB%"
+echo [PreBuild] Copying to "%TARGET_LIB%"...
+
+rem --- Create destination folder if missing ---
+for %%F in ("%TARGET_LIB%") do if not exist "%%~dpF" mkdir "%%~dpF"
+
+copy /Y "%BUILT_LIB%" "%TARGET_LIB%" >nul
+if errorlevel 1 (
+ echo [PreBuild] ERROR: Failed to copy built library to target path.
+ exit /b 1
+)
+
+echo [PreBuild] Copied successfully: "%TARGET_LIB%"
+exit /b 0
diff --git a/external/zlib b/external/zlib
new file mode 160000
index 0000000..5a82f71
--- /dev/null
+++ b/external/zlib
@@ -0,0 +1 @@
+Subproject commit 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71
diff --git a/mgs/3rdparty/zlib/wrapper/ZlibWrapper.h b/mgs/3rdparty/zlib/wrapper/ZlibWrapper.h
index 01d4ef4..a4d8225 100644
--- a/mgs/3rdparty/zlib/wrapper/ZlibWrapper.h
+++ b/mgs/3rdparty/zlib/wrapper/ZlibWrapper.h
@@ -1,5 +1,5 @@
#pragma once
-#include "../zlib.h"
+#include "zlib.h"
class ZlibWrapper {
public:
diff --git a/mgs/archive/face/stage/stage.cpp b/mgs/archive/face/stage/stage.cpp
index dc4ad0a..6d54675 100644
--- a/mgs/archive/face/stage/stage.cpp
+++ b/mgs/archive/face/stage/stage.cpp
@@ -37,6 +37,6 @@ void Stage::extract(uint16_t pageID, std::string output) {
void Stage::extractAll(std::string output) {
for (int i = 0; i < header.numPages; i++) {
- extract(i, output, "stage", true);
+ extract(i, output, filenameContainsString(filename, "STAGE2") ? "stage2" : "stage", true);
}
}
\ No newline at end of file