|
| 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 |
0 commit comments