Skip to content

Commit d73a3ff

Browse files
committed
Fix hivemind auto launching
1 parent ce22870 commit d73a3ff

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

RLBotCS/ManagerTools/MatchStarter.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int rlbotSocketsPort
1818

1919
private MatchSettingsT? _deferredMatchSettings;
2020
private MatchSettingsT? _matchSettings;
21+
private Dictionary<string, string> _hivemindNameMap = new();
2122
private int _expectedConnections;
2223
private int _connectionReadies;
2324

@@ -92,6 +93,7 @@ public void MapSpawned(string MapName)
9293
private void PreprocessMatch(MatchSettingsT matchSettings)
9394
{
9495
Dictionary<string, int> playerNames = [];
96+
_hivemindNameMap.Clear();
9597

9698
foreach (var playerConfig in matchSettings.PlayerConfigurations)
9799
{
@@ -108,6 +110,9 @@ private void PreprocessMatch(MatchSettingsT matchSettings)
108110
playerConfig.Name = playerName;
109111
}
110112

113+
if (playerConfig.Hivemind)
114+
_hivemindNameMap[playerConfig.Name] = playerName;
115+
111116
if (playerConfig.SpawnId == 0)
112117
playerConfig.SpawnId = playerConfig.Name.GetHashCode();
113118

@@ -116,18 +121,19 @@ private void PreprocessMatch(MatchSettingsT matchSettings)
116121
playerConfig.AgentId ??= "";
117122
}
118123

124+
Dictionary<string, int> scriptNames = [];
119125
foreach (var scriptConfig in matchSettings.ScriptConfigurations)
120126
{
121127
// De-duplicating similar names, Overwrites original value
122128
string scriptName = scriptConfig.Name ?? "";
123-
if (playerNames.TryGetValue(scriptName, out int value))
129+
if (scriptNames.TryGetValue(scriptName, out int value))
124130
{
125-
playerNames[scriptName] = ++value;
131+
scriptNames[scriptName] = ++value;
126132
scriptConfig.Name = scriptName + $" ({value})";
127133
}
128134
else
129135
{
130-
playerNames[scriptName] = 0;
136+
scriptNames[scriptName] = 0;
131137
scriptConfig.Name = scriptName;
132138
}
133139

@@ -162,7 +168,7 @@ private void StartBots(MatchSettingsT matchSettings)
162168
+ "_"
163169
+ playerConfig.RunCommand
164170
+ "_"
165-
+ playerConfig.Name
171+
+ _hivemindNameMap[playerConfig.Name]
166172
+ "_"
167173
+ playerConfig.Team;
168174

@@ -175,6 +181,8 @@ private void StartBots(MatchSettingsT matchSettings)
175181
}
176182
}
177183

184+
_hivemindNameMap.Clear();
185+
178186
_connectionReadies = 0;
179187
_expectedConnections = matchSettings.ScriptConfigurations.Count + processes.Count;
180188

0 commit comments

Comments
 (0)