Dictionary optimization

This commit is contained in:
Eduardo Cáceres
2022-05-02 13:15:19 +02:00
committed by atlimit8
parent b71402f64d
commit 1b69ff017d

View File

@@ -182,21 +182,21 @@ namespace OpenRA.Mods.Common.UtilityCommands
{ {
switch (s.Key) switch (s.Key)
{ {
case "Intro": case "Intro":
videos.Add(new MiniYamlNode("BackgroundVideo", s.Value.ToLowerInvariant() + ".vqa")); videos.Add(new MiniYamlNode("BackgroundVideo", s.Value.ToLowerInvariant() + ".vqa"));
break; break;
case "Brief": case "Brief":
videos.Add(new MiniYamlNode("BriefingVideo", s.Value.ToLowerInvariant() + ".vqa")); videos.Add(new MiniYamlNode("BriefingVideo", s.Value.ToLowerInvariant() + ".vqa"));
break; break;
case "Action": case "Action":
videos.Add(new MiniYamlNode("StartVideo", s.Value.ToLowerInvariant() + ".vqa")); videos.Add(new MiniYamlNode("StartVideo", s.Value.ToLowerInvariant() + ".vqa"));
break; break;
case "Win": case "Win":
videos.Add(new MiniYamlNode("WinVideo", s.Value.ToLowerInvariant() + ".vqa")); videos.Add(new MiniYamlNode("WinVideo", s.Value.ToLowerInvariant() + ".vqa"));
break; break;
case "Lose": case "Lose":
videos.Add(new MiniYamlNode("LossVideo", s.Value.ToLowerInvariant() + ".vqa")); videos.Add(new MiniYamlNode("LossVideo", s.Value.ToLowerInvariant() + ".vqa"));
break; break;
} }
} }
} }
@@ -360,21 +360,18 @@ namespace OpenRA.Mods.Common.UtilityCommands
{ {
switch (s.Key) switch (s.Key)
{ {
case "Allies": case "Allies":
pr.Allies = s.Value.Split(',').Intersect(players).Except(neutral).ToArray(); pr.Allies = s.Value.Split(',').Intersect(players).Except(neutral).ToArray();
pr.Enemies = s.Value.Split(',').SymmetricDifference(players).Except(neutral).ToArray(); pr.Enemies = s.Value.Split(',').SymmetricDifference(players).Except(neutral).ToArray();
break; break;
default: default:
Console.WriteLine("Ignoring unknown {0}={1} for player {2}", s.Key, s.Value, pr.Name); Console.WriteLine("Ignoring unknown {0}={1} for player {2}", s.Key, s.Value, pr.Name);
break; break;
} }
} }
// Overwrite default player definitions if needed // Overwrite default player definitions if needed
if (!mapPlayers.Players.ContainsKey(section)) mapPlayers.Players[section] = pr;
mapPlayers.Players.Add(section, pr);
else
mapPlayers.Players[section] = pr;
} }
public virtual CPos ParseActorLocation(string input, int loc) public virtual CPos ParseActorLocation(string input, int loc)