Private
Public Access
1
0

fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m15s

This commit is contained in:
Sebastian Unterschütz
2026-03-21 22:39:01 +01:00
parent ce092c8366
commit 7a86a8596e
3 changed files with 19 additions and 4 deletions

View File

@@ -74,6 +74,8 @@ func (g *Game) UpdateGame() {
g.btnDownActive = false
// --- 4. INPUT SENDEN (MIT CLIENT PREDICTION) ---
// Prediction läuft bei jedem Frame (60 TPS) für flüssige Darstellung.
// Netz-Send wird auf ~20/sek gedrosselt um Server-Last zu begrenzen.
if g.connected {
g.predictionMutex.Lock()
// Sequenznummer erhöhen
@@ -86,10 +88,23 @@ func (g *Game) UpdateGame() {
// Input für History speichern (für Server-Reconciliation)
g.pendingInputs[input.Sequence] = input
// Cap: nie mehr als 120 unbestätigte Inputs ansammeln
if len(g.pendingInputs) > 120 {
oldest := g.inputSequence - 120
for seq := range g.pendingInputs {
if seq < oldest {
delete(g.pendingInputs, seq)
}
}
}
g.predictionMutex.Unlock()
// Input an Server senden
g.SendInputWithSequence(input)
// Netz-Throttle: max 20 Inputs/Sek senden
if time.Since(g.lastInputTime) >= 50*time.Millisecond {
g.lastInputTime = time.Now()
g.SendInputWithSequence(input)
}
}
// --- 5. KAMERA LOGIK ---