BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
On this page
2026-11-28, the November notesHeroes stores what Battlefield 2 keeps in the registerThe control block has no cadence of its ownThe server's held weapon reaches its owner through the control blockThe count learned to say what a number is made of2026-10-30, fifth publishThe physics materials: one script holds the damage matrixTerrain in and out, the material map and the surrounding heightmapsLight: the soft sun, the overgrowth's shadow map and lamps in PLAYDerived maps from a top-down renderAI: a strategic area's second pair is its centreA mobile physics node turns a placed object into a spawnerGameplay objects as BF2 and 2142 ship themAmbient objects, effects, animation and a test benchEditor workflow: sky camera, layers, mods in PLAY, history on the command line2026-10-30, fourth publishThe 2005 wizards become level-wide checks with one-click fixesNew templates written as the game's own CON linesThe navigation mesh, generated and saved in the pageEach level was baked with its own sky light settingsHeroes' seated emotes: the room testA browser page must take its frame time from the animation frameThe editor's PLAY needs one player to start a round without botsSky edits, mods and history in the editor2026-10-30, third publishStatic lamps light only the light maps, and only objects in HeroesWhat the 2005 editor's derived maps holdThe editor's console runs the engine's own commands2026-10-30, second publishThe 2005 editor's light maps: a ring of sky lights around the sunHeroes resolves its antialiased frames in linear lightBF2: one object's oversized dirty mask starved the player's ghostHeroes' soldier physics has 2142's layout, not BF2'sHeroes' sky dome sits at the level's domeOffsetHeroes' emote gate has no vehicle-seat testThe original draws the chase camera from the blended vehicle2142 Titan: the camera's position decides which interior parts are drawnThe editor writes the level's own filesThe 2005 BF2 Editor, tool by tool2026-10-30, first publishA land detail layer stops 3 m under the sea (terrain compiler)Near tree leaves fade out through alpha-to-coverage, two samplesTerrain colour passes need a depth tolerance on Apple GPUsTrees and terrain shade the houses' lightmaps tooHow it is testedIn the code

Engine learnings

BF22142Heroes

The engine facts bf2-rs pinned down recently, newest first. Each publish of this wiki adds a dated section; every entry says what the original does, how we know, and where the code and the longer notes are. The pages of the Engine area explain the systems; this page is the changelog of what we found out about them.

2026-11-28, the November notes#

What the project pinned down in November, taken from the working notes. The longer pages that grew out of them are linked where they exist.

Heroes stores what Battlefield 2 keeps in the register#

BF22142Heroes

Battlefield 2 and 2142 were compiled to keep the intermediate results of a float expression in the x87 register; Heroes' compiler stores many of them as 32-bit floats on the way. The statements are the same, the last bit of the answer is not. Three places read to their end in November: the engine curve's read (BFHeroes.exe@bfh126!0x007d0993: x * 100 and the blend are each stored as a float, where bf2_w32ded.exe!0x006090e0 stores neither), the wheel speed step (BFHeroes.exe@bfh126!0x009588d6: the torque and the resistance are divided by the inertia and three results are stored, where bf2_w32ded.exe!0x00698a40 multiplies by the reciprocal), and the matrix products (BFHeroes.exe@bfh126!0x0088fc8f, 0x0088f817: every element summed as (a0 b0 + a1 b1) + a2 b2, where Battlefield 2 and 2142 add in other orders in six of the nine sums). Where the register is rounded to 24 bits (a client) a float store changes nothing, so the two forms of a store agree; where it holds 53 (a server) they part. The order of a sum shows at both. The arms sit inside the same Rust functions behind is_heroes(). Code: crates/bf2-gameplay/src/vehicle/curve.rs (evaluate_heroes), crates/bf2-physics/src/vehicle_friction.rs (wheel_speed_step_p), crates/bf2-physics/src/vecmath.rs.

The dedicated servers run the x87 at the C runtime's 53 bits; a client under Direct3D 9 runs it at 24. The same listing therefore gives two answers: of 1,000 ordinary matrix pairs, the affine product at 24 bits is another float than at 53 in 994. Every ported function that computes in the register takes the precision as an argument (X87Precision), and the oracle tests run both modes: 400 cases over 9,600 ticks at 53 bits and 200 cases over 4,800 ticks at 24, every tick bit-exact (full node state and transform). Code: crates/bf2-physics/src/fpu.rs, crates/bf2-physics/src/node.rs. Notes: notes/subsystems/physics-dynamics.md. Page: Float precision. Task H7314 and its reading round (2026-11-16).

The control block has no cadence of its own#

BF22142Heroes

The server writes the player's own object into a control block in every packet that follows a newly applied player action: no counter, no priority, no change test (GhostManager::setControlObject bf2_w32ded.exe!0x00556a40, writeTo 0x00558df0). The rate is therefore the connection's packet rate: 20 a second on a LAN type in Battlefield 2 and 2142, and 10 in Heroes, whose GSUpdateRate setting is registered and shipped as 10 (BFHeroes.exe@bfh126!0x00740cec). Each game has its own connection type table; the code that reads it is identical in Battlefield 2 and 2142, which is why a function map could not show the difference. Code: crates/bf2-net/src/ghostmgr.rs, crates/bf2-net/src/join.rs. Notes: notes/tracks/multiplayer.md. Page: The control block and prediction. Task H3898 (2026-11-10).

The server's held weapon reaches its owner through the control block#

BF2Heroes

SoldierNetworkable::setNetUpdate (BF2.exe!0x0062d4e0) runs its item block for every record it applies that is not a rag doll's, and the local soldier's control block is such a record: Battlefield 2's player data block names no weapon, so this is the only way the server's held weapon reaches the player who holds it. In Battlefield 2 and 2142 the client also selects with its own key in the same tick, so the player waits for nothing and the block only confirms. In Heroes GameLogic::selectWeapon asks whether this is the server, so a weapon key waits for the block: the round trip, up to a tenth of a second for the next packet, and a tick on each side (136 to 166 ms on loopback with our client). Code: bf2_client::predict (apply_control_item_bf2, apply_control_item_heroes). Notes: notes/tracks/multiplayer.md. Tasks H3697, H3780 (2026-11-10).

The count learned to say what a number is made of#

BF22142Heroes

"Tested" used to count every proof alike. Since November the counter gives each tested function its strongest proof (a1 a test names it, a2 link lines only, b the record only, d a twin's test, and four weaker ones), and the wiki shows the strict number beside the generous one. Tool: tools/bfheroes/parity_coverage.py (PROOF_KINDS). Page: Parity numbers. Tasks H4332, H4374.

2026-10-30, fifth publish#

The physics materials: one script holds the damage matrix#

BF22142Heroes

Every pair of physics materials (attacker, defender) has a damage modifier and its impact effect, sound and decal templates, all in one script: Common/Material/MaterialManagerSettings.con, where MaterialManager.createCell a b selects a pair and the damageMod and set{Effect,Sound,Decal}Template <index> <name> lines after it set its values (the last line of a value wins). The materials themselves (Material.active <id> blocks of name, type, friction, elasticity, ...) are in the define script it runs. A level may ship its own Levels/<level>/MaterialManagerSettings.con, which then wins, though no retail level of the three games does. The web editor's material editor reads both scripts as the level loaded them (bf2-physics' MaterialScript), edits one value, one material or one pair per undo step, writes each changed line in place, and previews a pair's effect and sound. Code: crates/bf2-editor/src/materials.rs. Notes: notes/editor/api.md "Materials". Tasks H2404, H2504.

Terrain in and out, the material map and the surrounding heightmaps#

BF22142Heroes
  • Heightmaps (H2396): the primary heightmap exports as a 16-bit greyscale PNG (north up) or as the level's own HeightmapPrimary.raw layout (little-endian u16, south row first; an unedited level exports the shipped file byte for byte). Import takes a PNG or RAW of any size, resamples it, and applies it as one sculpt stroke with undo; the outer ring of samples stays, as for the brushes. A material brush paints HeightmapPrimary.mat, the physics material per sample. Notes: notes/editor/api.md "Heightmap import / export and the material brush".
  • Surrounding terrain (H2401): the eight secondary heightmaps are 8-bit in every retail level (village: 129 x 129 samples at 4 m, one step is 0.64 m high). A brush stroke now works across the primary's edge, and the seam keeps the step it had between the two sides. The shipped seams are not one height everywhere (village's east edge stands 53.7 m over its placeholder secondary). Notes: notes/editor/api.md "Surrounding terrain".

Tasks H2396, H2401.

Light: the soft sun, the overgrowth's shadow map and lamps in PLAY#

Heroes
  • The sun is a view, not a ray (H2410): the 2005 generator looks at the sun from each sample through a 2 degree cone (sunLightFov) over 16 x 16 pixels, so a shadow's edge is soft by the cone's width. The terrain tiles now take that cone through the depth map (bake_sun::SUN_HALF_ANGLE, 1 degree); the statics keep their 3 x 3 test.
  • The overgrowth's light is a painted map (H2444): a tree takes its light from Overgrowth/OvergrowthShadowmap.raw (one byte per heightmap sample, read at the trunk when the tree is made), and the shipped map is painted rather than baked: village's full-shadow blob is 170. The re-bake now writes 170 + 85 x the sun's visibility only where the light changed, and keeps every other painted byte.
  • Lamps (H2474, H2473): the generator's lamp view lets the lamp post's own fixture cast too, which cuts ruin's lamp channel error from 8.35 to 4.63 / 255. A native round on the editor's overlay draws a moved lamp's light as the editor showed it (the lit wall: mean 149.3 in the round, 149.9 in the editor).

Notes: notes/editor/lighting.md "The soft sun", "Lamps" and the overgrowth's shadow map. Tasks H2410, H2444, H2474, H2473 (the per-level GI settings, H2447, are in the fourth publish).

Derived maps from a top-down render#

Heroes

The 2005 editor made the minimap and the ground hemi map with renderer.makeTopWorldScreen: the level drawn from above. The editor's save now does the same: it draws the level orthographically over each map's square into an offscreen target, with colour and depth read back (the depth becomes the height of the top surface per texel), so the statics, roads and trees reach the maps as well as the terrain. One finding from the fit: the shipped minimap draws tree canopies much lighter than the render (gain 1.6 / 1.44 / 2.8 against about 1.0 / 1.1 / 1.16 on bare land). The orthographic camera is set for that capture only (bf2_render::camera::set_ortho_view; Not retail, off for every other frame). Code: crates/bf2-editor/src/topdown.rs. Notes: notes/editor/api.md "Derived maps". Task H2471.

AI: a strategic area's second pair is its centre#

BF22142Heroes

In StrategicAreas.ai, aiStrategicArea.create <name> <x/z> <x/z> ... gives a corner and the centre of the box, not two corners (AIDLL_w32ded.dll!0x100e7e70; bf2-ai StrategicArea::is_inside_xz: the box is corner .. 2 x centre - corner; Karkand gpm_cq 32's 19/155 29/165 is a 20 m square around 29/165). The Heroes bots' rules (tools/bfheroes/bots_navmesh.py) wrote flag + 20 m as that pair, so their CTF boxes on heat sit 28 m off the flags; the editor's job centres them on the flags. The editor's Strategic areas panel edits the loaded layer's areas, neighbours, order positions and waypoints, and the navmesh job writes a level's bot files with the map (AI/AI.ai, Heroes' BotWeapons.ai and the layer's StrategicAreas.ai), so bots play a level made in the editor (scenario bfh_bots_editor_river_tdm). Code: crates/bf2-editor/src/strategic.rs, navmesh_ai.rs. Notes: notes/editor/api.md "AI strategic areas" and "Navigation mesh", notes/bfheroes/bots.md. Tasks H2406, H2497, H2395.

A mobile physics node turns a placed object into a spawner#

BF2

A template with a mobile physics node (physicsType Platform, for example) that is placed in StaticObjects.con without NetworkableInfo is not a static: the level load's convertDynamicObjects turns it into a spawner, and the object is missing from the round. The editor found this when a cloned gas station did not appear in PLAY (H2500); the Validation panel now flags such a placement and offers physicsType Mesh. Its second part also checks the rest of the 2005 wizards: a heavy tank's engine type (c_ETTank), player-turned rotational bundles without NetworkableInfo, and combat areas per team (H2480). Notes: notes/editor/api.md "Validation" and "Template authoring". Tasks H2480, H2500.

Gameplay objects as BF2 and 2142 ship them#

BF22142

The gameplay tools now make BF2 and 2142 objects the way their shipped files do. A control point gets its flagpole child (2142: its Nametag) and an explicit controlPointId, spawners carry one vehicle per team, and BF2's bases set timeToGetControl and timeToLoseControl 0 with unableToChangeTeam 1 (Heroes' bases use 9999). PLAY with a spawn point selected spawns there (+editorSpawnAt), and a control point's pin drags onto a spawn point's or spawner's to link them. Notes: notes/editor/api.md "Gameplay objects" and "PLAY". Tasks H2450, H2451, H2452.

Ambient objects, effects, animation and a test bench#

BF22142Heroes
  • Ambient objects (H2400, H2507): triggers, ambient effect areas and ambient sounds as AmbientObjects.con holds them, triggerables and their targets in Triggerables.con, each a new template run through the template host (the 2005 editor's CreateAmbientTrigger ... CreateTriggerableTarget); a triggerable's path can be scrubbed; a level's own ambient sounds are pins to move. Notes: notes/editor/api.md "Ambient objects and triggerables".
  • Effects and engine sounds (H2403): an effect player with pause and restart, the particle systems' curves, and the engine sound window. Notes: notes/editor/api.md "Effect previews".
  • Animation (H2405): every animation system the level's templates name (village: 169 on the 1.126 install) as a graph of triggers and bundles, and a bundle or .baf scrubbed on a kit with its bones drawn. Notes: notes/editor/api.md "Animation viewer".
  • Test bench (H2402): one vehicle on a flat copy of the open level with a water half (2.5 m above the sea level on one side, 5 m under it on the other), the player in it, and projectiles fired from the camera with a damage readout, in an in-page round (Not retail). Notes: notes/editor/api.md "Test bench".

Tasks H2400, H2507, H2403, H2405, H2402.

Editor workflow: sky camera, layers, mods in PLAY, history on the command line#

BF22142Heroes
  • Sky (H2487): the 2005 editor's Set Sun / Sunflare Direction From / To Camera; Heroes' flare direction is drawn as 2142's. Combat areas (H2453): every game mode layer's areas at once, and copy / paste between layers.
  • Mods (H2484, H2485): PLAY a mounted mod's level: the play page mounts the kept mod, and the round's server and client layer it; the object loader keeps the mod's scripts for the session.
  • History (H2494, H2496): bf2_editor --history, --diff and --revert over an overlay folder; a mod's URL, logo and menu music in its mod.desc. Notes: notes/editor/overlays.md "History and mod metadata".
  • Help, favourites, layers (H2491, H2492, H2493, H2467, H2468): enum values and ranges in the property help card, the asset star as a rebindable key, layer marks kept in the Preferences, collapsed scene groups that survive edits.

Notes: notes/editor/api.md, notes/editor/web.md. Tasks H2487, H2453, H2484, H2485, H2494, H2496, H2491, H2492, H2493, H2467, H2468.

2026-10-30, fourth publish#

The 2005 wizards become level-wide checks with one-click fixes#

BF22142Heroes

The 2005 Object Editor checked one object at a time with its wizards (Content/ObjectEditor/Wizards/<Car|General|Helicopter|Plane|Tank>/{Errors,Warnings}.con). The web editor's Validation panel runs the same kind of checks over the whole level at its first frame and again 0.3 s after each edit (about 2 ms on village; shipped village passes all of them). It finds a spawn point or spawner whose control point id names no control point, gameplay objects outside every combat area of the layer, a hitPoints above its maxHitPoints, and a spawned vehicle without a Camera, an EntryPoint or networkableInfo (the wizards' "Check Has Camera", "Check Has EntryPoint" and "Check PlayerControlObjects"). Each fix is one undo step, and the Camera fix writes the wizard's own resolution: a new <vehicle>_Camera template and its addTemplate line. Code: crates/bf2-editor/src/validate.rs. Notes: notes/editor/api.md "Validation". Task H2393 (with the layer groups of H2392 and the console of H2387, described in the earlier sections).

New templates written as the game's own CON lines#

BF22142Heroes

The 2005 Object Editor's template tools now exist in the web editor: clone a template with its children, add or remove children and components, change the type, copy settings from another template, and add a line. An authored template is just a type and its lines after ObjectTemplate., run through the level's template host at once, and saved into the overlay's Objects/<kind>/<name>/<name>.con the way the shipped scripts spell them. A new component comes with its properties' default lines from this wiki's CON reference (Armor: 38 lines, armor.maxHitPoints 10, ...), and the inspector's typed widgets (checkbox, enum, colour, number with a range) come from the same reference's argument types. The game loads a template once per level, so the editor rebuilds a changed template in its place (Not retail) to keep its rows and undo working. Code: crates/bf2-editor/src/authoring.rs. Notes: notes/editor/api.md "Template authoring". Task H2394.

The navigation mesh, generated and saved in the page#

BF22142Heroes

An AI navigation map is the pair Levels/<level>/AIPathFinding/<map>.qtr / .clb that the server loads after ai.init (AIPathfinding::loadQuadTrees, AIDLL_w32ded.dll!0x100a4530). The 2005 editor built them offline (GTS, NavMesh.exe, a clean-up by hand in Maya, FixNavmesh.bat), and Heroes ships none. The Navigation panel draws a level's maps over the ground (Karkand's Infantry: 10,045 polygons in 568 clusters) and generates one from the editor's collision world, sculpts and moved objects included, with bf2-ai's navgen (village: 6,061 polygons, 239 clusters, 0.4 s in the page). The save writes the .qtr / .clb into the overlay, where a round reads them like shipped ones. Code: crates/bf2-editor/src/navmesh.rs. Notes: notes/editor/api.md "Navigation mesh". Task H2395. The settings and the measured accuracy against the shipped BF2 and 2142 maps are on Navigation meshes (H2872).

Each level was baked with its own sky light settings#

Heroes

The 2005 generator's sky ring (see the second publish) now bakes the terrain's sky channel with each level's own settings, fitted from the shipped tiles because no shipped file keeps them (bake_sky::GI_LEVELS: ring and top intensity, skyWhite and the views' reach). The fits differ a lot between levels: lake has no ring at all (top light 0.65, skyWhite 0.64, 10 m views), and its tile's error drops from 24.59 to 2.10 / 255; heat's two tiles go from 10.15 and 10.62 to 8.44 and 7.15. A _night or _snow variant takes its day level's row. The statics keep the fitted SKY_FITS: no generator setting reproduces the village house. Notes: notes/editor/lighting.md "Per-level GI settings". Task H2447.

Heroes' seated emotes: the room test#

Heroes

The last test of Heroes' emote gate is a room test. Player vt+0x350 (BFHeroes.exe@bfh126!0x006eb0d4) looks the emote up in the player's emote list, and an emote item whose record has a meshRadius over 0 runs the soldier's room test (0x0078f9d7). The test casts 8 rays of that length, 0.5 m up from the soldier, 45 degrees apart, against the terrain and then against every object except the soldier's own vehicle (an IgnorePredicator of the control object's root, vtable 0x00f105c4), other soldiers included. Any hit blocks the animation. 1.126's Emotes.xml gives meshRadius 2.2 to the unicorn ride, the horse and the broom, so a seated unicorn plays only when 2.2 m around the hero are clear, for the emoter and for every observer. Every 1.126 seat starts in the chase view and the camera keys are unbound by default, so a retail player normally sees his own seated emote. Notes: notes/bfheroes/audio.md "Who sees it, in three clients". Tasks H2460, H2462.

A browser page must take its frame time from the animation frame#

BF22142Heroes

At a high refresh rate the web client's tank camera looked jittery in some browsers. Firefox and Safari report performance.now() in coarse steps, so a page that read the clock inside its frame added either 0 or 16.7 ms of game time per frame: the picture held, then jumped. The page's frame time is now the animation frame's own timestamp, latched once a frame (PageClock), and a coarse clock is smoothed so every frame adds its share (CoarseClock; Not retail). Code: crates/bf2-client/src/frame.rs. Proof: the scenario bfh_client_tank_camera_live110_coarse. Notes: notes/bfheroes/playability.md, row h4-r0085-tankcam. Task H2463.

The editor's PLAY needs one player to start a round without bots#

BF2

Since PLAY runs the loaded game mode layer, Karkand's 64-player conquest layer has no AI, and its round waited for sv.numPlayersNeededToStart (2) humans, so the spawn screen's DONE never spawned. A 16-player layer starts without humans because its AI loads (bf2-game round.rs WaitingForPlayers). With +editorSpawn the page's listen server now takes sv.numPlayersNeededToStart 1 (Not retail): alive 5.7 s after the spawn screen opened. Notes: notes/editor/api.md "PLAY". Task H2452.

Sky edits, mods and history in the editor#

BF22142Heroes
  • Sky (H2457, H2458): every Sky panel change is one undo step; a sun handle drags the sun in the viewport; the second cloud layer, the sun flare and your own presets join the 2005 editor's Day, Night and Cloudy. Notes: notes/editor/api.md "Sky, sun and water".
  • Mods that stay and load fast (H2454, H2455): a mounted mod is kept across reloads and game switches (the folder's handle, or a copy in the browser's storage up to 512 MB). Reads of a mod's files go in kept 1 MB pieces: a mod of Project Reality's shape loads its Karkand in 8.6-9.8 s instead of 29.3 s, and a mod's own Shaders_client.zip goes ahead of the game's. Notes: notes/editor/api.md "Mod packs".
  • Overlay history (H2407): every save is a snapshot (each file content stored once), with a per-file diff and a revert of one file or all of them; an overlay carries mod metadata (name, version, description, icon). Notes: notes/editor/overlays.md "History and mod metadata".
  • Property help and asset marks (H2399, H2408): every property name in the inspector and the graph opens this wiki's reference row as a tooltip (meaning, owners, per-game arguments and scope; built from the same xref.collect as the unified reference); the asset browser keeps favourites and recents, as the 2005 editor's resource bookmarks did. Notes: notes/editor/web.md "Property help", "Asset favourites and recents".

Tasks H2457, H2458, H2454, H2455, H2407, H2399, H2408.

2026-10-30, third publish#

Static lamps light only the light maps, and only objects in Heroes#

Heroes

A Heroes lamp post is two placed objects: the light_post_01 static and the light_post_glow_01 bundle. The bundle's .tweak adds three light_post_light bundles 3.5 m up, each holding the LightSource baselight_LightSource (lightType Point, isDynamic 0, castsStaticShadow 1, range 6 m, intensity 0.7, a warm colour). Light-mapped objects take such a static light only from their light maps: Heroes' RaShaderSTM.fx adds lightmap.r x singlePointColor (the level's Lightmanager.singlePointColor). In the shipped night levels with their own light maps, the statics near a lamp carry .r (royal_rumble: 50 of the 51 statics within 5 m are lit, none beyond 20 m), and the day levels' .r is 0. The ground gets no pool. Heroes' terrain shader reads only the tiles' .y and .z, and its live point-light pass takes dynamic lights only, so ruin's shipped tile is dark around its posts. The _night variants of lake, smack2 and seaside_skirmish ship no light maps of their own (they point at the day level's pages), so their posts light nothing baked in the original either.

The 2005 generator's lamp term: a point or spot light adds clamp(N.L) x clamp(1 - (d / range)^2) x Intensity x its view's read-back into the lamp channel (EditorRendDX9.dll@bf2editor!0x101b47eb..0x101b4844 draw the light in its colour with the casters black), clamped and written to .r.

  • bf2-rs: crates/bf2-editor/src/bake_lamps.rs (BakeRequest.lamps, on by default) finds every static lamp in the placed objects' template trees and gives each a 128-pixel shadow cube of the statics around it. The re-bake adds a moved lamp's reach at its old and new place, so moving a post re-bakes what it lit and what it lights now.
  • Measured on ruin's 12 receivers within 8 m of a post: lamp channel error 8.35 / 255 on average against the shipped pages; the trash bin beside a post is lit on 26.3 % of its texels (shipped 26.5 %). Not matched: the generator's exact light geometry (a cube map here).
  • Notes: notes/editor/lighting.md "Lamps". Task H2442.

What the 2005 editor's derived maps hold#

Heroes

Three files of a level are made from the rest of it, and the web editor now rewrites them when a sculpt or a paint stroke changes the ground. Each is a model fitted to Heroes' village, because the 2005 editor's renderer that made them is not in our data (Not retail in method):

  • groundhemi.dds (512 x 512 DXT1, set by hemiMapManager.setBaseHemiMap in Sky.con): the sun's visibility seen from above. Bundled and skinned meshes read it by their ground position (RaShaderBM calcGroundUVAndLerp); Heroes' rim-lit meshes multiply their sun by it when they are less than 3 m above the terrain. Model: the terrain light map's sun .y divided by the level's N.L curve (mean error 14.65 / 255).
  • Hud/Minimap/ingameMap.dds (512 x 512, the primary heightmap's square from above, north up): the colour map times the terrain shader's light (sun, sky and lamp channels), with a gain fitted to village (8.37 / 255).
  • The low-detail maps (256 x 256 DXT1 per patch): .b is detail layer 0's weight box-filtered from the detail map, .r is 1 - .b and .g is 0; this rule holds within 0.4 to 2.7 / 255 on village, lake and royal_rumble.

A save rewrites only the texels inside the ground the edits touched (file + model(now) - model(as loaded)), and keeps every other texel and DXT1 block byte for byte. The environment maps are not regenerated yet. Code: crates/bf2-editor/src/derived.rs. Notes: notes/editor/api.md "Derived maps". Task H2397.

The editor's console runs the engine's own commands#

BF22142Heroes

The Console panel's input line runs a typed line in the page's engine and says what it did. renderer.draw* and the renderer's debug setters change the view only. ObjectTemplate.<property> on the active template, Object.create, absolutePosition, rotation and delete become undo steps like any panel edit. Any other command the game's tables know is kept, and the save writes the kept lines as a block at the end of the level's Init.con in the overlay, so the level's scripts run them at the next load and in the game, on the server and the clients. run <file> runs a script of the level (without its control flow). Completion comes from this wiki's name index: the properties and commands the game has, each linked to its reference row. Code: crates/bf2-editor/src/console.rs. Notes: notes/editor/api.md "Console". Task H2387 (the layer groups of H2392 are in the second publish's editor panels).

2026-10-30, second publish#

The 2005 editor's light maps: a ring of sky lights around the sun#

BF22142Heroes

DICE's 2005 BF2 Editor made the shipped light maps of all three games. Its generator lives in EditorRendDX9.dll (LightmapGeneration.cpp, MeshLightSampling.cpp, StaticMeshLightmapGeneration.cpp); EditorEngine.dll's LightmapManager only holds the settings and starts lightmapGeneration.traceAllObjects / traceTerrain.

  • Casters are drawn black. StaticMesh_lightmapgen.fx / BundledMesh_lightmapgen.fx (technique lightmapGeneration, no back-face culling, depth on) draw every caster pure black into the light's view; alpha-tested materials pass on the base map's alpha with AlphaRef 50 (GREATER), so leaves cast leaf-shaped shadows.
  • Each light is a small view per sample (the block loop, EditorRendDX9.dll@bf2editor!0x101b24f0, H2409). One 1024 x 1024 target is cleared white; every sample of a block (points from the .samples files in bf2editor\LightmapSamples0N.zip) gets a 16 x 16 viewport in it, 4,096 per block. Per light the camera stands at the sample moved 2 cm along its normal and looks toward the light with the light's cone and reach; the casters are drawn black, and the share of white left in the 256 pixels is the light's cover. A light's shadow softness is therefore its cone over 256 pixels. The sun is one light with a 2 degree cone (sunLightFov: a soft sun). The sky ("GI") is a ring of numberOfGILights lights from GILightsBaseDir, turned about the vertical by heading + (i + 1) * 360 / (n + 1) degrees: placed by the sun's heading, with the sun's own slot left out (light setup EditorRendDX9.dll@bf2editor!0x101b0680, the heading 0x101b0370), plus a top light from straight above of GITopLightIntensity. The terrain casts only for the lights that are not sky lights (with renderTerrain).
  • The sum and the encode. Each light adds cover x (N.L + Softness) / (1 + Softness) x Intensity (0x101b5009; Softness wraps N.L, it is not a blur). Lamps go into .r, the sun into .g, the sky ring and top light into the sky term, each clamped to 0..1, and the sky is lifted by skyWhite: sky + (1 - sky) x skyWhite. The statics' sun channel carries no N.L (a flag makes it 1 above N.L 0.1). The values are truncated to bytes without gamma (0x103b5740), the sky moved into .b, then DXT1.
  • The defaults (bf2editor\Content\Light\DefaultLight.con, the Day preset): 8 sky lights from 0/0.33/-0.66 (26.6 degrees up), intensity 0.33, cone 45 degrees, reach 10 m, top light 0.1, skyWhite 0.3, sun cone 2 degrees at intensity 1. Cloudy / Night use 6 / 8 lights at 100 degrees, intensity 0.5, top light 0.25.
  • Why bf2-rs keeps per-level fits. A level keeps its own settings in its Sky.con inside if v_arg1 == BF2Editor, and no shipped BF2, 2142 or Heroes level has those lines (every .con of every level archive searched). The per-level parameters behind the different terrain shading curves are therefore not in the data. With the whole recipe the Day preset reproduces only woodlands' sky (all open sky) and Lunar's terrain sun (a plain N.L); the generator's own settings fitted per level reproduce the others with values no preset has (lake: no ring at all, top light 0.65, skyWhite 0.64). Each level was baked with its own settings, so the editor's bake keeps its curves fitted per level (TERRAIN_CURVES, SKY_FITS) and offers the generator with the Day preset as a recipe for new levels (BakeRequest.recipe).

Code: crates/bf2-editor bake_sky (editor, editor_gi_lights, SkyMaps::editor_sky; tests editor_ring_follows_the_sun, bake_bfheroes::editor_recipe_against_the_shipped_pages). The editor's own tools are listed in the BF2Editor inventory. Notes: notes/editor/lighting.md "The 2005 generator" and "The generator's block loop". Tasks H2368, H2409.

Heroes resolves its antialiased frames in linear light#

Heroes

The faint near tree leaves of H2332 came out darker and greener than the original's. Their colours were not the cause: the retail rig's record of the near SpriteLeaf draw has the same constants (OverGrowthAmbient (0.42, 0.43, 0.11), OverGrowthShadow (0.42, 0.38, 0.11)) and the same shader, without blending. The cause was the resolve. NVIDIA's and ATI's drivers average a multisampled back buffer in linear light by default, so a half-covered pixel is the gamma-correct mean of its samples. For example, sky (28, 85, 119) plus leaf (17, 29, 0), half each, gives (23, 65, 87) as a gamma 2.2 mean, (24, 63, 83) in the original's frame, and (23, 57, 60) as a plain mean.

  • bf2-rs: crates/bf2-render/src/enhance/quality.rs MsaaTargets::resolve draws the gamma-correct mean on Heroes' scene format (GAMMA_RESOLVE_WGSL: each sample to linear light, the mean, back), natively and in the browser. BF2, 2142 and the remaster's float scene keep the hardware resolve; they have not been compared with their originals yet.
  • Proof: sky hue under a village tree crown is 50.0 % in the original, was 22.8 % and is now 51.1 % (bfh_client_tree_near_fade). Notes: notes/bfheroes/render.md "The gamma-correct resolve". Task H2354.

BF2: one object's oversized dirty mask starved the player's ghost#

BF2

Gate run bfh86 on the live build's commit failed six BF2 scenarios that the previous gate had passed: their scripted player never spawned, and the server logged no spawn at all. The cause was a one-character change. H2260 had widened DestroyableRecord::state's dirty mask from mask & 3 to mask & 7 for every game, but BF2's DestroyableObject ghost layout has a 2-bit mask (2142 and Heroes have 3 bits). A new connection's full update sets every bit; cut to 7, it no longer fit the 2-bit field, so writing the state failed and the server had no state for those objects ("ghost source has no state", 42,770 times in one run).

The chain is the learning. Those ghosts stayed in the ghost manager's heap with their masks set and the highest accumulated priority, so they took each packet's entry budget. The player's own ghost was then not written after its first seconds (54 updates reached the client, against 1,510 in a passing run), the team change never reached the client's map, and the scripted spawn click never ran. One object that cannot be written can starve every other ghost. The Heroes checks missed it because Heroes scenarios spawn automatically.

  • Fix: crates/bf2-net/src/netrecord.rs DestroyableRecord::state cuts the mask to the layout's width (BF2 2 bits, 2142 / Heroes 3); test bf2_destroyable_state_from_a_full_mask. The six scenarios pass again. Task H2411.
  • Background: ghosts, events and data blocks.

Heroes' soldier physics has 2142's layout, not BF2's#

Heroes

The Rust soldier physics was a transcription of BF2's. Heroes' SoldierResponsePhysics has 2142's layout, one byte shorter: +0xf9 is the on-ground byte and +0xfa the swimming byte, with no was-on-ground byte. In BF2 +0xf9 is was_on_ground, the previous tick's value, one tick late. Its reset (BFHeroes.exe@bfh126!0x00963da0) clears the flag without BF2's copy, so the Heroes code that reads +0xf9 reads the current on-ground state. That code is the off-ground refusal of isSelectable on the server and in prediction, and the skydive sound.

Heroes also has its own arithmetic. addFriction (0x00963f17) computes its limits at run time (g / 30) and uses its own projection (0x0072db72). testIfValidTransformation (0x009670cd) sums the sphere height as (i spacing + (r - pivot)) + y. The node reset (0x0096ab60) keeps the mesh tangent speed, and addFrictionAtAbsolutePosition (0x0096abfa) stores every step as a float. Its animation system posts STNoSound for every stopped bundle that has a sound (0x00b0ad58, 0x00b0b1e5).

  • Code: crates/bf2-physics soldier.rs (SoldierResponse::reset_in, add_friction_in, SoldierNode::reset_in), soldier_mesh.rs (heroes_sphere_y_p), crates/bf2-anim runtime.rs; the readers moved to on_ground in bf2-server players_input.rs and bf2-client predict.rs. Notes: notes/bfheroes/parity_burndown.md "Soldier physics and animation system follow-ups". Task H2351.

Heroes' sky dome sits at the level's domeOffset#

Heroes

Village's open sky was brighter than the original's at the same pixel, with the same gradient about 135 rows lower on the screen: the dome sat too high. The shader was not the cause. The original's sky matrix carries a translation of -110 in y, which is village's Skydome.domeOffset -110, a command BF2 does not have and our client dropped as unknown. Heroes' RendDX9.dll registers skyDome.domeOffset, domeScale and domeMaxOffset. The domeOffset handler (RendDX9.dll@bfh126!0x100ff1a3, set path 0x100ff1c8) stores the float at SkyDome +0x14, the y of the dome's position, and the dome's world matrix takes that position as its translation. 24 retail levels set it (village -110, royal_rumble_day -175, seaside_skirmish 210, most others 0).

  • bf2-rs: LevelSettings::set_dome_offset moves the dome; the client resolves the command (DOME_OFFSET_BFH_ID, bf2-client commands.rs). Village's open sky at the 15 m eye is now within 5 levels of the original's on 98 % of its pixels (before: none). domeScale and domeMaxOffset (only seaside_skirmish sets them) are not applied yet.
  • Notes: notes/bfheroes/render.md "The sky dome's offset". Task H2424.

Heroes' emote gate has no vehicle-seat test#

Heroes

Game::playbackRadioMessage (BFHeroes.exe@bfh126!0x0045e670) always plays an emote's voice line, but plays its animation only when the sender's soldier passes a gate (0x0078f0dc). The gate checks: a trigger is set, the view is third person, the soldier is not sprinting or prone, the held item is not a firearm whose template sets allowEmoteAnimation 0, no victim control is active, and the emote has an animation entry. It does not test for a vehicle seat. On an observer's client another player's soldier is always in the third-person view (Soldier::handleUpdate 0x0072069b asserts it), so his emote plays in his seat. The local player's own view is first person in a seat with an inside camera, so his own emote is blocked there and plays in a seat with a chase camera. 2142's counterpart (BF2142.exe!0x005edbf0) has the same tests without the last two.

  • bf2-rs: while seated, the local player was mapped to the vehicle, so his own emote never reached the gate. Heroes now maps him to his kit soldier while seated (sound_world soldier_of, ClientGame::emote_gate). The victim-control and animation-entry tests are still open.
  • Notes: notes/bfheroes/audio.md "The seated emote's animation". Task H2438.

The original draws the chase camera from the blended vehicle#

Heroes

Players reported a jittery tank camera at about 110 frames a second. The original's frame (updateFrame, BFHeroes.exe@bfh126!0x00425779) runs the interpolator (0x00497dda) that blends the objects between the 30 Hz ticks, then the game's frame update and the render, and then restores (0x004981cb). The chase camera is computed from the blended vehicle, so it moves on every drawn frame, not on every tick. bf2-rs uses the same order. With a native 110 Hz clock, the drawn hull and the camera move on every frame (the camera's speed stays within 0.94 to 1.05 of its running median for 90 % of the frames) and the yaw turns on every frame.

  • Proof: the scenario bfh_client_tank_camera_live110. Still open: the browser page, which reads its frame clock inside the frame and can present a frame one or two refreshes late when it runs below the display's rate.
  • Notes: notes/bfheroes/playability.md, row h4-r0085-tankcam. Task H2443.

2142 Titan: the camera's position decides which interior parts are drawn#

2142

A soldier spawning at the EU Titan's stairwell landed on a landing where the view went black. The spawn room wall he stood against is an interior part, and his eye was outside the core room's hull (the hull drops from y 3.0 to 1.0-1.5 over the stairwell's notch). The original hides every interior part while the camera is outside (StaticMesh::update, RendDX9.dll@2142!0x100bdb00, and the component walk). It decides "inside" from the camera position: BF2142.exe!0x006fa8b0 would use the soldier's enclosing object only when the byte at 0x00a88e98 is 1, and its static initialiser (0x008ef730) sets it to 0 and no code writes it again. So the black frame follows the original's rule; one step into the spawn room, the room is drawn and lit. Not settled: the original's own frame on that landing (the retail rig had no display).

  • Notes: notes/bf2142/titan.md "H2421 / H2422". Task H2421.

The editor writes the level's own files#

BF22142Heroes

New panels of the web editor. Each one writes the retail files in their own layout through the overlay:

  • Gameplay (H2384): control points, spawn points and spawners as the shipped GamePlayObjects.con holds them. Each object gets its own template and one Object.create. Control points and spawners are placed inside if v_arg1 == host, spawn points are not, and links go through setControlPointId.
  • Combat areas (H2383, H2453): the CombatArea blocks of the loaded layer's GamePlayObjects.con; PLAY plays that layer. Every other game mode layer's areas can be drawn beside them in its own tint, and an area copied from one layer pastes into another (written into that layer's file).
  • Layers (H2392, H2449): the files' Object.layer lines become scene groups with an eye and a lock. A move rewrites only that line (bf2-con ConDoc::set_placement_line keeps every other byte).
  • Level settings (H2385): edits Init.con in place: team names, languages and flags, kits, tickets per layer size, ticket loss, the camera before spawn and the view distance.
  • Sky (H2386, H2437, H2457, H2458): the sun, light colours, fog, sky dome, both cloud layers, the sun flare and water, live, with the 2005 editor's Day, Night and Cloudy presets and your own; a sun handle to drag in the viewport; each change one undo step; saved to Sky.con and Water.con.
  • Terrain maps (H2356): every 2D map the terrain is built from, shown on the ground by swapping the patches' colour map texture (no new render pass).
  • Mods (H2371, H2375, H2440): a BF2 mod you own, mounted above the base game the way the game does it. Its folder goes first in the search paths, and its ServerArchives.con / ClientArchives.con lines mount its archives ahead of the base game's. See Mods in the editor.

The BF2Editor inventory shows their status against the 2005 editor. Tasks H2383, H2384, H2385, H2386, H2392, H2356, H2371.

The 2005 BF2 Editor, tool by tool#

BF22142Heroes

The BF2Editor inventory lists every tool of the original editor against what bf2.us/editor has today, which task plans it, and what we do better. It covers the shell and camera, terrain, object placement, gameplay objects, the Object Editor, lighting, materials, animation, AI and navigation meshes, the Maya pipeline, level and mod settings, and the console. It was read from the install's help files, its command sheet (107 commands, 624 tweaker properties) and the string tables of the editor and its ten plug-ins, and it ends with the missing tools in priority order. Task H2369.

2026-10-30, first publish#

A land detail layer stops 3 m under the sea (terrain compiler)#

Heroes

The original terrain compiler keeps a land detail layer on a triangle when the layer's detail weight there is above 0 and the triangle's highest vertex is at most 3 m under the sea level (inclusive: hi >= sea - 3 in 32-bit floats). Measured on every Battlefield Heroes level: no shipped land-layer triangle lies deeper; at exactly 3.0000 m every weighted triangle is in (village 29, lake 38, heat 13) and one raw height step deeper every one is out. The seas of those levels lie at 6 to 99 m with different Water.con settings and no level file carries the number, so it is a constant of the compiler. bf2-rs had 2 m with a strict >: that is why 333 of village's 22,305 triangles between 2 and 4 m under the sea disagreed.

The shipped files still hold about 9 % more land triangles than the rule rebuilds from the shipped detail maps, most likely faint brush-edge weights that the 5-bit / DXT1 maps round to 0 (inferred). The BF2 and 2142 levels were not measured; bf2-rs's terrain code is shared.

Update (H2950): the editor's own compile is now ported (TerrainEditable, RendDX9.dll!0x1010baa0; the Heroes writer RendDX9.dll@bfh126!0x1015fc63). A cell carries a land layer when any byte of the layer's 8-bit map in the cell's texels plus a margin (1 texel in BF2, 2 in 2142 and Heroes) is above 0; the cells go row by row, two triangles each, and the block is then sorted in place into the 85-node index tree (RendDX9.dll!0x101bb910). The same routine saves the detail maps after compiling, 5-bit / DXT1 and some at half size, which confirms the inference above: the weights the blocks were compiled from do not ship. Each patch's own cell decisions are read back from its blocks, and only cells the painter changed are decided from the maps again. With that, every patch of village, Strike_at_Karkand and Night_Flight compiles to its shipped terraindata.raw byte for byte, and so does a patch the web editor paints over with its own weights.

  • Code: crates/bf2-terrain/src/layers.rs (LAND_DEPTH, compile_blocks, FileCells, cell_decision); proof crates/bf2-terrain/tests/retail_layers.rs (village, Strike_at_Karkand and Night_Flight compiled to their shipped files), the editor gate tools/web/editor_checks/parity_terrain_layers.py.
  • Format: Terrain, level formats. Tasks H2269, H2950.

Near tree leaves fade out through alpha-to-coverage, two samples#

Heroes

The leaf crowns' shader RaShaderSpriteLeaf.fx gives each sprite the alpha 2 min(texture a, d / 25), d the distance from the sprite's centre to ObjectSpaceCamPos (the camera, StaticMesh vertex slot 6, RendDX9.dll@bfh126!0x100f9012), and its pass sets Alpha2Mask = 1 with AlphaRef 127. The High antialiasing preset ("2Samples", RendDX9.dll@bfh126!0x1002ab12) gives the device NVIDIA's ATOC alpha-to-mask value (0x1002456d), which the state cache (0x1004d2e6) turns on for that pass. The driver's 2-sample coverage then takes the place of the alpha test: sample 0 from alpha 0.25 (3.1 m for an opaque texel), sample 1 from 0.75 (9.4 m), resolved together. Close to a tree the crown stays as faint half-covered leaves over the sky instead of a solid wall.

  • bf2-rs: crates/bf2-shaders/src/wgsl.rs d3d_coverage covers half of the samples from alpha 0.25 and all of them from 0.75. It used to keep only the second sample, so every leaf went from solid to gone at 9.4 m. The same WGSL runs natively and in the browser.
  • Proof: the scenario bfh_client_tree_near_fade measures the sky seen through the crown 2 m and 4 m from a village leaf tree against the original's frames (2 m: 51.3 % original, 50.9 % ours); the bright open sky that showed through the cut-out crown before (50.9 % of the pixels) is gone (0.1 %; original 7.9 %). Notes: notes/bfheroes/render.md. Task H2332.

Terrain colour passes need a depth tolerance on Apple GPUs#

BF22142Heroes

Refractor draws the terrain as a depth pass (ZFillLightmap) followed by colour passes (the FullDetail layers, LowDiffuse, underWater) that test LESSEQUAL without writing depth, so it relies on both passes computing bit-identical positions. On a MacBook (Metal, through Chrome) the colour passes failed that test at object footprints, where the geomorph moves vertices: black holes that flicker as the camera moves. The likely cause is Metal's shader compilers rounding the two passes' position math differently (FullDetail also feeds the morphed height into its texture coordinates); it is inferred, no Apple hardware was available.

  • Fix (not retail: Direct3D 9 on Windows needs no tolerance): the terrain's colour passes set a depth bias of -16 / 2^24 (crates/bf2-render/src/terrain/mod.rs color_depth_slack), about 16 steps of Metal's 32-bit float depth and far below the roads' -168, so nothing drawn on the terrain loses its tie. BF2R_TERRAIN_SLACK overrides it.
  • Proof on substitutes: crates/bf2-editor/tests/terrain_holes_bf2.rs (Karkand, 784 views, 0 holes) and the editor's terrain_holes check on SwiftShader; the render harness is unchanged but for one road pixel by 1 / 255. A Mac run is the real proof. Notes: notes/subsystems/renderer.md "Terrain pass coverage". Task H2333.

Trees and terrain shade the houses' lightmaps too#

Heroes

In the shipped village light maps the tree canopies and the hills shade the statics (house walls and roofs), not only the ground. The editor's sun bake now rasterises the foliage (LOD 1, alpha-tested leaves) into both depth layers, and the terrain counts for an object only where it stands 3 m or more in front of it along the sun (TERRAIN_ON_OBJECTS in crates/bf2-editor/src/bake_sun.rs; closer, the ground a house stands in would shade its base). Over village's 62 houses the sun channel's error on texels lit in either bake went from 34.7 to 26.1 / 255.

The canopy outlines are not solved: no shadow proxy built from LOD 1's leaves (hulls, closings, openings, blobs) gets under 20.5 % disagreement with the shipped round canopy shadows, which come from something in the 2005 editor's light map generator that is not in the game data. Reverse-engineering that generator is in progress (H2368). Notes: notes/editor/lighting.md "Trees and terrain on the statics". Tasks H2334, H2303.

Sources: the registry rows named in each entry and the notes they cite. Written by hand; one dated section per publish.

How it is tested#

Each entry here is a fault that was found and mended, and names the task it came from. The test that holds an entry is the one its mend brought: most of the addresses this page cites stand in the text of a test of the crates it names. The wiki's own test checks only the page's form: that every entry names its task. An entry without a test of its own says how it was found (a played scenario, a comparison with the original server).

In the code#

The crates this page names, each with its line of docs/release/LAYOUT.md (the list is gathered by the wiki's build from the page itself):

CrateWhat it is
crates/bf2-editorPROGRAM bf2_editor: the web editor's engine host (wasm for the page, native for tests)
crates/bf2-physicsphysics: collision queries, materials, rigid-body integration
crates/bf2-clientthe client's engine assembly as a library: boot, console, profiles, movies, join, level load, frame loop
crates/bf2-netthe wire-compatible network protocol
crates/bf2-renderthe wgpu renderer
crates/bf2-terrainterrain and level data formats
crates/bf2-animskeletons, bone animations and the animation system
crates/bf2-gameplaythe behaviour of gameplay objects: weapons, projectiles, soldiers, vehicles

Files this page names: crates/bf2-gameplay/src/vehicle/curve.rs, crates/bf2-physics/src/vehicle_friction.rs, crates/bf2-physics/src/vecmath.rs, crates/bf2-physics/src/fpu.rs, crates/bf2-physics/src/node.rs, crates/bf2-net/src/ghostmgr.rs, crates/bf2-net/src/join.rs, crates/bf2-editor/src/materials.rs.

Source: docs/dev/engine/learnings.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.