From b45e10495d2c95d77bfeeda1d734f13a107385c0 Mon Sep 17 00:00:00 2001 From: FluxCapacitor2 <31071265+FluxCapacitor2@users.noreply.github.com> Date: Mon, 23 Dec 2024 03:54:42 -0500 Subject: [PATCH] Fix incorrect maxSlots being sent while handling GameStateChangedEvent --- .../server/event/GameStateChangedEvent.kt | 12 +----------- .../server/impl/OutgoingRPCHandlerImpl.kt | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/common/src/main/kotlin/com/bluedragonmc/server/event/GameStateChangedEvent.kt b/common/src/main/kotlin/com/bluedragonmc/server/event/GameStateChangedEvent.kt index 5588a4db..77ab54d1 100644 --- a/common/src/main/kotlin/com/bluedragonmc/server/event/GameStateChangedEvent.kt +++ b/common/src/main/kotlin/com/bluedragonmc/server/event/GameStateChangedEvent.kt @@ -1,6 +1,5 @@ package com.bluedragonmc.server.event -import com.bluedragonmc.api.grpc.CommonTypes import com.bluedragonmc.server.Game import com.bluedragonmc.server.utils.GameState @@ -9,13 +8,4 @@ import com.bluedragonmc.server.utils.GameState * Used to propagate state updates to external services, * such as with the MessagingModule. */ -class GameStateChangedEvent(game: Game, val oldState: GameState, val newState: GameState) : GameEvent(game) { - val rpcGameState: CommonTypes.GameState - get() { - return CommonTypes.GameState.newBuilder() - .setGameState(newState.mapToRpcState()) - .setJoinable(newState.canPlayersJoin) - .setOpenSlots(game.maxPlayers - game.players.size) - .build() - } -} \ No newline at end of file +class GameStateChangedEvent(game: Game, val oldState: GameState, val newState: GameState) : GameEvent(game) diff --git a/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt b/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt index e21adc47..0b9716e0 100644 --- a/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt +++ b/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt @@ -56,7 +56,7 @@ class OutgoingRPCHandlerImpl(serverAddress: String, serverPort: Int) : OutgoingR Messaging.outgoing.initGame(parent.id, parent.gameType, parent.rpcGameState) eventNode.listenAsync { event -> - Messaging.outgoing.updateGameState(parent.id, event.rpcGameState) + Messaging.outgoing.updateGameState(parent.id, event.game.rpcGameState) } eventNode.listenAsync { event ->