Use StringComparison.Ordinal for StartsWith checks in TechTree.cs.
This commit is contained in:
@@ -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<string> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user