Skip to content

Commit 8b6c5c4

Browse files
Deprecate console commands in DesiredGameState and allow match managers to bypass state setting (#177)
* Deprecate console commands in DesiredGameState and allow match manages to bypass state setting * Format * Update schema
1 parent 6633e01 commit 8b6c5c4

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using RLBot.Flat;
2+
3+
namespace RLBotCS.Server.BridgeMessage;
4+
5+
readonly struct RunConsoleCommand(ConsoleCommandT command) : IBridgeMessage
6+
{
7+
public void HandleMessage(BridgeContext context)
8+
{
9+
context.MatchCommandQueue.AddConsoleCommand(command.Command);
10+
}
11+
}

RLBotCS/Server/BridgeMessage/SetGameState.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using RLBot.Flat;
1+
using Microsoft.Extensions.Logging;
2+
using RLBot.Flat;
23
using RLBotCS.Conversion;
34

45
namespace RLBotCS.Server.BridgeMessage;
@@ -7,6 +8,13 @@ readonly struct SetGameState(DesiredGameStateT GameState) : IBridgeMessage
78
{
89
public void HandleMessage(BridgeContext context)
910
{
11+
if (GameState.ConsoleCommands.Count > 0)
12+
{
13+
context.Logger.LogWarning(
14+
"Running console commands through the DesiredGameState message is deprecated. "
15+
+ "Use the ConsoleCommand message type instead."
16+
);
17+
}
1018
foreach (var command in GameState.ConsoleCommands)
1119
context.MatchCommandQueue.AddConsoleCommand(command.Command);
1220

RLBotCS/Server/FlatBuffersSession.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,21 @@ await _bridge.WriteAsync(
304304
break;
305305

306306
case InterfaceMessage.DesiredGameState:
307-
if (!_stateSettingIsEnabled)
307+
if (!_stateSettingIsEnabled && _agentId != "")
308308
break;
309309

310310
var desiredGameState = msg.MessageAsDesiredGameState().UnPack();
311311
await _bridge.WriteAsync(new SetGameState(desiredGameState));
312312
break;
313313

314+
case InterfaceMessage.ConsoleCommand:
315+
if (!_stateSettingIsEnabled && _agentId != "")
316+
break;
317+
318+
var command = msg.MessageAsConsoleCommand().UnPack();
319+
await _bridge.WriteAsync(new RunConsoleCommand(command));
320+
break;
321+
314322
case InterfaceMessage.RenderingStatus:
315323
var renderingStatus = msg.MessageAsRenderingStatus().UnPack();
316324
await _rlbotServer.WriteAsync(new UpdateRenderingStatus(renderingStatus));

0 commit comments

Comments
 (0)