From 5a891daa596ca4bfc280618f2310a42415e08846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 2 Jul 2014 12:29:19 +0200 Subject: [PATCH] make GetSpawnOccupants more robust against invalid list queries fixes #5588 --- OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs index 3ebfae85f0..c306b67e82 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs @@ -150,14 +150,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var spawns = preview.SpawnPoints; return lobbyInfo.Clients - .Where(c => c.SpawnPoint != 0) + .Where(c => (c.SpawnPoint - 1 >= 0) && (c.SpawnPoint - 1 < spawns.Count)) .ToDictionary(c => spawns[c.SpawnPoint - 1], c => new SpawnOccupant(c)); } + public static Dictionary GetSpawnOccupants(IEnumerable players, MapPreview preview) { var spawns = preview.SpawnPoints; return players - .Where(c => c.SpawnPoint != 0) + .Where(c => (c.SpawnPoint - 1 >= 0) && (c.SpawnPoint - 1 < spawns.Count)) .ToDictionary(c => spawns[c.SpawnPoint - 1], c => new SpawnOccupant(c)); }