Skip to content

Commit 0cfe8e9

Browse files
committed
SpawnId -> PlayerId
1 parent 4899134 commit 0cfe8e9

File tree

12 files changed

+31
-33
lines changed

12 files changed

+31
-33
lines changed

RLBotCS/Conversion/GameStateToFlat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static GamePacketT ToFlatBuffers(this GameState gameState)
170170
Name = car.Name,
171171
Team = car.Team,
172172
Boost = car.Boost,
173-
SpawnId = car.SpawnId,
173+
PlayerId = car.PlayerId,
174174
ScoreInfo = new()
175175
{
176176
Score = car.ScoreInfo.Score,

RLBotCS/ManagerTools/AgentMapping.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace RLBotCS.ManagerTools;
66
public struct PlayerIdPair
77
{
88
public uint Index;
9-
public int SpawnId;
9+
public int PlayerId;
1010
}
1111

1212
public class AgentMapping
@@ -38,7 +38,7 @@ public void SetAgents(MatchConfigurationT matchConfig)
3838
playerConfig.Team,
3939
playerConfig.Name,
4040
playerConfig.AgentId,
41-
playerConfig.SpawnId
41+
playerConfig.PlayerId
4242
)
4343
);
4444
}
@@ -53,7 +53,7 @@ public void SetAgents(MatchConfigurationT matchConfig)
5353
Team.Scripts,
5454
scriptConfig.Name,
5555
scriptConfig.AgentId,
56-
scriptConfig.SpawnId
56+
scriptConfig.ScriptId
5757
)
5858
);
5959
}
@@ -69,7 +69,7 @@ public void SetAgents(MatchConfigurationT matchConfig)
6969
player.SetClient(clientId);
7070

7171
return (
72-
new PlayerIdPair { Index = player.Index, SpawnId = player.SpawnId },
72+
new PlayerIdPair { Index = player.Index, PlayerId = player.PlayerId },
7373
player.Team
7474
);
7575
}
@@ -99,7 +99,7 @@ public void SetAgents(MatchConfigurationT matchConfig)
9999
new PlayerIdPair
100100
{
101101
Index = playerMetadata.Index,
102-
SpawnId = playerMetadata.SpawnId,
102+
PlayerId = playerMetadata.PlayerId,
103103
}
104104
);
105105
}

RLBotCS/ManagerTools/ConfigParser.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Diagnostics;
2-
using System.Runtime.InteropServices;
32
using Microsoft.Extensions.Logging;
43
using RLBot.Flat;
54
using RLBotCS.Model;
@@ -346,7 +345,7 @@ private PlayerConfigurationT ParseCarTable(TomlTable table, string matchConfigPa
346345
Hivemind = false,
347346
RootDir = "",
348347
RunCommand = "",
349-
SpawnId = 0,
348+
PlayerId = 0,
350349
};
351350
}
352351

@@ -409,7 +408,7 @@ private PlayerConfigurationT LoadPlayerConfig(
409408
RunCommand = GetRunCommand(settings),
410409
Hivemind = GetValue(settings, Fields.AgentHivemind, false),
411410
RootDir = rootDir,
412-
SpawnId = 0,
411+
PlayerId = 0,
413412
Variety = variety,
414413
};
415414
}

RLBotCS/ManagerTools/ConfigValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ List<PlayerConfigurationT> players
161161
break;
162162
}
163163

164-
player.SpawnId =
164+
player.PlayerId =
165165
player.Variety.Type == PlayerClass.Human
166166
? 0
167167
: $"{player.AgentId}/{player.Team}/{i}".GetHashCode();
@@ -209,7 +209,7 @@ List<ScriptConfigurationT> scripts
209209
script.Name ??= "";
210210
script.RunCommand ??= "";
211211
script.RootDir ??= "";
212-
script.SpawnId = $"{script.AgentId}/{Team.Scripts}/{i}".GetHashCode();
212+
script.ScriptId = $"{script.AgentId}/{Team.Scripts}/{i}".GetHashCode();
213213
}
214214

215215
return valid;

RLBotCS/ManagerTools/MatchStarter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private void LoadMatch(MatchConfigurationT matchConfig, PlayerSpawner spawner)
272272

273273
if (matchConfig.PlayerConfigurations.Count <= i)
274274
{
275-
toDespawnIds.Add(lastPlayerConfig.SpawnId);
275+
toDespawnIds.Add(lastPlayerConfig.PlayerId);
276276
toDespawnNames.Add(
277277
$"{lastPlayerConfig.AgentId} (index {i}, team {lastPlayerConfig.Team})"
278278
);
@@ -285,7 +285,7 @@ private void LoadMatch(MatchConfigurationT matchConfig, PlayerSpawner spawner)
285285
|| lastPlayerConfig.Team != playerConfig.Team
286286
)
287287
{
288-
toDespawnIds.Add(lastPlayerConfig.SpawnId);
288+
toDespawnIds.Add(lastPlayerConfig.PlayerId);
289289
toDespawnNames.Add(
290290
$"{lastPlayerConfig.AgentId} (index {i}, team {lastPlayerConfig.Team})"
291291
);

RLBotCS/ManagerTools/PlayerSpawner.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void SpawnBot(PlayerConfigurationT config, BotSkill skill, uint desiredIn
1818
{
1919
PlayerMetadata? alreadySpawnedPlayer = _gameState
2020
.PlayerMapping.GetKnownPlayers()
21-
.FirstOrDefault(kp => config.SpawnId == kp.SpawnId);
21+
.FirstOrDefault(kp => config.PlayerId == kp.PlayerId);
2222
if (alreadySpawnedPlayer != null)
2323
// We've already spawned this player, don't duplicate them.
2424
return;
@@ -36,7 +36,7 @@ public void SpawnBot(PlayerConfigurationT config, BotSkill skill, uint desiredIn
3636
new SpawnTracker
3737
{
3838
CommandId = commandId,
39-
SpawnId = config.SpawnId,
39+
PlayerId = config.PlayerId,
4040
DesiredPlayerIndex = desiredIndex,
4141
IsCustomBot = skill == BotSkill.Custom,
4242
IsBot = true,
@@ -51,7 +51,7 @@ public void SpawnHuman(PlayerConfigurationT config, uint desiredIndex)
5151

5252
PlayerMetadata? alreadySpawnedPlayer = _gameState
5353
.PlayerMapping.GetKnownPlayers()
54-
.FirstOrDefault(kp => config.SpawnId == kp.SpawnId);
54+
.FirstOrDefault(kp => config.PlayerId == kp.PlayerId);
5555
if (alreadySpawnedPlayer != null)
5656
{
5757
_gameState.PlayerMapping.QueueIndexChange(
@@ -65,7 +65,7 @@ public void SpawnHuman(PlayerConfigurationT config, uint desiredIndex)
6565
new SpawnTracker
6666
{
6767
CommandId = 0, // Human spawning must use command id 0 for reasons in bridge
68-
SpawnId = config.SpawnId,
68+
PlayerId = config.PlayerId,
6969
DesiredPlayerIndex = desiredIndex,
7070
IsBot = false,
7171
IsCustomBot = false,
@@ -79,13 +79,13 @@ public void MakeHumanSpectate()
7979
spawnCommandQueue.AddConsoleCommand("spectate");
8080
}
8181

82-
public void DespawnPlayers(List<int> spawnIds)
82+
public void DespawnPlayers(List<int> playerIds)
8383
{
84-
foreach (int spawnId in spawnIds)
84+
foreach (int playerId in playerIds)
8585
{
8686
PlayerMetadata? player = _gameState
8787
.PlayerMapping.GetKnownPlayers()
88-
.FirstOrDefault(p => p.SpawnId == spawnId);
88+
.FirstOrDefault(p => p.PlayerId == playerId);
8989

9090
if (player != null)
9191
{

RLBotCS/Model/AgentMetadata.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
namespace RLBotCS.Model;
22

3-
public class AgentMetadata(uint index, uint team, string name, string agentId, int spawnId)
3+
public class AgentMetadata(uint index, uint team, string name, string agentId, int playerId)
44
{
55
public readonly uint Index = index;
66
public readonly uint Team = team;
77
public readonly string Name = name;
88
public readonly string AgentId = agentId;
9-
public readonly int SpawnId = spawnId;
9+
public readonly int PlayerId = playerId;
1010

1111
public int? ClientId { get; private set; } = null;
1212
public bool Ready { get; set; } = false;

RLBotCS/Server/BridgeMessage/SetInitLoadout.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace RLBotCS.Server.BridgeMessage;
77
/// Sets the loadout of a bot that has yet to ready up and spawn (replaces loadout generators from v4).
88
/// See also <see cref="StateSetLoadout"/> for loadout change during matches.
99
/// </summary>
10-
record SetInitLoadout(PlayerLoadoutT Loadout, int SpawnId) : IBridgeMessage
10+
record SetInitLoadout(PlayerLoadoutT Loadout, int PlayerId) : IBridgeMessage
1111
{
1212
public void HandleMessage(BridgeContext context)
1313
{
@@ -22,18 +22,18 @@ public void HandleMessage(BridgeContext context)
2222
{
2323
// BUG: If "wait_for_agents=false" then you cannot use the new 'loadout generators'
2424
context.Logger.LogWarning(
25-
"Cannot set initial loadout of bot with spawn id {}. Cars have already spawned.",
26-
SpawnId
25+
"Cannot set initial loadout of bot with player id {}. Cars have already spawned.",
26+
PlayerId
2727
);
2828
return;
2929
}
3030

31-
var player = matchConfig.PlayerConfigurations.Find(p => p.SpawnId == SpawnId);
31+
var player = matchConfig.PlayerConfigurations.Find(p => p.PlayerId == PlayerId);
3232
if (player is null)
3333
{
3434
context.Logger.LogError(
35-
"Cannot set loadout of player with spawn id {}. No such player exists.",
36-
SpawnId
35+
"Cannot set loadout of player with player id {}. No such player exists.",
36+
PlayerId
3737
);
3838
return;
3939
}

RLBotCS/Server/BridgeMessage/StateSetLoadout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void HandleMessage(BridgeContext context)
4646
new SpawnTracker
4747
{
4848
CommandId = commandId,
49-
SpawnId = meta.SpawnId,
49+
PlayerId = meta.PlayerId,
5050
DesiredPlayerIndex = meta.PlayerIndex,
5151
IsCustomBot = true,
5252
IsBot = true,

RLBotCS/Server/FlatBuffersSession.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Net.Sockets;
22
using System.Threading.Channels;
3-
using Google.FlatBuffers;
43
using Microsoft.Extensions.Logging;
54
using RLBot.Flat;
65
using RLBotCS.ManagerTools;
@@ -163,7 +162,7 @@ await _bridge.WriteAsync(
163162
if (maybeIdPair is { } pair)
164163
{
165164
await _bridge.WriteAsync(
166-
new SetInitLoadout(setLoadout.Loadout, pair.SpawnId)
165+
new SetInitLoadout(setLoadout.Loadout, pair.PlayerId)
167166
);
168167
}
169168
else
@@ -344,7 +343,7 @@ private async Task HandleInternalMessages()
344343
.Select(playerInfo => new ControllableInfoT()
345344
{
346345
Index = playerInfo.Index,
347-
SpawnId = playerInfo.SpawnId,
346+
Identifier = playerInfo.PlayerId,
348347
})
349348
.ToList();
350349

0 commit comments

Comments
 (0)