Private
Public Access
1
0

Add sequence numbers to server broadcasts and client state handling for out-of-order update detection.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 9m53s

This commit is contained in:
Sebastian Unterschütz
2026-01-06 18:52:27 +01:00
parent 2a635d0aaa
commit 23d42d42e7
5 changed files with 21 additions and 0 deletions

View File

@@ -72,6 +72,13 @@ func (g *Game) connectToServer() {
payloadBytes, _ := json.Marshal(msg.Payload)
var state game.GameState
if err := json.Unmarshal(payloadBytes, &state); err == nil {
// Out-of-Order-Erkennung: Ignoriere alte Updates
if state.Sequence > 0 && state.Sequence <= g.lastRecvSeq {
// Alte Nachricht - ignorieren
return nil
}
g.lastRecvSeq = state.Sequence
// Server Reconciliation für lokalen Spieler (VOR dem Lock)
for _, p := range state.Players {
if p.Name == g.playerName {