Skip to content

fix: add state machine validation and fix vote/captain disconnect handling#136

Open
Flegma wants to merge 4 commits intomainfrom
audit/396-state-machine
Open

fix: add state machine validation and fix vote/captain disconnect handling#136
Flegma wants to merge 4 commits intomainfrom
audit/396-state-machine

Conversation

@Flegma
Copy link
Copy Markdown
Contributor

@Flegma Flegma commented Apr 8, 2026

Summary

Test plan

  • Verify match progresses through normal flow: Scheduled -> Warmup -> Knife -> Live -> Finished
  • Verify illegal transitions (e.g. Finished -> Live, Paused -> Knife when not previously in Knife) are logged and rejected
  • Verify captain removal works during knife round (disconnect a captain during knife, confirm reassignment)
  • Verify captain-only votes resolve when one captain disconnects (start a captain vote, disconnect one captain, confirm remaining captain's vote resolves it)
  • Verify normal 2-captain votes still work as before (both captains present, both vote)

Flegma added 4 commits April 8, 2026 12:39
… disconnect

Add allowed-transitions dictionary to MatchManager.UpdateMapStatus so
illegal state jumps (e.g. Finished -> Live) are rejected with a warning.

Fix CaptainSystem.RemoveCaptain to allow captain removal during knife
round in addition to warmup.

Replace hardcoded captain vote count of 2 in VoteSystem.CheckVotes with
the dynamic expectedVoteCount so a single remaining captain can resolve
a vote when the other disconnects. Remove stray extra semicolon in
GetExpectedVoteCount.
SendSurrender() in GameEnd.cs calls UpdateMapStatus(Finished) after a
surrender, so Surrendered cannot be a terminal state. Without this,
the surrender flow silently fails to mark the map as Finished.
When a player disconnects, their vote was persisting in active votes
while GetExpectedVoteCount excluded them, causing inconsistent tallies.
Now cleans up votes from surrender, pause, resume, and restore systems.
Move the allowed-transition guard above CheckForBackupRestore so
illegal transitions are rejected before any side effects run.
@Flegma Flegma requested a review from lukepolo April 10, 2026 09:18
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