diff --git a/.editorconfig b/.editorconfig index fa7e52cd49..18c616fd83 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/OpenRA.Game/ExternalMods.cs b/OpenRA.Game/ExternalMods.cs index f15eb4f609..002cfbccca 100644 --- a/OpenRA.Game/ExternalMods.cs +++ b/OpenRA.Game/ExternalMods.cs @@ -257,7 +257,7 @@ namespace OpenRA } } - IEnumerable GetSupportDirs(ModRegistration registration) + static IEnumerable GetSupportDirs(ModRegistration registration) { var sources = new HashSet(4); if (registration.HasFlag(ModRegistration.System)) diff --git a/OpenRA.Game/FileFormats/Png.cs b/OpenRA.Game/FileFormats/Png.cs index ef69d7d2b9..0510bc9df3 100644 --- a/OpenRA.Game/FileFormats/Png.cs +++ b/OpenRA.Game/FileFormats/Png.cs @@ -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; diff --git a/OpenRA.Game/Graphics/ModelRenderer.cs b/OpenRA.Game/Graphics/ModelRenderer.cs index fd01ad8f5d..bef51430fb 100644 --- a/OpenRA.Game/Graphics/ModelRenderer.cs +++ b/OpenRA.Game/Graphics/ModelRenderer.cs @@ -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(); diff --git a/OpenRA.Game/Graphics/RgbaColorRenderer.cs b/OpenRA.Game/Graphics/RgbaColorRenderer.cs index 3c032e3ae2..591542633e 100644 --- a/OpenRA.Game/Graphics/RgbaColorRenderer.cs +++ b/OpenRA.Game/Graphics/RgbaColorRenderer.cs @@ -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). /// - 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); diff --git a/OpenRA.Game/Graphics/SpriteFont.cs b/OpenRA.Game/Graphics/SpriteFont.cs index 6e33fe60ac..c120e73fef 100644 --- a/OpenRA.Game/Graphics/SpriteFont.cs +++ b/OpenRA.Game/Graphics/SpriteFont.cs @@ -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, diff --git a/OpenRA.Game/Graphics/SpriteRenderer.cs b/OpenRA.Game/Graphics/SpriteRenderer.cs index 6c0ce15f2d..e286ed83bd 100644 --- a/OpenRA.Game/Graphics/SpriteRenderer.cs +++ b/OpenRA.Game/Graphics/SpriteRenderer.cs @@ -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; diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index f0787c1354..1100422eda 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -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; diff --git a/OpenRA.Game/InstalledMods.cs b/OpenRA.Game/InstalledMods.cs index 7913027ec3..a5d1ad0273 100644 --- a/OpenRA.Game/InstalledMods.cs +++ b/OpenRA.Game/InstalledMods.cs @@ -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 GetInstalledMods(IEnumerable searchPaths, IEnumerable explicitPaths) + static Dictionary GetInstalledMods(IEnumerable searchPaths, IEnumerable explicitPaths) { var ret = new Dictionary(); var candidates = GetCandidateMods(searchPaths) diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs index a4d9ef2124..bb9d72d097 100644 --- a/OpenRA.Game/ObjectCreator.cs +++ b/OpenRA.Game/ObjectCreator.cs @@ -49,7 +49,7 @@ namespace OpenRA assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => (asm, ns))).ToArray(); } - void LoadAssembly(List assemblyList, string resolvedPath) + static void LoadAssembly(List 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. diff --git a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs index 6c414da5ed..440d48bb43 100644 --- a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs +++ b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs @@ -30,7 +30,7 @@ namespace OpenRA.Primitives itemBoundsBins = Exts.MakeArray(rows * cols, _ => new Dictionary()); } - 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)); diff --git a/OpenRA.Game/Server/OrderBuffer.cs b/OpenRA.Game/Server/OrderBuffer.cs index 068a27dc2b..6ede800a9c 100644 --- a/OpenRA.Game/Server/OrderBuffer.cs +++ b/OpenRA.Game/Server/OrderBuffer.cs @@ -112,7 +112,7 @@ namespace OpenRA.Server } } - long Median(long[] a) + static long Median(long[] a) { Array.Sort(a); var n = a.Length; diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index f070670f4f..815e8fdb48 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -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)); diff --git a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs index 2d94b06c0e..572d2c23d0 100644 --- a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs +++ b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs @@ -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; diff --git a/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs b/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs index 6a8a52a062..a1c5adedb3 100644 --- a/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs +++ b/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs @@ -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; diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs index 9258e9120e..6bc60f98ec 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/ShpD2Loader.cs @@ -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; diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/ShpRemasteredLoader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/ShpRemasteredLoader.cs index 3a0cda88e7..d00d8ce7df 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/ShpRemasteredLoader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/ShpRemasteredLoader.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders static readonly Regex FilenameRegex = new(@"^(?.+?[\-_])(?\d{4})\.tga$"); static readonly Regex MetaRegex = new(@"^\{""size"":\[(?\d+),(?\d+)\],""crop"":\[(?\d+),(?\d+),(?\d+),(?\d+)\]\}$"); - int ParseGroup(Match match, string group) + static int ParseGroup(Match match, string group) { return int.Parse(match.Groups[group].Value); } diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/TmpRALoader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/TmpRALoader.cs index abd826c6b7..49437a6de3 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/TmpRALoader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/TmpRALoader.cs @@ -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(); diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/TmpTDLoader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/TmpTDLoader.cs index c525bfcb6d..9508122f05 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/TmpTDLoader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/TmpTDLoader.cs @@ -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(); diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/TmpTSLoader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/TmpTSLoader.cs index b52aca1606..620bfd53a2 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/TmpTSLoader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/TmpTSLoader.cs @@ -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(); diff --git a/OpenRA.Mods.Cnc/Traits/TDGunboat.cs b/OpenRA.Mods.Cnc/Traits/TDGunboat.cs index fb3057a39d..958b2cfbfb 100644 --- a/OpenRA.Mods.Cnc/Traits/TDGunboat.cs +++ b/OpenRA.Mods.Cnc/Traits/TDGunboat.cs @@ -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; diff --git a/OpenRA.Mods.Cnc/UtilityCommands/LegacySequenceImporter.cs b/OpenRA.Mods.Cnc/UtilityCommands/LegacySequenceImporter.cs index aeae5e6420..aff27231ea 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/LegacySequenceImporter.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/LegacySequenceImporter.cs @@ -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) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/PreReleaseWarningPrompt.cs b/OpenRA.Mods.Cnc/Widgets/Logic/PreReleaseWarningPrompt.cs index 5a2600562a..f8ce20a4a0 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/PreReleaseWarningPrompt.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/PreReleaseWarningPrompt.cs @@ -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(); diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index 7803576aa2..2de6716623 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -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)) { diff --git a/OpenRA.Mods.Common/AudioLoaders/Mp3Loader.cs b/OpenRA.Mods.Common/AudioLoaders/Mp3Loader.cs index 895dfb88fd..d92f22ad5a 100644 --- a/OpenRA.Mods.Common/AudioLoaders/Mp3Loader.cs +++ b/OpenRA.Mods.Common/AudioLoaders/Mp3Loader.cs @@ -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); } diff --git a/OpenRA.Mods.Common/AudioLoaders/WavLoader.cs b/OpenRA.Mods.Common/AudioLoaders/WavLoader.cs index 7c7c89fc31..46c94ff7f7 100644 --- a/OpenRA.Mods.Common/AudioLoaders/WavLoader.cs +++ b/OpenRA.Mods.Common/AudioLoaders/WavLoader.cs @@ -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); diff --git a/OpenRA.Mods.Common/FileFormats/WavReader.cs b/OpenRA.Mods.Common/FileFormats/WavReader.cs index 70469e9cfd..34de8d3506 100644 --- a/OpenRA.Mods.Common/FileFormats/WavReader.cs +++ b/OpenRA.Mods.Common/FileFormats/WavReader.cs @@ -258,7 +258,7 @@ namespace OpenRA.Mods.Common.FileFormats return ++currentBlock >= numBlocks; } - short WriteSample(short t, Queue data) + static short WriteSample(short t, Queue 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; diff --git a/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs b/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs index c18098a985..1be1ace602 100644 --- a/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs @@ -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); diff --git a/OpenRA.Mods.Common/Lint/CheckActorReferences.cs b/OpenRA.Mods.Common/Lint/CheckActorReferences.cs index 5d9c6d3e96..6d8f1f9a95 100644 --- a/OpenRA.Mods.Common/Lint/CheckActorReferences.cs +++ b/OpenRA.Mods.Common/Lint/CheckActorReferences.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint CheckTrait(emitError, actorInfo.Value, traitInfo, mapRules); } - void CheckTrait(Action emitError, ActorInfo actorInfo, TraitInfo traitInfo, Ruleset rules) + static void CheckTrait(Action 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 emitError, ActorInfo actorInfo, TraitInfo traitInfo, + static void CheckActorReference(Action emitError, ActorInfo actorInfo, TraitInfo traitInfo, FieldInfo fieldInfo, IReadOnlyDictionary dict, ActorReferenceAttribute attribute) { var values = LintExts.GetFieldValues(traitInfo, fieldInfo, attribute.DictionaryReference); @@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Lint } } - void CheckWeaponReference(Action emitError, ActorInfo actorInfo, TraitInfo traitInfo, + static void CheckWeaponReference(Action emitError, ActorInfo actorInfo, TraitInfo traitInfo, FieldInfo fieldInfo, IReadOnlyDictionary dict) { var values = LintExts.GetFieldValues(traitInfo, fieldInfo); @@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Lint } } - void CheckVoiceReference(Action emitError, ActorInfo actorInfo, TraitInfo traitInfo, + static void CheckVoiceReference(Action emitError, ActorInfo actorInfo, TraitInfo traitInfo, FieldInfo fieldInfo, IReadOnlyDictionary dict) { var values = LintExts.GetFieldValues(traitInfo, fieldInfo); diff --git a/OpenRA.Mods.Common/Lint/CheckAngle.cs b/OpenRA.Mods.Common/Lint/CheckAngle.cs index 112890e1e2..6fc9101ca7 100644 --- a/OpenRA.Mods.Common/Lint/CheckAngle.cs +++ b/OpenRA.Mods.Common/Lint/CheckAngle.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var weaponInfo in rules.Weapons) { diff --git a/OpenRA.Mods.Common/Lint/CheckConditions.cs b/OpenRA.Mods.Common/Lint/CheckConditions.cs index 7c7aca4bb0..4dc4060f25 100644 --- a/OpenRA.Mods.Common/Lint/CheckConditions.cs +++ b/OpenRA.Mods.Common/Lint/CheckConditions.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, emitWarning, mapRules); } - void Run(Action emitError, Action emitWarning, Ruleset rules) + static void Run(Action emitError, Action emitWarning, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckCursors.cs b/OpenRA.Mods.Common/Lint/CheckCursors.cs index 035a5a249f..245ee13c5e 100644 --- a/OpenRA.Mods.Common/Lint/CheckCursors.cs +++ b/OpenRA.Mods.Common/Lint/CheckCursors.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, modData, mapRules); } - void Run(Action emitError, ModData modData, Ruleset rules) + static void Run(Action emitError, ModData modData, Ruleset rules) { var fileSystem = modData.DefaultFileSystem; var sequenceYaml = MiniYaml.Merge(modData.Manifest.Cursors.Select(s => MiniYaml.FromStream(fileSystem.Open(s), s))); diff --git a/OpenRA.Mods.Common/Lint/CheckDefaultVisibility.cs b/OpenRA.Mods.Common/Lint/CheckDefaultVisibility.cs index e51c52e805..8838ee9354 100644 --- a/OpenRA.Mods.Common/Lint/CheckDefaultVisibility.cs +++ b/OpenRA.Mods.Common/Lint/CheckDefaultVisibility.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckHitShapes.cs b/OpenRA.Mods.Common/Lint/CheckHitShapes.cs index f3a830d205..0cfba5dcbb 100644 --- a/OpenRA.Mods.Common/Lint/CheckHitShapes.cs +++ b/OpenRA.Mods.Common/Lint/CheckHitShapes.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckInteractable.cs b/OpenRA.Mods.Common/Lint/CheckInteractable.cs index 1faf4d6180..b2eab3c7d8 100644 --- a/OpenRA.Mods.Common/Lint/CheckInteractable.cs +++ b/OpenRA.Mods.Common/Lint/CheckInteractable.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules, modData); } - void Run(Action emitError, Ruleset rules, ModData modData) + static void Run(Action 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(); diff --git a/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs b/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs index b42b9174f8..794b893b88 100644 --- a/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs +++ b/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { var worldActor = rules.Actors[SystemActors.World]; var locomotorInfos = worldActor.TraitInfos().ToArray(); @@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Lint } } - void CheckLocomotors(ActorInfo actorInfo, Action emitError, LocomotorInfo[] locomotorInfos, string locomotor) + static void CheckLocomotors(ActorInfo actorInfo, Action emitError, LocomotorInfo[] locomotorInfos, string locomotor) { if (!locomotorInfos.Any(l => l.Name == locomotor)) emitError($"Actor `{actorInfo.Name}` defines Locomotor `{locomotor}` not found on World actor."); diff --git a/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs b/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs index 6673b4ae44..e9dcd12012 100644 --- a/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs +++ b/OpenRA.Mods.Common/Lint/CheckMapMetadata.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, map.MapFormat, map.Author, map.Title, map.Categories); } - void Run(Action emitError, int mapFormat, string author, string title, string[] categories) + static void Run(Action 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}`."); diff --git a/OpenRA.Mods.Common/Lint/CheckNotifications.cs b/OpenRA.Mods.Common/Lint/CheckNotifications.cs index 13deb47d62..45b00662e1 100644 --- a/OpenRA.Mods.Common/Lint/CheckNotifications.cs +++ b/OpenRA.Mods.Common/Lint/CheckNotifications.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckPalettes.cs b/OpenRA.Mods.Common/Lint/CheckPalettes.cs index 45a95407e5..734df245ee 100644 --- a/OpenRA.Mods.Common/Lint/CheckPalettes.cs +++ b/OpenRA.Mods.Common/Lint/CheckPalettes.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { var palettes = new List(); var playerPalettes = new List(); @@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Lint } } - void GetPalettes(Ruleset rules, List palettes, List playerPalettes, Action emitError) + static void GetPalettes(Ruleset rules, List palettes, List playerPalettes, Action emitError) { // Palettes are only defined on the world actor. var worldActorInfo = rules.Actors[SystemActors.World]; diff --git a/OpenRA.Mods.Common/Lint/CheckPlayers.cs b/OpenRA.Mods.Common/Lint/CheckPlayers.cs index 392d62b794..848c042ebf 100644 --- a/OpenRA.Mods.Common/Lint/CheckPlayers.cs +++ b/OpenRA.Mods.Common/Lint/CheckPlayers.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, emitWarning, map.Players, map.Visibility, map.WorldActorInfo, map.SpawnPoints); } - void Run(Action emitError, Action emitWarning, MapPlayers players, MapVisibility visibility, ActorInfo worldActorInfo, CPos[] spawnPoints) + static void Run(Action emitError, Action emitWarning, MapPlayers players, MapVisibility visibility, ActorInfo worldActorInfo, CPos[] spawnPoints) { if (players.Players.Count > 64) emitError("Defining more than 64 players is not allowed."); diff --git a/OpenRA.Mods.Common/Lint/CheckRangeLimit.cs b/OpenRA.Mods.Common/Lint/CheckRangeLimit.cs index e6535cb5a0..c213fc4f5a 100644 --- a/OpenRA.Mods.Common/Lint/CheckRangeLimit.cs +++ b/OpenRA.Mods.Common/Lint/CheckRangeLimit.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var weaponInfo in rules.Weapons) { diff --git a/OpenRA.Mods.Common/Lint/CheckRevealFootprint.cs b/OpenRA.Mods.Common/Lint/CheckRevealFootprint.cs index c11e77af9b..f37391ec0c 100644 --- a/OpenRA.Mods.Common/Lint/CheckRevealFootprint.cs +++ b/OpenRA.Mods.Common/Lint/CheckRevealFootprint.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckSequences.cs b/OpenRA.Mods.Common/Lint/CheckSequences.cs index 3cae0317b0..daa864120e 100644 --- a/OpenRA.Mods.Common/Lint/CheckSequences.cs +++ b/OpenRA.Mods.Common/Lint/CheckSequences.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, emitWarning, rules, sequences); } - void Run(Action emitError, Action emitWarning, Ruleset rules, SequenceSet sequences) + static void Run(Action emitError, Action emitWarning, Ruleset rules, SequenceSet sequences) { var factions = rules.Actors[SystemActors.World].TraitInfos().Select(f => f.InternalName).ToArray(); foreach (var actorInfo in rules.Actors) diff --git a/OpenRA.Mods.Common/Lint/CheckSpriteBodies.cs b/OpenRA.Mods.Common/Lint/CheckSpriteBodies.cs index f2f4b84560..1c13eb5c0e 100644 --- a/OpenRA.Mods.Common/Lint/CheckSpriteBodies.cs +++ b/OpenRA.Mods.Common/Lint/CheckSpriteBodies.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckTooltips.cs b/OpenRA.Mods.Common/Lint/CheckTooltips.cs index 24eb7fa76f..90b71d83bc 100644 --- a/OpenRA.Mods.Common/Lint/CheckTooltips.cs +++ b/OpenRA.Mods.Common/Lint/CheckTooltips.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckTraitPrerequisites.cs b/OpenRA.Mods.Common/Lint/CheckTraitPrerequisites.cs index 9d4f044de4..bd8b3b9bf8 100644 --- a/OpenRA.Mods.Common/Lint/CheckTraitPrerequisites.cs +++ b/OpenRA.Mods.Common/Lint/CheckTraitPrerequisites.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, emitWarning, mapRules); } - void Run(Action emitError, Action emitWarning, Ruleset rules) + static void Run(Action emitError, Action emitWarning, Ruleset rules) { foreach (var actorInfo in rules.Actors) { diff --git a/OpenRA.Mods.Common/Lint/CheckUnknownTraitFields.cs b/OpenRA.Mods.Common/Lint/CheckUnknownTraitFields.cs index 3df676ddca..c3773b8352 100644 --- a/OpenRA.Mods.Common/Lint/CheckUnknownTraitFields.cs +++ b/OpenRA.Mods.Common/Lint/CheckUnknownTraitFields.cs @@ -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 actors, Action emitError, ModData modData) + static void CheckActors(IEnumerable actors, Action emitError, ModData modData) { foreach (var actor in actors) { @@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Lint } } - void CheckMapYaml(Action emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions) + static void CheckMapYaml(Action emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions) { if (ruleDefinitions == null) return; diff --git a/OpenRA.Mods.Common/Lint/CheckUnknownWeaponFields.cs b/OpenRA.Mods.Common/Lint/CheckUnknownWeaponFields.cs index 6ba61b5dc0..1c6486e7f8 100644 --- a/OpenRA.Mods.Common/Lint/CheckUnknownWeaponFields.cs +++ b/OpenRA.Mods.Common/Lint/CheckUnknownWeaponFields.cs @@ -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 weapons, Action emitError, Action emitWarning, ModData modData) + static void CheckWeapons(IEnumerable weapons, Action emitError, Action emitWarning, ModData modData) { var weaponInfo = typeof(WeaponInfo); foreach (var weapon in weapons) @@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Lint } } - void CheckMapYaml(Action emitError, Action emitWarning, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml weaponDefinitions) + static void CheckMapYaml(Action emitError, Action emitWarning, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml weaponDefinitions) { if (weaponDefinitions == null) return; diff --git a/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs b/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs index c84b68ea95..77b8618ca7 100644 --- a/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs +++ b/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { foreach (var actorInfo in rules.Actors) { @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Lint } } - void CheckVoices(ActorInfo actorInfo, Action emitError, Ruleset rules, string voiceSet) + static void CheckVoices(ActorInfo actorInfo, Action emitError, Ruleset rules, string voiceSet) { var soundInfo = rules.Voices[voiceSet.ToLowerInvariant()]; diff --git a/OpenRA.Mods.Common/Lint/CheckWorldAndPlayerInherits.cs b/OpenRA.Mods.Common/Lint/CheckWorldAndPlayerInherits.cs index 5476823b87..77acaf9d78 100644 --- a/OpenRA.Mods.Common/Lint/CheckWorldAndPlayerInherits.cs +++ b/OpenRA.Mods.Common/Lint/CheckWorldAndPlayerInherits.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Lint CheckMapYaml(emitError, modData, map, map.RuleDefinitions); } - void CheckMapYaml(Action emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions) + static void CheckMapYaml(Action 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 emitError, List nodes) + static void Run(Action emitError, List nodes) { // Build a list of all inheritance relationships. var inheritsMap = new Dictionary>(); @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Lint CheckInheritance(emitError, "Player", inheritsMap); } - void CheckInheritance(Action emitError, string actor, Dictionary> inheritsMap) + static void CheckInheritance(Action emitError, string actor, Dictionary> inheritsMap) { var toResolve = new Queue(inheritsMap.Keys.Where(k => string.Equals(k, actor, StringComparison.InvariantCultureIgnoreCase))); while (toResolve.TryDequeue(out var key)) diff --git a/OpenRA.Mods.Common/Lint/LintBuildablePrerequisites.cs b/OpenRA.Mods.Common/Lint/LintBuildablePrerequisites.cs index c76f02f859..dc16ef24b5 100644 --- a/OpenRA.Mods.Common/Lint/LintBuildablePrerequisites.cs +++ b/OpenRA.Mods.Common/Lint/LintBuildablePrerequisites.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, mapRules); } - void Run(Action emitError, Ruleset rules) + static void Run(Action emitError, Ruleset rules) { var providedPrereqs = rules.Actors.SelectMany(a => a.Value.TraitInfos().SelectMany(p => p.Prerequisites(a.Value))); diff --git a/OpenRA.Mods.Common/LoadScreens/ModContentLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/ModContentLoadScreen.cs index cfbe8e0856..84505703cf 100644 --- a/OpenRA.Mods.Common/LoadScreens/ModContentLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/ModContentLoadScreen.cs @@ -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) diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index 6c676cd236..90d55f0884 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -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) diff --git a/OpenRA.Mods.Common/Scripting/Global/ActorGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/ActorGlobal.cs index 73ae6b3a0c..ea8d22b990 100644 --- a/OpenRA.Mods.Common/Scripting/Global/ActorGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/ActorGlobal.cs @@ -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); diff --git a/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs index b97ae916e7..1f6a970d81 100644 --- a/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs @@ -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(); if (move == null) diff --git a/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs index 05e1e518ec..91b0601515 100644 --- a/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs +++ b/OpenRA.Mods.Common/SpriteLoaders/PngSheetLoader.cs @@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders return true; } - void RegionsFromFrames(Png png, out List regions, out List offsets) + static void RegionsFromFrames(Png png, out List regions, out List offsets) { regions = new List(); offsets = new List(); @@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders } } - void RegionsFromSlices(Png png, out List regions, out List offsets) + static void RegionsFromSlices(Png png, out List regions, out List offsets) { // Default: whole image is 1 frame. var frameSize = new Size(png.Width, png.Height); diff --git a/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs b/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs index ccb09a96fc..1140fda55b 100644 --- a/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs +++ b/OpenRA.Mods.Common/SpriteLoaders/ShpTSLoader.cs @@ -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; diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index d00526e158..260d471b5d 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -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()) if (deat.DisableEnemyAutoTarget(target, attacker)) diff --git a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/GroundStates.cs b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/GroundStates.cs index 2e47ec543a..70754fa927 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/GroundStates.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/GroundStates.cs @@ -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); } diff --git a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/NavyStates.cs b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/NavyStates.cs index c70d0cfeef..74afef7870 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/NavyStates.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/NavyStates.cs @@ -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(); diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs index 3eb301ecc7..490bdaaa24 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs @@ -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) diff --git a/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs b/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs index 6ff293beff..e790d332ed 100644 --- a/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs +++ b/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs @@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits return RenderAboveShroud(self, wr); } - IEnumerable RenderAboveShroud(Actor self, WorldRenderer wr) + static IEnumerable RenderAboveShroud(Actor self, WorldRenderer wr) { var pal = wr.Palette(TileSet.TerrainPaletteInternalName); var a = self.CurrentActivity; diff --git a/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs b/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs index fb3b6b63e3..3dd52d3c9c 100644 --- a/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs +++ b/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render decorations = selectedDecorations.Where(d => !d.RequiresSelection).ToArray(); } - IEnumerable ActivityTargetPath(Actor self) + static IEnumerable ActivityTargetPath(Actor self) { if (!self.IsInWorld || self.IsDead) yield break; diff --git a/OpenRA.Mods.Common/Traits/RevealOnFire.cs b/OpenRA.Mods.Common/Traits/RevealOnFire.cs index 654dac86b4..85e5351685 100644 --- a/OpenRA.Mods.Common/Traits/RevealOnFire.cs +++ b/OpenRA.Mods.Common/Traits/RevealOnFire.cs @@ -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; diff --git a/OpenRA.Mods.Common/Traits/World/ActorMap.cs b/OpenRA.Mods.Common/Traits/World/ActorMap.cs index 5356997454..c0dc75913a 100644 --- a/OpenRA.Mods.Common/Traits/World/ActorMap.cs +++ b/OpenRA.Mods.Common/Traits/World/ActorMap.cs @@ -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 withCondition) + static bool AnyActorsAt(InfluenceNode influenceNode, SubCell sub, Func withCondition) { var always = sub == SubCell.FullCell || sub == SubCell.Any; diff --git a/OpenRA.Mods.Common/Traits/World/MusicPlaylist.cs b/OpenRA.Mods.Common/Traits/World/MusicPlaylist.cs index 3bd2d563a4..e0d8a1a368 100644 --- a/OpenRA.Mods.Common/Traits/World/MusicPlaylist.cs +++ b/OpenRA.Mods.Common/Traits/World/MusicPlaylist.cs @@ -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; } diff --git a/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs b/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs index aacf9e0170..c3906d266e 100644 --- a/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs +++ b/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits } } - bool PreventMapSpawn(World world, ActorReference actorReference, IEnumerable preventMapSpawns) + static bool PreventMapSpawn(World world, ActorReference actorReference, IEnumerable preventMapSpawns) { foreach (var pms in preventMapSpawns) if (pms.PreventMapSpawn(world, actorReference)) diff --git a/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs b/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs index e57a74d98e..062e5438da 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainLighting.cs @@ -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; diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs index 7a61f81a7a..49b4bfd196 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs @@ -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(); var includes = new List(); diff --git a/OpenRA.Mods.Common/UtilityCommands/Rgba2Hex.cs b/OpenRA.Mods.Common/UtilityCommands/Rgba2Hex.cs index eae6456c74..984b800c30 100644 --- a/OpenRA.Mods.Common/UtilityCommands/Rgba2Hex.cs +++ b/OpenRA.Mods.Common/UtilityCommands/Rgba2Hex.cs @@ -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:"); diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index cf2e3c4919..517d295da0 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -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; diff --git a/OpenRA.Mods.D2k/SpriteLoaders/R8Loader.cs b/OpenRA.Mods.D2k/SpriteLoaders/R8Loader.cs index ace673c48c..3e8c7d1cc9 100644 --- a/OpenRA.Mods.D2k/SpriteLoaders/R8Loader.cs +++ b/OpenRA.Mods.D2k/SpriteLoaders/R8Loader.cs @@ -78,7 +78,7 @@ namespace OpenRA.Mods.D2k.SpriteLoaders } } - bool IsR8(Stream s) + static bool IsR8(Stream s) { var start = s.Position; diff --git a/OpenRA.Platforms.Default/OpenAlSoundEngine.cs b/OpenRA.Platforms.Default/OpenAlSoundEngine.cs index 9232d48812..18f2a079db 100644 --- a/OpenRA.Platforms.Default/OpenAlSoundEngine.cs +++ b/OpenRA.Platforms.Default/OpenAlSoundEngine.cs @@ -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) diff --git a/OpenRA.Platforms.Default/Sdl2Input.cs b/OpenRA.Platforms.Default/Sdl2Input.cs index 1a49829a9d..c0f11f04b8 100644 --- a/OpenRA.Platforms.Default/Sdl2Input.cs +++ b/OpenRA.Platforms.Default/Sdl2Input.cs @@ -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 diff --git a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs index a7b2ecdf13..11a4bc2c89 100644 --- a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs +++ b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs @@ -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) diff --git a/OpenRA.Platforms.Default/Shader.cs b/OpenRA.Platforms.Default/Shader.cs index 5280198d20..dced6d5775 100644 --- a/OpenRA.Platforms.Default/Shader.cs +++ b/OpenRA.Platforms.Default/Shader.cs @@ -29,7 +29,7 @@ namespace OpenRA.Platforms.Default readonly Queue 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); diff --git a/OpenRA.Test/OpenRA.Game/OrderTest.cs b/OpenRA.Test/OpenRA.Game/OrderTest.cs index 9d862a99a8..05b52e8213 100644 --- a/OpenRA.Test/OpenRA.Game/OrderTest.cs +++ b/OpenRA.Test/OpenRA.Game/OrderTest.cs @@ -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(); }