From 0b28aa86c55db01d7f99db87e6048e0adb519d41 Mon Sep 17 00:00:00 2001 From: NicEastvillage Date: Fri, 29 May 2026 08:39:14 +0200 Subject: [PATCH 1/2] Make rect rendering use W+H characters instead of W*H+H characters --- RLBotCS/Main.cs | 2 +- RLBotCS/ManagerTools/Rendering.cs | 36 +++++++++++++++++++------------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/RLBotCS/Main.cs b/RLBotCS/Main.cs index 18316c1..947d6a2 100644 --- a/RLBotCS/Main.cs +++ b/RLBotCS/Main.cs @@ -10,7 +10,7 @@ if (args.Length > 0 && args[0] == "--version") { Console.WriteLine( - "RLBotServer v5.0.0-rc.8\n" + "RLBotServer v5.0.0-rc.9\n" + $"Bridge {BridgeVersion.Version}\n" + "@ https://www.rlbot.org & https://github.com/RLBot/core" ); diff --git a/RLBotCS/ManagerTools/Rendering.cs b/RLBotCS/ManagerTools/Rendering.cs index 6382a51..8305e62 100644 --- a/RLBotCS/ManagerTools/Rendering.cs +++ b/RLBotCS/ManagerTools/Rendering.cs @@ -2,6 +2,7 @@ using Bridge.Controller; using Bridge.State; using Bridge.TCP; +using Microsoft.Extensions.Logging; using RLBot.Flat; using RLBotCS.Conversion; using Color = System.Drawing.Color; @@ -16,6 +17,9 @@ public class Rendering(TcpMessenger tcpMessenger) public const int ResolutionHeightPixels = 1080; public const int FontWidthPixels = 10; public const int FontHeightPixels = 20; + public const int RectangleStringMaxLength = 30_000; + + private readonly ILogger Logger = Logging.GetLogger("Rendering"); private readonly RenderingCommandQueue _renderingCommandQueue = new(tcpMessenger); private readonly Dictionary>> _clientRenderTracker = []; @@ -130,7 +134,7 @@ private ushort SendRect3D(Rect3DT rect3Dt, GameState gameState) /// scaled the string is scaled with returned scaling factor. We use this as a hack to created filled rectangles /// for rectangle rendering. /// - /// + /// The rectangle string and the font scaling private (string, float) MakeFakeRectangleString(int width, int height) { int Gcd(int a, int b) @@ -147,27 +151,31 @@ int Gcd(int a, int b) return a | b; } - // We use the greatest common divisor to simplify the fraction (width/height) - // minimizing the characters needed for the rectangle. int gcd = Gcd(width, height); int cols = (width / gcd) * (FontHeightPixels / FontWidthPixels); int rows = height / gcd; + float scale = gcd / (float)FontHeightPixels; - StringBuilder str = new StringBuilder(cols * rows + rows); - for (int r = 0; r < rows; r++) + if (cols + rows > RectangleStringMaxLength) { - for (int c = 0; c < cols; c++) - { - str.Append(' '); - } + // The width-height ratio has resulting in a very long string. + // TODO: Consider an approximate solution as backup. Do we ever hit this case though? + Logger.LogWarning( + "A rendered rectangle requires more characters than budget allows. Consider different width-height ratio." + ); + } - if (r + 1 < rows) - { - str.Append('\n'); - } + StringBuilder str = new StringBuilder(cols + rows); + for (int c = 0; c < cols; c++) + { + str.Append(' '); + } + for (int r = 0; r < rows - 1; r++) + { + str.Append('\n'); } - return (str.ToString(), gcd / (float)FontHeightPixels); + return (str.ToString(), scale); } public void AddRenderGroup( From 7f1ff7df08d314f6725e4c11af5c3bace509b40f Mon Sep 17 00:00:00 2001 From: Eric Veilleux Date: Fri, 29 May 2026 08:26:40 -0500 Subject: [PATCH 2/2] Revert version bump RC 8 has not been released yet --- RLBotCS/Main.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RLBotCS/Main.cs b/RLBotCS/Main.cs index 947d6a2..162c119 100644 --- a/RLBotCS/Main.cs +++ b/RLBotCS/Main.cs @@ -1,4 +1,4 @@ -using System.Threading.Channels; +using System.Threading.Channels; using Bridge; using Bridge.TCP; using Microsoft.Extensions.Logging; @@ -10,7 +10,7 @@ if (args.Length > 0 && args[0] == "--version") { Console.WriteLine( - "RLBotServer v5.0.0-rc.9\n" + "RLBotServer v5.0.0-rc.8\n" + $"Bridge {BridgeVersion.Version}\n" + "@ https://www.rlbot.org & https://github.com/RLBot/core" );