From 6570e1b22e28d435e3877be398c0ca5e5e7314e6 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 14 Jun 2016 20:09:07 +0100 Subject: [PATCH] Avoid crash when parsing an order with duplicate IDs. --- OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index 0755851d30..c643dd29f6 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -433,10 +433,14 @@ namespace OpenRA.Mods.Common.Server return true; } - var options = server.Map.Rules.Actors["player"].TraitInfos() + var allOptions = server.Map.Rules.Actors["player"].TraitInfos() .Concat(server.Map.Rules.Actors["world"].TraitInfos()) - .SelectMany(t => t.LobbyOptions(server.Map.Rules)) - .ToDictionary(o => o.Id, o => o); + .SelectMany(t => t.LobbyOptions(server.Map.Rules)); + + // Overwrite keys with duplicate ids + var options = new Dictionary(); + foreach (var o in allOptions) + options[o.Id] = o; var split = s.Split(' '); LobbyOption option;