From 0f7a744ef7516ee423830a4b5aeef83af6aa4722 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 18 Oct 2011 20:23:10 +1300 Subject: [PATCH] replace ridiculous GetSpawnColors function with something tidier --- OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs index 34a722b8a0..49ad2f0162 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs @@ -121,17 +121,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic public static Dictionary GetSpawnColors(OrderManager orderManager, Map map) { - var spawns = Map.SpawnPoints; - var sc = new Dictionary(); - - for (int i = 1; i <= spawns.Count(); i++) - { - var client = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == i); - if (client == null) - continue; - sc.Add(spawns.ElementAt(i - 1), client.ColorRamp.GetColor(0)); - } - return sc; + return orderManager.LobbyInfo.Clients + .Where( c => c.SpawnPoint != 0 ) + .ToDictionary( + c => Map.SpawnPoints.ElementAt( c.SpawnPoint - 1 ), + c => c.ColorRamp.GetColor(0)); } } }