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
#!/usr/bin/env python3
# Copyright 2026 İlyas Akın
# Additional terms under GNU GPL section 7 apply: see LICENSE.md.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Writes the ORIGINAL water grid step, as it stood at a given commit, for water_grid_oracle.
T1c moves the water grid's mesh motion out of WaterRenderObjClass::update, which runs on the client
pass, into WaterGridMotion, which the logic calls once per logic frame (defect 17). The oracle runs
the original text the way the engine ran it, so that (a) its one-pass-per-frame output is the golden
the moved code must match, and (b) its output under the catch-up is the armed control: the defect,
shown on the code that has it. The text is taken with `git show`, unchanged.
water_grid_oracle_extract.py <commit> <out.inc>
What it takes:
W3DWater.h the WaterMeshStatus enum and the WaterMeshData struct (in WATER_ORACLE_MEMBERS)
W3DWater.cpp update()'s logic-frame block, from `static UnsignedInt lastLogicFrame = 0;` to
`} // end if, a logic frame has passed` (in WATER_ORACLE_UPDATE)
It fails, rather than writing something plausible, if any piece is not found exactly once.
"""
import subprocess
import sys
DEVICE = 'GeneralsMD/Code/GameEngineDevice'
HEADER = f'{DEVICE}/Include/W3DDevice/GameClient/W3DWater.h'
SOURCE = f'{DEVICE}/Source/W3DDevice/GameClient/Water/W3DWater.cpp'
MEMBERS = [('\tenum WaterMeshStatus', '\t};'), ('\tstruct WaterMeshData', '\t};')]
BLOCK = ('\tstatic UnsignedInt lastLogicFrame = 0;', '\t} // end if, a logic frame has passed')
def fail(message):
print(f'water_grid_oracle_extract: FAIL - {message}')
sys.exit(1)
def show(commit, path):
run = subprocess.run(['git', 'show', f'{commit}:{path}'], capture_output=True)
if run.returncode != 0:
fail(f'git show {commit}:{path}: {run.stderr.decode().strip()}')
return run.stdout.decode('latin-1').replace('\r\n', '\n').split('\n')
def span(lines, first, last, name):
starts = [i for i, line in enumerate(lines) if line == first]
if len(starts) != 1:
fail(f'{name}: "{first.strip()}" found {len(starts)} times, want once')
ends = [i for i in range(starts[0], len(lines)) if lines[i] == last]
if not ends:
fail(f'{name}: no "{last.strip()}" after it')
return lines[starts[0]:ends[0] + 1]
def main():
if len(sys.argv) != 3:
print(__doc__)
return 2
commit, output = sys.argv[1], sys.argv[2]
full = subprocess.run(['git', 'rev-parse', commit], capture_output=True).stdout.decode().strip()
header, source = show(commit, HEADER), show(commit, SOURCE)
pieces = [f'// GENERATED by Tools/water_grid_oracle_extract.py from {full}. Do not edit: regenerate.\n'
f'// Each piece is that commit\'s text, unchanged; see water_grid_oracle.cpp for what wraps it.\n']
members = []
for first, last in MEMBERS:
members += span(header, first, last, first.strip())
pieces.append(f'#if defined(WATER_ORACLE_MEMBERS)\n// {HEADER}\n' + '\n'.join(members) + '\n#endif\n')
block = span(source, BLOCK[0], BLOCK[1], 'update\'s logic-frame block')
pieces.append(f'#if defined(WATER_ORACLE_UPDATE)\n// {SOURCE}, a block inside WaterRenderObjClass::update\n'
+ '\n'.join(block) + '\n#endif\n')
with open(output, 'w') as out:
out.write('\n'.join(pieces))
print(f'water_grid_oracle_extract: {len(block)} lines of update() from {full[:10]} -> {output}')
return 0
if __name__ == '__main__':
sys.exit(main())