diff --git a/RLBotCS/Server/BridgeHandler.cs b/RLBotCS/Server/BridgeHandler.cs index 0e9086a..1f2a3ee 100644 --- a/RLBotCS/Server/BridgeHandler.cs +++ b/RLBotCS/Server/BridgeHandler.cs @@ -61,21 +61,17 @@ private async Task HandleServer() bool timeAdvanced = deltaTime > 0.001; if (timeAdvanced) - { _context.PerfMonitor.AddRLBotSample(deltaTime); - _context.Writer.TryWrite(new DistributeGameState(_context.GameState)); - } + _context.Writer.TryWrite( + new DistributeGameState(_context.GameState, timeAdvanced) + ); var matchStarted = MessageHandler.ReceivedMatchInfo(messageClump); if (matchStarted) { _context.RenderingMgmt.ClearAllRenders(); _context.MatchHasStarted = true; - _context.Writer.TryWrite( - new MapSpawned( - _context.GameState.GameStateType == GameStateType.Inactive - ) - ); + _context.Writer.TryWrite(new MapSpawned()); } bool matchEnded = _context.GameState.GameStateType == GameStateType.Inactive; @@ -131,6 +127,7 @@ _context is _context.DelayMatchCommandSend = false; _context.QueuedMatchCommands = false; + _context.Logger.LogInformation("Sending delayed match commands"); _context.MatchCommandSender.Send(); } diff --git a/RLBotCS/Server/BridgeMessage.cs b/RLBotCS/Server/BridgeMessage.cs index 2a7dea7..314d92f 100644 --- a/RLBotCS/Server/BridgeMessage.cs +++ b/RLBotCS/Server/BridgeMessage.cs @@ -128,15 +128,6 @@ internal record ConsoleCommand(string Command) : IBridgeMessage public void HandleMessage(BridgeContext context) => context.QueueConsoleCommand(Command); } -internal record SetPaused(bool Pause) : IBridgeMessage -{ - public void HandleMessage(BridgeContext context) - { - context.QueuedMatchCommands = true; - context.MatchCommandSender.AddSetPausedCommand(Pause); - } -} - internal record SpawnMap(MatchSettingsT MatchSettings) : IBridgeMessage { public void HandleMessage(BridgeContext context) @@ -312,6 +303,15 @@ public void HandleMessage(BridgeContext context) } } +internal record EndMatch() : IBridgeMessage +{ + public void HandleMessage(BridgeContext context) + { + context.MatchCommandSender.AddMatchEndCommand(); + context.MatchCommandSender.Send(); + } +} + internal record ShowQuickChat(MatchCommT MatchComm) : IBridgeMessage { public void HandleMessage(BridgeContext context) => diff --git a/RLBotCS/Server/FlatbuffersMessage/DistributeGameState.cs b/RLBotCS/Server/FlatbuffersMessage/DistributeGameState.cs index eb46292..4450ac7 100644 --- a/RLBotCS/Server/FlatbuffersMessage/DistributeGameState.cs +++ b/RLBotCS/Server/FlatbuffersMessage/DistributeGameState.cs @@ -6,7 +6,7 @@ namespace RLBotCS.Server.FlatbuffersMessage; -internal record DistributeGameState(GameState GameState) : IServerMessage +internal record DistributeGameState(GameState GameState, bool timeAdvanced) : IServerMessage { private static void UpdateFieldInfo(ServerContext context, GameState gameState) { @@ -107,8 +107,12 @@ private static void DistributeState(ServerContext context, GameState gameState) public ServerAction Execute(ServerContext context) { UpdateFieldInfo(context, GameState); - DistributeBallPrediction(context, GameState); - DistributeState(context, GameState); + + if (timeAdvanced) + { + DistributeBallPrediction(context, GameState); + DistributeState(context, GameState); + } return ServerAction.Continue; } diff --git a/RLBotCS/Server/FlatbuffersMessage/MapSpawned.cs b/RLBotCS/Server/FlatbuffersMessage/MapSpawned.cs index 10a5c16..c4c903d 100644 --- a/RLBotCS/Server/FlatbuffersMessage/MapSpawned.cs +++ b/RLBotCS/Server/FlatbuffersMessage/MapSpawned.cs @@ -1,6 +1,6 @@ namespace RLBotCS.Server.FlatbuffersMessage; -internal record MapSpawned(bool NotifyMatchStarter) : IServerMessage +internal record MapSpawned() : IServerMessage { public ServerAction Execute(ServerContext context) { diff --git a/RLBotCS/Server/FlatbuffersMessage/StopMatch.cs b/RLBotCS/Server/FlatbuffersMessage/StopMatch.cs index 5b94a05..4a35110 100644 --- a/RLBotCS/Server/FlatbuffersMessage/StopMatch.cs +++ b/RLBotCS/Server/FlatbuffersMessage/StopMatch.cs @@ -14,6 +14,7 @@ public ServerAction Execute(ServerContext context) return ServerAction.Stop; } + context.Bridge.TryWrite(new EndMatch()); foreach (var (writer, _) in context.Sessions.Values) writer.TryWrite(new SessionMessage.StopMatch(ShutdownServer)); return ServerAction.Continue;