diff --git a/OpenRA.Mods.Common/Traits/Player/TechTree.cs b/OpenRA.Mods.Common/Traits/Player/TechTree.cs index a95830432a..4b335630ed 100644 --- a/OpenRA.Mods.Common/Traits/Player/TechTree.cs +++ b/OpenRA.Mods.Common/Traits/Player/TechTree.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.Primitives; @@ -66,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits public bool HasPrerequisites(IEnumerable prerequisites) { var ownedPrereqs = GatherOwnedPrerequisites(player); - return prerequisites.All(p => !(p.Replace("~", "").StartsWith("!") + return prerequisites.All(p => !(p.Replace("~", "").StartsWith("!", StringComparison.Ordinal) ^ !ownedPrereqs.ContainsKey(p.Replace("!", "").Replace("~", "")))); } @@ -134,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits foreach (var prereq in prerequisites) { var withoutTilde = prereq.Replace("~", ""); - if (withoutTilde.StartsWith("!") ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", ""))) + if (withoutTilde.StartsWith("!", StringComparison.Ordinal) ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", ""))) return false; } @@ -146,10 +147,10 @@ namespace OpenRA.Mods.Common.Traits // PERF: Avoid LINQ. foreach (var prereq in prerequisites) { - if (!prereq.StartsWith("~")) + if (!prereq.StartsWith("~", StringComparison.Ordinal)) continue; var withoutTilde = prereq.Replace("~", ""); - if (withoutTilde.StartsWith("!") ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", ""))) + if (withoutTilde.StartsWith("!", StringComparison.Ordinal) ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", ""))) return true; }