Skip to content

Commit 402ff55

Browse files
committed
Merge branch 'main' into replaymaxfix_sh
# Conflicts: # GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
2 parents 658e31d + 8a9db21 commit 402ff55

File tree

5,378 files changed

+259334
-371536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,378 files changed

+259334
-371536
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root=true
2+
3+
[*]
4+
insert_final_newline = true
5+
trim_trailing_whitespace = true
6+
7+
[{*.h,*.cpp,*.inl}]
8+
indent_style = unset
9+
indent_size = 2
10+
11+
[{CMakeLists.txt,*.cmake,*.py}]
12+
indent_style = spaces
13+
indent_size = 4

.github/copilot-instructions.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# AI Coding Agent Instructions
2+
3+
## Project Overview
4+
5+
This is the **GeneralsGameCode** project - a community-driven effort to fix and improve the classic RTS games *Command & Conquer: Generals* and *Zero Hour*. The codebase has been modernized from Visual Studio 6/C++98 to Visual Studio 2022/C++20 while maintaining retail compatibility.
6+
7+
## Architecture
8+
9+
### Dual Game Structure
10+
- **Generals/**: Original C&C Generals (v1.08) codebase
11+
- **GeneralsMD/**: Zero Hour expansion (v1.04) codebase - **primary focus**
12+
- **Core/**: Shared game engine and libraries used by both games
13+
14+
### Key Components
15+
- **Core/GameEngine/**: Base game engine with GameClient/GameLogic separation
16+
- **Core/Libraries/**: Internal libraries including WWVegas graphics framework
17+
- **Core/GameEngineDevice/**: Platform-specific rendering (DirectX 8)
18+
- **Core/Tools/**: Development tools (W3DView, texture compression, etc.)
19+
- **Dependencies/**: External dependencies (MaxSDK for VC6, utilities)
20+
21+
## Build System
22+
23+
### CMake Presets (Critical)
24+
- **vc6**: Visual Studio 6 compatible build (retail compatibility required)
25+
- **win32**: Modern Visual Studio 2022 build
26+
- **vc6-debug/vc6-profile**: Debug/profiling variants
27+
- Use `cmake --preset <preset-name>` followed by `cmake --build build/<preset>`
28+
29+
### Build Commands
30+
```bash
31+
# Configure with specific preset
32+
cmake --preset vc6
33+
34+
# Build (from project root)
35+
cmake --build build/vc6
36+
37+
# Build with tools and extras
38+
cmake --build build/vc6 --target <game>_tools <game>_extras
39+
```
40+
41+
### Retail Compatibility
42+
- VC6 builds are required for replay compatibility testing
43+
- Debug builds break retail compatibility
44+
- Use RTS_BUILD_OPTION_DEBUG=OFF for compatibility testing
45+
46+
## Development Workflow
47+
48+
### Code Change Documentation
49+
**Every user-facing change requires TheSuperHackers comment format:**
50+
```cpp
51+
// TheSuperHackers @keyword author DD/MM/YYYY Description
52+
```
53+
54+
Common keywords: `@bugfix`, `@feature`, `@performance`, `@refactor`, `@tweak`, `@build`
55+
56+
### Pull Request Guidelines
57+
- Title format: `type: Description starting with action verb`
58+
- Types: `bugfix:`, `feat:`, `fix:`, `refactor:`, `perf:`, `build:`
59+
- Zero Hour changes take precedence over Generals
60+
- Changes must be identical between both games when applicable
61+
62+
### Code Style
63+
- Maintain consistency with surrounding legacy code
64+
- Prefer C++98 style unless modern features add significant value
65+
- No big refactors mixed with logical changes
66+
- Use present tense in documentation ("Fixes" not "Fixed")
67+
68+
## Testing
69+
70+
### Replay Compatibility Testing
71+
Located in `GeneralsReplays/` - critical for ensuring retail compatibility:
72+
```bash
73+
generalszh.exe -jobs 4 -headless -replay subfolder/*.rep
74+
```
75+
- Requires VC6 optimized build with RTS_BUILD_OPTION_DEBUG=OFF
76+
- Copies replays to `%USERPROFILE%/Documents/Command and Conquer Generals Zero Hour Data/Replays`
77+
- CI automatically tests GeneralsMD builds against known replays
78+
79+
### Build Validation
80+
- CI tests multiple presets: vc6, vc6-profile, vc6-debug, win32 variants
81+
- Path-based change detection triggers relevant builds
82+
- Tools and extras are built with `+t+e` flags
83+
84+
## Common Patterns
85+
86+
### Memory Management
87+
- Manual memory management (delete/delete[]) - this is legacy C++98 code
88+
- STLPort for VC6 compatibility (see `cmake/stlport.cmake`)
89+
90+
### Game Engine Separation
91+
- **GameLogic**: Game state, rules, simulation
92+
- **GameClient**: Rendering, UI, platform-specific code
93+
- Clean separation maintained for potential future networking
94+
95+
### Module Structure
96+
```
97+
Core/
98+
├── GameEngine/Include/Common/ # Shared interfaces
99+
├── GameEngine/Include/GameLogic/ # Game simulation
100+
├── GameEngine/Include/GameClient/ # Rendering/UI
101+
├── Libraries/Include/rts/ # RTS-specific utilities
102+
└── Libraries/Source/WWVegas/ # Graphics framework
103+
```
104+
105+
## External Dependencies
106+
107+
### Required for Building
108+
- **VC6 builds**: Requires MSVC 6.0 toolchain (automated in CI via itsmattkc/MSVC600)
109+
- **Modern builds**: Visual Studio 2022, Ninja generator
110+
- **vcpkg** (optional): zlib, ffmpeg for enhanced builds
111+
112+
### Platform-Specific
113+
- **Windows**: DirectX 8, Miles Sound System, Bink Video
114+
- **Registry detection**: Automatic game install path detection from EA registry keys
115+
116+
## Tools and Utilities
117+
118+
### Development Scripts (`scripts/cpp/`)
119+
- `fixInludesCase.sh`: Fix include case sensitivity
120+
- `refactor_*.py`: Code refactoring utilities
121+
- `remove_trailing_whitespace.py`: Code cleanup
122+
123+
### Build Tools
124+
- W3DView: 3D model viewer
125+
- TextureCompress: Asset optimization
126+
- MapCacheBuilder: Map preprocessing
127+
128+
## Key Files to Understand
129+
- `CMakePresets.json`: All build configurations
130+
- `cmake/config-build.cmake`: Build options and feature flags
131+
- `Core/GameEngine/Include/`: Core engine interfaces
132+
- `**/Code/Main/WinMain.cpp`: Application entry points
133+
- `GeneralsReplays/`: Compatibility test data

.github/workflows/build-toolchain.yml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ on:
2828

2929
jobs:
3030
build:
31-
name: Preset ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
32-
runs-on: windows-latest
31+
name: ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }}
32+
runs-on: windows-2022
3333
timeout-minutes: 20
3434
steps:
3535
- name: Checkout Code
@@ -41,41 +41,38 @@ jobs:
4141
uses: actions/cache@v4
4242
with:
4343
path: C:\VC6
44-
key: vc6-permanent-cache-v1
44+
key: vc6-permanent-cache-v2
4545

4646
- name: Cache CMake Dependencies
4747
id: cache-cmake-deps
4848
uses: actions/cache@v4
4949
with:
5050
path: build\${{ inputs.preset }}\_deps
51-
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('cmake/**/*.cmake', '**/CMakeLists.txt') }}
52-
restore-keys: |
53-
cmake-deps-${{ inputs.preset }}-
51+
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
5452

55-
- name: Download VC6 Portable from Cloudflare R2
53+
- name: Download VC6 Portable from itsmattkc repo
5654
if: ${{ startsWith(inputs.preset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}
5755
env:
58-
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
59-
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
60-
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }}
61-
EXPECTED_HASH: "118D0F1ACBBD70C3F8B081CA4DBAF955FE0C6C359A76636E930AA89FDC551091"
56+
EXPECTED_HASH: "D0EE1F6DCEF7DB3AD703120D9FB4FAD49EBCA28F44372E40550348B1C00CA583"
57+
COMMIT: "001c4bafdcf2ef4b474d693acccd35a91e848f40"
6258
shell: pwsh
6359
run: |
6460
Write-Host "Downloading VC6 Portable Installation" -ForegroundColor Cyan
65-
aws s3 cp s3://github-ci/VS6_VisualStudio6.7z VS6_VisualStudio6.7z --endpoint-url $env:AWS_ENDPOINT_URL
61+
Invoke-WebRequest -Uri https://github.com/itsmattkc/MSVC600/archive/$env:COMMIT.zip -OutFile VS6_VisualStudio6.zip
6662
6763
Write-Host "Verifying File Integrity" -ForegroundColor Cyan
68-
$fileHash = (Get-FileHash -Path VS6_VisualStudio6.7z -Algorithm SHA256).Hash
64+
$fileHash = (Get-FileHash -Path VS6_VisualStudio6.zip -Algorithm SHA256).Hash
6965
Write-Host "Downloaded file SHA256: $fileHash"
7066
Write-Host "Expected file SHA256: $env:EXPECTED_HASH"
71-
if ($hash -ne $env:EXPECTED_HASH) {
67+
if ($fileHash -ne $env:EXPECTED_HASH) {
7268
Write-Error "Hash verification failed! File may be corrupted or tampered with."
7369
exit 1
7470
}
7571
7672
Write-Host "Extracting Archive" -ForegroundColor Cyan
77-
& 7z x VS6_VisualStudio6.7z -oC:\VC6
78-
Remove-Item VS6_VisualStudio6.7z -Verbose
73+
& Expand-Archive -Path VS6_VisualStudio6.zip -DestinationPath C:\VC6
74+
Move-Item -Path C:\VC6\MSVC600-$env:COMMIT -Destination C:\VC6\VC6SP6
75+
Remove-Item VS6_VisualStudio6.zip -Verbose
7976
8077
- name: Set Up VC6 Environment
8178
if: startsWith(inputs.preset, 'vc6')
@@ -136,7 +133,7 @@ jobs:
136133
137134
if ("${{ inputs.preset }}" -like "win32*") {
138135
# For win32 preset, look in config-specific subdirectories
139-
$configToUse = if ("${{ inputs.preset }}" -eq "win32dbg") { "Debug" } else { "Release" }
136+
$configToUse = if ("${{ inputs.preset }}" -match "debug") { "Debug" } else { "Release" }
140137
$files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose
141138
} else {
142139
$files = Get-ChildItem -Path "$buildDir\Core","$buildDir\${{ inputs.game }}" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose

0 commit comments

Comments
 (0)