Fix CA1310, CA1311
This commit is contained in:
committed by
Matthias Mailänder
parent
d83e579dfe
commit
285443f10f
@@ -670,6 +670,12 @@ dotnet_diagnostic.CA1304.severity = warning
|
|||||||
# Specify 'IFormatProvider'.
|
# Specify 'IFormatProvider'.
|
||||||
dotnet_diagnostic.CA1305.severity = warning
|
dotnet_diagnostic.CA1305.severity = warning
|
||||||
|
|
||||||
|
# Specify 'StringComparison' for correctness.
|
||||||
|
dotnet_diagnostic.CA1310.severity = warning
|
||||||
|
|
||||||
|
# Specify a culture or use an invariant version.
|
||||||
|
dotnet_diagnostic.CA1311.severity = warning
|
||||||
|
|
||||||
### Portability and Interoperability Rules
|
### Portability and Interoperability Rules
|
||||||
### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/interoperability-warnings
|
### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/interoperability-warnings
|
||||||
|
|
||||||
|
|||||||
@@ -83,14 +83,14 @@ namespace OpenRA.FileSystem
|
|||||||
|
|
||||||
public void Mount(string name, string explicitName = null)
|
public void Mount(string name, string explicitName = null)
|
||||||
{
|
{
|
||||||
var optional = name.StartsWith("~", StringComparison.Ordinal);
|
var optional = name.StartsWith('~');
|
||||||
if (optional)
|
if (optional)
|
||||||
name = name[1..];
|
name = name[1..];
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IReadOnlyPackage package;
|
IReadOnlyPackage package;
|
||||||
if (name.StartsWith("$", StringComparison.Ordinal))
|
if (name.StartsWith('$'))
|
||||||
{
|
{
|
||||||
name = name[1..];
|
name = name[1..];
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ namespace OpenRA.FileSystem
|
|||||||
public static string ResolveAssemblyPath(string path, Manifest manifest, InstalledMods installedMods)
|
public static string ResolveAssemblyPath(string path, Manifest manifest, InstalledMods installedMods)
|
||||||
{
|
{
|
||||||
var explicitSplit = path.IndexOf('|');
|
var explicitSplit = path.IndexOf('|');
|
||||||
if (explicitSplit > 0 && !path.StartsWith("^"))
|
if (explicitSplit > 0 && !path.StartsWith('^'))
|
||||||
{
|
{
|
||||||
var parent = path[..explicitSplit];
|
var parent = path[..explicitSplit];
|
||||||
var filename = path[(explicitSplit + 1)..];
|
var filename = path[(explicitSplit + 1)..];
|
||||||
@@ -304,7 +304,7 @@ namespace OpenRA.FileSystem
|
|||||||
if (parentPath == null)
|
if (parentPath == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (parentPath.StartsWith("$", StringComparison.Ordinal))
|
if (parentPath.StartsWith('$'))
|
||||||
{
|
{
|
||||||
if (!installedMods.TryGetValue(parentPath[1..], out var mod))
|
if (!installedMods.TryGetValue(parentPath[1..], out var mod))
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.FileSystem
|
|||||||
// in FileSystem.OpenPackage. Their internal name therefore contains the
|
// in FileSystem.OpenPackage. Their internal name therefore contains the
|
||||||
// full parent path too. We need to be careful to not add a second path
|
// full parent path too. We need to be careful to not add a second path
|
||||||
// prefix to these hacked packages.
|
// prefix to these hacked packages.
|
||||||
var filePath = filename.StartsWith(Name) ? filename : Path.Combine(Name, filename);
|
var filePath = filename.StartsWith(Name, StringComparison.Ordinal) ? filename : Path.Combine(Name, filename);
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||||
using (var s = File.Create(filePath))
|
using (var s = File.Create(filePath))
|
||||||
@@ -94,7 +94,7 @@ namespace OpenRA.FileSystem
|
|||||||
// in FileSystem.OpenPackage. Their internal name therefore contains the
|
// in FileSystem.OpenPackage. Their internal name therefore contains the
|
||||||
// full parent path too. We need to be careful to not add a second path
|
// full parent path too. We need to be careful to not add a second path
|
||||||
// prefix to these hacked packages.
|
// prefix to these hacked packages.
|
||||||
var filePath = filename.StartsWith(Name) ? filename : Path.Combine(Name, filename);
|
var filePath = filename.StartsWith(Name, StringComparison.Ordinal) ? filename : Path.Combine(Name, filename);
|
||||||
if (Directory.Exists(filePath))
|
if (Directory.Exists(filePath))
|
||||||
Directory.Delete(filePath, true);
|
Directory.Delete(filePath, true);
|
||||||
else if (File.Exists(filePath))
|
else if (File.Exists(filePath))
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ namespace OpenRA.GameRules
|
|||||||
static object LoadWarheads(MiniYaml yaml)
|
static object LoadWarheads(MiniYaml yaml)
|
||||||
{
|
{
|
||||||
var retList = new List<IWarhead>();
|
var retList = new List<IWarhead>();
|
||||||
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
|
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead", StringComparison.Ordinal)))
|
||||||
{
|
{
|
||||||
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
|
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace OpenRA.Graphics
|
|||||||
.Select(s => MiniYaml.FromStream(fileSystem.Open(s), s)));
|
.Select(s => MiniYaml.FromStream(fileSystem.Open(s), s)));
|
||||||
|
|
||||||
foreach (var c in chrome)
|
foreach (var c in chrome)
|
||||||
if (!c.Key.StartsWith("^", StringComparison.Ordinal))
|
if (!c.Key.StartsWith('^'))
|
||||||
LoadCollection(c.Key, c.Value);
|
LoadCollection(c.Key, c.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace OpenRA.Graphics
|
|||||||
foreach (var node in nodes)
|
foreach (var node in nodes)
|
||||||
{
|
{
|
||||||
// Nodes starting with ^ are inheritable but never loaded directly
|
// Nodes starting with ^ are inheritable but never loaded directly
|
||||||
if (node.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal))
|
if (node.Key.StartsWith(ActorInfo.AbstractActorPrefix))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
images[node.Key] = modData.SpriteSequenceLoader.ParseSequences(modData, tileSet, SpriteCache, node);
|
images[node.Key] = modData.SpriteSequenceLoader.ParseSequences(modData, tileSet, SpriteCache, node);
|
||||||
|
|||||||
@@ -275,7 +275,10 @@ namespace OpenRA
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var filename in contents)
|
foreach (var filename in contents)
|
||||||
if (filename.EndsWith(".yaml") || filename.EndsWith(".bin") || filename.EndsWith(".lua") || (format >= 12 && filename == "map.png"))
|
if (filename.EndsWith(".yaml", StringComparison.Ordinal) ||
|
||||||
|
filename.EndsWith(".bin", StringComparison.Ordinal) ||
|
||||||
|
filename.EndsWith(".lua", StringComparison.Ordinal) ||
|
||||||
|
(format >= 12 && filename == "map.png"))
|
||||||
streams.Add(package.GetStream(filename));
|
streams.Add(package.GetStream(filename));
|
||||||
|
|
||||||
// Take the SHA1
|
// Take the SHA1
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace OpenRA
|
|||||||
? MapClassification.Unknown : Enum<MapClassification>.Parse(kv.Value);
|
? MapClassification.Unknown : Enum<MapClassification>.Parse(kv.Value);
|
||||||
|
|
||||||
IReadOnlyPackage package;
|
IReadOnlyPackage package;
|
||||||
var optional = name.StartsWith("~", StringComparison.Ordinal);
|
var optional = name.StartsWith('~');
|
||||||
if (optional)
|
if (optional)
|
||||||
name = name[1..];
|
name = name[1..];
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ namespace OpenRA
|
|||||||
// HACK: If the path is inside the support directory then we may need to create it
|
// HACK: If the path is inside the support directory then we may need to create it
|
||||||
// Assume that the path is a directory if there is not an existing file with the same name
|
// Assume that the path is a directory if there is not an existing file with the same name
|
||||||
var resolved = Platform.ResolvePath(name);
|
var resolved = Platform.ResolvePath(name);
|
||||||
if (resolved.StartsWith(Platform.SupportDir) && !File.Exists(resolved))
|
if (resolved.StartsWith(Platform.SupportDir, StringComparison.Ordinal) && !File.Exists(resolved))
|
||||||
Directory.CreateDirectory(resolved);
|
Directory.CreateDirectory(resolved);
|
||||||
|
|
||||||
package = modData.ModFiles.OpenPackage(name);
|
package = modData.ModFiles.OpenPackage(name);
|
||||||
@@ -190,13 +190,13 @@ namespace OpenRA
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var name = kv.Key;
|
var name = kv.Key;
|
||||||
var optional = name.StartsWith("~", StringComparison.Ordinal);
|
var optional = name.StartsWith('~');
|
||||||
if (optional)
|
if (optional)
|
||||||
name = name[1..];
|
name = name[1..];
|
||||||
|
|
||||||
// Don't try to open the map directory in the support directory if it doesn't exist
|
// Don't try to open the map directory in the support directory if it doesn't exist
|
||||||
var resolved = Platform.ResolvePath(name);
|
var resolved = Platform.ResolvePath(name);
|
||||||
if (resolved.StartsWith(Platform.SupportDir) && (!Directory.Exists(resolved) || !File.Exists(resolved)))
|
if (resolved.StartsWith(Platform.SupportDir, StringComparison.Ordinal) && (!Directory.Exists(resolved) || !File.Exists(resolved)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
using (var package = (IReadWritePackage)modData.ModFiles.OpenPackage(name))
|
using (var package = (IReadWritePackage)modData.ModFiles.OpenPackage(name))
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ namespace OpenRA
|
|||||||
foreach (var r in ResolveInherits(parent, tree, inherited))
|
foreach (var r in ResolveInherits(parent, tree, inherited))
|
||||||
MergeIntoResolved(r, resolved, resolvedKeys, tree, inherited);
|
MergeIntoResolved(r, resolved, resolvedKeys, tree, inherited);
|
||||||
}
|
}
|
||||||
else if (n.Key.StartsWith("-", StringComparison.Ordinal))
|
else if (n.Key.StartsWith('-'))
|
||||||
{
|
{
|
||||||
var removed = n.Key[1..];
|
var removed = n.Key[1..];
|
||||||
if (resolved.RemoveAll(r => r.Key == removed) == 0)
|
if (resolved.RemoveAll(r => r.Key == removed) == 0)
|
||||||
|
|||||||
@@ -109,14 +109,14 @@ namespace OpenRA
|
|||||||
var p = Process.Start(psi);
|
var p = Process.Start(psi);
|
||||||
string line;
|
string line;
|
||||||
while ((line = p.StandardOutput.ReadLine()) != null)
|
while ((line = p.StandardOutput.ReadLine()) != null)
|
||||||
if (line.StartsWith("Operating System: "))
|
if (line.StartsWith("Operating System: ", StringComparison.Ordinal))
|
||||||
return line[18..] + suffix;
|
return line[18..] + suffix;
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
if (File.Exists("/etc/os-release"))
|
if (File.Exists("/etc/os-release"))
|
||||||
foreach (var line in File.ReadLines("/etc/os-release"))
|
foreach (var line in File.ReadLines("/etc/os-release"))
|
||||||
if (line.StartsWith("PRETTY_NAME="))
|
if (line.StartsWith("PRETTY_NAME=", StringComparison.Ordinal))
|
||||||
return line[13..^1] + suffix;
|
return line[13..^1] + suffix;
|
||||||
}
|
}
|
||||||
else if (CurrentPlatform == PlatformType.OSX)
|
else if (CurrentPlatform == PlatformType.OSX)
|
||||||
@@ -134,7 +134,7 @@ namespace OpenRA
|
|||||||
while ((line = p.StandardOutput.ReadLine()) != null)
|
while ((line = p.StandardOutput.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
line = line.Trim();
|
line = line.Trim();
|
||||||
if (line.StartsWith("System Version: "))
|
if (line.StartsWith("System Version: ", StringComparison.Ordinal))
|
||||||
return line[16..];
|
return line[16..];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ namespace OpenRA.Scripting
|
|||||||
// Remove the namespace and the trailing "Info"
|
// Remove the namespace and the trailing "Info"
|
||||||
return types.SelectMany(i => i.GetGenericArguments())
|
return types.SelectMany(i => i.GetGenericArguments())
|
||||||
.Select(g => g.Name.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault())
|
.Select(g => g.Name.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault())
|
||||||
.Select(s => s.EndsWith("Info") ? s.Remove(s.Length - 4, 4) : s)
|
.Select(s => s.EndsWith("Info", StringComparison.Ordinal) ? s.Remove(s.Length - 4, 4) : s)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
// Always load english strings to provide a fallback for missing translations.
|
// Always load english strings to provide a fallback for missing translations.
|
||||||
// It is important to load the english files first so the chosen language's files can override them.
|
// It is important to load the english files first so the chosen language's files can override them.
|
||||||
var paths = translations.Where(t => t.EndsWith("en.ftl")).ToHashSet();
|
var paths = translations.Where(t => t.EndsWith("en.ftl", StringComparison.Ordinal)).ToHashSet();
|
||||||
foreach (var t in translations)
|
foreach (var t in translations)
|
||||||
if (t.EndsWith($"{language}.ftl"))
|
if (t.EndsWith($"{language}.ftl", StringComparison.Ordinal))
|
||||||
paths.Add(t);
|
paths.Add(t);
|
||||||
|
|
||||||
foreach (var path in paths)
|
foreach (var path in paths)
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
|
|||||||
{
|
{
|
||||||
var vfh = VocFileHeader.Read(stream);
|
var vfh = VocFileHeader.Read(stream);
|
||||||
|
|
||||||
if (!vfh.Description.StartsWith("Creative Voice File"))
|
if (!vfh.Description.StartsWith("Creative Voice File", StringComparison.Ordinal))
|
||||||
throw new InvalidDataException("Voc header description not recognized");
|
throw new InvalidDataException("Voc header description not recognized");
|
||||||
if (vfh.DatablockOffset != 26)
|
if (vfh.DatablockOffset != 26)
|
||||||
throw new InvalidDataException("Voc header offset is wrong");
|
throw new InvalidDataException("Voc header offset is wrong");
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
|||||||
|
|
||||||
public VxlReader(Stream s)
|
public VxlReader(Stream s)
|
||||||
{
|
{
|
||||||
if (!s.ReadASCII(16).StartsWith("Voxel Animation"))
|
if (!s.ReadASCII(16).StartsWith("Voxel Animation", StringComparison.Ordinal))
|
||||||
throw new InvalidDataException("Invalid vxl header");
|
throw new InvalidDataException("Invalid vxl header");
|
||||||
|
|
||||||
s.ReadUInt32();
|
s.ReadUInt32();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc.Installer
|
|||||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||||
{
|
{
|
||||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||||
|
|
||||||
using (var source = File.OpenRead(sourcePath))
|
using (var source = File.OpenRead(sourcePath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
|
|
||||||
var player = basic.GetValue("Player", string.Empty);
|
var player = basic.GetValue("Player", string.Empty);
|
||||||
if (!string.IsNullOrEmpty(player))
|
if (!string.IsNullOrEmpty(player))
|
||||||
singlePlayer = !player.StartsWith("Multi");
|
singlePlayer = !player.StartsWith("Multi", StringComparison.Ordinal);
|
||||||
|
|
||||||
var mapSection = file.GetSection("Map");
|
var mapSection = file.GetSection("Map");
|
||||||
|
|
||||||
@@ -332,9 +332,9 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
var key = $"{loc % MapSize},{loc / MapSize}";
|
var key = $"{loc % MapSize},{loc / MapSize}";
|
||||||
var value = $"{type},{parts[2]}";
|
var value = $"{type},{parts[2]}";
|
||||||
var node = new MiniYamlNode(key, value);
|
var node = new MiniYamlNode(key, value);
|
||||||
if (type.StartsWith("sc"))
|
if (type.StartsWith("sc", StringComparison.Ordinal))
|
||||||
scorches.Add(node);
|
scorches.Add(node);
|
||||||
else if (type.StartsWith("cr"))
|
else if (type.StartsWith("cr", StringComparison.Ordinal))
|
||||||
craters.Add(node);
|
craters.Add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Commands
|
|||||||
|
|
||||||
public bool OnChat(string playername, string message)
|
public bool OnChat(string playername, string message)
|
||||||
{
|
{
|
||||||
if (message.StartsWith("/"))
|
if (message.StartsWith('/'))
|
||||||
{
|
{
|
||||||
var name = message[1..].Split(' ')[0].ToLowerInvariant();
|
var name = message[1..].Split(' ')[0].ToLowerInvariant();
|
||||||
var command = Commands.FirstOrDefault(x => x.Key == name);
|
var command = Commands.FirstOrDefault(x => x.Key == name);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||||
{
|
{
|
||||||
// Yaml path must be specified relative to a named directory (e.g. ^SupportDir)
|
// Yaml path must be specified relative to a named directory (e.g. ^SupportDir)
|
||||||
if (!actionYaml.Value.StartsWith("^"))
|
if (!actionYaml.Value.StartsWith('^'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var sourcePath = Platform.ResolvePath(actionYaml.Value);
|
var sourcePath = Platform.ResolvePath(actionYaml.Value);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||||
{
|
{
|
||||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||||
|
|
||||||
using (var source = File.OpenRead(sourcePath))
|
using (var source = File.OpenRead(sourcePath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||||
{
|
{
|
||||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||||
|
|
||||||
var volumeNode = actionYaml.Nodes.FirstOrDefault(n => n.Key == "Volumes");
|
var volumeNode = actionYaml.Nodes.FirstOrDefault(n => n.Key == "Volumes");
|
||||||
if (volumeNode == null)
|
if (volumeNode == null)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||||
{
|
{
|
||||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||||
|
|
||||||
using (var source = File.OpenRead(sourcePath))
|
using (var source = File.OpenRead(sourcePath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted, Action<string> updateMessage)
|
||||||
{
|
{
|
||||||
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
// Yaml path may be specified relative to a named directory (e.g. ^SupportDir) or the detected source path
|
||||||
var sourcePath = actionYaml.Value.StartsWith("^") ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
var sourcePath = actionYaml.Value.StartsWith('^') ? Platform.ResolvePath(actionYaml.Value) : FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||||
|
|
||||||
using (var source = File.OpenRead(sourcePath))
|
using (var source = File.OpenRead(sourcePath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Installer
|
|||||||
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted,
|
public void RunActionOnSource(MiniYaml actionYaml, string path, ModData modData, List<string> extracted,
|
||||||
Action<string> updateMessage)
|
Action<string> updateMessage)
|
||||||
{
|
{
|
||||||
var zipPath = actionYaml.Value.StartsWith("^")
|
var zipPath = actionYaml.Value.StartsWith('^')
|
||||||
? Platform.ResolvePath(actionYaml.Value)
|
? Platform.ResolvePath(actionYaml.Value)
|
||||||
: FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
: FS.ResolveCaseInsensitivePath(Path.Combine(path, actionYaml.Value));
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (sequenceReference.Prefix)
|
if (sequenceReference.Prefix)
|
||||||
{
|
{
|
||||||
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
|
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
|
||||||
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence)))
|
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence, StringComparison.Ordinal)))
|
||||||
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
|
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
|
||||||
}
|
}
|
||||||
else if (!sequences.HasSequence(i, sequence))
|
else if (!sequences.HasSequence(i, sequence))
|
||||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (sequenceReference.Prefix)
|
if (sequenceReference.Prefix)
|
||||||
{
|
{
|
||||||
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
|
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
|
||||||
if (!sequences.Sequences(image).Any(s => s.StartsWith(sequence)))
|
if (!sequences.Sequences(image).Any(s => s.StartsWith(sequence, StringComparison.Ordinal)))
|
||||||
emitWarning($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{image}`.");
|
emitWarning($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{image}`.");
|
||||||
}
|
}
|
||||||
else if (!sequences.HasSequence(image, sequence))
|
else if (!sequences.HasSequence(image, sequence))
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
static string NormalizeName(string key)
|
static string NormalizeName(string key)
|
||||||
{
|
{
|
||||||
var name = key.Split('@')[0];
|
var name = key.Split('@')[0];
|
||||||
if (name.StartsWith("-", StringComparison.Ordinal))
|
if (name.StartsWith('-'))
|
||||||
return name[1..];
|
return name[1..];
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
foreach (var t in actor.Value.Nodes)
|
foreach (var t in actor.Value.Nodes)
|
||||||
{
|
{
|
||||||
// Removals can never define children or values.
|
// Removals can never define children or values.
|
||||||
if (t.Key.StartsWith("-", StringComparison.Ordinal))
|
if (t.Key.StartsWith('-'))
|
||||||
{
|
{
|
||||||
if (t.Value.Nodes.Length > 0)
|
if (t.Value.Nodes.Length > 0)
|
||||||
emitError($"{t.Location} `{t.Key}` defines child nodes, which are not valid for removals.");
|
emitError($"{t.Location} `{t.Key}` defines child nodes, which are not valid for removals.");
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
static string NormalizeName(string key)
|
static string NormalizeName(string key)
|
||||||
{
|
{
|
||||||
var name = key.Split('@')[0];
|
var name = key.Split('@')[0];
|
||||||
if (name.StartsWith("-", StringComparison.Ordinal))
|
if (name.StartsWith('-'))
|
||||||
return name[1..];
|
return name[1..];
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
foreach (var field in weapon.Value.Nodes)
|
foreach (var field in weapon.Value.Nodes)
|
||||||
{
|
{
|
||||||
// Removals can never define children or values
|
// Removals can never define children or values
|
||||||
if (field.Key.StartsWith("-", StringComparison.Ordinal))
|
if (field.Key.StartsWith('-'))
|
||||||
{
|
{
|
||||||
if (field.Value.Nodes.Length > 0)
|
if (field.Value.Nodes.Length > 0)
|
||||||
emitError($"{field.Location} `{field.Key}` defines child nodes, which is not valid for removals.");
|
emitError($"{field.Location} `{field.Key}` defines child nodes, which is not valid for removals.");
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var bi = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
var bi = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
||||||
if (bi != null)
|
if (bi != null)
|
||||||
foreach (var prereq in bi.Prerequisites)
|
foreach (var prereq in bi.Prerequisites)
|
||||||
if (!prereq.StartsWith("~disabled") && !providedPrereqs.Contains(prereq.Replace("!", "").Replace("~", "")))
|
if (!prereq.StartsWith("~disabled", StringComparison.Ordinal) && !providedPrereqs.Contains(prereq.Replace("!", "").Replace("~", "")))
|
||||||
emitError($"Buildable actor `{actorInfo.Key}` has prereq `{prereq}` not provided by anything.");
|
emitError($"Buildable actor `{actorInfo.Key}` has prereq `{prereq}` not provided by anything.");
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException e)
|
catch (InvalidOperationException e)
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
lock (server.LobbyInfo)
|
lock (server.LobbyInfo)
|
||||||
{
|
{
|
||||||
// Kick command is always valid for the host
|
// Kick command is always valid for the host
|
||||||
if (command.StartsWith("kick "))
|
if (command.StartsWith("kick ", StringComparison.Ordinal))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (server.State == ServerState.GameStarted)
|
if (server.State == ServerState.GameStarted)
|
||||||
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
server.SendLocalizedMessageTo(conn, StateUnchangedGameStarted, Translation.Arguments("command", command));
|
server.SendLocalizedMessageTo(conn, StateUnchangedGameStarted, Translation.Arguments("command", command));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (client.State == Session.ClientState.Ready && !(command.StartsWith("state") || command == "startgame"))
|
else if (client.State == Session.ClientState.Ready && !(command.StartsWith("state", StringComparison.Ordinal) || command == "startgame"))
|
||||||
{
|
{
|
||||||
server.SendLocalizedMessageTo(conn, StateUnchangedReady);
|
server.SendLocalizedMessageTo(conn, StateUnchangedReady);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
|||||||
List<float2> frameOffsets;
|
List<float2> frameOffsets;
|
||||||
|
|
||||||
// Prefer manual defined regions over auto sliced regions.
|
// Prefer manual defined regions over auto sliced regions.
|
||||||
if (png.EmbeddedData.Any(meta => meta.Key.StartsWith("Frame[")))
|
if (png.EmbeddedData.Any(meta => meta.Key.StartsWith("Frame[", StringComparison.Ordinal)))
|
||||||
RegionsFromFrames(png, out frameRegions, out frameOffsets);
|
RegionsFromFrames(png, out frameRegions, out frameOffsets);
|
||||||
else
|
else
|
||||||
RegionsFromSlices(png, out frameRegions, out frameOffsets);
|
RegionsFromSlices(png, out frameRegions, out frameOffsets);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -110,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
// PERF: Avoid LINQ.
|
// PERF: Avoid LINQ.
|
||||||
foreach (var pref in prefixes)
|
foreach (var pref in prefixes)
|
||||||
if (name.StartsWith(pref))
|
if (name.StartsWith(pref, StringComparison.Ordinal))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -116,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString.StartsWith("Dev"))
|
if (order.OrderString.StartsWith("Dev", StringComparison.Ordinal))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OrderCount++;
|
OrderCount++;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -66,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public bool HasPrerequisites(IEnumerable<string> prerequisites)
|
public bool HasPrerequisites(IEnumerable<string> prerequisites)
|
||||||
{
|
{
|
||||||
var ownedPrereqs = GatherOwnedPrerequisites(Owner);
|
var ownedPrereqs = GatherOwnedPrerequisites(Owner);
|
||||||
return prerequisites.All(p => !(p.Replace("~", "").StartsWith("!", StringComparison.Ordinal)
|
return prerequisites.All(p => !(p.Replace("~", "").StartsWith('!')
|
||||||
^ !ownedPrereqs.ContainsKey(p.Replace("!", "").Replace("~", ""))));
|
^ !ownedPrereqs.ContainsKey(p.Replace("!", "").Replace("~", ""))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
foreach (var prereq in prerequisites)
|
foreach (var prereq in prerequisites)
|
||||||
{
|
{
|
||||||
var withoutTilde = prereq.Replace("~", "");
|
var withoutTilde = prereq.Replace("~", "");
|
||||||
if (withoutTilde.StartsWith("!", StringComparison.Ordinal) ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
if (withoutTilde.StartsWith('!') ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,10 +153,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// PERF: Avoid LINQ.
|
// PERF: Avoid LINQ.
|
||||||
foreach (var prereq in prerequisites)
|
foreach (var prereq in prerequisites)
|
||||||
{
|
{
|
||||||
if (!prereq.StartsWith("~", StringComparison.Ordinal))
|
if (!prereq.StartsWith('~'))
|
||||||
continue;
|
continue;
|
||||||
var withoutTilde = prereq.Replace("~", "");
|
var withoutTilde = prereq.Replace("~", "");
|
||||||
if (withoutTilde.StartsWith("!", StringComparison.Ordinal) ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
if (withoutTilde.StartsWith('!') ^ !ownedPrerequisites.ContainsKey(withoutTilde.Replace("!", "")))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void SyncMultiplayerCount()
|
void SyncMultiplayerCount()
|
||||||
{
|
{
|
||||||
var newCount = previews.Count(p => p.Info.Name == "mpspawn");
|
var newCount = previews.Count(p => p.Info.Name == "mpspawn");
|
||||||
var mp = Players.Players.Where(p => p.Key.StartsWith("Multi")).ToList();
|
var mp = Players.Players.Where(p => p.Key.StartsWith("Multi", StringComparison.Ordinal)).ToList();
|
||||||
foreach (var kv in mp)
|
foreach (var kv in mp)
|
||||||
{
|
{
|
||||||
var name = kv.Key;
|
var name = kv.Key;
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|||||||
defaultTilesetFilenamesNode = defaultsNode.LastChildMatching("TilesetFilenames") ?? defaultTilesetFilenamesNode;
|
defaultTilesetFilenamesNode = defaultsNode.LastChildMatching("TilesetFilenames") ?? defaultTilesetFilenamesNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((defaultFilenameNode == null || defaultTilesetFilenamesNode == null) && !imageNode.Key.StartsWith("^"))
|
if ((defaultFilenameNode == null || defaultTilesetFilenamesNode == null) && !imageNode.Key.StartsWith('^'))
|
||||||
{
|
{
|
||||||
var duplicateCount = new Dictionary<string, int>();
|
var duplicateCount = new Dictionary<string, int>();
|
||||||
var duplicateTilesetCount = new Dictionary<string, int>();
|
var duplicateTilesetCount = new Dictionary<string, int>();
|
||||||
@@ -372,7 +372,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|||||||
|
|
||||||
// Replace removals with masking
|
// Replace removals with masking
|
||||||
foreach (var node in sequenceNode.Value.Nodes)
|
foreach (var node in sequenceNode.Value.Nodes)
|
||||||
if (node.Key?.StartsWith("-") ?? false)
|
if (node.Key?.StartsWith('-') ?? false)
|
||||||
node.Key = node.Key[1..];
|
node.Key = node.Key[1..];
|
||||||
|
|
||||||
var combineNode = sequenceNode.LastChildMatching("Combine");
|
var combineNode = sequenceNode.LastChildMatching("Combine");
|
||||||
@@ -389,7 +389,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|||||||
}
|
}
|
||||||
|
|
||||||
var filename = string.IsNullOrEmpty(resolvedSequenceNode.Value.Value) ? imageName : resolvedSequenceNode.Value.Value;
|
var filename = string.IsNullOrEmpty(resolvedSequenceNode.Value.Value) ? imageName : resolvedSequenceNode.Value.Value;
|
||||||
if (filename.StartsWith("^"))
|
if (filename.StartsWith('^'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (useTilesetExtension || useTilesetCode)
|
if (useTilesetExtension || useTilesetCode)
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
var interfaceMembers = interfaceType.GetMembers();
|
var interfaceMembers = interfaceType.GetMembers();
|
||||||
foreach (var interfaceMember in interfaceMembers)
|
foreach (var interfaceMember in interfaceMembers)
|
||||||
{
|
{
|
||||||
if (interfaceMember.Name.StartsWith("get_") || interfaceMember.Name.StartsWith("set_") || interfaceMember.Name.StartsWith("add_") || interfaceMember.Name.StartsWith("remove_"))
|
if (interfaceMember.Name.StartsWith("get_", StringComparison.Ordinal) ||
|
||||||
|
interfaceMember.Name.StartsWith("set_", StringComparison.Ordinal) ||
|
||||||
|
interfaceMember.Name.StartsWith("add_", StringComparison.Ordinal) ||
|
||||||
|
interfaceMember.Name.StartsWith("remove_", StringComparison.Ordinal))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var interfaceMethod = interfaceMember as MethodInfo;
|
var interfaceMethod = interfaceMember as MethodInfo;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
}
|
}
|
||||||
|
|
||||||
var value = field.GetValue(section.Value);
|
var value = field.GetValue(section.Value);
|
||||||
if (value != null && !value.ToString().StartsWith("System."))
|
if (value != null && !value.ToString().StartsWith("System.", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"**Default Value:** {value}");
|
Console.WriteLine($"**Default Value:** {value}");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
.Select(type => new
|
.Select(type => new
|
||||||
{
|
{
|
||||||
type.Namespace,
|
type.Namespace,
|
||||||
Name = type.Name.EndsWith("Info") ? type.Name[..^4] : type.Name,
|
Name = type.Name.EndsWith("Info", StringComparison.Ordinal) ? type.Name[..^4] : type.Name,
|
||||||
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||||
RequiresTraits = RequiredTraitTypes(type)
|
RequiresTraits = RequiredTraitTypes(type)
|
||||||
.Select(y => y.Name),
|
.Select(y => y.Name),
|
||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
.Select(a =>
|
.Select(a =>
|
||||||
{
|
{
|
||||||
var name = a.AttributeType.Name;
|
var name = a.AttributeType.Name;
|
||||||
name = name.EndsWith("Attribute") ? name[..^9] : name;
|
name = name.EndsWith("Attribute", StringComparison.Ordinal) ? name[..^9] : name;
|
||||||
|
|
||||||
return new
|
return new
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
.Select(type => new
|
.Select(type => new
|
||||||
{
|
{
|
||||||
type.Namespace,
|
type.Namespace,
|
||||||
Name = type.Name.EndsWith("Info") ? type.Name[..^4] : type.Name,
|
Name = type.Name.EndsWith("Info", StringComparison.Ordinal) ? type.Name[..^4] : type.Name,
|
||||||
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
Description = string.Join(" ", Utility.GetCustomAttributes<DescAttribute>(type, false).SelectMany(d => d.Lines)),
|
||||||
InheritedTypes = type.BaseTypes()
|
InheritedTypes = type.BaseTypes()
|
||||||
.Select(y => y.Name)
|
.Select(y => y.Name)
|
||||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
.Select(a =>
|
.Select(a =>
|
||||||
{
|
{
|
||||||
var name = a.AttributeType.Name;
|
var name = a.AttributeType.Name;
|
||||||
name = name.EndsWith("Attribute") ? name[..^9] : name;
|
name = name.EndsWith("Attribute", StringComparison.Ordinal) ? name[..^9] : name;
|
||||||
|
|
||||||
return new
|
return new
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (buildable != null)
|
if (buildable != null)
|
||||||
{
|
{
|
||||||
var prerequisites = buildable.Prerequisites.Select(a => ActorName(modData.DefaultRules, a))
|
var prerequisites = buildable.Prerequisites.Select(a => ActorName(modData.DefaultRules, a))
|
||||||
.Where(s => !s.StartsWith("~", StringComparison.Ordinal) && !s.StartsWith("!", StringComparison.Ordinal));
|
.Where(s => !s.StartsWith('~') && !s.StartsWith('!'));
|
||||||
if (prerequisites.Any())
|
if (prerequisites.Any())
|
||||||
text += $"Requires {prerequisites.JoinWith(", ")}\n\n";
|
text += $"Requires {prerequisites.JoinWith(", ")}\n\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Commands;
|
using OpenRA.Mods.Common.Commands;
|
||||||
@@ -143,7 +142,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var team = teamChat && !disableTeamChat;
|
var team = teamChat && !disableTeamChat;
|
||||||
if (chatText.Text != "")
|
if (chatText.Text != "")
|
||||||
{
|
{
|
||||||
if (!chatText.Text.StartsWith("/", StringComparison.Ordinal))
|
if (!chatText.Text.StartsWith('/'))
|
||||||
{
|
{
|
||||||
// This should never happen, but avoid a crash if it does somehow (chat will just stay open)
|
// This should never happen, but avoid a crash if it does somehow (chat will just stay open)
|
||||||
if (!isObserver && orderManager.LocalClient == null && world.LocalPlayer == null)
|
if (!isObserver && orderManager.LocalClient == null && world.LocalPlayer == null)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
var prereqs = buildable.Prerequisites.Select(a => ActorName(mapRules, a))
|
var prereqs = buildable.Prerequisites.Select(a => ActorName(mapRules, a))
|
||||||
.Where(s => !s.StartsWith("~", StringComparison.Ordinal) && !s.StartsWith("!", StringComparison.Ordinal));
|
.Where(s => !s.StartsWith('~') && !s.StartsWith('!'));
|
||||||
|
|
||||||
var requiresSize = int2.Zero;
|
var requiresSize = int2.Zero;
|
||||||
if (prereqs.Any())
|
if (prereqs.Any())
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
var toComplete = "";
|
var toComplete = "";
|
||||||
if (text.StartsWith("/") && Commands != null)
|
if (text.StartsWith('/') && Commands != null)
|
||||||
{
|
{
|
||||||
prefix = "/";
|
prefix = "/";
|
||||||
suffix = "";
|
suffix = "";
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ namespace OpenRA.Platforms.Default
|
|||||||
var lines = p.StandardOutput.ReadToEnd().Split('\n');
|
var lines = p.StandardOutput.ReadToEnd().Split('\n');
|
||||||
|
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
if (line.StartsWith("Xft.dpi") && int.TryParse(line.AsSpan(8), out var dpi))
|
if (line.StartsWith("Xft.dpi", StringComparison.Ordinal) && int.TryParse(line.AsSpan(8), out var dpi))
|
||||||
windowScale = dpi / 96f;
|
windowScale = dpi / 96f;
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|||||||
Reference in New Issue
Block a user