BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
Battlefield 2142
On this page

Battlefield 2142's HUD: what it shares and what is its own

2142

2142's HUD is Battlefield 2's machine with new parts. The node tree, the builder's script commands and the variable layer are the same; the functions that write the variables were rewritten where the game changed: the weapon panel, the crosshair, the Titans, the item bar. Battlefield Heroes was built from 2142, so several of 2142's writers run in Heroes too.

Battlefield 2142's HUD: the screen, and who writes what (BF2142.exe) chat and kill messages the same two chat managers tickets, or the Titans' state strategic_objects_2142 the minimap Bf2MenuMapNode 0x00793b60 icons capture bar; missile silos CpInterface2142, cannon_row_2142 the watched player's name spectator HUD 0x00752050 health: a percent bottom_left (Battlefield 2's form) vehicle armor: a percent vehicle_armor_2142 0x007a18a0 the item bar weapon icons, unlocks, gadgets crosshair parts updateCrosshairPositions 0x007be770 ammunition, reload, heat updatePrimaryWeapon 0x007c1f10 The same node tree and variable layer as Battlefield 2, with its own writers; Heroes runs several of them.
The same screen as Battlefield 2's, with 2142's writers.

What is the same#

Everything on Battlefield 2's HUD page about how the HUD is built holds: BF2HudManager::init (BF2142.exe!0x0075cfa0) makes the menu system, the builder and the sub-managers, loads the node file and runs the HUD scripts; the variables are registered by name in the same layer; the map node draws the minimap, the spawn screen's map and the commander's map; two chat managers fill the chat and kill lists.

What is 2142's own#

Part2142Ours
the weapon panelupdatePrimaryWeapon (0x007c1f10): the rounds as %i, empty with endless ammunition, not written while a reload runs; the ammunition bar; the reload bar shown strictly between 0 and 1; a heat barhud_writers.rs primary_weapon_2142, primary_ammo_2142
the fire rate iconits own show flag and picture path (0x007be640)primary_weapon_2142
the crosshairits parts placed by updateCrosshairPositions (0x007be770)crosshair_positions
a vehicle's armorthe bar is the ratio; the number is a percent (0x007a18a0)hud_vehicle.rs vehicle_armor_2142
the capture interface2142's form of the two capture bars and the lock linehud_live.rs CpInterface2142
the watched player's namethe spectator HUD (0x00752050)spectator_hud.rs
the map's icons2142's object icons (0x00793b60) and icon colours for its own screenscrates/bf2-hud render/map.rs

The Titans#

In Titan mode the top of the screen shows the two Titans instead of plain tickets: each Titan's strategic objects with their state, and the row of missile silos. The writers are strategic_objects_2142, object_destroyed_2142, cannon_row_2142 and titan_mode_2142 in hud_live.rs; the mode's number for the HUD's script is game_mode_index_2142 (game modes).

What Heroes took from it#

Heroes runs 2142's arm for the ammunition (primary_ammo_2142), the capture interface (CpInterface2142) and the vehicle's armor bar, and has its own writers for what it changed: the health number in hit points, the item bar, the level arc (the Heroes HUD). Where a Heroes row of the sweep says "2142's arm, which Heroes runs", this page's function is the one meant.

What the port still lacks#

The 2142 HUD is the youngest of the three in the port. A list of its functions without a Rust counterpart is kept and worked down (notes/bf2142/hud-missing.md): from 69 addresses it went to 35 in five slices, and further since. What is left is mostly small: constructors and destructors of HUD classes, a few console methods of the commander's comm rose, parts of the bar node's marks, and front-end glue that the in-game HUD does not use. The health number's own 2142 twin was not read: a 2142 process keeps Battlefield 2's statements for it.

How a row of that list is read

Each function was read in the decompilation, and in the disassembly wherever a compare, a rounding or the order of arguments mattered. A row says what the function does, its Battlefield 2 twin when it has one, and what blocks the port: usually that the class was not identified, or that nothing of ours would call it yet.

How it is tested#

  • The weapon panel's writers (crates/bf2-client/src/hud_writers.rs): 2142's rockets, the clip string per game, the crosshair when zoomed.
  • On the game's own HUD scripts: the Titan HUD's silo row and destroyed parts (hud_titan_2142.rs), the commander's Titan move line on the map (map_titan_line_2142.rs), the commander's target screens, the comm rose's nine nodes.
  • Each in a 2142 process: the game is a process-wide setting, so every such program sets it first and tests nothing else.

All seven addresses of this page stand in a test's text. What the page lists under "still lacks" has none.

In the code#

WhatWhere
the shared HUDcrates/bf2-hud
2142's writerscrates/bf2-client/src/ (hud_writers.rs, hud_live.rs, hud_vehicle.rs, spectator_hud.rs)
what is missingnotes/bf2142/hud-missing.md

Notes: notes/subsystems/hud.md, notes/bf2142/hud-missing.md, notes/bf2142/titan.md.

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