Skip to content

Commit

Permalink
Fix incorrect maxSlots being sent while handling GameStateChangedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
FluxCapacitor2 committed Dec 23, 2024
1 parent 6a64c19 commit b45e104
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()
}
}
class GameStateChangedEvent(game: Game, val oldState: GameState, val newState: GameState) : GameEvent(game)
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class OutgoingRPCHandlerImpl(serverAddress: String, serverPort: Int) : OutgoingR
Messaging.outgoing.initGame(parent.id, parent.gameType, parent.rpcGameState)

eventNode.listenAsync<GameStateChangedEvent> { event ->
Messaging.outgoing.updateGameState(parent.id, event.rpcGameState)
Messaging.outgoing.updateGameState(parent.id, event.game.rpcGameState)
}

eventNode.listenAsync<AddEntityToInstanceEvent> { event ->
Expand Down

0 comments on commit b45e104

Please sign in to comment.