From 2f1289688d9329e8944549046a5dbd06b867dc1f Mon Sep 17 00:00:00 2001 From: VirxEC Date: Mon, 1 Jun 2026 21:23:30 -0500 Subject: [PATCH 1/2] Fix `UpdateRendering` --- RLBotCS/Server/FlatBuffersSession.cs | 34 +++++-------------- .../Server/ServerMessage/UpdateRendering.cs | 2 +- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/RLBotCS/Server/FlatBuffersSession.cs b/RLBotCS/Server/FlatBuffersSession.cs index 2c5cc4a..4dc3faa 100644 --- a/RLBotCS/Server/FlatBuffersSession.cs +++ b/RLBotCS/Server/FlatBuffersSession.cs @@ -35,7 +35,7 @@ public readonly record struct DistributeBallPrediction(BallPredictionT BallPredi public readonly record struct StopMatch(bool Force) : SessionMessage; - public readonly record struct UpdateRendering(RenderingStatus Status) : SessionMessage; + public readonly record struct UpdateRendering(RenderingStatusT Status) : SessionMessage; public readonly record struct PingResponse(ulong Cookie) : SessionMessage; } @@ -52,7 +52,7 @@ class FlatBuffersSession private readonly Channel _incomingMessages; private readonly ChannelWriter _rlbotServer; private readonly ChannelWriter _bridge; - private readonly Dictionary _gotInput = new(); + private readonly Dictionary _gotInput = []; /// Indicates that we received a ConnectionSettings message from the client, and that /// we now know its agent id (if any) and whether it is interested in ball prediction, match comms, @@ -72,7 +72,7 @@ class FlatBuffersSession private string _agentId = string.Empty; private uint _team = Team.Other; - private List _playerIdPairs = new(); + private List _playerIdPairs = []; private bool _sessionForceClosed; private bool _closed; @@ -311,7 +311,7 @@ await _bridge.WriteAsync( break; case InterfaceMessage.RenderingStatus: - var renderingStatus = msg.MessageAsRenderingStatus(); + var renderingStatus = msg.MessageAsRenderingStatus().UnPack(); await _rlbotServer.WriteAsync(new UpdateRendering(renderingStatus)); break; @@ -422,29 +422,11 @@ private async Task HandleInternalMessages() when m.Force || (_connectionEstablished && _closeBetweenMatches): _sessionForceClosed = m.Force; return; - case SessionMessage.UpdateRendering m - when (m.Status.IsBot && (_team == Team.Blue || _team == Team.Orange)) - || (!m.Status.IsBot && _team == Team.Scripts): + case SessionMessage.UpdateRendering m: + if (_playerIdPairs.Exists(p => p.Index == m.Status.Index)) + _renderingIsEnabled = m.Status.Status; - foreach (var player in _playerIdPairs) - { - if (player.Index == m.Status.Index) - { - _renderingIsEnabled = m.Status.Status; - SendPayloadToClient( - CoreMessageUnion.FromRenderingStatus( - new RenderingStatusT() - { - Index = player.Index, - IsBot = m.Status.IsBot, - Status = m.Status.Status, - } - ) - ); - - break; - } - } + SendPayloadToClient(CoreMessageUnion.FromRenderingStatus(m.Status)); break; case SessionMessage.PingResponse m: diff --git a/RLBotCS/Server/ServerMessage/UpdateRendering.cs b/RLBotCS/Server/ServerMessage/UpdateRendering.cs index 5b80bc0..02f5ded 100644 --- a/RLBotCS/Server/ServerMessage/UpdateRendering.cs +++ b/RLBotCS/Server/ServerMessage/UpdateRendering.cs @@ -2,7 +2,7 @@ namespace RLBotCS.Server.ServerMessage; -readonly struct UpdateRendering(RenderingStatus Status) : IServerMessage +readonly struct UpdateRendering(RenderingStatusT Status) : IServerMessage { public ServerAction Execute(ServerContext context) { From 01734cdd3785a398e0a0e8889211114353690da0 Mon Sep 17 00:00:00 2001 From: VirxEC Date: Tue, 2 Jun 2026 11:17:37 -0500 Subject: [PATCH 2/2] Filter rendering updates by session team --- RLBotCS/Server/FlatBuffersSession.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/RLBotCS/Server/FlatBuffersSession.cs b/RLBotCS/Server/FlatBuffersSession.cs index 4dc3faa..cd49832 100644 --- a/RLBotCS/Server/FlatBuffersSession.cs +++ b/RLBotCS/Server/FlatBuffersSession.cs @@ -423,10 +423,20 @@ private async Task HandleInternalMessages() _sessionForceClosed = m.Force; return; case SessionMessage.UpdateRendering m: - if (_playerIdPairs.Exists(p => p.Index == m.Status.Index)) - _renderingIsEnabled = m.Status.Status; + if (_team == Team.Other) + { + SendPayloadToClient(CoreMessageUnion.FromRenderingStatus(m.Status)); + return; + } - SendPayloadToClient(CoreMessageUnion.FromRenderingStatus(m.Status)); + bool isCorrectTeam = + (m.Status.IsBot && (_team == Team.Blue || _team == Team.Orange)) + || (!m.Status.IsBot && _team == Team.Scripts); + if (isCorrectTeam && _playerIdPairs.Exists(p => p.Index == m.Status.Index)) + { + _renderingIsEnabled = m.Status.Status; + SendPayloadToClient(CoreMessageUnion.FromRenderingStatus(m.Status)); + } break; case SessionMessage.PingResponse m: