Fix coop double-spawn of chrysalid from convertUnit packet race#10
Open
NonPolynomialTim wants to merge 1 commit into
Open
Fix coop double-spawn of chrysalid from convertUnit packet race#10NonPolynomialTim wants to merge 1 commit into
NonPolynomialTim wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.