From d73a3ff7a079eaa4d63afb9ebf01538d6619b1af Mon Sep 17 00:00:00 2001 From: Virx Date: Sat, 19 Oct 2024 19:38:52 -0400 Subject: [PATCH] Fix hivemind auto launching --- RLBotCS/ManagerTools/MatchStarter.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/RLBotCS/ManagerTools/MatchStarter.cs b/RLBotCS/ManagerTools/MatchStarter.cs index 3fd5033..5797d0e 100644 --- a/RLBotCS/ManagerTools/MatchStarter.cs +++ b/RLBotCS/ManagerTools/MatchStarter.cs @@ -18,6 +18,7 @@ int rlbotSocketsPort private MatchSettingsT? _deferredMatchSettings; private MatchSettingsT? _matchSettings; + private Dictionary _hivemindNameMap = new(); private int _expectedConnections; private int _connectionReadies; @@ -92,6 +93,7 @@ public void MapSpawned(string MapName) private void PreprocessMatch(MatchSettingsT matchSettings) { Dictionary playerNames = []; + _hivemindNameMap.Clear(); foreach (var playerConfig in matchSettings.PlayerConfigurations) { @@ -108,6 +110,9 @@ private void PreprocessMatch(MatchSettingsT matchSettings) playerConfig.Name = playerName; } + if (playerConfig.Hivemind) + _hivemindNameMap[playerConfig.Name] = playerName; + if (playerConfig.SpawnId == 0) playerConfig.SpawnId = playerConfig.Name.GetHashCode(); @@ -116,18 +121,19 @@ private void PreprocessMatch(MatchSettingsT matchSettings) playerConfig.AgentId ??= ""; } + Dictionary scriptNames = []; foreach (var scriptConfig in matchSettings.ScriptConfigurations) { // De-duplicating similar names, Overwrites original value string scriptName = scriptConfig.Name ?? ""; - if (playerNames.TryGetValue(scriptName, out int value)) + if (scriptNames.TryGetValue(scriptName, out int value)) { - playerNames[scriptName] = ++value; + scriptNames[scriptName] = ++value; scriptConfig.Name = scriptName + $" ({value})"; } else { - playerNames[scriptName] = 0; + scriptNames[scriptName] = 0; scriptConfig.Name = scriptName; } @@ -162,7 +168,7 @@ private void StartBots(MatchSettingsT matchSettings) + "_" + playerConfig.RunCommand + "_" - + playerConfig.Name + + _hivemindNameMap[playerConfig.Name] + "_" + playerConfig.Team; @@ -175,6 +181,8 @@ private void StartBots(MatchSettingsT matchSettings) } } + _hivemindNameMap.Clear(); + _connectionReadies = 0; _expectedConnections = matchSettings.ScriptConfigurations.Count + processes.Count;