Repository navigation
10 worked example target respawn
Not every investigation in this project has been a saga. This one — one of the smaller
items on the next-steps doc's backlog — took two FindDataXrefs.java calls and
two decompiles to resolve, which is worth showing precisely because it demonstrates the same
recipe scales down, not just up.
Document 4 had already found and named the two candidate
position pools (0xB4/0xDC tile values) and the level loader's random-commit logic, and
left one loose end: right after picking one random candidate per pool, the loader computes
pool_count >> 1 and stores it somewhere, un-investigated. The plan's own guess at the time
was "possibly a win-condition threshold." A guess recorded as a guess, not asserted as fact
— exactly what document 6's rule 5 asks for.
The anchor already existed (the two globals the loader writes those halved counts into,
DAT_0048ca20 and DAT_0048ca24) — no new string or API search needed, just
FindDataXrefs.java 0048ca20. It came back with only 3 references total: the loader
(already known) and 2 inside a single other function, FUN_00432710. A 3-reference result
is a strong signal on its own — whatever this value does, it's used in exactly one other
place, so that's the whole story.
Reading FUN_00432710:
uVar5 = (*param_2 & 0xc000) >> 0xe; /* pool index from tile bits 14-15 */
...
iVar1 = *(int *)(&DAT_0048ca20 + uVar5 * 4); /* this pool's remaining budget */
*(int *)(&DAT_0048ca20 + uVar5 * 4) = iVar1 + -1; /* decrement it */
...
/* if this was the pool's tracked active target, call FUN_00432600(uVar5) to replace it */Two things fall out immediately. First, param_2 here is a tile pointer being handled by
what's clearly an object-destruction path — this function runs when something gets removed
from play. Second, (tile & 0xc000) >> 14 reads bits 14-15 of the tile's runtime value —
which section 1.5 had already flagged as a dumped-but-unchased field, guessed to be
"orientation-ish." Seeing it used as a small array index here (0 or 1, selecting between two
adjacent 4-byte globals DAT_0048ca20/DAT_0048ca24) rules that guess out on the spot: it's
a pool-membership tag, not orientation. A wrong guess sitting in the docs long enough to
get checked against real code is exactly what those guesses are for.
FUN_00432600(pool) (the replacement call) was worth reading in full, decompiling it
directly by address since it was already named from the caller. It scans the pool's own
candidate array (confirmed by a quick decompile of FUN_00413db0, the function that
originally built that array, to nail down exactly which global belongs to which pool letter
— pool_index==0/tile 0xB4 uses DAT_0045ae70/DAT_0045ae28, pool_index==1/tile 0xDC
uses DAT_0045b270/DAT_0045ae2c) for any candidate still showing an "intact" state, and if
any remain, randomly activates one as the new target.
Not "destroy half the pool's targets simultaneously to win" (the original guess). Instead: each pool is a rotating single-target spawner — exactly one destructible target is live per pool at a time, and destroying it immediately activates a replacement from the pool's remaining candidates, up to a total budget of half the pool's candidate count. That's a materially different — and, reading it, more obviously correct — description of the "bases keep reappearing somewhere else" feel the original game is known for.
The rotating spawner became TargetPool (engine, game/target_pool.gd), one per pool. Its budget is the halved
count the loader stores in DAT_0048ca20 / DAT_0048ca24, and destroy_active() is FUN_00432710's decrement
followed by FUN_00432600's pick:
# game/target_pool.gd
func _init(tile_positions: Array) -> void:
candidates = tile_positions.duplicate()
intact.resize(candidates.size())
intact.fill(true)
budget = candidates.size() >> 1 # the loader's "pool_count >> 1"
if not candidates.is_empty():
active_index = randi() % candidates.size() # one random candidate per pool
func destroy_active() -> bool:
if active_index < 0:
return false
intact[active_index] = false
active_index = -1
budget -= 1 # FUN_00432710: DAT_0048ca20[pool] - 1
if budget <= 0:
return false
var remaining: Array = [] # FUN_00432600: a random still-intact candidate
for i in intact.size():
if intact[i]:
remaining.append(i)
if remaining.is_empty():
return false
active_index = remaining[randi() % remaining.size()]
return trueMatchController._damage_tile_amount calls it when the destroyed tile is a pool's active target. The port keeps one
TargetPool per pool id instead of reading the pool from tile bits 14-15. The "pool went silent" branch spawning the
flag came later (document 26):
# game/match_controller.gd, _damage_tile_amount()
for pool_id in pools:
var pool: TargetPool = pools[pool_id]
var active_tile = pool.get_active_position()
if active_tile == null or active_tile != t:
continue
var reactivated := pool.destroy_active()
target_hit.emit(pool_id, t)
...
if not reactivated:
# The pool went silent for good: FUN_00432710 falls through to spawn its flag object
_spawn_flag(pool_id, tile_px)
return trueThe full cross-reference list for both budget globals is exactly 3 sites, all now read. Nothing anywhere in the binary reads both budgets together to declare a match won or lost. That means the actual mission-complete condition — if it exists and is driven by these counters at all — is implemented somewhere this investigation didn't reach. Rather than guess further, this was recorded as the honest boundary of what was actually traced: the replacement mechanism is solved with the same confidence as every other entry in this document series; the win condition is a clearly-scoped next step, not something papered over. See the next-steps doc for it as a next action.
The obvious next step was named above: FUN_0042c4d0, called right as a pool's tracking
gets cleared once its budget runs out. Decompiling it directly settled the question in one
step — but not the way the lead suggested:
void __cdecl FUN_0042c4d0(int param_1)
{
if ((*(uint *)(param_1 + 0xc) & 0x80) == 0) {
*(uint *)(param_1 + 0xc) = *(uint *)(param_1 + 0xc) | 0x80;
*(int *)(param_1 + 0x38) = DAT_0046a7b0;
DAT_0046a7b0 = param_1;
}
}That's a generic "mark this object dead (flag bit 0x80) and link it into a free list" —
nothing about pools, targets, or match state at all. Its caller list confirms it: over 35
call sites scattered across the entire binary, covering what look like vehicles,
projectiles, and ordinary objects generally. It's called from FUN_00432710 for the same
reason it's called everywhere else — some bookkeeping object is done being used — not as a
special win-condition hook.
In the port this has no counterpart of its own: a Godot node that is done is freed with queue_free(), so there is
no free list to link it into.
This is worth recording precisely because it's a disproof, not a success — per
document 6's rule 5, a wrong lead is worth keeping on the
record with what actually happened to it, so nobody re-spends the same effort re-checking
it. The trail from here runs into a large, general AI-targeting/combat module
(FUN_00432d00, FUN_00432d80, FUN_00432e40 and neighbors — found by the same
FindDataXrefs.java sweep, this time on the per-pool "active target" pointer array) with no
obvious "declare victory" anchor visible in it. Rather than opening an unbounded
investigation into an unrelated subsystem chasing a hunch, this is where the trail was left
— honestly marked as a checked-and-ruled-out lead, not a solved question. See
the next-steps doc for the current state of this open item.
Next: Worked example: confirming a dead end fast by rereading work already on hand.
Return Fire, rebuilt
Elsewhere