Skip to content

GM lines run only on a confirmed selection (#296) - #301

Merged
pjerra merged 4 commits into
devfrom
fix/gm-selection-echo
Oct 23, 2026
Merged

pjerra merged 4 commits into
devfrom
fix/gm-selection-echo

Conversation

@pjerra

@pjerra pjerra commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Closes the last part of #296: a GM chat line (.levelup, .respawn, .aura, ...) could run on a stale selection.

  • The session keeps a log of every CMSG_SET_SELECTION it sends; an echo of the player's target field confirms a selection only when it answers the session's own send. A value the session never sent (the core rewrites the field on attack start/stop and stuns) makes the selection unknown.
  • While the agent is attacking, in combat or stunned (and 1 s after), no echo confirms and no selection-bound GM line goes out; afterwards it selects again and needs a fresh echo. All waits share the 3 s timer; on timeout it returns an error and sends nothing.
  • .respawn and the .aura buffs go through the same confirmed path. The log is capped at 32 entries.

Tests: session log unit tests (fresh/stale echo, attack stop, attack on a player, cap, far teleport, combat rewrite to the pending unit) and command-level tests including the separate-threads race; -race runs green; full go test ./... green; mutations turn them red.
Reviews: Opus cold review SHIP (after one fix round), Codex adversarial approve (after two fix rounds).

…#296)

selectConfirmed accepted any echo of the player's target field that showed the
unit, so an echo from an earlier select of the same unit, with another unit's
select still pending behind it, confirmed the new select; the GM line then ran
on that other unit. The session now keeps a log of the selections it sent and
moves a lower bound on the server's progress with each echo (to the oldest send
the echo can answer). A selection is confirmed only when every send from there
on is that unit. Reselecting the unit already confirmed needs no echo (the core
sends none for an unchanged field). When a new echo could not be told from an
old one, a neutral selection (none, else the agent itself) is made and confirmed
first. Respawn's wait for a cleared selection uses the same rule.
…on (#296 review)

UNIT_FIELD_TARGET is also written by Unit::Attack, Unit::AttackStop and a stun,
without touching the selection GM commands read. An echo of a value the session
never sent now leaves the selection in force unknown, and a repeated select is
confirmed with no echo only when the base came from an echo of the session's
own send; otherwise a neutral selection is made first (one the log, the dropped
sends and the field do not hold). The log is capped at 32 sends; an echo of a
dropped unit confirms nothing. The confirmed select lives in the session
(SelectConfirmed); GMOn (.aura world buffs) goes through it and GMOnConfirmed,
and .respawn is sent with GMOnConfirmed on a confirmed clear.
… stunned (#296 review 2)

The core rewrites the player's target field only through Attack, AttackStop
and stun apply/end; a rewrite to exactly the unit of a pending select read as
its echo. While the player is hot (its own SMSG_ATTACKSTART until the
ATTACKSTOP, UNIT_FLAG_IN_COMBAT or UNIT_FLAG_STUNNED) and for
SelectionCombatSettle after, no echo confirms and no GM line on a selection
goes out. Cooling down fences off every send so far; SelectConfirmed waits
inside its timer, then selects again (through a neutral selection when the
unit was fenced off) and needs the echo of that new send. A neutral selection
no longer counts the unknown base's placeholder as a unit.
When GPS started before the session had read the create block, the target
field was unknown and SelectConfirmed made a neutral selection of nothing
first, which the test refused (CI run 39915580906). The test now echoes every
selection, allows only one neutral selection of nothing before the commander,
and still checks that .gps runs with the commander selected.
@pjerra
pjerra merged commit e9b14ff into dev Oct 23, 2026
1 check passed
@pjerra
pjerra deleted the fix/gm-selection-echo branch October 26, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant