Skip to content

Fix coop double-spawn of chrysalid from convertUnit packet race#10

Open
NonPolynomialTim wants to merge 1 commit into
xcomcoopdev:mainfrom
NonPolynomialTim:fix/coop-chrysalid-double-spawn
Open

Fix coop double-spawn of chrysalid from convertUnit packet race#10
NonPolynomialTim wants to merge 1 commit into
xcomcoopdev:mainfrom
NonPolynomialTim:fix/coop-chrysalid-double-spawn

Conversation

@NonPolynomialTim

Copy link
Copy Markdown
Contributor

Summary: Fixes a co-op bug where killing a chrysalid-spawning zombie and its resulting chrysalid in the same auto-shot leaves a frozen, immortal chrysalid on the observing player's screen for the rest of the mission.

Root cause: Both the convertUnit network-packet handler (connectionTCP.cpp) and the local coop-death UnitDieBState::think() call SavedBattleGame::convertUnit for the same dying zombie. The respawn-only-once guard lived only at the callers; the packet handler was unguarded. When the local death state wins the race, the packet handler spawns a second chrysalid that never receives a death packet — it stands frozen and desyncs subsequent unit IDs. Timing-dependent, hence the same-auto-shot trigger.

Fix: Enforce the guard inside SavedBattleGame::convertUnit (the chokepoint both paths share); the race loser becomes a no-op (return nullptr). Callers already null-check or ignore the return.

Validated manually in 2-player co-op; both units now die correctly on both screens.

In co-op both the convertUnit network-packet handler and the local
coop-death UnitDieBState call SavedBattleGame::convertUnit for the same
dying zombie. The respawn-only-once guard lived only at the callers, so
when the local death state won the race the unguarded packet handler
spawned a second chrysalid on the observing player. That extra unit never
received a death packet, stood frozen for the rest of the mission, and
desynced subsequent unit IDs.

Enforce the already-respawned guard inside convertUnit itself so the loser
of the race is a no-op. Callers already null-check or ignore the return.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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