From 2cc23738305ef9736d7da00199e41af536bec4ab Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 2 Jul 2024 13:35:09 +0400 Subject: [PATCH] Fix BloxstrapRPC not working in certain system locales TIL String.IndexOf() is subject to the system locale :( https://discord.com/channels/1099468797410283540/1169289170024407102 --- Bloxstrap/Integrations/ActivityWatcher.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/Integrations/ActivityWatcher.cs b/Bloxstrap/Integrations/ActivityWatcher.cs index 9447e11..0355a78 100644 --- a/Bloxstrap/Integrations/ActivityWatcher.cs +++ b/Bloxstrap/Integrations/ActivityWatcher.cs @@ -17,6 +17,7 @@ private const string GameJoiningEntryPattern = @"! Joining game '([0-9a-f\-]{36})' place ([0-9]+) at ([0-9\.]+)"; private const string GameJoiningUDMUXPattern = @"UDMUX Address = ([0-9\.]+), Port = [0-9]+ \| RCC Server Address = ([0-9\.]+), Port = [0-9]+"; private const string GameJoinedEntryPattern = @"serverId: ([0-9\.]+)\|[0-9]+"; + private const string GameMessageEntryPattern = @"\[BloxstrapRPC\] (.*)"; private int _gameClientPid; private int _logEntriesRead = 0; @@ -243,7 +244,16 @@ } else if (entry.Contains(GameMessageEntry)) { - string messagePlain = entry.Substring(entry.IndexOf(GameMessageEntry) + GameMessageEntry.Length + 1); + var match = Regex.Match(entry, GameMessageEntryPattern); + + if (match.Groups.Count != 2) + { + App.Logger.WriteLine(LOG_IDENT, $"Failed to assert format for RPC message entry"); + App.Logger.WriteLine(LOG_IDENT, entry); + return; + } + + string messagePlain = match.Groups[1].Value; Message? message; App.Logger.WriteLine(LOG_IDENT, $"Received message: '{messagePlain}'");