Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
build: one committed build.bat, nothing to fill in first
Olcay Seygan0450a033c8cf
diff --git a/.gitignore b/.gitignoreindex 8722110a0..9955964f1 100644--- a/.gitignore+++ b/.gitignore@@ -10,9 +10,6 @@ build-perf/__pycache__/*.pyc-# Local copy of build.example.bat, tweaked per machine-build.bat-CLAUDE.mdAGENTS.mddiff --git a/README.md b/README.mdindex a4f47196c..b42e502dc 100644--- a/README.md+++ b/README.md@@ -134,27 +134,32 @@ stencil volumes were both built and measured, then reverted, and CHANGELOG says## Build it-Win32 x86 only. The code is full of 32-bit inline assembly, and an x64 configure is refused on-purpose. Visual Studio 2022 with the Desktop C++ workload is enough.+Double-click `build.bat`. That is the whole thing on a clone that has never been built: it finds+cmake, fetches what EA stripped and what GitHub will not hold, configures, builds, and copies the+exe and the five FFmpeg DLLs into `GeneralsMD/Run/`. Three minutes on a 2024 desktop. Visual Studio+2022 with the Desktop C++ workload is the one prerequisite.++x64 only. The 32-bit build and the last of the inline assembly went in September 2026, and `-A+Win32` is now a configure error.```console-cmake -S GeneralsMD/Code -B build -G "Visual Studio 17 2022" -A Win32-cmake --build build --config Release-ctest --test-dir build -C Release --output-on-failure+build.bat :: Release+build.bat Release test :: and run the 39 test binaries+build.bat Release generals :: just the game+build.bat clean :: throw the build tree away first```-`build.example.bat` wraps all three. Copy it to `build.bat` and fill in the paths for your machine.--The build copies `generals.exe` into `GeneralsMD/Run/`, which is the only place the game starts. Put-your Zero Hour `*.big` files next to it and the base game's `*.big` files in `Run/ZH_Generals/`,-since Zero Hour is not standalone and mounts both.--> [!IMPORTANT]-> EA stripped some third-party sources, and they are not committed here either. Drop in zlib 1.1.4,-> LZH-Light 1.0, a minimal DirectX 8 SDK and the GameSpy SDK before the first build. STLport, the-> 3ds Max 4 SDK, NVASM, the Miles and Bink SDKs and SafeDisc are not needed: sound and video run-> through the `mss32.dll` and `binkw32.dll` your own install already has. The stub DLLs of the same-> names in `build/Release/` are link libraries only, and copying one into `Run/` silences the game.+What `build.bat` fetches for you, into places the repository leaves empty: zlib 1.1.4, LZH-Light+1.0, a minimal DirectX 8 SDK, the GameSpy SDK, and the fork's own upscaled art from this+repository's `art-latest` release, checked against the sha256 in its `art.json`. Nothing to fill in+first, and running it again costs a directory check per library. STLport, the 3ds Max 4 SDK, NVASM+and SafeDisc are not needed. Neither are the Miles and Bink SDKs: sound and video are compiled into+the exe over XAudio2 and FFmpeg, and the retail `mss32.dll` and `BINKW32.DLL` are 32-bit images+this process could not load anyway.++What it cannot fetch is the game. Put your Zero Hour `*.big` files next to `generals.exe` in+`GeneralsMD/Run/` and the base game's in `Run/ZH_Generals/`, since Zero Hour is not standalone and+mounts both.The launcher is a separate Electron project,[olcayseygan/zhr-launcher](https://github.com/olcayseygan/zhr-launcher).diff --git a/build.bat b/build.batnew file mode 100644index 000000000..f435da3e5--- /dev/null+++ b/build.bat@@ -0,0 +1,120 @@+@echo off+setlocal enabledelayedexpansion++rem Build C&C Generals Zero Hour, x64. Double-click it, or:+rem+rem build.bat configure (if needed) + build Release+rem build.bat Debug build another config (Release|RelWithDebInfo|Debug)+rem build.bat Release test build, then run ctest+rem build.bat Release generals build a single target+rem build.bat clean delete the build tree and configure from scratch+rem+rem Nothing to edit before the first run: it finds cmake itself, fetches the third-party+rem sources EA stripped and the fork's own art, builds, and copies the exe and everything+rem beside it into GeneralsMD\Run. What it cannot fetch is the game: a Zero Hour install's+rem *.big go next to generals.exe in GeneralsMD\Run, and the base game's in Run\ZH_Generals.+rem+rem The four knobs below are overrides. Every one of them empty is the supported path.++set "CMAKE="+set "VS_EDITIONS=Community Professional Enterprise BuildTools"+set "GENERATOR=Visual Studio 17 2022"+set "DEFAULT_CONFIG=Release"+set "BUILD="++rem Double-clicked from Explorer, the window closes on the last line and nobody reads it.+rem A double-click passes no arguments and puts this file's own name in the parent command line.+set "PAUSE_AT_END="+if "%~1"=="" echo %cmdcmdline% | find /i "%~nx0" >nul && set "PAUSE_AT_END=1"++set "ROOT=%~dp0"+set "SRC=%ROOT%GeneralsMD\Code"+if not defined BUILD set "BUILD=%ROOT%build64"+set "CONFIG=%~1"+set "ARG2=%~2"++if /i "%CONFIG%"=="clean" (+ echo [build] removing %BUILD%+ if exist "%BUILD%" rmdir /s /q "%BUILD%"+ set "CONFIG=%ARG2%"+ set "ARG2="+)+if "%CONFIG%"=="" set "CONFIG=%DEFAULT_CONFIG%"++set "RUNTESTS="+set "TARGET="+if /i "%ARG2%"=="test" (set "RUNTESTS=1") else (if not "%ARG2%"=="" set "TARGET=%ARG2%")++rem --- locate cmake: the override, then PATH, then the copy shipped with VS2022 ---+if defined CMAKE if not exist "%CMAKE%" (+ echo [build] ERROR: CMAKE is set to "%CMAKE%" at the top of this file, but that file does not exist.+ goto :fail+)+for /f "delims=" %%C in ('where cmake 2^>nul') do if not defined CMAKE set "CMAKE=%%C"+if not defined CMAKE (+ for %%E in (%VS_EDITIONS%) do (+ set "TRY=C:\Program Files\Microsoft Visual Studio\2022\%%E\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"+ if not defined CMAKE if exist "!TRY!" set "CMAKE=!TRY!"+ )+)+if not defined CMAKE (+ echo [build] ERROR: cmake.exe not found on PATH or under Visual Studio 2022.+ echo [build] Install Visual Studio 2022 with the C++ desktop workload and run this again.+ goto :fail+)+echo [build] cmake: %CMAKE%+echo [build] config: %CONFIG%++rem --- third-party sources the repository does not carry (zlib, LZH-Light, the DirectX 8 headers,+rem the GameSpy SDK) and the upscaled art. Fetches whatever is missing and is a no-op once it is+rem there, so one build.bat on a fresh clone is enough. ---+powershell -NoProfile -ExecutionPolicy Bypass -File "%SRC%\Tools\vendor.ps1"+if !errorlevel! neq 0 (+ echo [build] ERROR: fetching the third-party sources failed.+ goto :fail+)++rem --- configure (only when the cache is missing) ---+if not exist "%BUILD%\CMakeCache.txt" (+ echo [build] configuring %SRC% -^> %BUILD%+ "%CMAKE%" -S "%SRC%" -B "%BUILD%" -G "%GENERATOR%" -A x64+ if !errorlevel! neq 0 (+ echo [build] ERROR: configure failed.+ goto :fail+ )+)++rem --- build ---+if defined TARGET (+ echo [build] building target %TARGET%+ "%CMAKE%" --build "%BUILD%" --config %CONFIG% --target %TARGET%+) else (+ "%CMAKE%" --build "%BUILD%" --config %CONFIG%+)+if !errorlevel! neq 0 (+ echo [build] ERROR: build failed.+ goto :fail+)++rem --- tests ---+if defined RUNTESTS (+ rem ctest lives beside cmake. It is not on PATH when cmake came from the VS2022 install,+ rem and "cmake -E chdir ctest" then fails with a bare "no such file or directory".+ for %%I in ("%CMAKE%") do set "CTEST=%%~dpIctest.exe"+ echo [build] running !CTEST!+ "!CTEST!" --test-dir "%BUILD%" -C %CONFIG% --output-on-failure+ if !errorlevel! neq 0 (+ echo [build] ERROR: tests failed.+ goto :fail+ )+)++echo [build] done. %ROOT%GeneralsMD\Run\generals.exe is the one to run.+if defined PAUSE_AT_END pause+endlocal+exit /b 0++:fail+if defined PAUSE_AT_END pause+endlocal+exit /b 1diff --git a/build.example.bat b/build.example.batdeleted file mode 100644index e8644fef2..000000000--- a/build.example.bat+++ /dev/null@@ -1,120 +0,0 @@-@echo off-setlocal enabledelayedexpansion--rem Build C&C Generals Zero Hour (x64 by default; set PLATFORM=Win32 for the 32-bit build).-rem-rem build.bat configure (if needed) + build Release-rem build.bat Debug build another config (Release|RelWithDebInfo|Debug)-rem build.bat Release test build, then run ctest-rem build.bat Release generals build a single target-rem build.bat clean delete build\ and reconfigure from scratch-rem-rem This is the committed template. Copy it to build.bat (git-ignored) and edit-rem the MACHINE SETTINGS block below to match this PC:-rem-rem copy build.example.bat build.bat--rem ------------------------------ MACHINE SETTINGS ------------------------------rem Leave a value empty to let the script work it out on its own.--rem Full path to cmake.exe. Empty = PATH first, then the copy shipped with VS2022.-set "CMAKE="--rem Visual Studio editions to probe for that shipped cmake, in order.-set "VS_EDITIONS=Community Professional Enterprise BuildTools"--rem CMake generator. x64 is the shipping build; Win32 still configures and is the reference the-rem x64 picture and simulation are compared against.-set "GENERATOR=Visual Studio 17 2022"-set "PLATFORM=x64"--rem Config used when the command line does not name one.-set "DEFAULT_CONFIG=Release"--rem Build tree. Empty = <repo>\build. Point it at a fast local disk if this-rem checkout lives on a network share or a slow drive.-set "BUILD="-rem --------------------------- END MACHINE SETTINGS ------------------------------set "ROOT=%~dp0"-set "SRC=%ROOT%GeneralsMD\Code"-rem One tree per platform, so the two can sit side by side: build64\ and build\.-if not defined BUILD if /i "%PLATFORM%"=="x64" (set "BUILD=%ROOT%build64") else (set "BUILD=%ROOT%build")-set "CONFIG=%~1"-set "ARG2=%~2"--if /i "%CONFIG%"=="clean" (- echo [build] removing %BUILD%- if exist "%BUILD%" rmdir /s /q "%BUILD%"- set "CONFIG=%ARG2%"- set "ARG2="-)-if "%CONFIG%"=="" set "CONFIG=%DEFAULT_CONFIG%"--set "RUNTESTS="-set "TARGET="-if /i "%ARG2%"=="test" (set "RUNTESTS=1") else (if not "%ARG2%"=="" set "TARGET=%ARG2%")--rem --- locate cmake: MACHINE SETTINGS, then PATH, then the copy shipped with VS2022 ----if defined CMAKE if not exist "%CMAKE%" (- echo [build] ERROR: CMAKE is set to "%CMAKE%" in the MACHINE SETTINGS block, but that file does not exist.- exit /b 1-)-for /f "delims=" %%C in ('where cmake 2^>nul') do if not defined CMAKE set "CMAKE=%%C"-if not defined CMAKE (- for %%E in (%VS_EDITIONS%) do (- set "TRY=C:\Program Files\Microsoft Visual Studio\2022\%%E\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"- if not defined CMAKE if exist "!TRY!" set "CMAKE=!TRY!"- )-)-if not defined CMAKE (- echo [build] ERROR: cmake.exe not found on PATH or under Visual Studio 2022.- exit /b 1-)-echo [build] cmake: %CMAKE%-echo [build] config: %CONFIG%--rem --- third-party sources the repository does not carry (zlib, LZH-Light, the DirectX 8 headers-rem and the GameSpy SDK). Fetches whatever is missing and is a no-op once it is there, so one-rem build.bat on a fresh clone is enough. ----powershell -NoProfile -ExecutionPolicy Bypass -File "%SRC%\Tools\vendor.ps1"-if !errorlevel! neq 0 (- echo [build] ERROR: fetching the third-party sources failed.- exit /b 1-)--rem --- configure (only when the cache is missing) ----if not exist "%BUILD%\CMakeCache.txt" (- echo [build] configuring %SRC% -^> %BUILD%- "%CMAKE%" -S "%SRC%" -B "%BUILD%" -G "%GENERATOR%" -A %PLATFORM%- if !errorlevel! neq 0 (- echo [build] ERROR: configure failed.- exit /b 1- )-)--rem --- build ----if defined TARGET (- echo [build] building target %TARGET%- "%CMAKE%" --build "%BUILD%" --config %CONFIG% --target %TARGET%-) else (- "%CMAKE%" --build "%BUILD%" --config %CONFIG%-)-if !errorlevel! neq 0 (- echo [build] ERROR: build failed.- exit /b 1-)--rem --- tests ----if defined RUNTESTS (- echo [build] running ctest- "%CMAKE%" -E chdir "%BUILD%" ctest -C %CONFIG% --output-on-failure- if !errorlevel! neq 0 (- echo [build] ERROR: tests failed.- exit /b 1- )-)--echo [build] done. output: %BUILD%\%CONFIG%-endlocal-exit /b 0