Fix CA1822

This commit is contained in:
RoosterDragon
2023-03-12 16:24:19 +00:00
committed by Pavel Penev
parent e4cac1fffc
commit 277699cbd5
77 changed files with 109 additions and 105 deletions

View File

@@ -689,6 +689,10 @@ dotnet_diagnostic.CA1717.severity = warning
# Remove empty finalizers.
dotnet_diagnostic.CA1821.severity = warning
# Mark members as static.
dotnet_code_quality.CA1822.api_surface = private,internal
dotnet_diagnostic.CA1822.severity = warning
# Avoid unused private fields.
dotnet_diagnostic.CA1823.severity = warning

View File

@@ -257,7 +257,7 @@ namespace OpenRA
}
}
IEnumerable<string> GetSupportDirs(ModRegistration registration)
static IEnumerable<string> GetSupportDirs(ModRegistration registration)
{
var sources = new HashSet<string>(4);
if (registration.HasFlag(ModRegistration.System))

View File

@@ -271,7 +271,7 @@ namespace OpenRA.FileFormats
throw new InvalidDataException("Unknown pixel format");
}
void WritePngChunk(Stream output, string type, Stream input)
static void WritePngChunk(Stream output, string type, Stream input)
{
input.Position = 0;

View File

@@ -302,7 +302,7 @@ namespace OpenRA.Graphics
return fbo;
}
void DisableFrameBuffer(IFrameBuffer fbo)
static void DisableFrameBuffer(IFrameBuffer fbo)
{
Game.Renderer.Flush();
Game.Renderer.Context.DisableDepthBuffer();

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Graphics
/// Will behave badly if the lines are parallel.
/// Z position is the average of a and b (ignores actual intersection point if it exists).
/// </summary>
float3 IntersectionOf(in float3 a, in float3 da, in float3 b, in float3 db)
static float3 IntersectionOf(in float3 a, in float3 da, in float3 b, in float3 db)
{
var crossA = a.X * (a.Y + da.Y) - a.Y * (a.X + da.X);
var crossB = b.X * (b.Y + db.Y) - b.Y * (b.X + db.X);

View File

@@ -123,7 +123,7 @@ namespace OpenRA.Graphics
}
}
float2 Rotate(float2 v, float sina, float cosa, float2 offset)
static float2 Rotate(float2 v, float sina, float cosa, float2 offset)
{
return new float2(
v.X * cosa - v.Y * sina + offset.X,

View File

@@ -114,7 +114,7 @@ namespace OpenRA.Graphics
return new int2(sheetIndex, secondarySheetIndex);
}
float ResolveTextureIndex(Sprite s, PaletteReference pal)
static float ResolveTextureIndex(Sprite s, PaletteReference pal)
{
if (pal == null)
return 0;

View File

@@ -172,7 +172,7 @@ namespace OpenRA.Graphics
UpdateViewportZooms();
}
float CalculateMinimumZoom(float minHeight, float maxHeight)
static float CalculateMinimumZoom(float minHeight, float maxHeight)
{
var h = Game.Renderer.NativeResolution.Height;

View File

@@ -54,7 +54,7 @@ namespace OpenRA
return mods;
}
Manifest LoadMod(string id, string path)
static Manifest LoadMod(string id, string path)
{
IReadOnlyPackage package = null;
try
@@ -79,7 +79,7 @@ namespace OpenRA
return null;
}
Dictionary<string, Manifest> GetInstalledMods(IEnumerable<string> searchPaths, IEnumerable<string> explicitPaths)
static Dictionary<string, Manifest> GetInstalledMods(IEnumerable<string> searchPaths, IEnumerable<string> explicitPaths)
{
var ret = new Dictionary<string, Manifest>();
var candidates = GetCandidateMods(searchPaths)

View File

@@ -49,7 +49,7 @@ namespace OpenRA
assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => (asm, ns))).ToArray();
}
void LoadAssembly(List<Assembly> assemblyList, string resolvedPath)
static void LoadAssembly(List<Assembly> assemblyList, string resolvedPath)
{
// .NET doesn't provide any way of querying the metadata of an assembly without either:
// (a) loading duplicate data into the application domain, breaking the world.

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Primitives
itemBoundsBins = Exts.MakeArray(rows * cols, _ => new Dictionary<T, Rectangle>());
}
void ValidateBounds(T actor, Rectangle bounds)
static void ValidateBounds(T actor, Rectangle bounds)
{
if (bounds.Width == 0 || bounds.Height == 0)
throw new ArgumentException($"Bounds of actor {actor} are empty.", nameof(bounds));

View File

@@ -112,7 +112,7 @@ namespace OpenRA.Server
}
}
long Median(long[] a)
static long Median(long[] a)
{
Array.Sort(a);
var n = a.Length;

View File

@@ -702,7 +702,7 @@ namespace OpenRA.Server
}
}
byte[] CreateFrame(int client, int frame, byte[] data)
static byte[] CreateFrame(int client, int frame, byte[] data)
{
var ms = new MemoryStream(data.Length + 12);
ms.WriteArray(BitConverter.GetBytes(data.Length + 4));
@@ -712,7 +712,7 @@ namespace OpenRA.Server
return ms.GetBuffer();
}
byte[] CreateAckFrame(int frame, byte count)
static byte[] CreateAckFrame(int frame, byte count)
{
var ms = new MemoryStream(14);
ms.WriteArray(BitConverter.GetBytes(6));
@@ -723,7 +723,7 @@ namespace OpenRA.Server
return ms.GetBuffer();
}
byte[] CreateTickScaleFrame(float scale)
static byte[] CreateTickScaleFrame(float scale)
{
var ms = new MemoryStream(17);
ms.WriteArray(BitConverter.GetBytes(9));

View File

@@ -278,7 +278,7 @@ namespace OpenRA.Traits
frozenActorsById.Remove(fa.ID);
}
Rectangle FootprintBounds(FrozenActor fa)
static Rectangle FootprintBounds(FrozenActor fa)
{
var p1 = fa.Footprint[0];
var minU = p1.U;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
{
public class AudLoader : ISoundLoader
{
bool IsAud(Stream s)
static bool IsAud(Stream s)
{
var start = s.Position;
s.Position += 11;

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
}
}
bool IsShpD2(Stream s)
static bool IsShpD2(Stream s)
{
var start = s.Position;
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
return b == 5 || b <= 3;
}
ShpD2Frame[] ParseFrames(Stream s)
static ShpD2Frame[] ParseFrames(Stream s)
{
var start = s.Position;

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
static readonly Regex FilenameRegex = new(@"^(?<prefix>.+?[\-_])(?<frame>\d{4})\.tga$");
static readonly Regex MetaRegex = new(@"^\{""size"":\[(?<width>\d+),(?<height>\d+)\],""crop"":\[(?<left>\d+),(?<top>\d+),(?<right>\d+),(?<bottom>\d+)\]\}$");
int ParseGroup(Match match, string group)
static int ParseGroup(Match match, string group)
{
return int.Parse(match.Groups[group].Value);
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
}
}
bool IsTmpRA(Stream s)
static bool IsTmpRA(Stream s)
{
var start = s.Position;
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
return a == 0 && b == 0x2c73;
}
TmpRAFrame[] ParseFrames(Stream s)
static TmpRAFrame[] ParseFrames(Stream s)
{
var start = s.Position;
var width = s.ReadUInt16();

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
}
}
bool IsTmpTD(Stream s)
static bool IsTmpTD(Stream s)
{
var start = s.Position;
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
return a == 0 && b == 0x0D1AFFFF;
}
TmpTDFrame[] ParseFrames(Stream s)
static TmpTDFrame[] ParseFrames(Stream s)
{
var start = s.Position;
var width = s.ReadUInt16();

View File

@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
}
}
bool IsTmpTS(Stream s)
static bool IsTmpTS(Stream s)
{
var start = s.Position;
s.Position += 8;
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
return test == sx * sy / 2 + 52;
}
ISpriteFrame[] ParseFrames(Stream s)
static ISpriteFrame[] ParseFrames(Stream s)
{
var start = s.Position;
var templateWidth = s.ReadUInt32();

View File

@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Cnc.Traits
return MoveStep(MovementSpeed, facing);
}
WVec MoveStep(int speed, WAngle facing)
static WVec MoveStep(int speed, WAngle facing)
{
var dir = new WVec(0, -1024, 0).Rotate(WRot.FromYaw(facing));
return speed * dir / 1024;

View File

@@ -252,7 +252,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
Console.WriteLine();
}
void ConvertStartLengthFacings(string input)
static void ConvertStartLengthFacings(string input)
{
var splitting = input.Split(',');
if (splitting.Length >= 3)

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
ShowMainMenu(world);
}
void ShowMainMenu(World world)
static void ShowMainMenu(World world)
{
promptAccepted = true;
Ui.ResetAll();

View File

@@ -312,7 +312,7 @@ namespace OpenRA.Mods.Common.Activities
path = null;
}
bool CellIsEvacuating(Actor self, CPos cell)
static bool CellIsEvacuating(Actor self, CPos cell)
{
foreach (var actor in self.World.ActorMap.GetActorsAt(cell))
{

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.AudioLoaders
{
public class Mp3Loader : ISoundLoader
{
bool IsMp3(Stream s)
static bool IsMp3(Stream s)
{
var start = s.Position;
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.AudioLoaders
}
}
Stream Clone(Mp3Format cloneFrom)
static Stream Clone(Mp3Format cloneFrom)
{
return SegmentStream.CreateWithoutOwningStream(cloneFrom.stream, 0, (int)cloneFrom.stream.Length);
}

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.AudioLoaders
{
public class WavLoader : ISoundLoader
{
bool IsWave(Stream s)
static bool IsWave(Stream s)
{
var start = s.Position;
var type = s.ReadASCII(4);

View File

@@ -258,7 +258,7 @@ namespace OpenRA.Mods.Common.FileFormats
return ++currentBlock >= numBlocks;
}
short WriteSample(short t, Queue<byte> data)
static short WriteSample(short t, Queue<byte> data)
{
data.Enqueue((byte)t);
data.Enqueue((byte)(t >> 8));
@@ -266,7 +266,7 @@ namespace OpenRA.Mods.Common.FileFormats
}
// This code contains elements from libsndfile
short DecodeNibble(short nibble, byte bpred, ref short idelta, ref short s1, ref short s2)
static short DecodeNibble(short nibble, byte bpred, ref short idelta, ref short s1, ref short s2)
{
var predict = (s1 * AdaptCoeff1[bpred] + s2 * AdaptCoeff2[bpred]) >> 8;

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Graphics
}
}
void DrawSelectionBar(float2 start, float2 end, float value, Color barColor)
static void DrawSelectionBar(float2 start, float2 end, float value, Color barColor)
{
var c = Color.FromArgb(128, 30, 30, 30);
var c2 = Color.FromArgb(128, 10, 10, 10);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint
CheckTrait(emitError, actorInfo.Value, traitInfo, mapRules);
}
void CheckTrait(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo, Ruleset rules)
static void CheckTrait(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo, Ruleset rules)
{
var actualType = traitInfo.GetType();
foreach (var field in Utility.GetFields(actualType))
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void CheckActorReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
static void CheckActorReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
FieldInfo fieldInfo, IReadOnlyDictionary<string, ActorInfo> dict, ActorReferenceAttribute attribute)
{
var values = LintExts.GetFieldValues(traitInfo, fieldInfo, attribute.DictionaryReference);
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void CheckWeaponReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
static void CheckWeaponReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
FieldInfo fieldInfo, IReadOnlyDictionary<string, WeaponInfo> dict)
{
var values = LintExts.GetFieldValues(traitInfo, fieldInfo);
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void CheckVoiceReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
static void CheckVoiceReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
FieldInfo fieldInfo, IReadOnlyDictionary<string, SoundInfo> dict)
{
var values = LintExts.GetFieldValues(traitInfo, fieldInfo);

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var weaponInfo in rules.Weapons)
{

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, emitWarning, mapRules);
}
void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
static void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, modData, mapRules);
}
void Run(Action<string> emitError, ModData modData, Ruleset rules)
static void Run(Action<string> emitError, ModData modData, Ruleset rules)
{
var fileSystem = modData.DefaultFileSystem;
var sequenceYaml = MiniYaml.Merge(modData.Manifest.Cursors.Select(s => MiniYaml.FromStream(fileSystem.Open(s), s)));

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules, modData);
}
void Run(Action<string> emitError, Ruleset rules, ModData modData)
static void Run(Action<string> emitError, Ruleset rules, ModData modData)
{
// As the map has not been created we need to get MapGrid info directly from manifest.
var grid = modData.Manifest.Get<MapGrid>();

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
var worldActor = rules.Actors[SystemActors.World];
var locomotorInfos = worldActor.TraitInfos<LocomotorInfo>().ToArray();
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void CheckLocomotors(ActorInfo actorInfo, Action<string> emitError, LocomotorInfo[] locomotorInfos, string locomotor)
static void CheckLocomotors(ActorInfo actorInfo, Action<string> emitError, LocomotorInfo[] locomotorInfos, string locomotor)
{
if (!locomotorInfos.Any(l => l.Name == locomotor))
emitError($"Actor `{actorInfo.Name}` defines Locomotor `{locomotor}` not found on World actor.");

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, map.MapFormat, map.Author, map.Title, map.Categories);
}
void Run(Action<string> emitError, int mapFormat, string author, string title, string[] categories)
static void Run(Action<string> emitError, int mapFormat, string author, string title, string[] categories)
{
if (mapFormat < Map.SupportedMapFormat)
emitError($"Map format `{mapFormat}` does not match the supported version `{Map.CurrentMapFormat}`.");

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
var palettes = new List<string>();
var playerPalettes = new List<string>();
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void GetPalettes(Ruleset rules, List<string> palettes, List<string> playerPalettes, Action<string> emitError)
static void GetPalettes(Ruleset rules, List<string> palettes, List<string> playerPalettes, Action<string> emitError)
{
// Palettes are only defined on the world actor.
var worldActorInfo = rules.Actors[SystemActors.World];

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, emitWarning, map.Players, map.Visibility, map.WorldActorInfo, map.SpawnPoints);
}
void Run(Action<string> emitError, Action<string> emitWarning, MapPlayers players, MapVisibility visibility, ActorInfo worldActorInfo, CPos[] spawnPoints)
static void Run(Action<string> emitError, Action<string> emitWarning, MapPlayers players, MapVisibility visibility, ActorInfo worldActorInfo, CPos[] spawnPoints)
{
if (players.Players.Count > 64)
emitError("Defining more than 64 players is not allowed.");

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var weaponInfo in rules.Weapons)
{

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, emitWarning, rules, sequences);
}
void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules, SequenceSet sequences)
static void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules, SequenceSet sequences)
{
var factions = rules.Actors[SystemActors.World].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
foreach (var actorInfo in rules.Actors)

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, emitWarning, mapRules);
}
void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
static void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Lint
CheckMapYaml(emitError, modData, map, map.RuleDefinitions);
}
string NormalizeName(string key)
static string NormalizeName(string key)
{
var name = key.Split('@')[0];
if (name.StartsWith("-", StringComparison.Ordinal))
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Lint
return name;
}
void CheckActors(IEnumerable<MiniYamlNode> actors, Action<string> emitError, ModData modData)
static void CheckActors(IEnumerable<MiniYamlNode> actors, Action<string> emitError, ModData modData)
{
foreach (var actor in actors)
{
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void CheckMapYaml(Action<string> emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions)
static void CheckMapYaml(Action<string> emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions)
{
if (ruleDefinitions == null)
return;

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Lint
CheckMapYaml(emitError, emitWarning, modData, map, map.WeaponDefinitions);
}
string NormalizeName(string key)
static string NormalizeName(string key)
{
var name = key.Split('@')[0];
if (name.StartsWith("-", StringComparison.Ordinal))
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Lint
return name;
}
void CheckWeapons(IEnumerable<MiniYamlNode> weapons, Action<string> emitError, Action<string> emitWarning, ModData modData)
static void CheckWeapons(IEnumerable<MiniYamlNode> weapons, Action<string> emitError, Action<string> emitWarning, ModData modData)
{
var weaponInfo = typeof(WeaponInfo);
foreach (var weapon in weapons)
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void CheckMapYaml(Action<string> emitError, Action<string> emitWarning, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml weaponDefinitions)
static void CheckMapYaml(Action<string> emitError, Action<string> emitWarning, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml weaponDefinitions)
{
if (weaponDefinitions == null)
return;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
foreach (var actorInfo in rules.Actors)
{
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Lint
}
}
void CheckVoices(ActorInfo actorInfo, Action<string> emitError, Ruleset rules, string voiceSet)
static void CheckVoices(ActorInfo actorInfo, Action<string> emitError, Ruleset rules, string voiceSet)
{
var soundInfo = rules.Voices[voiceSet.ToLowerInvariant()];

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Lint
CheckMapYaml(emitError, modData, map, map.RuleDefinitions);
}
void CheckMapYaml(Action<string> emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions)
static void CheckMapYaml(Action<string> emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions)
{
if (ruleDefinitions == null)
return;
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, nodes);
}
void Run(Action<string> emitError, List<MiniYamlNode> nodes)
static void Run(Action<string> emitError, List<MiniYamlNode> nodes)
{
// Build a list of all inheritance relationships.
var inheritsMap = new Dictionary<string, List<string>>();
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Lint
CheckInheritance(emitError, "Player", inheritsMap);
}
void CheckInheritance(Action<string> emitError, string actor, Dictionary<string, List<string>> inheritsMap)
static void CheckInheritance(Action<string> emitError, string actor, Dictionary<string, List<string>> inheritsMap)
{
var toResolve = new Queue<string>(inheritsMap.Keys.Where(k => string.Equals(k, actor, StringComparison.InvariantCultureIgnoreCase)));
while (toResolve.TryDequeue(out var key))

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, mapRules);
}
void Run(Action<string> emitError, Ruleset rules)
static void Run(Action<string> emitError, Ruleset rules)
{
var providedPrereqs = rules.Actors.SelectMany(a => a.Value.TraitInfos<ITechTreePrerequisiteInfo>().SelectMany(p => p.Prerequisites(a.Value)));

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.LoadScreens
}
}
bool IsModInstalled(ModContent content)
static bool IsModInstalled(ModContent content)
{
return content.Packages
.Where(p => p.Value.Required)

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Orders
this.variants = variants.ToArray();
}
PlaceBuildingCellType MakeCellType(bool valid, bool lineBuild = false)
static PlaceBuildingCellType MakeCellType(bool valid, bool lineBuild = false)
{
var cell = valid ? PlaceBuildingCellType.Valid : PlaceBuildingCellType.Invalid;
if (lineBuild)

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Scripting
public ActorGlobal(ScriptContext context)
: base(context) { }
ActorInit CreateInit(string initName, LuaValue value)
static ActorInit CreateInit(string initName, LuaValue value)
{
// Find the requested type
var initInstance = initName.Split(ActorInfo.TraitInstanceSeparator);

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Scripting
return a;
}
void Move(Actor actor, CPos dest)
static void Move(Actor actor, CPos dest)
{
var move = actor.TraitOrDefault<IMove>();
if (move == null)

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
return true;
}
void RegionsFromFrames(Png png, out List<Rectangle> regions, out List<float2> offsets)
static void RegionsFromFrames(Png png, out List<Rectangle> regions, out List<float2> offsets)
{
regions = new List<Rectangle>();
offsets = new List<float2>();
@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
}
}
void RegionsFromSlices(Png png, out List<Rectangle> regions, out List<float2> offsets)
static void RegionsFromSlices(Png png, out List<Rectangle> regions, out List<float2> offsets)
{
// Default: whole image is 1 frame.
var frameSize = new Size(png.Width, png.Height);

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
}
}
bool IsShpTS(Stream s)
static bool IsShpTS(Stream s)
{
var start = s.Position;
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
return f == imageCount || type < 4;
}
ShpTSFrame[] ParseFrames(Stream s)
static ShpTSFrame[] ParseFrames(Stream s)
{
var start = s.Position;

View File

@@ -444,7 +444,7 @@ namespace OpenRA.Mods.Common.Traits
return chosenTarget;
}
bool PreventsAutoTarget(Actor attacker, Actor target)
static bool PreventsAutoTarget(Actor attacker, Actor target)
{
foreach (var deat in target.TraitsImplementing<IDisableEnemyAutoTarget>())
if (deat.DisableEnemyAutoTarget(target, attacker))

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
return ShouldFlee(owner, enemies => !AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemies));
}
protected Actor FindClosestEnemy(Squad owner)
protected static Actor FindClosestEnemy(Squad owner)
{
return owner.SquadManager.FindClosestEnemy(owner.Units.First().CenterPosition);
}

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
return ShouldFlee(owner, enemies => !AttackOrFleeFuzzy.Default.CanAttack(owner.Units, enemies));
}
protected Actor FindClosestEnemy(Squad owner)
protected static Actor FindClosestEnemy(Squad owner)
{
var first = owner.Units.First();

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
bool TargetChanged(in Target lastTarget, in Target target)
static bool TargetChanged(in Target lastTarget, in Target target)
{
// Invalidate reveal changing the target.
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.Actor)

View File

@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
return RenderAboveShroud(self, wr);
}
IEnumerable<IRenderable> RenderAboveShroud(Actor self, WorldRenderer wr)
static IEnumerable<IRenderable> RenderAboveShroud(Actor self, WorldRenderer wr)
{
var pal = wr.Palette(TileSet.TerrainPaletteInternalName);
var a = self.CurrentActivity;

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render
decorations = selectedDecorations.Where(d => !d.RequiresSelection).ToArray();
}
IEnumerable<WPos> ActivityTargetPath(Actor self)
static IEnumerable<WPos> ActivityTargetPath(Actor self)
{
if (!self.IsInWorld || self.IsDead)
yield break;

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
Player GetTargetPlayer(in Target target)
static Player GetTargetPlayer(in Target target)
{
if (target.Type == TargetType.Actor)
return target.Actor.Owner;

View File

@@ -345,7 +345,7 @@ namespace OpenRA.Mods.Common.Traits
}
// NOTE: pos required to be in map bounds
bool AnyActorsAt(InfluenceNode influenceNode, CPos a, SubCell sub, bool checkTransient)
static bool AnyActorsAt(InfluenceNode influenceNode, CPos a, SubCell sub, bool checkTransient)
{
var always = sub == SubCell.FullCell || sub == SubCell.Any;
for (var i = influenceNode; i != null; i = i.Next)
@@ -376,7 +376,7 @@ namespace OpenRA.Mods.Common.Traits
}
// NOTE: can not check aircraft
bool AnyActorsAt(InfluenceNode influenceNode, SubCell sub, Func<Actor, bool> withCondition)
static bool AnyActorsAt(InfluenceNode influenceNode, SubCell sub, Func<Actor, bool> withCondition)
{
var always = sub == SubCell.FullCell || sub == SubCell.Any;

View File

@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
&& world.Map.Rules.Music[song].Exists;
}
bool SongExists(MusicInfo song)
static bool SongExists(MusicInfo song)
{
return song != null && song.Exists;
}

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
bool PreventMapSpawn(World world, ActorReference actorReference, IEnumerable<IPreventMapSpawn> preventMapSpawns)
static bool PreventMapSpawn(World world, ActorReference actorReference, IEnumerable<IPreventMapSpawn> preventMapSpawns)
{
foreach (var pms in preventMapSpawns)
if (pms.PreventMapSpawn(world, actorReference))

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits
info.BinSize * tileScale);
}
Rectangle Bounds(LightSource source)
static Rectangle Bounds(LightSource source)
{
var c = source.Pos;
var r = source.Range.Length;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
string IUtilityCommand.Name => "--map-rules";
bool IUtilityCommand.ValidateArguments(string[] args) { return args.Length == 2; }
void MergeAndPrint(Map map, string key, MiniYaml value)
static void MergeAndPrint(Map map, string key, MiniYaml value)
{
var nodes = new List<MiniYamlNode>();
var includes = new List<string>();

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
return !invalid || PrintUsage();
}
bool PrintUsage()
static bool PrintUsage()
{
Console.WriteLine("");
Console.WriteLine("Usage:");
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
return !invalid || PrintUsage();
}
bool PrintUsage()
static bool PrintUsage()
{
Console.WriteLine("");
Console.WriteLine("Usage:");

View File

@@ -481,7 +481,7 @@ namespace OpenRA.Mods.Common.Widgets
return world.OrderGenerator.HandleKeyPress(e);
}
ScrollDirection CheckForDirections()
static ScrollDirection CheckForDirections()
{
var margin = Game.Settings.Game.ViewportEdgeScrollMargin;
var directions = ScrollDirection.None;

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.D2k.SpriteLoaders
}
}
bool IsR8(Stream s)
static bool IsR8(Stream s)
{
var start = s.Position;

View File

@@ -291,7 +291,7 @@ namespace OpenRA.Platforms.Default
PauseSound(source, paused);
}
void PauseSound(uint source, bool paused)
static void PauseSound(uint source, bool paused)
{
AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE, out var state);
if (paused)

View File

@@ -20,8 +20,8 @@ namespace OpenRA.Platforms.Default
{
MouseButton lastButtonBits = MouseButton.None;
public string GetClipboardText() { return SDL.SDL_GetClipboardText(); }
public bool SetClipboardText(string text) { return SDL.SDL_SetClipboardText(text) == 0; }
public static string GetClipboardText() { return SDL.SDL_GetClipboardText(); }
public static bool SetClipboardText(string text) { return SDL.SDL_SetClipboardText(text) == 0; }
static MouseButton MakeButton(byte b)
{
@@ -40,7 +40,7 @@ namespace OpenRA.Platforms.Default
| ((raw & (int)SDL.SDL_Keymod.KMOD_SHIFT) != 0 ? Modifiers.Shift : 0);
}
int2 EventPosition(Sdl2PlatformWindow device, int x, int y)
static int2 EventPosition(Sdl2PlatformWindow device, int x, int y)
{
// On Windows and Linux (X11) events are given in surface coordinates
// These must be scaled to our effective window coordinates

View File

@@ -351,7 +351,7 @@ namespace OpenRA.Platforms.Default
input = new Sdl2Input();
}
byte[] DoublePixelData(byte[] data, Size size)
static byte[] DoublePixelData(byte[] data, Size size)
{
var scaledData = new byte[4 * data.Length];
for (var y = 0; y < size.Height; y++)
@@ -498,13 +498,13 @@ namespace OpenRA.Platforms.Default
public string GetClipboardText()
{
VerifyThreadAffinity();
return input.GetClipboardText();
return Sdl2Input.GetClipboardText();
}
public bool SetClipboardText(string text)
{
VerifyThreadAffinity();
return input.SetClipboardText(text);
return Sdl2Input.SetClipboardText(text);
}
static void SetSDLAttributes(GLProfile profile)

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Platforms.Default
readonly Queue<int> unbindTextures = new();
readonly uint program;
protected uint CompileShaderObject(int type, string name)
protected static uint CompileShaderObject(int type, string name)
{
var ext = type == OpenGL.GL_VERTEX_SHADER ? "vert" : "frag";
var filename = Path.Combine(Platform.EngineDir, "glsl", name + "." + ext);

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Test
[TestFixture]
public class OrderTest
{
byte[] RoundTripOrder(byte[] bytes)
static byte[] RoundTripOrder(byte[] bytes)
{
return Order.Deserialize(null, new BinaryReader(new MemoryStream(bytes))).Serialize();
}