Fix player reconnection by re-registering sync context

When an existing player reconnects to a game, their sync context
is now updated so they continue receiving real-time updates.
This commit is contained in:
Ryan Hamamura
2026-01-14 21:54:07 -10:00
parent 2cd5b1d289
commit ee762fb841
4 changed files with 51 additions and 10 deletions

View File

@@ -196,6 +196,13 @@ func (gi *GameInstance) GetPlayerColor(pid PlayerID) int {
return 0
}
func (gi *GameInstance) RegisterSync(playerID PlayerID, sync Syncable) {
gi.playersMu.Lock()
gi.players[playerID] = sync
gi.playersMu.Unlock()
gi.dirty = true
}
func (gi *GameInstance) CreateRematch(gs *GameStore) *GameInstance {
gi.gameMu.Lock()
defer gi.gameMu.Unlock()