Skip to content

107 worked example the radar ping

Alex Diakovsky edited this page Sep 28, 2026 · 2 revisions

107. Worked example: the radar's ping

Question: issue #32's footage comparison (document 103) caught the radar filling with a smooth red-to-yellow gradient during a busy fight — nothing the port draws. Document 68 already found the 16 cels behind it and document 71 corrected an early misreading (they aren't the Jeep's direction arrow), but neither ever traced the trigger precisely enough to build it, and the port's radar has never drawn anything but the map and the flag's blip. Scripts and field names are in the tracing cheat sheet.

Step 1: the trigger reuses a field already traced

FUN_004122d0, the kind-6 radar element's draw callback (document 68), ends with this block (DecompileMany.java 0x4122d0 0x412790):

if (**(int **)(iVar4 + 0x14) == 1) {                              // the tracked object's class is 1 (a vehicle) -- always true, it is always the panel's own vehicle
    iVar5 = DAT_00480d38 - *(int *)(*(int *)(iVar4 + 0x60) + 0x4c);   // now - state+0x4c
    if ((-10 < iVar5) && (iVar5 < 0x40)) {
        uVar7 = FUN_00410b70(*(int *)(*(int *)(iVar4 + 0x60) + 0x20), *(int *)(param_2 + 0x14));
        iVar5 = 0xf - ((int)uVar7 >> 0x10);
        if (iVar5 < 0) iVar5 = 0;  if (0xf < iVar5) iVar5 = 0xf;
        iVar5 = FUN_00413c90((uint *)(iVar5 * 0x44 + DAT_0044964c + 0x2052c));   // celtable + 0x2052c = cel 1947 (0x2052c / 0x44 = 1947)
        // ... placed to exactly fill the window, see step 3
    }
}

state+0x4c is document 47/59's "hit until" deadline: FUN_0040c460, the hit callback, sets it to now + 10 on every successful hit (piVar1[0x13] = DAT_00480d38 + 10, 0x13 * 4 = 0x4c). So now - state+0x4c starts at -10 the instant a hit lands and crosses 0 ten ticks later (when the hit flash itself ends); the ping's own window, -10 < iVar5 < 0x40 (64), therefore covers every tick from the hit itself through 74 ticks later — the hit flash's own 10 ticks, then 64 more. Nothing about "is this a Jeep" survives this reading: **(iVar4+0x14) == 1 just confirms the tracked object is a vehicle at all, which it always is (a panel only ever tracks its own vehicle) — document 68's "if the tracked object is a Jeep" was this same misreading document 71 already flagged for the cel identity; it turns out to have been wrong about the class test too, not only about what the cels show.

The 16 cels: rendering them directly from ART.CAR (a straight per-pixel decode through the shared PLUT, since all sixteen are ordinary PRE0 == 0 sprites) shows exactly a growing ring animation, confirming document 71's correction independently — frame 0 a single lit pixel, growing steadily into a solid yellow ring by around frame 8, then a red halo joining outside it for the last four or five frames (packs/original_pc/sprites/effect/shockwave_ring_tan/*.png, shockwave_ring_orange/*.png).

Two of the sixteen (1947, 1948, the two smallest frames) were misclassified in the registry as prop.ammo_crate_olive.06 and decoration.camo_swatch.123 — corrected to effect.shockwave_ring_tan.00a/.00b to match the other fourteen, already (correctly) named effect.shockwave_ring_tan.01-.10 and effect.shockwave_ring_orange.01-.04.

Step 2: what the footage actually shows

Given the trigger, the busy-fight frame from document 103 is one ping, near its largest frame, for the panel's own vehicle — not several overlapping pings from nearby vehicles. Nothing in FUN_004122d0 reads any object but the tracked one; a panel has no way to show anyone else's ping. The "smooth gradient filling the whole radar" is simply frame 15 (or close to it) at video compression and scale: the yellow ring plus red halo, at its biggest, covers almost the entire 32 x 32 window.

Step 3: the ring exactly fills the window

The placement math confirms this directly:

*(int *)(iVar5 + 0x10) = (*(int *)(iVar1 + 0xc) - *(int *)(iVar5 + 0x3c)) * 0x8000 + panelX + iVar1+4;
*(int *)(iVar5 + 0x14) = (*(int *)(iVar1 + 0x10) - *(int *)(iVar5 + 0x40)) * 0x8000 + panelY + iVar1+8;

iVar1+0xc/+0x10 are the radar window's own width/height (32, 32, document 68); iVar5+0x3c/+0x40 are the chosen cel's own width/height — also 32 x 32 for every one of these sixteen. The difference is always 0, so the ring is drawn flush with the window's own corner, at its own native size: it doesn't sit centred as a small icon, it is the window, exactly the size document 103's footage frame shows.

What's still open: the growth curve

The frame index comes from FUN_00410b70(state+0x20, param_2+0x14), and FUN_00410b70 is nothing more than a 16.16 fixed-point multiply (DecompileMany.java 0x410b70: (param_1 * param_2) >> 16, confirmed, not a heading function despite document 68's original guess). state+0x20 is written in the same hit handler, FUN_0040c460 (piVar1[8] = piVar1[8] - (param_3 - piVar1[7]), 8*4=0x20), but as part of what reads like a hit-debounce or count field (piVar1[7] at +0x1c, compared against the current tick to reject a repeat hit within the same tick) — not confirmed to be a clean, monotonically-changing elapsed-time fraction the way the trigger's own state+0x4c is. Untangling +0x1c/+0x20's full role (they don't appear in the tracing cheat sheet's state-field table yet) would need its own pass; this session's time went to the trigger and the cel identity instead.

Port choice, not traced: the 16 frames are spread evenly across the confirmed 74-tick window (tools/data/radar.json's "ping"."window_ticks") rather than through the untraced state+0x20 curve. The trigger (whether and for how long a ping shows) is traced; only the exact shape of its growth is a stand-in.

Applied in the port

The player's own hit is tracked in MatchController, not Vehicle, since take_damage()'s two callers already know the exact moment a hit registers:

# game/match_controller.gd
var _player_hit_at_ms := -1.0e9

func _register_hit(v: Vehicle) -> void:
	if v == vehicle:
		_player_hit_at_ms = Time.get_ticks_msec()

func radar_ping_frame() -> int:
	var rd: Dictionary = pack.radar_data.get("ping", {})
	if rd.is_empty():
		return -1
	var window: float = float(rd["window_ticks"])
	var ticks := (Time.get_ticks_msec() - _player_hit_at_ms) / 1000.0 * Vehicle.TICK_HZ
	if ticks < 0.0 or ticks >= window:
		return -1
	return clampi(int(ticks / window * rd["sprite_ids"].size()), 0, rd["sprite_ids"].size() - 1)
# both take_damage() call sites, box damage and shell hits:
if Collision.polygon_hits_box(v.hit_polygon(), b.position, b.box()):
	if v.take_damage(dmg):
		_register_hit(v)
...
if Collision.segment_hits_polygon(from, to, v.hit_polygon()):
	if v.take_damage(p.damage):
		_register_hit(v)
	impact_effect.emit("0x444b68", to)

game/radar_view.gd adds a TextureRect sized exactly to the radar window (matching step 3's zero offset), shown while radar_ping_frame() >= 0. tools/extract_radar.py now writes "ping": {"cels": [1947..1962], "window_ticks": 74} into radar.json; build_pack.py resolves the cels to sprite ids the same way the panel's base cels already are.

tools/tests/radar_ping_check.gd (13 checks): no ping before any hit; frame 0 right at the hit; about the midpoint frame halfway through the window; the last frame near the window's end; no ping once it closes; a hit on a different vehicle doesn't start the player's ping; armour blocking a hit outright doesn't either; RadarView builds and correctly sizes the overlay; two different frames resolve to two different, real atlas regions. A screenshot (RF_DEBUG_PING=<ticks>, new) at 5 and 35 ticks shows a small red dot growing into the same red-orange-yellow gradient document 103's footage frame shows.

Still not drawn (issue #17): the grid overlay (cel 1963) and the corner-bracket cursor (cel 1964).

Addendum: a lead on the growth curve, not a trace

Kind 6's own init, FUN_00412170 (DisasmForce.java 0x412170 0x4121a0, since Ghidra's decompiler mis-typed its call to FUN_00410c10 as taking no arguments when the raw disassembly clearly pushes two), sets slot+0x14 once, at panel creation, to FUN_00410c10(state+0x20, 0x100000). FUN_00410c10 turns out to be a fixed-point divide (DisasmForce.java 0x410c10 0x410c50: FILD/FMUL 0x43d000 (1/65536) on both arguments, FDIVP, FMUL 0x43d008 (65536.0) on the result — the 1/65536 factors cancel, leaving (a / b) * 65536), not the argument-less "get a time or random value" document 68 assumed it might be.

That would make slot+0x14 = fixed_div(state+0x20 at creation, 0x100000), and the ping code's FUN_00410b70(state+0x20 <now>, slot+0x14) an ordinary fixed multiply of the live value against that stored ratio. Chasing where state+0x20 starts from: the vehicle's whole state block is initialised by a flat 80-dword copy from record + 8 (FUN_0040b700, the creation function: for (i = 0x50; i != 0; i--) *dst++ = *src++ from (type record) + 8) — so state+0x20's starting value is record + 0x28, which by dword offset lines up with the record's already-traced hit points field. If that identification is right, state+0x20 is the same hp document 47's hit callback already decrements (FUN_0040c460: the same function, re-read here, turns out to take (victim, hitter, damage), and its param_3 - piVar1[7] < 1 guard is the armour check — piVar1[7] (state+0x1c) also traces back to record + 0x24, the record's own armour field, by the same copy).

Not confirmed, and the arithmetic doesn't obviously work out: plugging in the traced hit-point values (Tank 22, Jeep 1, MSV 26, Heli 15) against the 0x100000/65536 scaling gives a ratio so small that the ping would sit at frame 15 for any positive hp, on every vehicle, all the time — not the growing animation the cels clearly show. Either one of the offsets in this chain is wrong, state+0x20 isn't really hp despite lining up with the record copy, or there is a scaling step still missing. Recorded here as a real lead — the fixed-divide identity and the record-copy source are both directly confirmed in the disassembly — rather than folded into the trace above, since following it to a number that actually explains the animation would need more time than this pass had. The port's even 74-tick spread stands as the shipped approximation.

Clone this wiki locally