diff --git a/RLBotCS/Server/BridgeMessage/RunConsoleCommand.cs b/RLBotCS/Server/BridgeMessage/RunConsoleCommand.cs new file mode 100644 index 0000000..90ff60c --- /dev/null +++ b/RLBotCS/Server/BridgeMessage/RunConsoleCommand.cs @@ -0,0 +1,11 @@ +using RLBot.Flat; + +namespace RLBotCS.Server.BridgeMessage; + +readonly struct RunConsoleCommand(ConsoleCommandT command) : IBridgeMessage +{ + public void HandleMessage(BridgeContext context) + { + context.MatchCommandQueue.AddConsoleCommand(command.Command); + } +} diff --git a/RLBotCS/Server/BridgeMessage/SetGameState.cs b/RLBotCS/Server/BridgeMessage/SetGameState.cs index d946f2d..924519a 100644 --- a/RLBotCS/Server/BridgeMessage/SetGameState.cs +++ b/RLBotCS/Server/BridgeMessage/SetGameState.cs @@ -1,4 +1,5 @@ -using RLBot.Flat; +using Microsoft.Extensions.Logging; +using RLBot.Flat; using RLBotCS.Conversion; namespace RLBotCS.Server.BridgeMessage; @@ -7,6 +8,13 @@ readonly struct SetGameState(DesiredGameStateT GameState) : IBridgeMessage { public void HandleMessage(BridgeContext context) { + if (GameState.ConsoleCommands.Count > 0) + { + context.Logger.LogWarning( + "Running console commands through the DesiredGameState message is deprecated. " + + "Use the ConsoleCommand message type instead." + ); + } foreach (var command in GameState.ConsoleCommands) context.MatchCommandQueue.AddConsoleCommand(command.Command); diff --git a/RLBotCS/Server/FlatBuffersSession.cs b/RLBotCS/Server/FlatBuffersSession.cs index 306a480..fcf59c8 100644 --- a/RLBotCS/Server/FlatBuffersSession.cs +++ b/RLBotCS/Server/FlatBuffersSession.cs @@ -304,13 +304,21 @@ await _bridge.WriteAsync( break; case InterfaceMessage.DesiredGameState: - if (!_stateSettingIsEnabled) + if (!_stateSettingIsEnabled && _agentId != "") break; var desiredGameState = msg.MessageAsDesiredGameState().UnPack(); await _bridge.WriteAsync(new SetGameState(desiredGameState)); break; + case InterfaceMessage.ConsoleCommand: + if (!_stateSettingIsEnabled && _agentId != "") + break; + + var command = msg.MessageAsConsoleCommand().UnPack(); + await _bridge.WriteAsync(new RunConsoleCommand(command)); + break; + case InterfaceMessage.RenderingStatus: var renderingStatus = msg.MessageAsRenderingStatus().UnPack(); await _rlbotServer.WriteAsync(new UpdateRenderingStatus(renderingStatus)); diff --git a/flatbuffers-schema b/flatbuffers-schema index c2648b4..f90c844 160000 --- a/flatbuffers-schema +++ b/flatbuffers-schema @@ -1 +1 @@ -Subproject commit c2648b4fa30d9d3b228466d51746c84ee2f20a6c +Subproject commit f90c844f2f5118e28647d39b71cbde5a2cd6accf