fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m13s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m13s
This commit is contained in:
@@ -57,10 +57,12 @@ type InputState struct {
|
||||
type Game struct {
|
||||
appState int
|
||||
conn *nats.EncodedConn
|
||||
wsConn *wsConn // WebSocket für WASM
|
||||
gameState game.GameState
|
||||
stateMutex sync.Mutex
|
||||
connected bool
|
||||
wsConn *wsConn // WebSocket für WASM
|
||||
connGeneration int // Erhöht bei jedem Disconnect; macht alte WS-Handler ungültig
|
||||
isConnecting bool // Guard gegen mehrfaches connectAndStart()
|
||||
gameState game.GameState
|
||||
stateMutex sync.Mutex
|
||||
connected bool
|
||||
world *game.World
|
||||
assetsImages map[string]*ebiten.Image
|
||||
|
||||
@@ -904,6 +906,14 @@ func (g *Game) resetForNewGame() {
|
||||
}
|
||||
|
||||
func (g *Game) connectAndStart() {
|
||||
// Guard: verhindert mehrfaches gleichzeitiges Verbinden
|
||||
if g.isConnecting {
|
||||
log.Println("⚠️ connectAndStart bereits aktiv, ignoriere doppelten Aufruf")
|
||||
return
|
||||
}
|
||||
g.isConnecting = true
|
||||
defer func() { g.isConnecting = false }()
|
||||
|
||||
g.resetForNewGame()
|
||||
|
||||
// Verbindung über plattformspezifische Implementierung
|
||||
|
||||
Reference in New Issue
Block a user