# Ground Control: Second Drop **Ground Control: Second Drop** is an unofficial remaster mod for **Ground Control Anthology v1.0.1.1**. For now, it focuses on gameplay. The mod adds formation movement, backward moves, dropship calls, new camera controls, modern resolutions and more. ## Installation 1. Download the latest release ZIP from this repository’s Releases page. 2. Extract these three files into your game folder, next to `gc.exe`: - `wsock32.dll` - `gcmod_core.dll` - `gcmod.ini` 3. Start the game. The mod loads when the game starts. It reads its settings from `gcmod.ini` and writes a log to `gcmod.log`, both in the game folder. After you change `gcmod.ini`, restart the game. ## In-game shortcuts | Shortcut | Action | | --- | --- | | **F10** | Show or hide the status overlay in the upper-right corner. | | **F11** | Switch between the original and the replacement textures. | | **F12** | Save a screenshot. | | **Alt + move order** | Make vehicles drive backward. | | **Hold middle mouse button** | Turn and tilt the camera. | | **Double press a group key (1 to 0)** | Center the camera on a squad of that group. | ## Features and configuration Turn each feature on or off in `gcmod.ini`. `off` keeps the original game. ## Pathfinding #### ◆ Formation movement **Setting:** `avoid` Squads move in formation, steer around other units, and plan their routes around other squads. Faster squads overtake slower ones. --- ## Gameplay #### ◆ Reverse movement **Setting:** `reverse` Hold Alt while giving a move order to make vehicles drive backward. `reverse_key` changes the key. #### ◆ Whole-squad boarding **Setting:** `squadboarding` When one infantry unit boards an APC, its whole squad boards. #### ◆ Infantry crushing **Setting:** `crush` Fast vehicles run over enemy infantry. #### ◆ No hit slowdown **Setting:** `disablehitslow` Units under fire keep their speed. #### ◆ Dropship call **Setting:** `dropship_call` Once your dropships have dropped their units, you can call an empty dropship to land where you choose. #### ◆ Reinforcement at a called dropship **Setting:** `dropship_reinforce` A called dropship brings back the lost members of nearby squads. #### ◆ Healing by dropships **Setting:** `dropship_heal` A called dropship heals nearby units. APCs no longer heal. #### ◆ Dropship faction fix **Setting:** `dropship_faction_fix` Dropships that bring Order units show the Order model. --- ## Display and controls #### ◆ Modern resolutions and interface scaling **Settings:** `modern_resolution`, `resolution`, `ui_scale` Adds modern 16:9 resolutions and a larger interface for them. #### ◆ Middle-mouse camera control **Setting:** `middlerotate` Hold the middle mouse button to turn and tilt the camera. Mouse wheel up zooms in. #### ◆ Camera on a group **Setting:** `groupfocus` Press a group key twice to center the camera on that group and follow it. #### ◆ Click to deselect **Setting:** `clickdeselect` Left-click empty ground to deselect all squads. #### ◆ Weapon range for force fire **Setting:** none, always on. Holding the force-fire key shows how far the selected squads can hit. #### ◆ Large textures **Setting:** none, always on. Sharper replacement textures in the `data/textures` folder replace the game's textures. F11 switches between the original and the replacement textures. #### ◆ Screenshots **Setting:** `screenshot` F12 saves a screenshot in the `screenshots` folder. --- ## Audio #### ◆ Loop mission music **Setting:** `music_loop` The loading-screen music keeps playing during the mission. #### ◆ AI voice volume **Setting:** `ai_voice_slider` Adds a volume slider for the computer announcements. ## Building from source The project includes two programs that share most of their code: - **The mod** - **The simulator** (`build/sim.exe`), which runs pathfinding test scenarios on game maps outside the game. The simulator calls the pathfinding and formation code from `gc.exe` and recreates the rest of the base game’s movement system. It also runs the mod’s formation movement code, allowing repeated comparisons between the original and modified behavior. --- ## Development setup Run all commands below in **Git Bash**, from the project root. 1. **Install Ground Control from GOG or Steam.** Both editions use the same `gc.exe`. - The simulator looks for the game in `C:\Program Files\GOG Galaxy\Games\Ground Control` by default. Use `--exe PATH` to specify another executable. - `tools/decompilation/gcdis.py` uses the default Steam installation folder. 2. **Install Git for Windows** to provide Git Bash. 3. **Install Python 3** and make sure `python` works in Git Bash. To use a different Python executable, set the `PYTHON` environment variable; the build scripts use it when set. 4. **Install Capstone** for the disassembler, `tools/decompilation/gcdis.py`: ```bash pip install --target tools/decompilation/pylib capstone==5.0.9 ``` 5. **Download llvm-mingw release 20261006** from the [llvm-mingw releases page](https://github.com/mstorsjo/llvm-mingw/releases). Use `llvm-mingw-20261006-msvcrt-x86_64.zip`. 6. **Extract the toolchain** to `tools/toolchain/llvm-mingw`. The compiler should be at: ```text tools/toolchain/llvm-mingw/bin/i686-w64-mingw32-clang.exe ``` 7. **Extract the game maps** for the simulator, replacing `` with your installation path: ```bash python -I tools/common/sdf.py extract "/Missions.sdf" build/sdf/Missions ``` The simulator reads maps from `build/sdf/Missions` by default. Use `--maps DIR` to specify another directory. --- ## Mod #### ◆ Build and install the mod ```bash bash mod/build.sh ``` The build writes `wsock32.dll`, `gcmod_core.dll`, and `gcmod.ini` to `build/mod/dist`. Copy all three files into your game folder, alongside `gc.exe`. If you have customized `gcmod.ini`, transfer your settings to the new configuration file. #### ◆ Reload the core during development The mod has two DLLs: `wsock32.dll` is the loader, and `gcmod_core.dll` contains the features. - **Loader updates require the game to be closed.** Windows keeps `wsock32.dll` open while the game is running. - **Core updates can be applied while the game is running.** Replace `gcmod_core.dll`; the loader loads the new core between frames. The core rereads `gcmod.ini` each time it loads. #### ◆ Game hooks The loader `wsock32.dll` forwards the real wsock32 exports and patches game functions in memory when it loads. The file `gc.exe` on disk stays unchanged. A hook overwrites the first instructions of a function with a 5-byte jump (`mod/loader/patch.c`). The overwritten bytes, called the stolen bytes, must end on an instruction boundary, and their count comes from the disassembly. A trampoline runs those bytes and jumps back, so the hook can call the original function. A function that already has a hook cannot get a second one, because its first bytes are then the jump of the first hook. The loader keeps its own hooks for the whole session. The core `gcmod_core.dll` installs its hooks through the loader (`install_core_hook`, `mod/loader/reload.c`), which removes them before the core unloads. So a new hook needs only a new core. The game functions themselves are described in [docs/game/](docs/game/README.md). Hooks of the loader, all in `mod/loader/hooks.c`: | Address | Game function | Stolen bytes | What the hook does | |---|---|---|---| | 0x4e8200 | `PathFinder::LoadGrid` | 6 | After the original: gives the core the map name; the core builds its clearance fields. | | 0x50e7e0 | `Mover::SetMove` | 7 | After the original: gives the core the route of the squad. | | 0x504950 | `Squad::Update` | 6 | Before the original: tells the core that the squad updates, and checks once that squads update on the frame thread. | | 0x504510 | `Squad::~Squad` | 7 | Before the original: the core forgets the squad. The computer squad destructor (0x502950) calls it too. | | 0x4085c4 | `CD3duContext::UpdateFrame` | 5 | Reloads the core between frames, then lets the core draw on the frame. | | 0x4b1020 | `Ingameinterface::CalculateSquadFormationPoints` | 7 | After the original: the core rewrites the positions of a group order (`--keeporder`). | | 0x50e5b0 | `Mover` tick (foot units and Crayven vehicles) | 7 | The core moves formation members; other units run the original. | | 0x431cd0 | D3DX renderer constructor | 5 | Loads the core before the first screen, if none is loaded yet. | Seen in game: squad updates and shown frames run on one thread, so a core reload between frames is safe. Hooks of the core: | Address | Game function | Stolen bytes | Feature (file) | |---|---|---|---| | 0x513f50 | hover `Mover` tick (Order and Phoenix vehicles) | 6 | formation movement (`mod/pathfinding/bridge.c`): as the loader hook of 0x50e5b0 | | 0x4d09f0 | mouse handler of the 3D view | 7 | `--clickdeselect` (`mod/interface/ground_click.c`) | | 0x4af660 | nearest pick | 7 | `--clickdeselect` | | 0x4b6a80 | border rotation | 7 | `--middlerotate` (`mod/interface/middle_rotate.c`) | | 0x4b0060 | key and joystick camera | 6 | inverted mouse wheel zoom (`mod/interface/group_focus.c`) | | 0x4b8520 | group selection | 6 | `--groupfocus` (`mod/interface/group_focus.c`) | | 0x4c09d0 | camera update | 6 | `--groupcenter` (`mod/interface/group_focus.c`) | | 0x403f20 | apply function of the video menu | 6 | `modern_resolution` (`mod/interface/resolution.c`) | | 0x463200 | entry adder of the size row | 6 | `modern_resolution` | | 0x467cc0 | page add function | 5 | `modern_resolution` | | 0x431eb0 | renderer slot 2 (set size) | 8 | `modern_resolution` | | 0x431ed0 | renderer slot 3 (create context) | 6 | `ui_scale` (`mod/interface/ui_scale.c`) | | 0x434870 | renderer slot 36 (image copy) | 5 | `ui_scale` | | 0x4189c0 | movie frame function | 6 | `ui_scale` | | 0x4a4d00 | `SessionClient::StopLoadingMusic` | 5 | `music_loop` (`mod/sound/music_loop.c`) | | 0x4c3070 | `IGMessageQueue::Update` | 7 | `ai_voice_slider` (`mod/sound/ai_voice_volume.c`) | | 0x4748f0 | builder of the General options page | 6 | `ai_voice_slider` | | 0x462d40 | slider binding | 11 | `ai_voice_slider` | | 0x4206f0 | options load into the menu copy | 6 | `ai_voice_slider` | | 0x420610 | options copy-back at Accept | 6 | `ai_voice_slider` | | 0x50ab30 | `Squad::OrderMove` | 6 | `--reverse` (`mod/gameplay/reverse_order.c`) | | 0x505110 | `Squad::QueueMove` | 6 | `--reverse` | | 0x510b20 | *Physics* of a mover | 6 | `--crush` (`mod/gameplay/crush.c`) | | 0x4fb940 | speed effects of an entity | 6 | `disablehitslow` (`mod/gameplay/hit_slowdown.c`) | | 0x4b1f10 | widget update of the interface | 7 | `dropship_call` (`mod/gameplay/dropship_call.c`) | | 0x4d04b0 | input handler of the normal mode | 6 | `dropship_call` | | 0x4d0f70 | event handler of the normal mode | 7 | `dropship_call` | | 0x4c2690 | cursor update | 7 | `dropship_call` | | 0x4efb60 | collision object constructor | 7 | `dropship_call` | | 0x50cb70 | server dropship update | 6 | `dropship_call` (`mod/gameplay/dropship_server.c`) | | 0x4fa0f0 | entity death | 6 | `dropship_call` (`mod/gameplay/dropship_server.c`) | | 0x4da510 | client dropship visual update | 6 | `dropship_call` (`mod/gameplay/dropship_visual.c`) | | 0x4bb730 | model creation of a client entity | 6 | `dropship_call` (`mod/gameplay/dropship_visual.c`) | | 0x4b6f90 | order builder of the interface | 7 | `dropship_call` (`mod/gameplay/dropship_guard.c`): guard order on a called dropship | | 0x504df0 | *Squad::MoveTo* | 6 | `dropship_call` (`mod/gameplay/dropship_guard.c`): guard moves out of the ship's blocked disc | | 0x4c66b0 | `CL_Squad::SetControlledEntities` | 6 | `dropship_reinforce` (`mod/gameplay/dropship_reinforce.c`) | | 0x50c970 | server dropship constructor | 7 | `dropship_faction_fix` (`mod/gameplay/dropship_faction.c`) | | 0x50e100 | server healer update | 6 | `dropship_heal` (`mod/gameplay/dropship_heal.c`) | Other patches in game memory: - `ui_scale` replaces four entries in the vtable of the Direct3D device: `DrawPrimitive`, `DrawIndexedPrimitive`, `SetViewport` and `Clear`. The vtable is shared by every device object of its class. Seen in game: the Direct3D runtime replaced its own `DrawPrimitive` entry after the first draw, so the mod writes its entries back whenever one changes. - The dropship call gives single objects their own copy of a vtable in the game heap. The sound emitter of a landed dropship gets a copy whose slot 5 plays no sound (0x53f4c0). The building model under a called dropship gets a copy whose draw slot only returns (0x50bb10). - The large textures (`mod/interface/large_textures.c`) rewrite code bytes of the texture load (0x44e010): its size rounding at 0x44e092, and the 256-pixel limits at 0x44e13c and 0x44e143. The core writes the game bytes back before it unloads. - The texture switch (`mod/interface/texture_switch.c`) replaces the `CreateFileA` entry of the gc.exe import table (0x60d124) with a function that, while the original textures are shown, reports texture files in `data/textures` as missing. The core writes the entry back before it unloads. - `--clickdeselect` sets the console variable `leftclickmovement` (0x67773c) to 0 while the game handles a ground click, and restores it after. - The screenshots, the squad boarding (`mod/gameplay/squad_boarding.c`) and the run-over kills at the end of a frame use no hook of their own: they run from the frame hook and call game functions directly. --- ## Simulator #### ◆ Build and run the simulator Build the simulator: ```bash bash simulator/build.sh ``` Run the `ridge` scenario with coordination enabled and random seed 3: ```bash build/sim.exe --avoid coord --seed 3 ridge ``` The simulator’s `--avoid` option accepts `original` for base-game movement, `form` for formation movement, or `coord` for formation movement with squad coordination. #### ◆ Compare simulations Compare two configurations across seeds 1–20 and print their average results: ```bash python -I tools/simulator/compare.py 20 "off=--wholeparked,off" "on=" -- --avoid coord ``` This example disables `--wholeparked` in the `off` configuration and retains the defaults in the `on` configuration. Check that two simulator builds produce identical output for the same arguments: ```bash python -I tools/simulator/compare_builds.py OLD.exe build/sim.exe ``` #### ◆ Generate a replay page ```bash bash simulator/replay/build_replay.sh build/replay 3 ridge ``` This generates new simulator traces and writes `build/replay/replay.html`, including an additional tab for the `ridge` scenario with seed 3. See [docs/SWITCHES.md](docs/SWITCHES.md) for the on/off switches of the simulator and the mod.