Sanitize saved skirmish factions.

This commit is contained in:
Paul Chote
2025-02-22 09:51:21 +00:00
committed by Gustas
parent 3f4e4db836
commit 4ea0e70589
3 changed files with 18 additions and 12 deletions

View File

@@ -92,12 +92,18 @@ namespace OpenRA.Mods.Common.Server
}
}
var selectableFactions = server.Map.WorldActorInfo.TraitInfos<FactionInfo>()
.Where(f => f.Selectable)
.Select(f => f.InternalName)
.ToList();
var playerNode = nodes.NodeWithKeyOrDefault("Player");
if (playerNode != null)
{
var client = server.GetClient(conn);
SkirmishSlot.DeserializeToClient(playerNode.Value, client);
client.Color = LobbyCommands.SanitizePlayerColor(server, client.Color, client.Index);
client.Faction = LobbyCommands.SanitizePlayerFaction(server, client.Faction, selectableFactions);
}
var botsNode = nodes.NodeWithKeyOrDefault("Bots");
@@ -128,6 +134,8 @@ namespace OpenRA.Mods.Common.Server
if (client.Slot != null && !server.LobbyInfo.Slots[client.Slot].LockColor)
client.Color = LobbyCommands.SanitizePlayerColor(server, client.Color, client.Index);
client.Faction = LobbyCommands.SanitizePlayerFaction(server, client.Faction, selectableFactions);
server.LobbyInfo.Clients.Add(client);
S.SyncClientToPlayerReference(client, server.Map.Players.Players[client.Slot]);
}