Native macOS engine for Forged Alliance skirmishes, using game data from an existing installation.
Supreme Commander: Forged Alliance کا اوپن سورس متبادل
Native macOS engine for Forged Alliance skirmishes, using game data from an existing installation. Loads Forged Alliance maps, models, blueprints and sound banks from a retail installation.
READMEGitHub پر akwiatkowski/recoil-metal
The Forged Alliance runtime is a Mac-native RTS engine that reads Recoil and Supreme Commander content straight off disk — their maps, models, textures, unit blueprints and sound banks — and plays a match out of them. It draws through Metal directly instead of translating OpenGL, and its simulation is fixed-point, so the same command log replays the same match tick for tick.
The FA runtime is not a Recoil port. Recoil's engine is ~385k lines and reaching a Mac GPU costs it four translation layers; this is a new C++23 core built test-first through vertical slices of the two games' data formats. Formats convert, behaviour gets reimplemented.
Two runtimes, separate simulations: recoil-metal runs FA through native
Metal; recoil-bar launches the pinned upstream-derived Recoil engine for BAR.
The BAR launcher shares rm_foundation with FA, not its simulation or Lua VM.
BAR renders its persistent 3D world through native Metal into the same Kosmickrisp
framebuffer (zero-copy borrowed attachments): SMF terrain, S3O units, features,
model projectiles, transparent variants, shadow-map receive, env cubemap, and the BumpWater
surface. Compat by design: grass, decals, sky, billboard particles, icons/lines,
minimap 2D, Rml UI, CUS GL4 custom materials, debug drawers, and offscreen
generation (shadow/reflection/refraction/deferred) which feeds native sampling.
Cross-platform multiplayer is not claimed.
docs/benchmark-m4.md).--hash-log writes a per-tick state hash and
--check-hash-log names the tick a divergence began at..s3o models and 2552 .dds textures..smf/.smt maps with .s3o models, and
Supreme Commander .scmap maps with .scm models, in one scene if you like.
The loader is picked by the file's own magic bytes.easy through turtle, plus
adaptive/random), persistent scouting routes, commander enhancements
and native builder management. The corpus is vendored at a pinned commit and
never patched: 254 engine names are bound, and fresh hour-long SCMP_009
duels are decisive with no AI errors — easy ends at 14:08.8, turtle at
30:59.8, tech at 31:23.8 — with the easy run's independent repeat matching
all 36,000 state hashes. Full evidence in
docs/faf-duel-2026-09-08.md.FA="/path/to/Supreme Commander Forged Alliance"
# A whole skirmish on a retail map — spawn to victory banner, headless,
# and identical on every run.
./build/recoil-metal "$FA/maps/SCMP_009/SCMP_009.scmap" --gamedata "$FA/gamedata" \
--skirmish --armies 2 --play 620 --screenshot /tmp/victory.png 1280 720
# 6s first extractor, 19s power, 55s land factory, 68s first tank off the line,
# 432s the attack column, 590s the fight at your commander's feet, 594s the banner.
Without any game content at all, ./build/recoil-metal still opens on
procedurally generated terrain.
Where it stands. Twenty milestones are done and the twentieth ends in that
banner. Since then the window learned to fight in real time rather than being
handed a finished scene, and Forged Alliance's own AI took over the opponents:
selectable personalities now play decisive hour-long duels on the retail map
with no AI errors. The long version — every milestone, and everything
after the match — is in docs/milestones.md; the design
decisions and their rejected alternatives are in
ADR_DECISIONS.md.
Deliberately still open: the Lua host arc (a real VM, a coroutine scheduler
on the 10 Hz tick, one unit's Unit.lua lifecycle diffed tick by tick against
the native run), lockstep networking and FAF lobby integration, and Linux
through an RHI seam — for which the only present obligation is confinement, and
platform and GPU code already stays inside src/platform and src/render.
This is a playable vertical slice, not a claim of Forged Alliance feature
parity. The canonical Forged Alliance gameplay progress dashboard
shows every subsystem's estimated implementation, retail-validation, and retail-analysis
completion. Each stable subsystem ID also carries its exact next task and a copy-ready /goal
prompt. The detailed evidence behind those estimates remains in
docs/fa-exe-analysis-plan.md.
This is a personal research project, spun out of work on FAR (Forged Alliance Reborn). Its original premise was that FAR was blocked on macOS: Recoil's model path needs OpenGL 4.3+ SSBOs and Apple caps OpenGL at 4.1. That turned out to be wrong, and usefully so — Apple's OpenGL is not the only OpenGL on the platform, and FAR now renders on this Mac through SDL3 → Mesa EGL → Zink → kosmickrisp → Metal. The 4.1 cap is irrelevant.
Which makes the question sharper rather than moot:
Recoil reaches the GPU on Apple Silicon through four translation layers. What does that cost, and what does a purpose-built Metal renderer buy back — and what does a modern C++ engine core look like when built test-first, without 20 years of legacy coupling?
It also makes the answer measurable: there is a working OpenGL baseline to benchmark against on the same machine, which the project previously did not have.
Every image below is this renderer's own output, written by --screenshot.
Both content families throughout: Recoil/BAR maps and models, and Supreme
Commander .scmap maps with .scm models.
The interface — the build tray draws the archives' own 64×64 icons, names and mass costs; the minimap is the .scmap's own embedded preview | A match that ends — a scripted opponent builds a base, streams tanks, and comes for your commander |
Sky and water, ported from the games' own sky.fx and water2.fx | The same code on a .scmap — the horizon colour is the map's, not ours |
The Supreme Commander ground splat — nine tiled strata assembled per frame from a recipe, since a .scmap bakes no ground texture at all | Seton's Clutch, whole-map |
| Shadow mapping from a camera-following light box | 800 instanced units, each on its own animation phase |
| Click-to-move, five seconds after the order | The same order once A* pathfinding landed — units route round what they cannot climb |
| Refraction and planar reflection — the sea absorbs by Beer-Lambert, so a shallow sandy bottom stays sandy | A 4096-square map, decimated to fit rather than refused |
| Selection rings that follow the ground rather than hovering flat over it | Per-stratum normal maps, at the scale an 8-elmo height sample cannot reach |
| The scenery a map places — 5182 props here, and 46 971 on the busiest stock map | Dust, aged entirely in the vertex shader |
More in the milestone notes: m5-units-close,
m5-units-wide,
m8-rally-50s,
m10-water,
m10-water-fa,
m12-map-sky-coast,
m12-map-sky-desert.
Requires macOS 14+, Apple clang from the Command Line Tools (xcode-select --install — no Xcode), and CMake + Ninja.
brew install cmake ninja
git clone <this repo> recoil-metal && cd recoil-metal
Two dependencies are vendored into third_party/ and neither is committed.
CMake fails with these exact commands if either is missing:
# Apple's official C++ bindings for Metal
git clone --depth 1 https://github.com/apple/metal-cpp third_party/metal-cpp
# miniz, a single-file MIT ZIP reader — Recoil ships content in .sdz archives,
# which are ZIPs
mkdir -p third_party/miniz && curl -L \
https://github.com/richgel999/miniz/releases/download/3.0.2/miniz-3.0.2.zip \
| tar -xf - -C third_party/miniz
Then build and test. Catch2 is fetched by CMake at configure time:
make build
make test
# 2026-09-23 audit: 2085/2086 pass; fixed-point guard fails (details below).
Or without the Makefile:
mise exec -- cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
mise exec -- cmake --build build
mise exec -- ctest --test-dir build --output-on-failure
A handful of tests skip rather than fail when no game content is present — see
Getting content.
For strict content acceptance,
run mise exec -- make test-content; any skipped or failed check fails the run.
make help lists every target with the content paths it resolved. The short
version:
make run # procedural terrain — no game content needed at all
make play # a duel you drive: army 0 is yours, army 1 is scripted
make all-units FACTIONS=uef,cybran # manual 1v1 with every mobile unit and no fog
make watch # every side scripted, nothing selectable, no fog
make demo # a live 4v4 of FAF tech brains, random factions, no fog, real speed
make verify # replay 7000 ticks against the golden hash log (currently diverges at tick 0)
make all-units seats a controllable first faction and a stationary opposing faction
(FACTIONS=uef,cybran, or the default UEF/Aeon). Every mobile blueprint is staged
with clearance near its army's start; aircraft park nearby. Both fleets face
each other across one connected, draft-safe side-map ocean for naval battles.
Each army gets an Aeon Paragon at its map edge for resource income. The whole
map is visible, and the opposing army issues no build or attack orders; its
units still defend themselves. Use a map with a navigable ocean.
Anything is overridable: make play ARMIES=8 ALLIANCES=2 FACTIONS=uef,seraphim.
Add FAF=1 to play or watch when Forged Alliance's AI should drive the
opponents instead of the deterministic native script.
Content roots come from local.mk first, then the environment
(RM_FA_ROOT, RM_BAR_ROOT, RM_BAR_MAPS).
The binary underneath takes a map and a pile of flags:
./build/recoil-metal # procedural terrain, no assets needed
./build/recoil-metal path/to/map.smf # a real Recoil map
mise exec -- make prepare-bar # verify external runtime/content pins, then mount an isolated datadir
mise exec -- make play-bar # real BAR: human Armada versus BAR's built-in SimpleAI
mise exec -- make smoke-bar # observe player movement/building, AI actions and rendered UI
Hybrid native Metal (2026-10-10): smoke renders SMF terrain (1.57M tris), S3O units,
BumpWater surface, and opportunistic features/alpha/projectiles through direct MSL;
the checker requires terrain/units/water markers plus gameplay and reports the rest.
Smoke disables CUS GL4 (luarules disablecusgl4) because BAR's options widget
force-enables it on capable GPUs, masking engine unit draws; normal play keeps
CUS GL4. Native shading: diffuse/teamcolor/alpha + shadow-map receive + env cubemap
The engine/Mesa builds live in build/bar/engine-build and build/bar/mesa-install;
BAR, maps and fonts remain external. tools/bar-runtime.lock.json pins upstream revisions, the
actual numeric ancestor tag, port patch and compiled artifact/content hashes.
BAR_ENGINE, BAR_MESA, BAR_GAME, BAR_RUNTIME_MAP and BAR_DATA override
full-game paths; BAR_ROOT remains the Metal preview corpus. The launcher accepts explicit font/dependency paths.
For setup/source-build recipes, run mise exec -- python3 tools/bar_runtime.py --help.
fetch-engine obtains the pinned source/tag/submodules and applies the recorded
macOS patch; do not build a tagless shallow clone or override its release number.
An imported private baseline can be used with build/recoil-bar --bundle DIR.
Export with mise exec -- python3 tools/bar_runtime.py export --export-dir DIR;
review the asset licenses before transferring or distributing that directory.
--smoke uses BAR's existing developer test runner and an isolated raw LuaUI
test, not modified game content. It observes API-issued player MOVE/BUILD effects,
completion of a SimpleAI-commanded building, live build/order menus and a rendered
frame. It temporarily enables cheats/full visibility for the runner, but creates
no units or resources. make smoke-bar validates the current upstream report and
receipt; inspect screenshots too. BAR's upstream infolog-only test is disabled, so this is not an all-errors-clean claim.
Verified baseline, 2026-10-10: the default make smoke-bar and the exported
private bundle both pass the real player MOVE/solar BUILD, SimpleAI construction
and final-frame RGB regression. Evidence is in build/bar/testlog/results.json,
build/bar/infolog.txt and build/bar/screenshots/; bundle evidence is in
build/bar-final-bundle-smoke/. Library tracing confirms bundled EGL, Gallium,
Kosmickrisp and native dependencies are loaded, not the donor installation.
The recorded Mesa patches repair native window sizing and remove the fork's unconditional color-blit alpha override, which made RmlUI erase the scene. MSAA, RmlUI and game rendering remain enabled. Shader caches are isolated per datadir. This is a single-player baseline, not BAR-wide visual parity or public multiplayer validation; driver capability and content warnings remain. Normal launch reached gameplay without cheats; OS-level visual/input capture was limited by the locked desktop. Engine framebuffer captures were inspected.
--bench is windowed and vsync-limited — use it to eyeball GPU ms.
--bench-offscreen is headless and unthrottled, and is the comparable
number.
./build/recoil-metal path/to/map.smf --bench 600 docs/bench.csv
./build/recoil-metal path/to/map.smf --bench-offscreen 2060 docs/bench.csv
# The Recoil OpenGL baseline for the same map (needs FAR's zink build)
tools/bench_recoil_gl.sh docs/bench-recoil-gl.csv
The benchmark states which quality switches were on, since otherwise two of its own numbers are not comparable.
BAR=~/projects/llm/games/faf/forged-alliance-reborn/reference/BAR/objects3d/Units
# 800 instances: one per map start position, the rest scattered on land
./build/recoil-metal path/to/map.smf --units $BAR/corgantbig.s3o 800
# --focus frames the first instance instead of the whole map, because a unit is
# under 1% of an 8192-elmo map's width and otherwise renders as a few pixels
./build/recoil-metal path/to/map.smf --units $BAR/corgantbig.s3o 40 --focus
# repeat --units for more models; textures shared between them upload once
./build/recoil-metal path/to/map.smf \
--units $BAR/corgantbig.s3o 30 --units $BAR/armstump.s3o 60 \
--units $BAR/corraid.s3o 60 --focus
# scene: 3 models, 4 textures uploaded, 2 texture binds per frame
Left-click selects the unit under the cursor (a ring appears under it); right-click orders it to the ground under the cursor and marks the spot — a crossed amber ring that shrinks toward the point and fades over a second and a half. A cross rather than another ring, because the two appear on the same ground within a second of each other and colour alone is one distinction too few. Drags still belong to the camera — only a press and release that stayed put counts as a click.
# --march <x> <z> <seconds>: order EVERY unit to a point and pre-run the sim.
# Click-to-move cannot be screenshotted, so this is the reproducible way in:
# the same orders and the same tick count give the same scene every run.
./build/recoil-metal "$MAP" --units $BAR/armstump.s3o 200 --march 1500 1500 0 --focus
# ...and the same scene frozen 14 seconds later, headless
./build/recoil-metal "$MAP" --units $BAR/armstump.s3o 40 \
--march 2000 2000 14 --focus --screenshot /tmp/marched.png 1200 800
--units <model.s3o> [count] [scale], repeatable. Textures are resolved by the
name the .s3o carries, under BAR's unittextures/; models naming the same
file share one upload, and the draws are ordered so each texture pair is bound
once per frame rather than once per model — which is the unit Recoil batches on
too. The first --units takes the map's start positions; the rest are scattered.
FA="/path/to/Supreme Commander Forged Alliance"
# The whole skirmish, spawn to victory banner, deterministic: a scripted
# opponent (a fixed build order plus one attack wave — core/sim/BuildOrder.hpp,
# not an AI) builds a base, streams tanks, and comes for your commander.
./build/recoil-metal "$FA/maps/SCMP_009/SCMP_009.scmap" --gamedata "$FA/gamedata" \
--skirmish --armies 2 --play 620 \
--screenshot /tmp/victory.png 1280 720
# The same match at any earlier moment is a screenshot of that stage:
# 6s the first extractor, 19s power, 55s the land factory, 68s the first tank
# off the line, 432s the attack column, 590s the fight at your commander's
# feet, 594s the banner.
# --focus frames the first instance — the player's commander, which is exactly
# where the wave arrives; --look aims at a world point instead (X Z RADIUS).
./build/recoil-metal "$FA/maps/SCMP_009/SCMP_009.scmap" --gamedata "$FA/gamedata" \
--skirmish --armies 2 --play 590 --focus \
--screenshot /tmp/the-fight.png 1280 720
The stage times above describe the milestone-20 reference run, not a current
hash baseline. In the 2026-09-23 700-second run, army 0 lost its commander at
593.9s and team 1 won at 608.8s. make verify replays 7000 ticks against
docs/golden-p1.log but diverged at tick 0 on that run;
do not re-record the baseline without attributing that difference. The full
CTest run also fails the sim's arithmetic is fixed point on float use in
Enhancement.hpp/.cpp, Combat.cpp and CommandAdvance.cpp (2085/2086 pass).
The scoped EXE-versus-implementation assessment is in
docs/fa-gameplay-progress.md.
--play <seconds> is --march without the blanket move order — the sim runs
and the scripted armies decide their own movement. --armies N takes the first
N of the map's start positions (SCMP_009 declares eight; a duel wants two). The
player is army 0 and the script drives everyone else.
| 1:00 — the opponent's base: extractor, power, factory | 1:08 — the first tank rolls off the pad |
| 9:50 — the wave arrives at the player's commander, health bars over the damaged | 9:54 — a match that ends |
--data-dir <dir> adds a directory to the asset search path, and --archive <file.sdz> extracts a Recoil archive to a temporary directory and searches
that. Both are repeatable and searched in the order given. Model and texture
lookups fall back to the historical hard-coded BAR layout, so existing command
lines keep working.
# A unit definition names its own model, found through the search path
./build/recoil-metal "$MAP" --data-dir ~/games/bar \
--units ~/games/bar/units/ArmBots/armpw.lua 40
RTS conventions, because the camera was a model viewer's before this and a view that swings when you meant to select is the most disorienting thing an RTS camera can do.
| input | does |
|---|---|
W A S D | pan the map. Speed is scaled by the frustum's width at the target, so it feels the same zoomed in as out — one and a half seconds to cross the visible width |
| left click | select one of YOUR units. Shift/cmd/ctrl adds to the set |
| left drag | band-select everything of yours inside the rectangle |
| double click | widen to the TYPE — every unit like it that projects into the viewport. On screen rather than map-wide, because both reference games do that, and "everything like this, everywhere" silently commits units you cannot see |
| right click | order: move to the ground, attack the enemy under the cursor, assist your own builder (lend it your build rate — a factory turning out units or an extractor mid-upgrade takes assist even when scratched), repair a damaged ally, or reclaim the wreck |
| cmd + right click | overcharge: fire the commander's manual weapon at the target once the energy bar has filled |
shift+A, then right click | attack-move: engage visible enemies on the route, then resume the destination |
P, then right click | patrol between the unit's starting point and the destination; repeat P, then shift-right-click to add a waypoint |
| shift + any order | queue it behind the ones already given, drawn in the world as you go |
ctrl+0–9 / 0–9 | set a control group / recall it, the dead pruned out on recall |
| click a tray cell, then the ground | build: a subtle terrain/water grid appears; the ghost is cyan where the footprint fits and red where it does not. Escape, right-click or a second cell click cancels |
| click a tray cell, then drag on the ground | build a row: live model silhouettes show every snapped site, initially packed by footprint. Release queues those sites (capped at 128, skips unplaceable ground). The cell stays armed for another row; Escape or right-click disarms |
| mouse wheel mid-drag | row spacing: up tightens to touching footprints, down spreads to 40 build squares (320 elmos, about 80% of a T2 point defence's range) whatever the footprint. Silhouettes update while held; the camera zoom stays fixed during the drag |
| click a command cell, then right click | arm the command shown in the fixed 4×3 rack; Stop applies immediately and disabled positions stay put |
| click AUTO MEX | a standing order for the selected field engineers: whenever one is idle it walks to the nearest free mass or hydrocarbon deposit on your side of the map and builds there, then the next. Lit while on; click again to lift it. A manual order takes precedence and the engineer resumes when idle |
M | same AUTO MEX toggle for the selected field engineers, without the click. Silent unless the selection holds one |
E | open/close the economy window — the same action as clicking the economy module |
hold space + drag | swing the camera. Let go and it returns to the overhead view the app opened with, so a glance never costs you your bearings |
| shift + drag | pan with the mouse |
| scroll | zoom |
make test-build-preview checks packed and spaced silhouettes through native mouse
and wheel events, verifies that release queues the visible sites, and saves captures
under build/build-preview.png* (including Escape cancelling a held row and hiding the grid).
The map is framed whole on load (OrbitCamera::frame), so the opening view is the
whole map rather than a corner of it.
Panning drags the ground under the cursor rather than moving by a tuned constant — the step comes from the frustum's width at the camera's target, so it keeps pace with the pointer at any zoom. The target is held inside the map, since at a whole-map framing one point of mouse travel is ~18 elmos and a single ordinary drag would otherwise leave the map with nothing to navigate back by.
A resource panel is an instrument, not a scoreboard. What a player of this game watches is not how much mass they have but which way it is going and whether their build is funded — the economy is a flow and a stall slows everything by one shared fraction — so the panel shows rate and throttle first and totals second.
▪ MASS 120 / 650 +2.5
████░░░░░░░░░░░░░░░░░░░░░░
▓▓▓▓▓▓▓▓▓▓▓|▓▓▓▓▓▓▓▓▓▓▓▓ <- the flow strip
▪ ENERGY 144 / 5000 +3.0
█░░░░░░░░░░░░░░░░░░░░░░░░░
▓▓▓▓▓▓▓▓▓▓▓|▓▓▓▓▒▒▒▒▒▒▒▒
BUILDING AT 8% ▬▬▬░░░░░░░░░░ <- only while there is a stall
The flow strip is the one thing here worth remembering. Income grows from the left in green and drain from the right in red, meeting at a notch. Where they meet is the reading: past the notch you are earning, short of it you are spending down, and no number has to be read for it. Two states ride on the same bar — a lit cap when the store is full and income is being thrown away, and a throttle line when construction is not fully funded — both of them real mechanics rather than decoration.
Two typefaces, deliberately paired. Avenir Next Condensed for labels, which are read once and should look engraved; Menlo for readouts, because its figures are tabular and in a proportional face a live mass figure jitters sideways as its digits change width. An engraved label against a mechanical counter.
The chrome wears the player's faction and the resources never do. Mass is green and energy amber in every livery, because those are identities a player has learned. Three of the four faction colours collide with a reserved one — Aeon's green with mass, Cybran's red with a loss, Seraphim's gold with energy — and the collision is resolved by moving the livery, since a resource's colour is an identity and a faction's is a coat of paint. A test asserts the distance, and it caught the first two attempts being too close to tell apart.
Panels share one quarter-resolution Metal Performance Shaders backdrop, with distinct response rather than extra decoration: UEF laminated glass, Aeon opalescent ceramic, Cybran smoked composite, Seraphim crystalline plate, BAR field acrylic, and restrained Neutral chrome. Their lit edge and corner brackets say where a panel ends without a full border competing with the numbers. Classic FAF uses its complete retail nine-slice; an incomplete set falls back atomically to Neutral. Geometry, typography, and semantic colours do not move between any of them.
--ui fa|bar|neutral|faf changes vocabulary and chrome without moving controls. BAR uses
METAL and a warm field-acrylic fallback; neutral observer presentation uses MATERIAL and
ownerless cyan. Rectangular maps keep one aspect-preserving minimap projection, so the preview,
fog, pips, camera footprint, and clicks all agree and the letterbox itself is inert.
Three switches, all on by default, all one keypress away:
| key | flag | default | costs |
|---|---|---|---|
r | --no-reflections | on | +0.50 ms |
n | --no-stratum-normals | on | +0.21 ms |
o | --no-props | on | +0.17 ms at a working zoom, nothing zoomed out |
f | --refraction | off | +0.17 to +0.28 ms |
Defaults are looks-best, deliberately. The cheap-by-default argument is the usual one and it is wrong here: what is being demonstrated is how the content looks when a Metal renderer draws it, and a reader who runs this should see what the screenshots show. What that does oblige is that the benchmark states which switches were on, since otherwise two of its own numbers are not comparable — which it now does.
The water's refraction is the one that defaults off, and by the same rule rather than as an exception to it: with the wave field this water has, it does not look best. The offset itself works — it needs a copy of the colour target, since a framebuffer fetch reads one pixel and no other, so the pass splits in two around a blit — and what it reveals is that the field being bent by is two analytic wave trains standing in for the engine's four scrolling normal maps. Move a screen-space sample by a field that regular and it draws the field's own lattice across the water: rings tens of pixels wide at swell frequency, a diagonal hatch at ripple frequency, at every strength down to a quarter of the engine's. It is waiting on the water's normal coming from real textures, which was never the part that looked hard.
To state a preference rather than pass a flag, write a Lua table to
~/Library/Application Support/recoil-metal/settings.lua. It is read by the same
data reader that reads mapinfo.lua; a missing file is the ordinary case, and a
key of the wrong type is reported rather than coerced.
-- a machine that would rather have the frame rate
{
reflections = false,
stratum_normals = true,
props = false,
refraction = false,
}
Flags beat the file: a flag is somebody asking for this run, the file is somebody
stating a preference. There is no --reflections to turn one back on, because the
defaults are already on and the only thing a flag has ever needed to say is "not
this time".
Everything below needs game content — see Getting content.
Factory trays offer every unit allowed by the factory's blueprint, with the highest unlocked tier first and tier labels on the buttons. Engineers likewise expose their authored construction tiers, including shields and other supported build categories. Unupgraded commanders keep their T1 menu. Use the header's page arrows for remaining units. Select a T1 or T2 extractor to see its next-tier upgrade. While T1→T2 is running, the tray offers T3; clicking it queues T3 automatically after T2. Pending orders and selection follow the replacement building, and Stop cancels the chain. The upgrade queue shows each tier with a Cancel button. Cancel queued T3 to keep T2 progressing; cancel T2 to remove it and the dependent T3. Clear Queue stops both.
mise exec -- ./build/rm_tests '[headless-ui]' exercises button hit-testing and the
shared click handler, the full upgrade chain, save/restore, cancellation and enemy
ownership rejection without a GPU.
Weapon sprites and beam strips now resolve their effects from original Lua class
declarations and load the referenced emitter/DDS assets. See
weapon visual checks and current limits.
mise exec -- make test-guard-ui replays a Guard scenario on the retail map twice: a
mortar escorts a tank across SCMP_009 terrain, and the run must reproduce pixels and
simulation hashes with the guard order still standing.
mise exec -- make test-upgrade-ui additionally renders the upgrading extractor
offscreen twice, checks the T3 queue button and the two-tier queue, and compares pixels and simulation
hashes. It requires the retail install and Metal; artifacts stay in build/upgrade-ui/.
Hold Shift while placing buildings to append orders and keep placement armed for additional sites. A plain placement replaces the current order and exits placement; right-click cancels the placement tool. Factory unit buttons append production orders, and Shift-clicking an upgrade queues it after existing work.
Buildings face cardinal directions, keeping their models aligned with the grid. The FA and classic FAF interfaces use square unit-selection outlines; weapon range indicators remain circular.
Select a unit or building to see its mass and energy production and actual spending per second. Green double rings mark mass deposits; amber rings mark hydrocarbon deposits. Both also appear on the minimap. Extractors must be built on mass deposits, and hydrocarbon plants on hydrocarbon deposits. Nearby placement snaps to the matching deposit; occupied sites remain blocked.
For a periodic per-army and per-unit breakdown, run
mise exec -- make skirmish LOG_LEVEL=debug LOG_FILE=build/economy.log.
See resource diagnostics for attribution.
# Terrain blocks sight, which is Recoil's model and the default: hills hide what
# is behind them and high ground is worth taking.
./build/recoil-metal "$FA/maps/SCMP_009/SCMP_009.scmap" --gamedata "$FA/gamedata" \
--skirmish --armies 2 --play 300
# Flat discs, which is what Supreme Commander does — `effects/vision.fx` stamps a
# radius at a position and never samples a height, so you see over mountains.
./build/recoil-metal "$FA/maps/SCMP_009/SCMP_009.scmap" --gamedata "$FA/gamedata" \
--skirmish --armies 2 --play 300 --vision-style fa
# ...and `--observer` draws no fog at all, because watching is seeing everything.
Every unit sees as far as its own blueprint says: Forged Alliance's Intel block
in ogrids (a Cybran ACU's VisionRadius = 26 is 208 elmos), BAR's
sightdistance in elmos already. 355 of the 568 shipped blueprints see, 57 carry
radar, 67 sonar; the widest radar is 4800 elmos against the widest sight of 800,
which is what says radar is a different order of thing from sight.
What it changes, in order of how much you notice:
nearestTarget picked from the whole unit store filtered by hostility and
range, so everything in the match engaged targets across the map.The two engines disagree about what vision is, which is why the style is a
setting rather than a decision — see ADR-037. The structure underneath is
Recoil's: a reference count per square per alliance, so one unit's sight can be
withdrawn without re-deriving every other unit's. The grid is integer and enters
the state hash, so --hash-log and make verify cover it with no new machinery.
Since then, eight of ADR-037's nine landed. Omni sees everything in its radius, cloaked and stealthed alike — 17 units declare one — and it is a grid of its own rather than a flag on the vision grid, because it answers a different question at contact time: vision asks "is this square lit", omni asks "is this square lit by something nothing can hide from". Merging them would have meant either stealth defeats omni or stealth defeats nothing. Cloak and the two per-unit stealth flags hide a unit from a named sense; the stealth fields (the B4203 generators, seven units declaring each radius) are a second kind of grid entirely — "who is HIDDEN here" rather than "who can see here", keyed by the field owner's alliance rather than the viewer's. CloakField has no entry because it appears zero times in retail content.
Still absent, each for its own stated reason: a water-vision grid (nothing is submerged yet, so it would have no target to answer about and no test that could tell it from an empty one), air LOS (it needs a flying/grounded distinction the coverage query does not yet make), and seismic.
.scm loads into the same Model struct .s3o does, and the same magic sniff
picks the loader:
FA=~/projects/llm/input/faf/units
./build/recoil-metal "$MAP" --units $FA/UEL0201/UEL0201_LOD0.scm 40 --focus
# both content families in one scene, one draw each
./build/recoil-metal "$MAP" --units $FA/UEL0201/UEL0201_LOD0.scm 40 \
--units $BAR/armstump.s3o 40
Models are extracted once from the retail install's units.scd (a ZIP) into
~/projects/llm/input/faf/ — see tests/test_real_scm.cpp for the command.
Textures are found beside the model by Supreme Commander's naming convention
(_Albedo, _SpecTeam), since .scm names none.
Same binary, same arguments — the format is sniffed from the file's magic:
FA="/Volumes/Samsung_T5/faf/Supreme Commander Forged Alliance/maps"
./build/recoil-metal "$FA/SCMP_009/SCMP_009.scmap"
# BAR units on a Forged Alliance map: both content families in one scene
./build/recoil-metal "$FA/SCMP_009/SCMP_009.scmap" --units $BAR/corgantbig.s3o 250
Ground colour comes from the map's terrain-type array rather than a texture:
.scmap ships no baked ground, so until the splat shader exists those bands are
the stand-in. No game assets are read from anywhere but the retail install.
The splat's layers are paths into env.scd, another ZIP. Only the layer
directories are extracted — 402 files and 135 MiB of the archive's 1.15 GiB of
DDS, of which the stock maps name 184 — so a ZIP reader stays deferred:
python3 - <<'PY'
import zipfile, os
scd = '/Volumes/Samsung_T5/faf/Supreme Commander Forged Alliance/gamedata/env.scd'
dest = os.path.expanduser('~/projects/llm/input/faf')
z = zipfile.ZipFile(scd)
for n in z.namelist():
if n.lower().startswith('env/') and '/layers/' in n.lower() and n.lower().endswith('.dds'):
z.extract(n, dest)
PY
Without them the map still draws: the terrain-type colour bands from milestone 6 stay loaded as the fallback, and the splat simply does not switch on.
The same archive, and the same deal — a .scmap's props name blueprints
(/env/Tropical/Props/Trees/Palm02_s1_prop.bp) whose meshes and textures sit
beside them. 1511 files and 160 MiB, against 335 blueprints the stock maps
between them reference:
python3 - <<'PY'
import zipfile, os
scd = '/Volumes/Samsung_T5/faf/Supreme Commander Forged Alliance/gamedata/env.scd'
dest = os.path.expanduser('~/projects/llm/input/faf')
z = zipfile.ZipFile(scd)
for n in z.namelist():
if n.lower().startswith('env/') and '/props/' in n.lower() \
and n.lower().endswith(('.bp', '.scm', '.dds')):
z.extract(n, dest)
PY
Without them the map draws bare: the prop list is still parsed and counted, and every blueprint that fails to resolve is reported once.
--animate <file.sca> attaches an animation to the --units before it. The
windowed app advances its own clock; --time <seconds> freezes it, which is what
makes a screenshot or a benchmark of an animated scene reproducible.
./build/recoil-metal "$MAP" \
--units $FA/DEL0204/DEL0204_lod0.scm 1 \
--animate $FA/DEL0204/DEL0204_awalk.sca --focus
# animation DEL0204_awalk: 2.33s, 71 keyframes, 19 of 20 bones driven
Every keyframe's pose is computed once at upload and playback is a buffer
offset, so 800 animated units cost 0.70 ms/frame — the same as 800 static ones.
.s3o has no equivalent: the format carries no rotation at all, and Recoil
drives unit motion from scripts instead.
The feature question needed a corpus rather than one map. BAR publishes a validated index of live maps with direct download URLs, which is the only part of this worth scripting:
mkdir -p ~/projects/llm/input/recoil/maps/bar && cd ~/projects/llm/input/recoil/maps/bar
curl -s -o /tmp/live_maps.json \
https://maps-metadata.beyondallreason.dev/latest/live_maps.validated.json
python3 -c "import json;[print(d['downloadURL']) for d in json.load(open('/tmp/live_maps.json'))]" \
| head -8 | while read -r u; do
curl -s --max-filesize 45000000 -O "$u" # most are 25-85 MB
done
for f in *.sd7; do 7zz e -y "$f" -o"${f%.sd7}" "maps/*.smf" >/dev/null; done
What they say is in the milestone notes: sixteen TreeTypeN entries declared and
never used, on every map checked. Only the .smf is extracted, because the feature
list is the only thing this corpus was fetched to answer.
For repeated offscreen AI experiments, the tracked runner keeps each run's logs,
commands, hashes and final screenshot under build/ai-matches/<name>/:
mise exec -- python3 tools/ai_match.py run tech-hour --personality tech --seconds 3600 --timeout 1200
mise exec -- python3 tools/ai_match.py status
mise exec -- python3 tools/ai_match.py stop tech-hour
mise exec -- python3 tools/ai_match.py stop tech-hour --force
run stays attached to its tool/terminal session and records the exit code; use
another invocation for status or stop. --seconds is simulation time and
--timeout is an optional wall-clock limit. Job names cannot be reused, preserving
earlier evidence. Stop verifies the recorded PID's creation time and command before
sending a signal. The runner always uses the local build, observer mode, mute and
offscreen capture. A persistent approval for
mise exec -- python3 tools/ai_match.py covers these operations without approving
arbitrary shell commands or system-wide process termination.
The walkthrough above uses about half of these. The rest exist for the same
reason --screenshot does: a headless run has no cursor, and interface that
only appears under one cannot otherwise be captured, tested, or diffed.
| flag | does |
|---|---|
--gamedata <dir> / --data-dir <dir> / --archive <file> | where content is found: the retail gamedata folder, a loose tree, or one .scd/.sdz mounted by hand |
--units <path> <n> | spawn N of a model or blueprint, scattered deterministically |
--factions <a,b,…> | each seat's side, cycled — mirrors and matchups are one flag |
--armies <n> / --alliances <n> | how many of the map's start positions are seated, and how they pair up |
--skirmish | spawn commanders and run the match rules |
--observer | watch without a seat: no fog, no selection, nobody's commander |
--march <x> <z> <s> / --play <s> | pre-run the sim: with a blanket move order, or letting each side decide |
--tick-rate <hz> | the sim's rate for this run, 5–50 Hz. Applied first, because speeds and reloads derive from it at spawn |
--no-interpolate | draw the newest snapshot rather than blending two. Every golden image is taken with this — a screenshot of tick N should be tick N, not depend on when the process was scheduled |
--focus / --look <x> <z> <r> | aim the capture at the first instance, or at a world point |
--select <n> / --select-type <id> / --hover <n> / --ghost <x> <z> | light up interface a headless run has no cursor to produce: N units selected or the first unit with a blueprint id selected, the Nth tray option hovered with its info card, the placement ghost at a world point |
--ui <fa|bar|neutral|faf> / --ui-scale <0.5..3> | select FA, BAR, neutral, or classic FAF presentation (fa is the default; the first resource reads Mass, Metal, or Material respectively; faf wears the game's own nine-slice chrome); request HUD scaling relative to automatic size. Values clamp; available fit wins, and enlargement uses only room beyond the automatic 2.5× cap |
--ui-effects <full|reduced|off> | override the HUD backdrop material. Full and Reduced share one quarter-resolution MPS blur; Off renders directly to the drawable with no backdrop targets or composition passes. Without an override, macOS Reduced Transparency selects Off |
--window <w> <h> / --fullscreen | choose the initial window size in logical points (bounded by the HUD's 1280x720 floor), or use the current display's native fullscreen size |
--vision-style <recoil|fa> | whether terrain blocks sight |
--placement <grid|free> | snap structures to the 8-elmo build grid as Supreme Commander does (the default), or place them at the exact click |
--ai-faf | FAF's own AI plays every army, through the sandbox |
--ai-personality <name> | Select easy (default), medium, tech, rushland, rushair, rushnaval, rushbalanced, turtle, adaptive or random. Implies --ai-faf; applies to every army. Named choices select their main-base template; adaptive/random score FAF templates per army at startup. Selection is repeatable for the same map dimensions and army index. The startup log names each chosen template. Surface-naval upgrades and production reach T3; commander enhancements and proper scouting are still under development. |
--ai-log / --ai-debug / --ai-sanity | narrate the AI's decisions and the corpus's own LOG lines; the debug report; the closing census of what was built, which bindings were called, and which corpus functions ran |
--log-level <trace|debug|info|warn|error|off> / --log-file <f> | filter timestamped operational diagnostics (default info) and optionally append the same records to a file; debug includes order and construction lifecycle traces |
--hash-log <f> / --check-hash-log <f> | write a per-tick state hash, or replay against one and name the tick a divergence began at |
--command-log <f> / --replay-commands <f> | record the orders given, or play them back into the same match |
--print-events | narrate the sim's own event queue |
--volume <0–1> / --mute | the mixer |
--dump-weapon <id> | print one blueprint's weapons as the loader read them |
--bench <n> / --bench-offscreen <n> <csv> | windowed and vsync-limited, or headless and unthrottled — the second is the comparable number |
--screenshot <f> <w> <h> / --backing <s> | render one frame offscreen and exit; <w> <h> is the logical size and --backing the display scale it stands in for, so 1280 720 --backing 2 is a 2560x1440 capture laid out and font-rasterised exactly as a 2x window would be |
--bench-hud / --bench-size <w> <h> | make the offscreen benchmark draw the interface a screenshot of the same scene shows, and at a logical size other than 1920x1080; --backing applies too. World-only runs the identical headless composition with only the 2D HUD/minimap cleared, so subtraction does not change particles or icon fallbacks; it remains the default so published numbers stay comparable |
--time <s> / --animate | advance the clock before capturing; run model animation |
--no-reflections --no-stratum-normals --no-props --refraction | quality, as in the table above |
No game assets are or will ever be committed. Tests that need them skip rather than fail. These are the recipes for providing your own from installs you own.
No game assets are committed, so the real-map tests skip unless one is present. To provide it:
mkdir -p ~/projects/llm/input/recoil/maps && cd $_
curl -sLO "https://files-cdn.beyondallreason.dev/file/9fc29b4e9dd666d9f9866280fb3c0861/angel_crossing_1.4.sd7"
7zz e -y angel_crossing_1.4.sd7 maps/aw04.smf maps/aw04.smt mapinfo.lua -o.
Extract all three, not just the .smf: mapinfo.lua carries the authoritative
height range (the binary header's is wrong on this map), and aw04.smt is the
ground texture. Without the .smt the terrain still renders, shaded by
elevation — which is also what the engine does for a missing tile file.
--screenshot renders one frame offscreen and writes a PNG. No window, so it
works regardless of which Space is active — capturing the app's own window by id
fails outright for a window on an inactive Space, which is why this exists.
./build/recoil-metal path/to/map.smf --units $BAR/corgantbig.s3o 40 --focus \
--screenshot docs/images/units.png 2000 1200
PNG encoding goes through ImageIO, which is part of the OS — not a dependency.
The renderer always writes PNG. What the README shows is a downscaled JPEG of it (1600 px wide, quality 90), which is a fifth of the bytes for detail that is invisible at the width GitHub renders an image anyway. Regenerate the whole set after adding a shot:
cd docs/images && for f in *.png; do
sips -Z 1600 -s format jpeg -s formatOptions 90 "$f" --out "${f%.png}.jpg"
done
.gitignore); the JPEGs are what is committed.This is the FA implementation strategy, not the BAR compatibility strategy. BAR runs the existing Recoil engine; its simulation, Lua API, UI and protocol are not reimplemented by this project.
Measured on the real tree (reference/RecoilEngine in FAR, Spring/Recoil
rts/): of ~1.95M lines, 1.57M is rts/lib/ — vendored third-party code
nobody rewrites. The engine proper is ~385k lines:
| Subsystem | kLOC | Plan |
|---|---|---|
| Sim (units, weapons, pathing) | 83k | later, semantics reimplemented — not classes |
| Lua bindings | 74k | never port; reimplement minimal when needed |
| Rendering (OpenGL) | 67k | replaced — this project |
| System (SDL, threads, FS) | 65k | take only what's needed |
| Game / ExternalAI / RmlUI / Net / Menu | ~81k | never port |
Two facts make the strategy possible: rts/Sim includes zero GL headers,
and only 18 sim files touch rendering globals — the sim↔rendering boundary is
real. But a horizontal port (Sim → Lua → Game → System) still means ~250k
lines before one pixel renders. So instead: vertical slices through data
formats. Loaders are small and data-shaped; the renderer is new.
The rule, inherited from FAR: assets/formats convert, behaviour gets reimplemented.
recoil-metal/
├── CMakeLists.txt single build file, sections commented
├── src/
│ ├── core/ pure C++ — no Metal, no AppKit, fully unit-tested
│ │ ├── sim/ the simulation: units, orders, combat, economy,
│ │ │ pathing, intel, reclaim, shields, replay, hashing
│ │ ├── unit/ unit definitions, the build tree, adjacency tables
│ │ ├── blueprint/ Supreme Commander `.bp` reading
│ │ ├── map/ SMF/SMT and `.scmap` loaders, mapinfo.lua, tile atlas
│ │ ├── model/ `.s3o` and `.scm`/`.sca` into one model struct
│ │ ├── scene/ what is drawn, and the batches it is drawn in
│ │ ├── ui/ HUD, minimap, build tray, roster, icon atlas
│ │ ├── audio/ XACT wave banks, mixer, cues
│ │ ├── vfs/ archive mounting and search-path priority
│ │ ├── lua/ Lua table-literal reader (data, not programs)
│ │ ├── data/ the shipped openings and tables
│ │ ├── mesh/ heightfield triangulation
│ │ ├── texture/ DDS decoding and atlas packing
│ │ ├── text/ glyph atlas
│ │ ├── bench/ the benchmark harness
│ │ ├── settings/ quality switches
│ │ └── camera/ orbit camera + projection
│ ├── app/ FA wiring: CLI, match loop, FAF AI adapter
│ ├── games/bar/ Recoil launcher and actual BAR runtime acceptance
│ ├── render/ Metal renderer (Objective-C++ where bridging)
│ ├── platform/ AppKit window + display link (pImpl hides ObjC)
│ └── main.mm thin entry point
├── tests/ Catch2 unit and integration tests; 2,113 CTest entries
├── third_party/ metal-cpp and miniz (fetched, gitignored)
│ NEVER modified — `make ai`, ADR-039)
└── docs/ research notes, benchmark results, the golden hash log
The existing core/... paths contain both neutral and FA-specific code.
CMake targets, not directory names, define which runtime owns each component:
| Targets | Ownership |
|---|---|
rm_foundation | Neutral logging/task pool; both executables link it |
rm_content, rm_render_data, rm_audio | CPU asset readers, geometry/camera/text preparation, mixer |
rm_fa_data, rm_fa_sim, rm_fa_presentation, rm_fa_app | FA formats, gameplay, scene/UI, application |
rm_metal, rm_platform | Extracted native rendering and macOS window/audio implementations |
rm_metal still consumes FA presentation types; extracting a library does not
make that interface BAR-compatible. rm_platform depends on rm_metal because
the window owns a renderer. recoil-bar links only rm_foundation and executes
Recoil separately. Neither game shares unit storage, tick arithmetic or Lua state.
Licence: GPL-3.0-or-later — the full text is in LICENSE.
The original code in this repository is licensed under the GNU General Public
License, version 3 or (at your option) any later version. Third-party code keeps
its own licence: fetched dependencies (third_party/, vendor/, the pinned
Recoil engine) are not part of this repository, and the files adapted from
Recoil below remain under Recoil's terms — "version 2 of the License, or (at
your option) any later version" — which permit distributing them as part of
this GPL-3.0-or-later work.
What is adapted, and therefore what carries the obligation:
| Here | From |
|---|---|
.smf / .smt map loaders | rts/Map/SMF/ |
.s3o model loader and its team-colour convention | rts/Rendering/Models/, ModelFragProgGL4.glsl |
The 30 Hz tick, and GAME_SPEED with it | rts/Sim/Misc/GlobalConstants.h |
Water plane at y = 0 | rts/Map/Ground.h |
| Model lighting defaults | rts/Map/MapInfo.cpp |
Supreme Commander shaders (terrain.fx, mesh.fx, water2.fx, sky.fx) are
read as a specification and reimplemented in MSL — no HLSL is copied, and
none of it is redistributed here. Reading either engine's source as a spec is
unrestricted; the adapted Recoil code above keeps Recoil's licence.
No game assets are or will ever be committed — same rule as FAR. The
screenshots under docs/images/ are output of this renderer, not game content,
though they necessarily depict textures the two games ship.
BAR's Lua code is GPL, but its artwork uses mixed licenses, including
CC BY-NC-ND; see the external game's LICENSE.md and license_*.txt.
The BAR preparation/export tools do not grant redistribution rights. Keep
game/map/font assets out of git and review each asset's terms before sharing
a runtime bundle. The captured Recoil macOS source patch is GPL-derived.
GitHub سے آخری اپ ڈیٹ: 4 گھنٹے پہلے
GitHub کے اعداد دن میں چند بار تازہ کیے جاتے ہیں۔
لاگ اِن کریں یا اکاؤنٹ بنائیں تاکہ تبصرہ کر سکیں۔
ابھی کوئی تبصرہ نہیں۔ پہلا تبصرہ آپ کریں۔
فخر سے دکھائیں: آپ کے درجے اور ریٹنگ والا لائیو کارڈ، جو خود بخود اپ ڈیٹ ہوتا ہے۔
چھوٹا والا چاہیے؟ یہ شامل کریں: ?style=flat