Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions RLBotCS/Server/BridgeMessage/RunConsoleCommand.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
10 changes: 9 additions & 1 deletion RLBotCS/Server/BridgeMessage/SetGameState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RLBot.Flat;
using Microsoft.Extensions.Logging;
using RLBot.Flat;
using RLBotCS.Conversion;

namespace RLBotCS.Server.BridgeMessage;
Expand All @@ -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);

Expand Down
10 changes: 9 additions & 1 deletion RLBotCS/Server/FlatBuffersSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading