Skip to content

Commit 9337625

Browse files
Deprecate console commands in DesiredGameState and allow match manages to bypass state setting
1 parent 6633e01 commit 9337625

4 files changed

Lines changed: 28 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: 7 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,11 @@ 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("Running console commands through the DesiredGameState message is deprecated. " +
14+
"Use the ConsoleCommand message type instead.");
15+
}
1016
foreach (var command in GameState.ConsoleCommands)
1117
context.MatchCommandQueue.AddConsoleCommand(command.Command);
1218

RLBotCS/Server/FlatBuffersSession.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,20 @@ 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;
313+
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;
313321

314322
case InterfaceMessage.RenderingStatus:
315323
var renderingStatus = msg.MessageAsRenderingStatus().UnPack();

0 commit comments

Comments
 (0)