Skip to content
Merged
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 != "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always allowing console commands is one thing, but always allowing state setting when it's supposed to be off is something else imo. I thought the point of splitting off console commands was to allow them to be used by match managers even when state setting is disabled, without letting them do state setting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo match managers are allowed to do anything. It's their match.

The splitting was just to clean up the API.

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