Prevent locked spawns from being selected.

This commit is contained in:
Paul Chote
2016-03-06 11:38:00 +00:00
parent 8b9bdadf53
commit ccdae033ff

View File

@@ -875,6 +875,22 @@ namespace OpenRA.Mods.Common.Server
return true; return true;
} }
// Check if any other slot has locked the requested spawn
if (spawnPoint > 0)
{
var spawnLockedByAnotherSlot = server.LobbyInfo.Slots.Where(ss => ss.Value.LockSpawn).Any(ss =>
{
var pr = PlayerReferenceForSlot(server, ss.Value);
return pr != null && pr.Spawn == spawnPoint;
});
if (spawnLockedByAnotherSlot)
{
server.SendOrderTo(conn, "Message", "The spawn point is locked to another player slot.");
return true;
}
}
targetClient.SpawnPoint = spawnPoint; targetClient.SpawnPoint = spawnPoint;
server.SyncLobbyClients(); server.SyncLobbyClients();
return true; return true;
@@ -1037,5 +1053,13 @@ namespace OpenRA.Mods.Common.Server
if (client.Slot == null || !server.LobbyInfo.Slots[client.Slot].LockColor) if (client.Slot == null || !server.LobbyInfo.Slots[client.Slot].LockColor)
client.Color = SanitizePlayerColor(server, client.Color, client.Index); client.Color = SanitizePlayerColor(server, client.Color, client.Index);
} }
public PlayerReference PlayerReferenceForSlot(S server, Session.Slot slot)
{
if (slot == null)
return null;
return server.MapPlayers.Players[slot.PlayerReference];
}
} }
} }