Fix BloxstrapRPC not working in certain system locales

TIL String.IndexOf() is subject to the system locale :(

https://discord.com/channels/1099468797410283540/1169289170024407102
This commit is contained in:
pizzaboxer 2024-07-02 13:35:09 +04:00
parent facb992bf3
commit 2cc2373830
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -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}'");