Fix IDE0028, IDE0300, IDE0301, IDE0302, IDE0303, IDE0304.
Silence IDE0305.
This commit is contained in:
committed by
Pavel Penev
parent
0740991c12
commit
79454d8fd2
@@ -138,7 +138,7 @@ dotnet_diagnostic.IDE0017.severity = warning
|
||||
|
||||
# IDE0028 Use collection initializers
|
||||
#dotnet_style_collection_initializer = true
|
||||
dotnet_diagnostic.IDE0028.severity = suggestion # TODO: Consider enabling
|
||||
dotnet_diagnostic.IDE0028.severity = warning
|
||||
|
||||
# IDE0029/IDE0030/IDE0270 Use coalesce expression (non-nullable types)/Use coalesce expression (nullable types)/Use coalesce expression (if null)
|
||||
#dotnet_style_coalesce_expression = true
|
||||
@@ -308,27 +308,27 @@ dotnet_diagnostic.IDE0241.severity = warning
|
||||
|
||||
# IDE0300 Use collection expression for array
|
||||
# From above, uses dotnet_style_prefer_collection_expression
|
||||
dotnet_diagnostic.IDE0300.severity = suggestion # TODO: Consider enabling
|
||||
dotnet_diagnostic.IDE0300.severity = warning
|
||||
|
||||
# IDE0301 Use collection expression for empty
|
||||
# From above, uses dotnet_style_prefer_collection_expression
|
||||
dotnet_diagnostic.IDE0301.severity = suggestion # TODO: Consider enabling
|
||||
dotnet_diagnostic.IDE0301.severity = warning
|
||||
|
||||
# IDE0302 Use collection expression for stackalloc
|
||||
# From above, uses dotnet_style_prefer_collection_expression
|
||||
dotnet_diagnostic.IDE0302.severity = suggestion # TODO: Consider enabling
|
||||
dotnet_diagnostic.IDE0302.severity = warning
|
||||
|
||||
# IDE0303 Use collection expression for 'Create()'
|
||||
# From above, uses dotnet_style_prefer_collection_expression
|
||||
dotnet_diagnostic.IDE0303.severity = suggestion # TODO: Consider enabling
|
||||
dotnet_diagnostic.IDE0303.severity = warning
|
||||
|
||||
# IDE0304 Use collection expression for builder
|
||||
# From above, uses dotnet_style_prefer_collection_expression
|
||||
dotnet_diagnostic.IDE0304.severity = suggestion # TODO: Consider enabling
|
||||
dotnet_diagnostic.IDE0304.severity = warning
|
||||
|
||||
# IDE0305 Use collection expression for fluent
|
||||
# From above, uses dotnet_style_prefer_collection_expression
|
||||
dotnet_diagnostic.IDE0305.severity = suggestion # TODO: Consider enabling
|
||||
dotnet_diagnostic.IDE0305.severity = silent
|
||||
|
||||
## Field preferences
|
||||
|
||||
|
||||
@@ -89,21 +89,21 @@ namespace OpenRA
|
||||
sealed class ConditionState
|
||||
{
|
||||
/// <summary>Delegates that have registered to be notified when this condition changes.</summary>
|
||||
public readonly List<VariableObserverNotifier> Notifiers = new();
|
||||
public readonly List<VariableObserverNotifier> Notifiers = [];
|
||||
|
||||
/// <summary>Unique integers identifying granted instances of the condition.</summary>
|
||||
public readonly HashSet<int> Tokens = new();
|
||||
public readonly HashSet<int> Tokens = [];
|
||||
}
|
||||
|
||||
readonly Dictionary<string, ConditionState> conditionStates = new();
|
||||
readonly Dictionary<string, ConditionState> conditionStates = [];
|
||||
|
||||
/// <summary>Each granted condition receives a unique token that is used when revoking.</summary>
|
||||
readonly Dictionary<int, string> conditionTokens = new();
|
||||
readonly Dictionary<int, string> conditionTokens = [];
|
||||
|
||||
int nextConditionToken = 1;
|
||||
|
||||
/// <summary>Cache of condition -> enabled state for quick evaluation of token counter conditions.</summary>
|
||||
readonly Dictionary<string, int> conditionCache = new();
|
||||
readonly Dictionary<string, int> conditionCache = [];
|
||||
|
||||
/// <summary>Read-only version of conditionCache that is passed to IConditionConsumers.</summary>
|
||||
readonly IReadOnlyDictionary<string, int> readOnlyConditionCache;
|
||||
@@ -541,7 +541,7 @@ namespace OpenRA
|
||||
if (EnabledTargetablePositions.Any())
|
||||
return enabledTargetableWorldPositions;
|
||||
|
||||
return new[] { CenterPosition };
|
||||
return [CenterPosition];
|
||||
}
|
||||
|
||||
#region Conditions
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace OpenRA
|
||||
public override string ToString() { return X + "," + Y; }
|
||||
|
||||
public static readonly CVec[] Directions =
|
||||
{
|
||||
[
|
||||
new(-1, -1),
|
||||
new(-1, 0),
|
||||
new(-1, 1),
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA
|
||||
new(1, -1),
|
||||
new(1, 0),
|
||||
new(1, 1),
|
||||
};
|
||||
];
|
||||
|
||||
#region Scripting interface
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA
|
||||
public static class CryptoUtil
|
||||
{
|
||||
// Fixed byte pattern for the OID header
|
||||
static readonly byte[] OIDHeader = { 0x30, 0xD, 0x6, 0x9, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0xD, 0x1, 0x1, 0x1, 0x5, 0x0 };
|
||||
static readonly byte[] OIDHeader = [0x30, 0xD, 0x6, 0x9, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0xD, 0x1, 0x1, 0x1, 0x5, 0x0];
|
||||
|
||||
static readonly char[] HexUpperAlphabet = "0123456789ABCDEF".ToArray();
|
||||
static readonly char[] HexLowerAlphabet = "0123456789abcdef".ToArray();
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA
|
||||
|
||||
public class ExternalMods : IReadOnlyDictionary<string, ExternalMod>
|
||||
{
|
||||
readonly Dictionary<string, ExternalMod> mods = new();
|
||||
readonly Dictionary<string, ExternalMod> mods = [];
|
||||
readonly SheetBuilder sheetBuilder;
|
||||
|
||||
Sheet CreateSheet()
|
||||
@@ -122,13 +122,13 @@ namespace OpenRA
|
||||
return;
|
||||
|
||||
var key = ExternalMod.MakeKey(mod);
|
||||
var yaml = new MiniYamlNode("Registration", new MiniYaml("", new[]
|
||||
{
|
||||
var yaml = new MiniYamlNode("Registration", new MiniYaml("",
|
||||
[
|
||||
new MiniYamlNode("Id", mod.Id),
|
||||
new MiniYamlNode("Version", mod.Metadata.Version),
|
||||
new MiniYamlNode("LaunchPath", launchPath),
|
||||
new MiniYamlNode("LaunchArgs", new[] { "Game.Mod=" + mod.Id }.Concat(launchArgs).JoinWith(", "))
|
||||
}));
|
||||
]));
|
||||
|
||||
var iconNodes = new List<MiniYamlNode>();
|
||||
|
||||
|
||||
@@ -413,11 +413,6 @@ namespace OpenRA
|
||||
return ts.Except(exclusions);
|
||||
}
|
||||
|
||||
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> source)
|
||||
{
|
||||
return new HashSet<T>(source);
|
||||
}
|
||||
|
||||
public static Dictionary<TKey, TSource> ToDictionaryWithConflictLog<TSource, TKey>(
|
||||
this IEnumerable<TSource> source, Func<TSource, TKey> keySelector,
|
||||
string debugName, Func<TKey, string> logKey, Func<TSource, string> logValue)
|
||||
@@ -460,14 +455,14 @@ namespace OpenRA
|
||||
// Check for a key conflict:
|
||||
if (!output.TryAdd(key, element))
|
||||
{
|
||||
dupKeys ??= new Dictionary<TKey, List<string>>();
|
||||
dupKeys ??= [];
|
||||
if (!dupKeys.TryGetValue(key, out var dupKeyMessages))
|
||||
{
|
||||
// Log the initial conflicting value already inserted:
|
||||
dupKeyMessages = new List<string>
|
||||
{
|
||||
dupKeyMessages =
|
||||
[
|
||||
logValue(output[key])
|
||||
};
|
||||
];
|
||||
dupKeys.Add(key, dupKeyMessages);
|
||||
}
|
||||
|
||||
@@ -664,7 +659,7 @@ namespace OpenRA
|
||||
if (index == -1)
|
||||
{
|
||||
// The remaining string is an empty string
|
||||
str = ReadOnlySpan<char>.Empty;
|
||||
str = [];
|
||||
Current = span;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -530,8 +530,8 @@ namespace OpenRA
|
||||
if (value != null)
|
||||
{
|
||||
var parts = value.Split(SplitComma, StringSplitOptions.RemoveEmptyEntries);
|
||||
var ctor = fieldType.GetConstructor(new[] { typeof(string[]) });
|
||||
return ctor.Invoke(new object[] { parts.Select(p => p.Trim()).ToArray() });
|
||||
var ctor = fieldType.GetConstructor([typeof(string[])]);
|
||||
return ctor.Invoke([parts.Select(p => p.Trim()).ToArray()]);
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
@@ -544,7 +544,7 @@ namespace OpenRA
|
||||
|
||||
var innerType = fieldType.GetGenericArguments()[0];
|
||||
var innerValue = GetValue("Nullable<T>", innerType, value, field);
|
||||
return fieldType.GetConstructor(new[] { innerType }).Invoke(new[] { innerValue });
|
||||
return fieldType.GetConstructor([innerType]).Invoke([innerValue]);
|
||||
}
|
||||
|
||||
public static void Load(object self, MiniYaml my)
|
||||
@@ -565,7 +565,7 @@ namespace OpenRA
|
||||
val = fli.Loader(my);
|
||||
else
|
||||
{
|
||||
missing ??= new List<string>();
|
||||
missing ??= [];
|
||||
missing.Add(fli.YamlName);
|
||||
continue;
|
||||
}
|
||||
@@ -576,7 +576,7 @@ namespace OpenRA
|
||||
{
|
||||
if (fli.Attribute.Required)
|
||||
{
|
||||
missing ??= new List<string>();
|
||||
missing ??= [];
|
||||
missing.Add(fli.YamlName);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
public class Png
|
||||
{
|
||||
static readonly byte[] Signature = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
|
||||
static readonly byte[] Signature = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
||||
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
public Color[] Palette { get; }
|
||||
public byte[] Data { get; }
|
||||
public SpriteFrameType Type { get; }
|
||||
public Dictionary<string, string> EmbeddedData = new();
|
||||
public Dictionary<string, string> EmbeddedData = [];
|
||||
|
||||
public int PixelStride => Type == SpriteFrameType.Indexed8 ? 1 : Type == SpriteFrameType.Rgb24 ? 3 : 4;
|
||||
|
||||
|
||||
@@ -29,16 +29,16 @@ namespace OpenRA.FileSystem
|
||||
public class FileSystem : IReadOnlyFileSystem
|
||||
{
|
||||
public IEnumerable<IReadOnlyPackage> MountedPackages => mountedPackages.Keys;
|
||||
readonly Dictionary<IReadOnlyPackage, int> mountedPackages = new();
|
||||
readonly Dictionary<string, IReadOnlyPackage> explicitMounts = new();
|
||||
readonly Dictionary<IReadOnlyPackage, int> mountedPackages = [];
|
||||
readonly Dictionary<string, IReadOnlyPackage> explicitMounts = [];
|
||||
readonly string modID;
|
||||
|
||||
// Mod packages that should not be disposed
|
||||
readonly List<IReadOnlyPackage> modPackages = new();
|
||||
readonly List<IReadOnlyPackage> modPackages = [];
|
||||
readonly IReadOnlyDictionary<string, Manifest> installedMods;
|
||||
readonly IPackageLoader[] packageLoaders;
|
||||
|
||||
Cache<string, List<IReadOnlyPackage>> fileIndex = new(_ => new List<IReadOnlyPackage>());
|
||||
Cache<string, List<IReadOnlyPackage>> fileIndex = new(_ => []);
|
||||
|
||||
public FileSystem(string modID, IReadOnlyDictionary<string, Manifest> installedMods, IPackageLoader[] packageLoaders)
|
||||
{
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA.FileSystem
|
||||
explicitMounts.Clear();
|
||||
modPackages.Clear();
|
||||
|
||||
fileIndex = new Cache<string, List<IReadOnlyPackage>>(_ => new List<IReadOnlyPackage>());
|
||||
fileIndex = new Cache<string, List<IReadOnlyPackage>>(_ => []);
|
||||
}
|
||||
|
||||
public void TrimExcess()
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace OpenRA
|
||||
throw new ArgumentException("Expected a comma separated list of name, value arguments " +
|
||||
"but the number of arguments is not a multiple of two", nameof(args));
|
||||
|
||||
fluentArgs = new Dictionary<string, IFluentType>();
|
||||
fluentArgs = [];
|
||||
for (var i = 0; i < args.Length; i += 2)
|
||||
{
|
||||
var argKey = args[i] as string;
|
||||
|
||||
@@ -356,7 +356,7 @@ namespace OpenRA
|
||||
var explicitModPaths = Array.Empty<string>();
|
||||
if (modID != null && (File.Exists(modID) || Directory.Exists(modID)))
|
||||
{
|
||||
explicitModPaths = new[] { modID };
|
||||
explicitModPaths = [modID];
|
||||
modID = Path.GetFileNameWithoutExtension(modID);
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ namespace OpenRA
|
||||
var modSearchArg = args.GetValue("Engine.ModSearchPaths", null);
|
||||
var modSearchPaths = modSearchArg != null ?
|
||||
FieldLoader.GetValue<string[]>("Engine.ModsPath", modSearchArg) :
|
||||
new[] { Path.Combine(Platform.EngineDir, "mods") };
|
||||
[Path.Combine(Platform.EngineDir, "mods")];
|
||||
|
||||
Mods = new InstalledMods(modSearchPaths, explicitModPaths);
|
||||
Console.WriteLine("Internal mods:");
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA
|
||||
public TimeSpan Duration => EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero;
|
||||
|
||||
public IList<Player> Players { get; }
|
||||
public HashSet<int> DisabledSpawnPoints = new();
|
||||
public HashSet<int> DisabledSpawnPoints = [];
|
||||
public MapPreview MapPreview => Game.ModData.MapCache[MapUid];
|
||||
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
|
||||
public bool IsSinglePlayer => HumanPlayers.Count() == 1;
|
||||
@@ -48,8 +48,8 @@ namespace OpenRA
|
||||
|
||||
public GameInformation()
|
||||
{
|
||||
Players = new List<Player>();
|
||||
playersByRuntime = new Dictionary<OpenRA.Player, Player>();
|
||||
Players = [];
|
||||
playersByRuntime = [];
|
||||
}
|
||||
|
||||
public static GameInformation Deserialize(string data, string path)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA
|
||||
/// You can remove inherited traits by adding a - in front of them as in -TraitName: to inherit everything, but this trait.
|
||||
/// </summary>
|
||||
public readonly string Name;
|
||||
readonly TypeDictionary traits = new();
|
||||
readonly TypeDictionary traits = [];
|
||||
TraitInfo[] constructOrderCache = null;
|
||||
|
||||
public ActorInfo(ObjectCreator creator, string name, MiniYaml node)
|
||||
|
||||
@@ -17,14 +17,14 @@ namespace OpenRA.GameRules
|
||||
{
|
||||
public class SoundInfo
|
||||
{
|
||||
public readonly Dictionary<string, string[]> Variants = new();
|
||||
public readonly Dictionary<string, string[]> Prefixes = new();
|
||||
public readonly Dictionary<string, string[]> Voices = new();
|
||||
public readonly Dictionary<string, string[]> Notifications = new();
|
||||
public readonly Dictionary<string, string[]> Variants = [];
|
||||
public readonly Dictionary<string, string[]> Prefixes = [];
|
||||
public readonly Dictionary<string, string[]> Voices = [];
|
||||
public readonly Dictionary<string, string[]> Notifications = [];
|
||||
public readonly string DefaultVariant = ".aud";
|
||||
public readonly string DefaultPrefix = "";
|
||||
public readonly HashSet<string> DisableVariants = new();
|
||||
public readonly HashSet<string> DisablePrefixes = new();
|
||||
public readonly HashSet<string> DisableVariants = [];
|
||||
public readonly HashSet<string> DisablePrefixes = [];
|
||||
|
||||
public readonly Lazy<Dictionary<string, SoundPool>> VoicePools;
|
||||
public readonly Lazy<Dictionary<string, SoundPool>> NotificationsPools;
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.GameRules
|
||||
public readonly float VolumeModifier;
|
||||
public readonly InterruptType Type;
|
||||
readonly string[] clips;
|
||||
readonly List<string> liveclips = new();
|
||||
readonly List<string> liveclips = [];
|
||||
|
||||
public SoundPool(float volumeModifier, InterruptType interruptType, params string[] clips)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.GameRules
|
||||
public class WarheadArgs
|
||||
{
|
||||
public WeaponInfo Weapon;
|
||||
public int[] DamageModifiers = Array.Empty<int>();
|
||||
public int[] DamageModifiers = [];
|
||||
public WPos? Source;
|
||||
public WRot ImpactOrientation;
|
||||
public WPos ImpactPosition;
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.GameRules
|
||||
|
||||
[Desc("Delay in ticks between firing shots from the same ammo magazine. If one entry, it will be used for all bursts.",
|
||||
"If multiple entries, their number needs to match Burst - 1.")]
|
||||
public readonly int[] BurstDelays = { 5 };
|
||||
public readonly int[] BurstDelays = [5];
|
||||
|
||||
[Desc("The minimum range the weapon can fire.")]
|
||||
public readonly WDist MinRange = WDist.Zero;
|
||||
@@ -128,7 +128,7 @@ namespace OpenRA.GameRules
|
||||
public readonly IProjectileInfo Projectile;
|
||||
|
||||
[FieldLoader.LoadUsing(nameof(LoadWarheads))]
|
||||
public readonly List<IWarhead> Warheads = new();
|
||||
public readonly List<IWarhead> Warheads = [];
|
||||
|
||||
/// <summary>
|
||||
/// This constructor is used solely for documentation generation.
|
||||
@@ -139,7 +139,7 @@ namespace OpenRA.GameRules
|
||||
{
|
||||
// Resolve any weapon-level yaml inheritance or removals
|
||||
// HACK: The "Defaults" sequence syntax prevents us from doing this generally during yaml parsing
|
||||
content = content.WithNodes(MiniYaml.Merge(new IReadOnlyCollection<MiniYamlNode>[] { content.Nodes }));
|
||||
content = content.WithNodes(MiniYaml.Merge([content.Nodes]));
|
||||
FieldLoader.Load(this, content);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,10 +73,10 @@ namespace OpenRA.Graphics
|
||||
shadow, pos, offset - new WVec(0, 0, height), CurrentSequence.ShadowZOffset + zOffset + height, palette,
|
||||
CurrentSequence.Scale, 1f, float3.Ones, tintModifiers,
|
||||
true, rotation);
|
||||
return new IRenderable[] { shadowRenderable, imageRenderable };
|
||||
return [shadowRenderable, imageRenderable];
|
||||
}
|
||||
|
||||
return new IRenderable[] { imageRenderable };
|
||||
return [imageRenderable];
|
||||
}
|
||||
|
||||
public IRenderable[] RenderUI(WorldRenderer wr, int2 pos, in WVec offset, int zOffset, PaletteReference palette, float scale = 1f, float rotation = 0f)
|
||||
@@ -92,10 +92,10 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var shadowPos = pos - new int2((int)(scale * shadow.Size.X / 2), (int)(scale * shadow.Size.Y / 2));
|
||||
var shadowRenderable = new UISpriteRenderable(shadow, WPos.Zero + offset, shadowPos, CurrentSequence.ShadowZOffset + zOffset, palette, scale, 1f, rotation);
|
||||
return new IRenderable[] { shadowRenderable, imageRenderable };
|
||||
return [shadowRenderable, imageRenderable];
|
||||
}
|
||||
|
||||
return new IRenderable[] { imageRenderable };
|
||||
return [imageRenderable];
|
||||
}
|
||||
|
||||
public Rectangle ScreenBounds(WorldRenderer wr, WPos pos, in WVec offset)
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public readonly int[] PanelRegion = null;
|
||||
public readonly PanelSides PanelSides = PanelSides.All;
|
||||
public readonly Dictionary<string, Rectangle> Regions = new();
|
||||
public readonly Dictionary<string, Rectangle> Regions = [];
|
||||
}
|
||||
|
||||
public static IReadOnlyDictionary<string, Collection> Collections => collections;
|
||||
@@ -71,11 +71,11 @@ namespace OpenRA.Graphics
|
||||
dpiScale = Game.Renderer.WindowScale;
|
||||
|
||||
fileSystem = modData.DefaultFileSystem;
|
||||
collections = new Dictionary<string, Collection>();
|
||||
cachedSheets = new Dictionary<string, (Sheet, int)>();
|
||||
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
|
||||
cachedPanelSprites = new Dictionary<string, Sprite[]>();
|
||||
cachedCollectionSheets = new Dictionary<Collection, (Sheet, int)>();
|
||||
collections = [];
|
||||
cachedSheets = [];
|
||||
cachedSprites = [];
|
||||
cachedPanelSprites = [];
|
||||
cachedCollectionSheets = [];
|
||||
|
||||
var stringPool = new HashSet<string>(); // Reuse common strings in YAML
|
||||
var chrome = MiniYaml.Merge(modData.Manifest.Chrome
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Graphics
|
||||
var sheetDensity = SheetForCollection(collection);
|
||||
if (cachedCollection == null)
|
||||
{
|
||||
cachedCollection = new Dictionary<string, Sprite>();
|
||||
cachedCollection = [];
|
||||
cachedSprites.Add(collectionName, cachedCollection);
|
||||
}
|
||||
|
||||
@@ -240,11 +240,11 @@ namespace OpenRA.Graphics
|
||||
// PERF: We don't need to search for images if there are no definitions.
|
||||
// PERF: It's more efficient to send an empty array rather than an array of 9 nulls.
|
||||
if (collection.Regions.Count == 0)
|
||||
return Array.Empty<Sprite>();
|
||||
return [];
|
||||
|
||||
// Support manual definitions for unusual dialog layouts
|
||||
sprites = new[]
|
||||
{
|
||||
sprites =
|
||||
[
|
||||
TryGetImage(collectionName, "corner-tl"),
|
||||
TryGetImage(collectionName, "border-t"),
|
||||
TryGetImage(collectionName, "corner-tr"),
|
||||
@@ -254,7 +254,7 @@ namespace OpenRA.Graphics
|
||||
TryGetImage(collectionName, "corner-bl"),
|
||||
TryGetImage(collectionName, "border-b"),
|
||||
TryGetImage(collectionName, "corner-br")
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
cachedPanelSprites.Add(collectionName, sprites);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Graphics
|
||||
public IHardwareCursor[] Cursors;
|
||||
}
|
||||
|
||||
readonly Dictionary<string, Cursor> cursors = new();
|
||||
readonly Dictionary<string, Cursor> cursors = [];
|
||||
readonly SheetBuilder sheetBuilder;
|
||||
readonly GraphicSettings graphicSettings;
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace OpenRA.Graphics
|
||||
var height = frame.Size.Height;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
return Array.Empty<byte>();
|
||||
return [];
|
||||
|
||||
var data = new byte[4 * width * height];
|
||||
unsafe
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace OpenRA.Graphics
|
||||
public ITexture ColorShifts { get; }
|
||||
|
||||
public int Height { get; private set; }
|
||||
readonly Dictionary<string, ImmutablePalette> palettes = new();
|
||||
readonly Dictionary<string, MutablePalette> mutablePalettes = new();
|
||||
readonly Dictionary<string, int> indices = new();
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
float[] colorShiftBuffer = Array.Empty<float>();
|
||||
readonly Dictionary<string, ImmutablePalette> palettes = [];
|
||||
readonly Dictionary<string, MutablePalette> mutablePalettes = [];
|
||||
readonly Dictionary<string, int> indices = [];
|
||||
byte[] buffer = [];
|
||||
float[] colorShiftBuffer = [];
|
||||
|
||||
public HardwarePalette()
|
||||
{
|
||||
|
||||
@@ -43,11 +43,11 @@ namespace OpenRA.Graphics
|
||||
: base("model")
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 3, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", ShaderVertexAttributeType.Float, 4, 12),
|
||||
new ShaderVertexAttribute("aVertexTexMetadata", ShaderVertexAttributeType.Float, 2, 28),
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace OpenRA.Graphics
|
||||
public RenderPostProcessPassShaderBindings(string name)
|
||||
: base("postprocess", "postprocess_" + name) { }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 2, 0)
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
public sealed class RenderPostProcessPassTexturedShaderBindings : ShaderBindings
|
||||
@@ -55,10 +55,10 @@ namespace OpenRA.Graphics
|
||||
: base("postprocess_textured", "postprocess_textured_" + name)
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 2, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", ShaderVertexAttributeType.Float, 2, 8),
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var tr = new float3(br.X, tl.Y, tl.Z);
|
||||
var bl = new float3(tl.X, br.Y, br.Z);
|
||||
DrawPolygon(new[] { tl, tr, br, bl }, width, color, blendMode);
|
||||
DrawPolygon([tl, tr, br, bl], width, color, blendMode);
|
||||
}
|
||||
|
||||
public void FillRect(in float3 tl, in float3 br, Color color, BlendMode blendMode = BlendMode.Alpha)
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Graphics
|
||||
public sealed class SheetBuilder : IDisposable
|
||||
{
|
||||
public readonly SheetType Type;
|
||||
readonly List<Sheet> sheets = new();
|
||||
readonly List<Sheet> sheets = [];
|
||||
readonly Func<Sheet> allocateSheet;
|
||||
readonly int margin;
|
||||
int rowHeight = 0;
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace OpenRA.Graphics
|
||||
|
||||
readonly Dictionary<
|
||||
int,
|
||||
(int[] Frames, MiniYamlNode.SourceLocation Location, AdjustFrame AdjustFrame, bool Premultiplied)> spriteReservations = new();
|
||||
readonly Dictionary<string, List<int>> reservationsByFilename = new();
|
||||
(int[] Frames, MiniYamlNode.SourceLocation Location, AdjustFrame AdjustFrame, bool Premultiplied)> spriteReservations = [];
|
||||
readonly Dictionary<string, List<int>> reservationsByFilename = [];
|
||||
|
||||
readonly Dictionary<int, Sprite[]> resolvedSprites = new();
|
||||
readonly Dictionary<int, Sprite[]> resolvedSprites = [];
|
||||
|
||||
readonly Dictionary<int, (string Filename, MiniYamlNode.SourceLocation Location)> missingFiles = new();
|
||||
readonly Dictionary<int, (string Filename, MiniYamlNode.SourceLocation Location)> missingFiles = [];
|
||||
|
||||
int nextReservationToken = 1;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var token = nextReservationToken++;
|
||||
spriteReservations[token] = (frames?.ToArray(), location, adjustFrame, premultiplied);
|
||||
reservationsByFilename.GetOrAdd(filename, _ => new List<int>()).Add(token);
|
||||
reservationsByFilename.GetOrAdd(filename, _ => []).Add(token);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
@@ -17,7 +16,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
public class SpriteRenderable : IPalettedRenderable, IModifyableRenderable, IFinalizedRenderable
|
||||
{
|
||||
public static readonly IEnumerable<IRenderable> None = Array.Empty<IRenderable>();
|
||||
public static readonly IEnumerable<IRenderable> None = [];
|
||||
|
||||
readonly Sprite sprite;
|
||||
readonly WPos pos;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Graphics
|
||||
public sealed class TerrainSpriteLayer : IDisposable
|
||||
{
|
||||
// PERF: we can reuse the IndexBuffer as all layers have the same size.
|
||||
static readonly ConditionalWeakTable<World, IndexBufferRc> IndexBuffers = new();
|
||||
static readonly ConditionalWeakTable<World, IndexBufferRc> IndexBuffers = [];
|
||||
readonly IndexBufferRc indexBufferWrapper;
|
||||
|
||||
public readonly BlendMode BlendMode;
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
|
||||
readonly IVertexBuffer<Vertex> vertexBuffer;
|
||||
readonly Vertex[] vertices;
|
||||
readonly bool[] ignoreTint;
|
||||
readonly HashSet<int> dirtyRows = new();
|
||||
readonly HashSet<int> dirtyRows = [];
|
||||
readonly int indexRowStride;
|
||||
readonly int vertexRowStride;
|
||||
readonly bool restrictToBounds;
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace OpenRA.Graphics
|
||||
public static class Util
|
||||
{
|
||||
// yes, our channel order is nuts.
|
||||
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
|
||||
static readonly int[] ChannelMasks = [2, 1, 0, 3];
|
||||
|
||||
public static uint[] CreateQuadIndices(int quads)
|
||||
{
|
||||
var indices = new uint[quads * 6];
|
||||
ReadOnlySpan<uint> cornerVertexMap = stackalloc uint[] { 0, 1, 2, 2, 3, 0 };
|
||||
ReadOnlySpan<uint> cornerVertexMap = [0, 1, 2, 2, 3, 0];
|
||||
for (var i = 0; i < indices.Length; i++)
|
||||
indices[i] = cornerVertexMap[i % 6] + (uint)(4 * (i / 6));
|
||||
|
||||
@@ -277,13 +277,13 @@ namespace OpenRA.Graphics
|
||||
size.X * angleSin - size.Y * angleCos,
|
||||
(size.X * angleSin - size.Y * angleCos) * size.Z / size.Y);
|
||||
|
||||
return new float3[]
|
||||
{
|
||||
return
|
||||
[
|
||||
center - ra,
|
||||
center + rb,
|
||||
center + ra,
|
||||
center - rb
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -53,12 +53,12 @@ namespace OpenRA.Graphics
|
||||
: base("combined")
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 3, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", ShaderVertexAttributeType.Float, 4, 12),
|
||||
new ShaderVertexAttribute("aVertexAttributes", ShaderVertexAttributeType.UInt, 1, 28),
|
||||
new ShaderVertexAttribute("aVertexTint", ShaderVertexAttributeType.Float, 4, 32)
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,19 +31,19 @@ namespace OpenRA.Graphics
|
||||
|
||||
public event Action PaletteInvalidated = null;
|
||||
|
||||
readonly HashSet<Actor> onScreenActors = new();
|
||||
readonly HashSet<Actor> onScreenActors = [];
|
||||
readonly HardwarePalette palette = new();
|
||||
readonly Dictionary<string, PaletteReference> palettes = new();
|
||||
readonly Dictionary<string, PaletteReference> palettes = [];
|
||||
readonly IRenderTerrain terrainRenderer;
|
||||
readonly Lazy<DebugVisualizations> debugVis;
|
||||
readonly Func<string, PaletteReference> createPaletteReference;
|
||||
readonly bool enableDepthBuffer;
|
||||
|
||||
readonly List<IFinalizedRenderable> preparedRenderables = new();
|
||||
readonly List<IFinalizedRenderable> preparedOverlayRenderables = new();
|
||||
readonly List<IFinalizedRenderable> preparedAnnotationRenderables = new();
|
||||
readonly List<IFinalizedRenderable> preparedRenderables = [];
|
||||
readonly List<IFinalizedRenderable> preparedOverlayRenderables = [];
|
||||
readonly List<IFinalizedRenderable> preparedAnnotationRenderables = [];
|
||||
|
||||
readonly List<IRenderable> renderablesBuffer = new();
|
||||
readonly List<IRenderable> renderablesBuffer = [];
|
||||
readonly IRenderer[] renderers;
|
||||
readonly IRenderPostProcessPass[] postProcessPasses;
|
||||
|
||||
@@ -429,7 +429,7 @@ namespace OpenRA.Graphics
|
||||
public float[] ScreenVector(in WVec vec)
|
||||
{
|
||||
var xyz = ScreenVectorComponents(vec);
|
||||
return new[] { xyz.X, xyz.Y, xyz.Z, 1f };
|
||||
return [xyz.X, xyz.Y, xyz.Z, 1f];
|
||||
}
|
||||
|
||||
public int2 ScreenPxOffset(in WVec vec)
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace OpenRA
|
||||
[FluentReference]
|
||||
public readonly string Description = "";
|
||||
|
||||
public readonly HashSet<string> Types = new();
|
||||
public readonly HashSet<string> Types = [];
|
||||
|
||||
[FluentReference]
|
||||
public readonly HashSet<string> Contexts = new();
|
||||
public readonly HashSet<string> Contexts = [];
|
||||
|
||||
public readonly bool Readonly = false;
|
||||
public bool HasDuplicates { get; internal set; }
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace OpenRA
|
||||
public sealed class HotkeyManager
|
||||
{
|
||||
readonly Dictionary<string, Hotkey> settings;
|
||||
readonly Dictionary<string, HotkeyDefinition> definitions = new();
|
||||
readonly Dictionary<string, Hotkey> keys = new();
|
||||
readonly Dictionary<string, HotkeyDefinition> definitions = [];
|
||||
readonly Dictionary<string, Hotkey> keys = [];
|
||||
|
||||
public HotkeyManager(IReadOnlyFileSystem fileSystem, Dictionary<string, Hotkey> settings, Manifest manifest)
|
||||
{
|
||||
|
||||
@@ -78,11 +78,11 @@ namespace OpenRA
|
||||
public readonly MiniYaml LoadScreen;
|
||||
public readonly string DefaultOrderGenerator;
|
||||
|
||||
public readonly string[] Assemblies = Array.Empty<string>();
|
||||
public readonly string[] SoundFormats = Array.Empty<string>();
|
||||
public readonly string[] SpriteFormats = Array.Empty<string>();
|
||||
public readonly string[] PackageFormats = Array.Empty<string>();
|
||||
public readonly string[] VideoFormats = Array.Empty<string>();
|
||||
public readonly string[] Assemblies = [];
|
||||
public readonly string[] SoundFormats = [];
|
||||
public readonly string[] SpriteFormats = [];
|
||||
public readonly string[] PackageFormats = [];
|
||||
public readonly string[] VideoFormats = [];
|
||||
public readonly int FontSheetSize = 512;
|
||||
public readonly int CursorSheetSize = 512;
|
||||
|
||||
@@ -91,15 +91,15 @@ namespace OpenRA
|
||||
public readonly bool AllowUnusedFluentMessagesInExternalPackages = true;
|
||||
|
||||
readonly string[] reservedModuleNames =
|
||||
{
|
||||
[
|
||||
"Include", "Metadata", "FileSystem", "MapFolders", "Rules",
|
||||
"Sequences", "ModelSequences", "Cursors", "Chrome", "Assemblies", "ChromeLayout", "Weapons",
|
||||
"Voices", "Notifications", "Music", "FluentMessages", "TileSets", "ChromeMetrics", "Missions", "Hotkeys",
|
||||
"ServerTraits", "LoadScreen", "DefaultOrderGenerator", "SupportsMapsFrom", "SoundFormats", "SpriteFormats", "VideoFormats",
|
||||
"RequiresMods", "PackageFormats", "AllowUnusedFluentMessagesInExternalPackages", "FontSheetSize", "CursorSheetSize"
|
||||
};
|
||||
];
|
||||
|
||||
readonly TypeDictionary modules = new();
|
||||
readonly TypeDictionary modules = [];
|
||||
readonly Dictionary<string, MiniYaml> yaml;
|
||||
|
||||
bool customDataLoaded;
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
// Merge inherited overrides
|
||||
yaml = new MiniYaml(null, MiniYaml.Merge(new[] { nodes })).ToDictionary();
|
||||
yaml = new MiniYaml(null, MiniYaml.Merge([nodes])).ToDictionary();
|
||||
|
||||
Metadata = FieldLoader.Load<ModMetadata>(yaml["Metadata"]);
|
||||
|
||||
@@ -207,11 +207,11 @@ namespace OpenRA
|
||||
throw new InvalidDataException($"`{kv.Key}` is not a valid mod manifest entry.");
|
||||
|
||||
IGlobalModData module;
|
||||
var ctor = t.GetConstructor(new[] { typeof(MiniYaml) });
|
||||
var ctor = t.GetConstructor([typeof(MiniYaml)]);
|
||||
if (ctor != null)
|
||||
{
|
||||
// Class has opted-in to DIY initialization
|
||||
module = (IGlobalModData)ctor.Invoke(new object[] { kv.Value });
|
||||
module = (IGlobalModData)ctor.Invoke([kv.Value]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -229,7 +229,7 @@ namespace OpenRA
|
||||
static string[] YamlList(Dictionary<string, MiniYaml> yaml, string key)
|
||||
{
|
||||
if (!yaml.TryGetValue(key, out var value))
|
||||
return Array.Empty<string>();
|
||||
return [];
|
||||
|
||||
return value.Nodes.Select(n => n.Key).ToArray();
|
||||
}
|
||||
@@ -279,11 +279,11 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
IGlobalModData module;
|
||||
var ctor = t.GetConstructor(new[] { typeof(MiniYaml) });
|
||||
var ctor = t.GetConstructor([typeof(MiniYaml)]);
|
||||
if (ctor != null)
|
||||
{
|
||||
// Class has opted-in to DIY initialization
|
||||
module = (IGlobalModData)ctor.Invoke(new object[] { data.Value });
|
||||
module = (IGlobalModData)ctor.Invoke([data.Value]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -74,11 +74,11 @@ namespace OpenRA
|
||||
if (initInstance.Length > 1)
|
||||
type.GetField(nameof(ActorInit.InstanceName)).SetValue(init, initInstance[1]);
|
||||
|
||||
var loader = type.GetMethod("Initialize", new[] { typeof(MiniYaml) });
|
||||
var loader = type.GetMethod("Initialize", [typeof(MiniYaml)]);
|
||||
if (loader == null)
|
||||
throw new InvalidDataException($"{initInstance[0]}Init does not define a yaml-assignable type.");
|
||||
|
||||
loader.Invoke(init, new[] { initYaml });
|
||||
loader.Invoke(init, [initYaml]);
|
||||
return init;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -158,7 +157,7 @@ namespace OpenRA
|
||||
|
||||
/// <summary>Defines the order of the fields in map.yaml.</summary>
|
||||
static readonly MapField[] YamlFields =
|
||||
{
|
||||
[
|
||||
new("MapFormat"),
|
||||
new("RequiresMod"),
|
||||
new("Title"),
|
||||
@@ -179,7 +178,7 @@ namespace OpenRA
|
||||
new("Voices", nameof(VoiceDefinitions), required: false),
|
||||
new("Music", nameof(MusicDefinitions), required: false),
|
||||
new("Notifications", nameof(NotificationDefinitions), required: false),
|
||||
};
|
||||
];
|
||||
|
||||
// Format versions
|
||||
public int MapFormat { get; private set; }
|
||||
@@ -193,13 +192,13 @@ namespace OpenRA
|
||||
public bool LockPreview;
|
||||
public Rectangle Bounds;
|
||||
public MapVisibility Visibility = MapVisibility.Lobby;
|
||||
public string[] Categories = { "Conquest" };
|
||||
public string[] Categories = ["Conquest"];
|
||||
|
||||
public int2 MapSize { get; private set; }
|
||||
|
||||
// Player and actor yaml. Public for access by the map importers and lint checks.
|
||||
public IReadOnlyCollection<MiniYamlNode> PlayerDefinitions = ImmutableArray<MiniYamlNode>.Empty;
|
||||
public IReadOnlyCollection<MiniYamlNode> ActorDefinitions = ImmutableArray<MiniYamlNode>.Empty;
|
||||
public IReadOnlyCollection<MiniYamlNode> PlayerDefinitions = [];
|
||||
public IReadOnlyCollection<MiniYamlNode> ActorDefinitions = [];
|
||||
|
||||
// Custom map yaml. Public for access by the map importers and lint checks
|
||||
public MiniYaml RuleDefinitions;
|
||||
@@ -211,7 +210,7 @@ namespace OpenRA
|
||||
public MiniYaml MusicDefinitions;
|
||||
public MiniYaml NotificationDefinitions;
|
||||
|
||||
public readonly Dictionary<CPos, TerrainTile> ReplacedInvalidTerrainTiles = new();
|
||||
public readonly Dictionary<CPos, TerrainTile> ReplacedInvalidTerrainTiles = [];
|
||||
|
||||
// Generated data
|
||||
public readonly MapGrid Grid;
|
||||
@@ -283,7 +282,7 @@ namespace OpenRA
|
||||
|
||||
// Take the SHA1
|
||||
if (streams.Count == 0)
|
||||
return CryptoUtil.SHA1Hash(Array.Empty<byte>());
|
||||
return CryptoUtil.SHA1Hash([]);
|
||||
|
||||
var merged = streams[0];
|
||||
for (var i = 1; i < streams.Count; i++)
|
||||
@@ -368,8 +367,8 @@ namespace OpenRA
|
||||
if (MapFormat < SupportedMapFormat)
|
||||
throw new InvalidDataException($"Map format {MapFormat} is not supported.\n File: {package.Name}");
|
||||
|
||||
PlayerDefinitions = yaml.NodeWithKeyOrDefault("Players")?.Value.Nodes ?? ImmutableArray<MiniYamlNode>.Empty;
|
||||
ActorDefinitions = yaml.NodeWithKeyOrDefault("Actors")?.Value.Nodes ?? ImmutableArray<MiniYamlNode>.Empty;
|
||||
PlayerDefinitions = yaml.NodeWithKeyOrDefault("Players")?.Value.Nodes ?? [];
|
||||
ActorDefinitions = yaml.NodeWithKeyOrDefault("Actors")?.Value.Nodes ?? [];
|
||||
|
||||
Grid = modData.Manifest.Get<MapGrid>();
|
||||
|
||||
@@ -516,7 +515,7 @@ namespace OpenRA
|
||||
foreach (var cell in AllCells)
|
||||
{
|
||||
var uv = cell.ToMPos(Grid.Type);
|
||||
cellProjection[uv] = Array.Empty<PPos>();
|
||||
cellProjection[uv] = [];
|
||||
inverseCellProjection[uv] = new List<MPos>(1);
|
||||
}
|
||||
|
||||
@@ -532,7 +531,7 @@ namespace OpenRA
|
||||
if (Grid.MaximumTerrainHeight == 0)
|
||||
{
|
||||
uv = cell.ToMPos(Grid.Type);
|
||||
cellProjection[cell] = new[] { (PPos)uv };
|
||||
cellProjection[cell] = [(PPos)uv];
|
||||
var inverse = inverseCellProjection[uv];
|
||||
inverse.Clear();
|
||||
inverse.Add(uv);
|
||||
@@ -607,7 +606,7 @@ namespace OpenRA
|
||||
// Any changes to this function should be reflected when setting projectionSafeBounds.
|
||||
var height = mapHeight[uv];
|
||||
if (height == 0)
|
||||
return new[] { (PPos)uv };
|
||||
return [(PPos)uv];
|
||||
|
||||
// Odd-height ramps get bumped up a level to the next even height layer
|
||||
if ((height & 1) == 1 && Ramp[uv] != 0)
|
||||
@@ -1044,7 +1043,7 @@ namespace OpenRA
|
||||
return (PPos)CellContaining(projectedPos).ToMPos(Grid.Type);
|
||||
}
|
||||
|
||||
static readonly PPos[] NoProjectedCells = Array.Empty<PPos>();
|
||||
static readonly PPos[] NoProjectedCells = [];
|
||||
public PPos[] ProjectedCellsCovering(MPos uv)
|
||||
{
|
||||
if (!initializedCellProjection)
|
||||
@@ -1064,7 +1063,7 @@ namespace OpenRA
|
||||
InitializeCellProjection();
|
||||
|
||||
if (!inverseCellProjection.Contains(uv))
|
||||
return new List<MPos>();
|
||||
return [];
|
||||
|
||||
return inverseCellProjection[uv];
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA
|
||||
{
|
||||
public static readonly MapPreview UnknownMap = new(null, null, MapGridType.Rectangular, null);
|
||||
public IReadOnlyDictionary<IReadOnlyPackage, MapClassification> MapLocations => mapLocations;
|
||||
readonly Dictionary<IReadOnlyPackage, MapClassification> mapLocations = new();
|
||||
readonly Dictionary<IReadOnlyPackage, MapClassification> mapLocations = [];
|
||||
public bool LoadPreviewImages = true;
|
||||
|
||||
readonly Cache<string, MapPreview> previews;
|
||||
@@ -37,17 +37,17 @@ namespace OpenRA
|
||||
Thread previewLoaderThread;
|
||||
bool previewLoaderThreadShutDown = true;
|
||||
readonly object syncRoot = new();
|
||||
readonly Queue<MapPreview> generateMinimap = new();
|
||||
readonly Queue<MapPreview> generateMinimap = [];
|
||||
|
||||
public HashSet<string> StringPool { get; } = new();
|
||||
public HashSet<string> StringPool { get; } = [];
|
||||
|
||||
readonly List<MapDirectoryTracker> mapDirectoryTrackers = new();
|
||||
readonly List<MapDirectoryTracker> mapDirectoryTrackers = [];
|
||||
|
||||
/// <summary>
|
||||
/// The most recently modified or loaded map at runtime.
|
||||
/// </summary>
|
||||
public string LastModifiedMap { get; private set; } = null;
|
||||
readonly Dictionary<string, string> mapUpdates = new();
|
||||
readonly Dictionary<string, string> mapUpdates = [];
|
||||
|
||||
string lastLoadedLastModifiedMap;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA
|
||||
readonly MapClassification classification;
|
||||
|
||||
enum MapAction { Add, Delete, Update }
|
||||
readonly Dictionary<string, MapAction> mapActionQueue = new();
|
||||
readonly Dictionary<string, MapAction> mapActionQueue = [];
|
||||
|
||||
bool dirty = false;
|
||||
|
||||
|
||||
@@ -37,43 +37,43 @@ namespace OpenRA
|
||||
Orientation = orientation;
|
||||
if (type == MapGridType.RectangularIsometric)
|
||||
{
|
||||
Corners = new[]
|
||||
{
|
||||
Corners =
|
||||
[
|
||||
new WVec(0, -724, 724 * (int)tl),
|
||||
new WVec(724, 0, 724 * (int)tr),
|
||||
new WVec(0, 724, 724 * (int)br),
|
||||
new WVec(-724, 0, 724 * (int)bl),
|
||||
};
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
Corners = new[]
|
||||
{
|
||||
Corners =
|
||||
[
|
||||
new WVec(-512, -512, 512 * (int)tl),
|
||||
new WVec(512, -512, 512 * (int)tr),
|
||||
new WVec(512, 512, 512 * (int)br),
|
||||
new WVec(-512, 512, 512 * (int)bl)
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
if (split == RampSplit.X)
|
||||
{
|
||||
Polygons = new[]
|
||||
{
|
||||
new[] { Corners[0], Corners[1], Corners[3] },
|
||||
new[] { Corners[1], Corners[2], Corners[3] }
|
||||
};
|
||||
Polygons =
|
||||
[
|
||||
[Corners[0], Corners[1], Corners[3]],
|
||||
[Corners[1], Corners[2], Corners[3]]
|
||||
];
|
||||
}
|
||||
else if (split == RampSplit.Y)
|
||||
{
|
||||
Polygons = new[]
|
||||
{
|
||||
new[] { Corners[0], Corners[1], Corners[2] },
|
||||
new[] { Corners[0], Corners[2], Corners[3] }
|
||||
};
|
||||
Polygons =
|
||||
[
|
||||
[Corners[0], Corners[1], Corners[2]],
|
||||
[Corners[0], Corners[2], Corners[3]]
|
||||
];
|
||||
}
|
||||
else
|
||||
Polygons = new[] { Corners };
|
||||
Polygons = [Corners];
|
||||
|
||||
// Initial value must be assigned before HeightOffset can be called
|
||||
CenterHeightOffset = 0;
|
||||
@@ -115,14 +115,14 @@ namespace OpenRA
|
||||
public readonly bool EnableDepthBuffer = false;
|
||||
|
||||
public readonly WVec[] SubCellOffsets =
|
||||
{
|
||||
[
|
||||
new(0, 0, 0), // full cell - index 0
|
||||
new(-299, -256, 0), // top left - index 1
|
||||
new(256, -256, 0), // top right - index 2
|
||||
new(0, 0, 0), // center - index 3
|
||||
new(-299, 256, 0), // bottom left - index 4
|
||||
new(256, 256, 0), // bottom right - index 5
|
||||
};
|
||||
];
|
||||
|
||||
public CellRamp[] Ramps { get; }
|
||||
|
||||
@@ -159,8 +159,9 @@ namespace OpenRA
|
||||
var halfBackward = -halfForward;
|
||||
|
||||
// Slope types are hardcoded following the convention from the TS and RA2 map format
|
||||
Ramps = new[]
|
||||
{
|
||||
Ramps =
|
||||
[
|
||||
|
||||
// Flat
|
||||
new CellRamp(Type, WRot.None),
|
||||
|
||||
@@ -193,7 +194,7 @@ namespace OpenRA
|
||||
new CellRamp(Type, WRot.None, tl: RampCornerHeight.Half, br: RampCornerHeight.Half, split: RampSplit.Y),
|
||||
new CellRamp(Type, WRot.None, tr: RampCornerHeight.Half, bl: RampCornerHeight.Half, split: RampSplit.X),
|
||||
new CellRamp(Type, WRot.None, tl: RampCornerHeight.Half, br: RampCornerHeight.Half, split: RampSplit.X),
|
||||
};
|
||||
];
|
||||
|
||||
TilesByDistance = CreateTilesByDistance();
|
||||
}
|
||||
@@ -202,7 +203,7 @@ namespace OpenRA
|
||||
{
|
||||
var ts = new List<CVec>[MaximumTileSearchRange + 1];
|
||||
for (var i = 0; i < MaximumTileSearchRange + 1; i++)
|
||||
ts[i] = new List<CVec>();
|
||||
ts[i] = [];
|
||||
|
||||
for (var j = -MaximumTileSearchRange; j <= MaximumTileSearchRange; j++)
|
||||
for (var i = -MaximumTileSearchRange; i <= MaximumTileSearchRange; i++)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA
|
||||
public readonly Dictionary<string, PlayerReference> Players;
|
||||
|
||||
public MapPlayers()
|
||||
: this(new List<MiniYamlNode>()) { }
|
||||
: this([]) { }
|
||||
|
||||
public MapPlayers(IEnumerable<MiniYamlNode> playerDefinitions)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA
|
||||
Name = $"Multi{index}",
|
||||
Faction = "Random",
|
||||
Playable = true,
|
||||
Enemies = new[] { "Creeps" }
|
||||
Enemies = ["Creeps"]
|
||||
};
|
||||
Players.Add(p.Name, p);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA
|
||||
public readonly string[] categories;
|
||||
public readonly int players;
|
||||
public readonly Rectangle bounds;
|
||||
public readonly short[] spawnpoints = Array.Empty<short>();
|
||||
public readonly short[] spawnpoints = [];
|
||||
public readonly MapGridType map_grid_type;
|
||||
public readonly string minimap;
|
||||
public readonly bool downloading;
|
||||
@@ -195,7 +195,7 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
static readonly CPos[] NoSpawns = Array.Empty<CPos>();
|
||||
static readonly CPos[] NoSpawns = [];
|
||||
readonly MapCache cache;
|
||||
readonly ModData modData;
|
||||
IReadOnlyPackage package;
|
||||
@@ -321,7 +321,7 @@ namespace OpenRA
|
||||
{
|
||||
MapFormat = 0,
|
||||
Title = "Unknown Map",
|
||||
Categories = new[] { "Unknown" },
|
||||
Categories = ["Unknown"],
|
||||
Author = "Unknown Author",
|
||||
TileSet = "unknown",
|
||||
Players = null,
|
||||
@@ -421,11 +421,11 @@ namespace OpenRA
|
||||
newData.SpawnPoints = spawns.ToArray();
|
||||
}
|
||||
else
|
||||
newData.SpawnPoints = Array.Empty<CPos>();
|
||||
newData.SpawnPoints = [];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
newData.SpawnPoints = Array.Empty<CPos>();
|
||||
newData.SpawnPoints = [];
|
||||
newData.Status = MapStatus.Unavailable;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
namespace OpenRA
|
||||
@@ -54,8 +53,8 @@ namespace OpenRA
|
||||
public bool LockHandicap = false;
|
||||
public int Handicap = 0;
|
||||
|
||||
public string[] Allies = Array.Empty<string>();
|
||||
public string[] Enemies = Array.Empty<string>();
|
||||
public string[] Allies = [];
|
||||
public string[] Enemies = [];
|
||||
|
||||
public PlayerReference() { }
|
||||
public PlayerReference(MiniYaml my) { FieldLoader.Load(this, my); }
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA
|
||||
{
|
||||
public readonly string Type;
|
||||
public readonly BitSet<TargetableType> TargetTypes;
|
||||
public readonly HashSet<string> AcceptsSmudgeType = new();
|
||||
public readonly HashSet<string> AcceptsSmudgeType = [];
|
||||
public readonly Color Color;
|
||||
public readonly bool RestrictPlayerColor = false;
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
public MiniYamlNode(string k, string v, string c = null)
|
||||
: this(k, new MiniYaml(v, Enumerable.Empty<MiniYamlNode>()), c) { }
|
||||
: this(k, new MiniYaml(v, []), c) { }
|
||||
|
||||
public MiniYamlNode(string k, string v, IEnumerable<MiniYamlNode> n)
|
||||
: this(k, new MiniYaml(v, n), null) { }
|
||||
@@ -115,7 +115,7 @@ namespace OpenRA
|
||||
const int SpacesPerLevel = 4;
|
||||
static readonly Func<string, string> StringIdentity = s => s;
|
||||
static readonly Func<MiniYaml, MiniYaml> MiniYamlIdentity = my => my;
|
||||
static readonly Dictionary<string, MiniYamlNode> ConflictScratch = new();
|
||||
static readonly Dictionary<string, MiniYamlNode> ConflictScratch = [];
|
||||
|
||||
public readonly string Value;
|
||||
public readonly ImmutableArray<MiniYamlNode> Nodes;
|
||||
@@ -196,12 +196,12 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
public MiniYaml(string value)
|
||||
: this(value, Enumerable.Empty<MiniYamlNode>()) { }
|
||||
: this(value, []) { }
|
||||
|
||||
public MiniYaml(string value, IEnumerable<MiniYamlNode> nodes)
|
||||
{
|
||||
Value = value;
|
||||
Nodes = ImmutableArray.CreateRange(nodes);
|
||||
Nodes = nodes.ToImmutableArray();
|
||||
}
|
||||
|
||||
static List<MiniYamlNode> FromLines(IEnumerable<ReadOnlyMemory<char>> lines, string name, bool discardCommentsAndWhitespace, HashSet<string> stringPool)
|
||||
@@ -210,7 +210,7 @@ namespace OpenRA
|
||||
// Pool these strings so we only need one copy of each unique string.
|
||||
// This saves on long-term memory usage as parsed values can often live a long time.
|
||||
// A caller can also provide a pool as input, allowing de-duplication across multiple parses.
|
||||
stringPool ??= new HashSet<string>();
|
||||
stringPool ??= [];
|
||||
|
||||
var result = new List<List<MiniYamlNode>>
|
||||
{
|
||||
@@ -352,7 +352,7 @@ namespace OpenRA
|
||||
{
|
||||
var lastLevel = parsedLines[^1].Level;
|
||||
while (lastLevel >= result.Count)
|
||||
result.Add(new List<MiniYamlNode>());
|
||||
result.Add([]);
|
||||
|
||||
while (parsedLines.Count > 0 && parsedLines[^1].Level >= level)
|
||||
{
|
||||
@@ -393,14 +393,14 @@ namespace OpenRA
|
||||
|
||||
public static List<MiniYamlNode> FromString(string text, string name, bool discardCommentsAndWhitespace = true, HashSet<string> stringPool = null)
|
||||
{
|
||||
return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None).Select(s => s.AsMemory()), name, discardCommentsAndWhitespace, stringPool);
|
||||
return FromLines(text.Split(["\r\n", "\n"], StringSplitOptions.None).Select(s => s.AsMemory()), name, discardCommentsAndWhitespace, stringPool);
|
||||
}
|
||||
|
||||
public static List<MiniYamlNode> Merge(IEnumerable<IReadOnlyCollection<MiniYamlNode>> sources)
|
||||
{
|
||||
var sourcesList = sources.ToList();
|
||||
if (sourcesList.Count == 0)
|
||||
return new List<MiniYamlNode>();
|
||||
return [];
|
||||
|
||||
var tree = sourcesList
|
||||
.Where(s => s != null)
|
||||
@@ -696,7 +696,7 @@ namespace OpenRA
|
||||
public MiniYamlBuilder(string value, List<MiniYamlNode> nodes)
|
||||
{
|
||||
Value = value;
|
||||
Nodes = nodes == null ? new List<MiniYamlNodeBuilder>() : nodes.ConvertAll(x => new MiniYamlNodeBuilder(x));
|
||||
Nodes = nodes == null ? [] : nodes.ConvertAll(x => new MiniYamlNodeBuilder(x));
|
||||
}
|
||||
|
||||
public MiniYaml Build()
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA
|
||||
|
||||
public ModData(Manifest mod, InstalledMods mods, bool useLoadScreen = false)
|
||||
{
|
||||
Languages = Array.Empty<string>();
|
||||
Languages = [];
|
||||
|
||||
// Take a local copy of the manifest
|
||||
Manifest = new Manifest(mod.Id, mod.Package);
|
||||
@@ -82,19 +82,19 @@ namespace OpenRA
|
||||
|
||||
var terrainFormat = Manifest.Get<TerrainFormat>();
|
||||
var terrainLoader = ObjectCreator.FindType(terrainFormat.Type + "Loader");
|
||||
var terrainCtor = terrainLoader?.GetConstructor(new[] { typeof(ModData) });
|
||||
var terrainCtor = terrainLoader?.GetConstructor([typeof(ModData)]);
|
||||
if (terrainLoader == null || !terrainLoader.GetInterfaces().Contains(typeof(ITerrainLoader)) || terrainCtor == null)
|
||||
throw new InvalidOperationException($"Unable to find a terrain loader for type '{terrainFormat.Type}'.");
|
||||
|
||||
TerrainLoader = (ITerrainLoader)terrainCtor.Invoke(new[] { this });
|
||||
TerrainLoader = (ITerrainLoader)terrainCtor.Invoke([this]);
|
||||
|
||||
var sequenceFormat = Manifest.Get<SpriteSequenceFormat>();
|
||||
var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader");
|
||||
var sequenceCtor = sequenceLoader?.GetConstructor(new[] { typeof(ModData) });
|
||||
var sequenceCtor = sequenceLoader?.GetConstructor([typeof(ModData)]);
|
||||
if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || sequenceCtor == null)
|
||||
throw new InvalidOperationException($"Unable to find a sequence loader for type '{sequenceFormat.Type}'.");
|
||||
|
||||
SpriteSequenceLoader = (ISpriteSequenceLoader)sequenceCtor.Invoke(new[] { this });
|
||||
SpriteSequenceLoader = (ISpriteSequenceLoader)sequenceCtor.Invoke([this]);
|
||||
|
||||
Hotkeys = new HotkeyManager(ModFiles, Game.Settings.Keys, Manifest);
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace OpenRA.Network
|
||||
public sealed class EchoConnection : IConnection
|
||||
{
|
||||
const int LocalClientId = 1;
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new();
|
||||
readonly Queue<(int Frame, OrderPacket Orders)> orders = new();
|
||||
readonly Queue<OrderPacket> immediateOrders = new();
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = [];
|
||||
readonly Queue<(int Frame, OrderPacket Orders)> orders = [];
|
||||
readonly Queue<OrderPacket> immediateOrders = [];
|
||||
bool disposed;
|
||||
|
||||
int IConnection.LocalClientId => LocalClientId;
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Network
|
||||
void IConnection.StartGame()
|
||||
{
|
||||
// Inject an empty frame to fill the gap we are making by projecting forward orders
|
||||
orders.Enqueue((0, new OrderPacket(Array.Empty<Order>())));
|
||||
orders.Enqueue((0, new OrderPacket([])));
|
||||
}
|
||||
|
||||
void IConnection.Send(int frame, IEnumerable<Order> o)
|
||||
@@ -100,12 +100,12 @@ namespace OpenRA.Network
|
||||
{
|
||||
public readonly ConnectionTarget Target;
|
||||
internal ReplayRecorder Recorder { get; private set; }
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sentSync = new();
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> queuedSyncPackets = new();
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sentSync = [];
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> queuedSyncPackets = [];
|
||||
|
||||
readonly Queue<(int Frame, OrderPacket Orders)> sentOrders = new();
|
||||
readonly Queue<OrderPacket> sentImmediateOrders = new();
|
||||
readonly ConcurrentQueue<(int FromClient, byte[] Data)> receivedPackets = new();
|
||||
readonly Queue<(int Frame, OrderPacket Orders)> sentOrders = [];
|
||||
readonly Queue<OrderPacket> sentImmediateOrders = [];
|
||||
readonly ConcurrentQueue<(int FromClient, byte[] Data)> receivedPackets = [];
|
||||
TcpClient tcp;
|
||||
volatile ConnectionState connectionState = ConnectionState.Connecting;
|
||||
volatile int clientId;
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace OpenRA.Network
|
||||
|
||||
public ConnectionTarget()
|
||||
{
|
||||
endpoints = new[] { new DnsEndPoint("invalid", 0) };
|
||||
endpoints = [new DnsEndPoint("invalid", 0)];
|
||||
}
|
||||
|
||||
public ConnectionTarget(string host, int port)
|
||||
{
|
||||
endpoints = new[] { new DnsEndPoint(host, port) };
|
||||
endpoints = [new DnsEndPoint(host, port)];
|
||||
}
|
||||
|
||||
public ConnectionTarget(IEnumerable<DnsEndPoint> endpoints)
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Network
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return Enumerable.Empty<IPEndPoint>();
|
||||
return [];
|
||||
}
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
@@ -86,22 +86,22 @@ namespace OpenRA.Network
|
||||
// Loaded from file and updated during gameplay
|
||||
public int LastOrdersFrame { get; private set; }
|
||||
public int LastSyncFrame { get; private set; }
|
||||
byte[] lastSyncPacket = Array.Empty<byte>();
|
||||
byte[] lastSyncPacket = [];
|
||||
|
||||
// Loaded from file or set on game start
|
||||
public Session.Global GlobalSettings { get; private set; }
|
||||
public Dictionary<string, Session.Slot> Slots { get; private set; }
|
||||
public Dictionary<string, SlotClient> SlotClients { get; private set; }
|
||||
public Dictionary<int, MiniYaml> TraitData = new();
|
||||
public Dictionary<int, MiniYaml> TraitData = [];
|
||||
|
||||
// Set on game start
|
||||
int[] clientsBySlotIndex = Array.Empty<int>();
|
||||
int[] clientsBySlotIndex = [];
|
||||
int firstBotSlotIndex = -1;
|
||||
|
||||
public GameSave()
|
||||
{
|
||||
LastOrdersFrame = -1;
|
||||
Slots = new Dictionary<string, Session.Slot>();
|
||||
Slots = [];
|
||||
}
|
||||
|
||||
public GameSave(string filepath)
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Network
|
||||
GlobalSettings = Session.Global.Deserialize(globalSettings[0].Value);
|
||||
|
||||
var slots = MiniYaml.FromString(rs.ReadLengthPrefixedString(Encoding.UTF8, Connection.MaxOrderLength), $"{filepath}:slots");
|
||||
Slots = new Dictionary<string, Session.Slot>();
|
||||
Slots = [];
|
||||
foreach (var s in slots)
|
||||
{
|
||||
var slot = Session.Slot.Deserialize(s.Value);
|
||||
@@ -134,7 +134,7 @@ namespace OpenRA.Network
|
||||
}
|
||||
|
||||
var slotClients = MiniYaml.FromString(rs.ReadLengthPrefixedString(Encoding.UTF8, Connection.MaxOrderLength), $"{filepath}:slotClients");
|
||||
SlotClients = new Dictionary<string, SlotClient>();
|
||||
SlotClients = [];
|
||||
foreach (var s in slotClients)
|
||||
{
|
||||
var slotClient = SlotClient.Deserialize(s.Value);
|
||||
@@ -166,8 +166,8 @@ namespace OpenRA.Network
|
||||
|
||||
// Perform a deep clone by round-tripping the data
|
||||
GlobalSettings = Session.Global.Deserialize(lobbyInfo.GlobalSettings.Serialize().Value);
|
||||
Slots = new Dictionary<string, Session.Slot>();
|
||||
SlotClients = new Dictionary<string, SlotClient>();
|
||||
Slots = [];
|
||||
SlotClients = [];
|
||||
foreach (var s in lobbyInfo.Slots)
|
||||
{
|
||||
Slots[s.Key] = Session.Slot.Deserialize(s.Value.Serialize().Value);
|
||||
|
||||
@@ -48,7 +48,8 @@ namespace OpenRA.Network
|
||||
public class GameServer
|
||||
{
|
||||
static readonly string[] SerializeFields =
|
||||
{
|
||||
[
|
||||
|
||||
// Server information
|
||||
"Name", "Address",
|
||||
|
||||
@@ -57,7 +58,7 @@ namespace OpenRA.Network
|
||||
|
||||
// Current server state
|
||||
"Map", "State", "MaxPlayers", "Protected", "Authentication", "DisabledSpawnPoints"
|
||||
};
|
||||
];
|
||||
|
||||
public const int ProtocolVersion = 2;
|
||||
|
||||
@@ -133,7 +134,7 @@ namespace OpenRA.Network
|
||||
public readonly GameClient[] Clients;
|
||||
|
||||
/// <summary>The list of spawnpoints that are disabled for this game.</summary>
|
||||
public readonly int[] DisabledSpawnPoints = Array.Empty<int>();
|
||||
public readonly int[] DisabledSpawnPoints = [];
|
||||
|
||||
public string ModLabel => $"{ModTitle} ({Version})";
|
||||
|
||||
@@ -228,7 +229,7 @@ namespace OpenRA.Network
|
||||
Protected = !string.IsNullOrEmpty(server.Settings.Password);
|
||||
Authentication = server.Settings.RequireAuthentication || server.Settings.ProfileIDWhitelist.Length > 0;
|
||||
Clients = server.LobbyInfo.Clients.Select(c => new GameClient(c)).ToArray();
|
||||
DisabledSpawnPoints = server.LobbyInfo.DisabledSpawnPoints?.ToArray() ?? Array.Empty<int>();
|
||||
DisabledSpawnPoints = server.LobbyInfo.DisabledSpawnPoints?.ToArray() ?? [];
|
||||
}
|
||||
|
||||
public string ToPOSTData(bool lanGame)
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Network
|
||||
|
||||
public static class OrderIO
|
||||
{
|
||||
static readonly OrderPacket NoOrders = new(Array.Empty<Order>());
|
||||
static readonly OrderPacket NoOrders = new([]);
|
||||
|
||||
public static byte[] SerializeSync((int Frame, int SyncHash, ulong DefeatState) data)
|
||||
{
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace OpenRA.Network
|
||||
const string DesyncCompareLogs = "notification-desync-compare-logs";
|
||||
|
||||
readonly SyncReport syncReport;
|
||||
readonly Dictionary<int, Queue<(int Frame, OrderPacket Orders)>> pendingOrders = new();
|
||||
readonly Dictionary<int, (int SyncHash, ulong DefeatState)> syncForFrame = new();
|
||||
readonly Dictionary<int, Queue<(int Frame, OrderPacket Orders)>> pendingOrders = [];
|
||||
readonly Dictionary<int, (int SyncHash, ulong DefeatState)> syncForFrame = [];
|
||||
|
||||
public Session LobbyInfo = new();
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace OpenRA.Network
|
||||
internal int GameSaveLastFrame = -1;
|
||||
internal int GameSaveLastSyncFrame = -1;
|
||||
|
||||
readonly List<Order> localOrders = new();
|
||||
readonly List<Order> localImmediateOrders = new();
|
||||
readonly List<Order> localOrders = [];
|
||||
readonly List<Order> localImmediateOrders = [];
|
||||
|
||||
readonly List<ClientOrder> processClientOrders = new();
|
||||
readonly List<int> processClientsToRemove = new();
|
||||
readonly List<ClientOrder> processClientOrders = [];
|
||||
readonly List<int> processClientsToRemove = [];
|
||||
|
||||
bool disposed;
|
||||
bool generateSyncReport = false;
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace OpenRA.Network
|
||||
public (int ClientId, byte[] Packet)[] Packets;
|
||||
}
|
||||
|
||||
readonly Queue<Chunk> chunks = new();
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new();
|
||||
readonly Queue<Chunk> chunks = [];
|
||||
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = [];
|
||||
readonly int orderLatency;
|
||||
|
||||
public readonly int TickCount;
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace OpenRA.Network
|
||||
{
|
||||
public class Session
|
||||
{
|
||||
public List<Client> Clients = new();
|
||||
public List<Client> Clients = [];
|
||||
|
||||
// Keyed by the PlayerReference id that the slot corresponds to
|
||||
public Dictionary<string, Slot> Slots = new();
|
||||
public Dictionary<string, Slot> Slots = [];
|
||||
|
||||
public HashSet<int> DisabledSpawnPoints = new();
|
||||
public HashSet<int> DisabledSpawnPoints = [];
|
||||
|
||||
public Global GlobalSettings = new();
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace OpenRA.Network
|
||||
public int NetFrameInterval = 3;
|
||||
|
||||
[FieldLoader.Ignore]
|
||||
public Dictionary<string, LobbyOptionState> LobbyOptions = new();
|
||||
public Dictionary<string, LobbyOptionState> LobbyOptions = [];
|
||||
|
||||
public static Global Deserialize(MiniYaml data)
|
||||
{
|
||||
@@ -240,7 +240,7 @@ namespace OpenRA.Network
|
||||
var data = new MiniYamlNode("GlobalSettings", FieldSaver.Save(this));
|
||||
var options = LobbyOptions.Select(kv => new MiniYamlNode(kv.Key, FieldSaver.Save(kv.Value)));
|
||||
data = data.WithValue(data.Value.WithNodesAppended(
|
||||
new[] { new MiniYamlNode("Options", new MiniYaml(null, options)) }));
|
||||
[new MiniYamlNode("Options", new MiniYaml(null, options))]));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,9 +166,9 @@ namespace OpenRA.Network
|
||||
public int Frame;
|
||||
public int SyncedRandom;
|
||||
public int TotalCount;
|
||||
public readonly List<TraitReport> Traits = new();
|
||||
public readonly List<EffectReport> Effects = new();
|
||||
public readonly List<OrderManager.ClientOrder> Orders = new();
|
||||
public readonly List<TraitReport> Traits = [];
|
||||
public readonly List<EffectReport> Effects = [];
|
||||
public readonly List<OrderManager.ClientOrder> Orders = [];
|
||||
}
|
||||
|
||||
struct TraitReport
|
||||
@@ -238,11 +238,11 @@ namespace OpenRA.Network
|
||||
// PERF: If the member is a Boolean, we can also avoid the allocation caused by boxing it.
|
||||
// Instead, we can just return the resulting strings directly.
|
||||
var getBoolString = Expression.Condition(getMember, TrueString, FalseString);
|
||||
return Expression.Lambda<Func<ISync, string>>(getBoolString, name, new[] { SyncParam }).Compile();
|
||||
return Expression.Lambda<Func<ISync, string>>(getBoolString, name, [SyncParam]).Compile();
|
||||
}
|
||||
|
||||
var boxedCopy = Expression.Convert(getMember, typeof(object));
|
||||
return Expression.Lambda<Func<ISync, object>>(boxedCopy, name, new[] { SyncParam }).Compile();
|
||||
return Expression.Lambda<Func<ISync, object>>(boxedCopy, name, [SyncParam]).Compile();
|
||||
}
|
||||
|
||||
// For reference types, we have to call ToString right away to get a snapshot of the value. We cannot
|
||||
@@ -266,13 +266,13 @@ namespace OpenRA.Network
|
||||
// (ISync sync) => { var foo = ((TSync)sync).Foo; return foo == null ? null : foo.ToString(); }
|
||||
var memberVariable = Expression.Variable(memberType, getMember.Member.Name);
|
||||
var assignMemberVariable = Expression.Assign(memberVariable, getMember);
|
||||
var member = Expression.Block(new[] { memberVariable }, assignMemberVariable);
|
||||
var member = Expression.Block([memberVariable], assignMemberVariable);
|
||||
getString = Expression.Call(member, toString);
|
||||
var nullMember = Expression.Constant(null, memberType);
|
||||
getString = Expression.Condition(Expression.Equal(member, nullMember), NullString, getString);
|
||||
}
|
||||
|
||||
return Expression.Lambda<Func<ISync, string>>(getString, name, new[] { SyncParam }).Compile();
|
||||
return Expression.Lambda<Func<ISync, string>>(getString, name, [SyncParam]).Compile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA
|
||||
{
|
||||
// .NET does not support unloading assemblies, so mod libraries will leak across mod changes.
|
||||
// This tracks the assemblies that have been loaded since game start so that we don't load multiple copies
|
||||
static readonly Dictionary<string, Assembly> ResolvedAssemblies = new();
|
||||
static readonly Dictionary<string, Assembly> ResolvedAssemblies = [];
|
||||
|
||||
readonly Cache<string, Type> typeCache;
|
||||
readonly Cache<Type, ConstructorInfo> ctorCache;
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA
|
||||
|
||||
public T CreateObject<T>(string className)
|
||||
{
|
||||
return CreateObject<T>(className, new Dictionary<string, object>());
|
||||
return CreateObject<T>(className, []);
|
||||
}
|
||||
|
||||
public T CreateObject<T>(string className, Dictionary<string, object> args)
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA
|
||||
|
||||
public object CreateBasic(Type type)
|
||||
{
|
||||
return type.GetConstructor(Array.Empty<Type>()).Invoke(Array.Empty<object>());
|
||||
return type.GetConstructor([]).Invoke([]);
|
||||
}
|
||||
|
||||
public object CreateUsingArgs(ConstructorInfo ctor, Dictionary<string, object> args)
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace OpenRA
|
||||
// Therefore assign the uninitialized actor and run the Created callbacks
|
||||
// by calling Initialize ourselves.
|
||||
var playerActorType = world.Type == WorldType.Editor ? SystemActors.EditorPlayer : SystemActors.Player;
|
||||
PlayerActor = new Actor(world, playerActorType.ToString(), new TypeDictionary { new OwnerInit(this) });
|
||||
PlayerActor = new Actor(world, playerActorType.ToString(), [new OwnerInit(this)]);
|
||||
PlayerActor.Initialize(true);
|
||||
|
||||
Shroud = PlayerActor.Trait<Shroud>();
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Primitives
|
||||
/// </summary>
|
||||
public class ActionQueue
|
||||
{
|
||||
readonly List<DelayedAction> actions = new();
|
||||
readonly List<DelayedAction> actions = [];
|
||||
|
||||
public void Add(Action a, long desiredTime)
|
||||
{
|
||||
|
||||
@@ -219,9 +219,9 @@ namespace OpenRA.Primitives
|
||||
public override string ToString()
|
||||
{
|
||||
if (A == 255)
|
||||
return CryptoUtil.ToHex(stackalloc byte[3] { R, G, B });
|
||||
return CryptoUtil.ToHex([R, G, B]);
|
||||
|
||||
return CryptoUtil.ToHex(stackalloc byte[4] { R, G, B, A });
|
||||
return CryptoUtil.ToHex([R, G, B, A]);
|
||||
}
|
||||
|
||||
public static Color Transparent => FromArgb(0x00FFFFFF);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Primitives
|
||||
|
||||
public ObservableList()
|
||||
{
|
||||
innerList = new List<T>();
|
||||
innerList = [];
|
||||
}
|
||||
|
||||
public virtual void Add(T item)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Primitives
|
||||
public Polygon(Rectangle bounds)
|
||||
{
|
||||
BoundingRect = bounds;
|
||||
Vertices = new[] { bounds.TopLeft, bounds.BottomLeft, bounds.BottomRight, bounds.TopRight };
|
||||
Vertices = [bounds.TopLeft, bounds.BottomLeft, bounds.BottomRight, bounds.TopRight];
|
||||
isRectangle = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Primitives
|
||||
|
||||
readonly int rows, cols, binSize;
|
||||
readonly Dictionary<T, Rectangle>[] itemBoundsBins;
|
||||
readonly Dictionary<T, Rectangle> itemBounds = new();
|
||||
readonly Dictionary<T, Rectangle> itemBounds = [];
|
||||
|
||||
public SpatiallyPartitioned(int width, int height, int binSize)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Primitives
|
||||
static readonly Func<Type, ITypeContainer> CreateTypeContainer = t =>
|
||||
(ITypeContainer)typeof(TypeContainer<>).MakeGenericType(t).GetConstructor(Type.EmptyTypes).Invoke(null);
|
||||
|
||||
readonly Dictionary<Type, ITypeContainer> data = new();
|
||||
readonly Dictionary<Type, ITypeContainer> data = [];
|
||||
|
||||
ITypeContainer InnerGet(Type t)
|
||||
{
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Primitives
|
||||
{
|
||||
if (data.TryGetValue(typeof(T), out var container))
|
||||
return ((TypeContainer<T>)container).Objects;
|
||||
return Array.Empty<T>();
|
||||
return [];
|
||||
}
|
||||
|
||||
public void Remove<T>(T val)
|
||||
@@ -131,7 +131,7 @@ namespace OpenRA.Primitives
|
||||
|
||||
sealed class TypeContainer<T> : ITypeContainer
|
||||
{
|
||||
public List<T> Objects { get; } = new List<T>();
|
||||
public List<T> Objects { get; } = [];
|
||||
|
||||
public int Count => Objects.Count;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA
|
||||
public SpriteRenderer WorldSpriteRenderer { get; }
|
||||
public RgbaSpriteRenderer WorldRgbaSpriteRenderer { get; }
|
||||
public RgbaColorRenderer WorldRgbaColorRenderer { get; }
|
||||
public IRenderer[] WorldRenderers = Array.Empty<IRenderer>();
|
||||
public IRenderer[] WorldRenderers = [];
|
||||
public RgbaColorRenderer RgbaColorRenderer { get; }
|
||||
public SpriteRenderer SpriteRenderer { get; }
|
||||
public RgbaSpriteRenderer RgbaSpriteRenderer { get; }
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA
|
||||
|
||||
readonly IVertexBuffer<Vertex> tempVertexBuffer;
|
||||
readonly IIndexBuffer quadIndexBuffer;
|
||||
readonly Stack<Rectangle> scissorState = new();
|
||||
readonly Stack<Rectangle> scissorState = [];
|
||||
readonly ITexture worldBufferSnapshot;
|
||||
|
||||
IFrameBuffer screenBuffer;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Scripting
|
||||
if (actor.Disposed)
|
||||
commandClasses = commandClasses.Where(c => c.HasAttribute<ExposedForDestroyedActors>()).ToArray();
|
||||
|
||||
Bind(CreateObjects(commandClasses, new object[] { Context, actor }));
|
||||
Bind(CreateObjects(commandClasses, [Context, actor]));
|
||||
}
|
||||
|
||||
public void OnActorDestroyed()
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace OpenRA.Scripting
|
||||
throw new InvalidOperationException($"[ScriptGlobal] attribute not found for global table '{type}'");
|
||||
|
||||
Name = names[0].Name;
|
||||
Bind(new[] { this });
|
||||
Bind([this]);
|
||||
}
|
||||
|
||||
protected IEnumerable<T> FilteredObjects<T>(IEnumerable<T> objects, LuaFunction filter)
|
||||
@@ -220,7 +220,7 @@ namespace OpenRA.Scripting
|
||||
if (ctor == null)
|
||||
throw new InvalidOperationException($"{b.Name} must define a constructor that takes a {nameof(ScriptContext)} context parameter");
|
||||
|
||||
var binding = (ScriptGlobal)ctor.Invoke(new[] { this });
|
||||
var binding = (ScriptGlobal)ctor.Invoke([this]);
|
||||
using (var obj = binding.ToLuaValue(this))
|
||||
runtime.Globals.Add(binding.Name, obj);
|
||||
}
|
||||
@@ -341,7 +341,7 @@ namespace OpenRA.Scripting
|
||||
return outer.SelectMany(i => i.GetGenericArguments());
|
||||
}
|
||||
|
||||
static readonly object[] NoArguments = Array.Empty<object>();
|
||||
static readonly object[] NoArguments = [];
|
||||
Type[] FilterActorCommands(ActorInfo ai)
|
||||
{
|
||||
return FilterCommands(ai, knownActorCommands);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Scripting
|
||||
protected abstract string MemberNotFoundError(string memberName);
|
||||
|
||||
protected readonly ScriptContext Context;
|
||||
readonly Dictionary<string, ScriptMemberWrapper> members = new();
|
||||
readonly Dictionary<string, ScriptMemberWrapper> members = [];
|
||||
|
||||
protected ScriptObjectWrapper(ScriptContext context)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Scripting
|
||||
: base(context)
|
||||
{
|
||||
this.player = player;
|
||||
Bind(CreateObjects(context.PlayerCommands, new object[] { context, player }));
|
||||
Bind(CreateObjects(context.PlayerCommands, [context, player]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Traits
|
||||
return info.SelectionPriority(modifiers) - (long)pixelDistance << 16;
|
||||
}
|
||||
|
||||
static readonly Actor[] NoActors = Array.Empty<Actor>();
|
||||
static readonly Actor[] NoActors = [];
|
||||
|
||||
public static IEnumerable<Actor> SubsetWithHighestSelectionPriority(this IEnumerable<Actor> actors, Modifiers modifiers)
|
||||
{
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace OpenRA.Server
|
||||
|
||||
long lastReceivedTime = 0;
|
||||
|
||||
readonly BlockingCollection<byte[]> sendQueue = new();
|
||||
readonly Queue<int> pingHistory = new();
|
||||
readonly BlockingCollection<byte[]> sendQueue = [];
|
||||
readonly Queue<int> pingHistory = [];
|
||||
|
||||
public Connection(Server server, Socket socket, string authToken)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Server
|
||||
{
|
||||
public static IEnumerable<T> Except<T>(this IEnumerable<T> ts, T t)
|
||||
{
|
||||
return ts.Except(new[] { t });
|
||||
return ts.Except([t]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Server
|
||||
|
||||
public class MapStatusCache
|
||||
{
|
||||
readonly Dictionary<MapPreview, Session.MapStatus> cache = new();
|
||||
readonly Dictionary<MapPreview, Session.MapStatus> cache = [];
|
||||
readonly Action<string, Session.MapStatus> onStatusChanged;
|
||||
readonly bool enableRemoteLinting;
|
||||
readonly ModData modData;
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace OpenRA.Server
|
||||
Stopwatch gameTimer;
|
||||
long nextUpdate = 0;
|
||||
|
||||
readonly ConcurrentDictionary<int, long> timestamps = new();
|
||||
readonly ConcurrentDictionary<int, Queue<long>> deltas = new();
|
||||
readonly ConcurrentDictionary<int, long> timestamps = [];
|
||||
readonly ConcurrentDictionary<int, Queue<long>> deltas = [];
|
||||
|
||||
int timestep;
|
||||
int ticksPerInterval;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Server
|
||||
[FluentReference("remaining")]
|
||||
const string ChatTemporaryDisabled = "notification-chat-temp-disabled";
|
||||
|
||||
readonly Dictionary<int, List<long>> messageTracker = new();
|
||||
readonly Dictionary<int, List<long>> messageTracker = [];
|
||||
readonly Server server;
|
||||
readonly Action<Connection, int, int, byte[]> dispatchOrdersToClient;
|
||||
readonly Action<Connection, string, object[]> sendFluentMessageTo;
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Server
|
||||
public bool IsPlayerAtFloodLimit(Connection conn)
|
||||
{
|
||||
if (!messageTracker.ContainsKey(conn.PlayerIndex))
|
||||
messageTracker.Add(conn.PlayerIndex, new List<long>());
|
||||
messageTracker.Add(conn.PlayerIndex, []);
|
||||
|
||||
var isAdmin = server.GetClient(conn)?.IsAdmin ?? false;
|
||||
var settings = server.Settings;
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Server
|
||||
if (!isAdmin && time < settings.FloodLimitJoinCooldown)
|
||||
{
|
||||
var remaining = CalculateRemaining(settings.FloodLimitJoinCooldown);
|
||||
sendFluentMessageTo(conn, ChatTemporaryDisabled, new object[] { "remaining", remaining });
|
||||
sendFluentMessageTo(conn, ChatTemporaryDisabled, ["remaining", remaining]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Server
|
||||
if (tracker.Count >= settings.FloodLimitMessageCount)
|
||||
{
|
||||
var remaining = CalculateRemaining(tracker[0] + settings.FloodLimitInterval);
|
||||
sendFluentMessageTo(conn, ChatTemporaryDisabled, new object[] { "remaining", remaining });
|
||||
sendFluentMessageTo(conn, ChatTemporaryDisabled, ["remaining", remaining]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,12 +120,12 @@ namespace OpenRA.Server
|
||||
public readonly ServerType Type;
|
||||
public bool IsMultiplayer => Type == ServerType.Dedicated || Type == ServerType.Multiplayer;
|
||||
|
||||
public readonly List<Connection> Conns = new();
|
||||
public readonly List<Connection> Conns = [];
|
||||
|
||||
public Session LobbyInfo;
|
||||
public ServerSettings Settings;
|
||||
public ModData ModData;
|
||||
public List<string> TempBans = new();
|
||||
public List<string> TempBans = [];
|
||||
|
||||
// Managed by LobbyCommands
|
||||
public MapPreview Map;
|
||||
@@ -137,19 +137,19 @@ namespace OpenRA.Server
|
||||
public int OrderLatency = 1;
|
||||
|
||||
readonly int randomSeed;
|
||||
readonly List<TcpListener> listeners = new();
|
||||
readonly TypeDictionary serverTraits = new();
|
||||
readonly List<TcpListener> listeners = [];
|
||||
readonly TypeDictionary serverTraits = [];
|
||||
readonly PlayerDatabase playerDatabase;
|
||||
|
||||
OrderBuffer orderBuffer;
|
||||
|
||||
volatile ServerState internalState = ServerState.WaitingPlayers;
|
||||
|
||||
readonly BlockingCollection<IServerEvent> events = new();
|
||||
readonly BlockingCollection<IServerEvent> events = [];
|
||||
|
||||
ReplayRecorder recorder;
|
||||
GameInformation gameInfo;
|
||||
readonly List<GameInformation.Player> worldPlayers = new();
|
||||
readonly List<GameInformation.Player> worldPlayers = [];
|
||||
readonly Stopwatch pingUpdated = Stopwatch.StartNew();
|
||||
|
||||
public readonly VoteKickTracker VoteKickTracker;
|
||||
@@ -802,7 +802,7 @@ namespace OpenRA.Server
|
||||
recorder = null;
|
||||
}
|
||||
|
||||
readonly Dictionary<int, byte[]> syncForFrame = new();
|
||||
readonly Dictionary<int, byte[]> syncForFrame = [];
|
||||
int lastDefeatStateFrame;
|
||||
ulong lastDefeatState;
|
||||
|
||||
@@ -998,7 +998,7 @@ namespace OpenRA.Server
|
||||
if (!InterpretCommand(o.TargetString, conn))
|
||||
{
|
||||
Log.Write("server", $"Unknown server command: {o.TargetString}");
|
||||
SendFluentMessageTo(conn, UnknownServerCommand, new object[] { "command", o.TargetString });
|
||||
SendFluentMessageTo(conn, UnknownServerCommand, ["command", o.TargetString]);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1401,12 +1401,12 @@ namespace OpenRA.Server
|
||||
for (var i = 0; i < OrderLatency; i++)
|
||||
{
|
||||
from.LastOrdersFrame = firstFrame + i;
|
||||
var frameData = CreateFrame(from.PlayerIndex, from.LastOrdersFrame, Array.Empty<byte>());
|
||||
var frameData = CreateFrame(from.PlayerIndex, from.LastOrdersFrame, []);
|
||||
foreach (var to in conns)
|
||||
DispatchFrameToClient(to, from.PlayerIndex, frameData);
|
||||
|
||||
RecordOrder(from.LastOrdersFrame, Array.Empty<byte>(), from.PlayerIndex);
|
||||
GameSave?.DispatchOrders(from, from.LastOrdersFrame, Array.Empty<byte>());
|
||||
RecordOrder(from.LastOrdersFrame, [], from.PlayerIndex);
|
||||
GameSave?.DispatchOrders(from, from.LastOrdersFrame, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace OpenRA.Server
|
||||
[FluentReference("kickee")]
|
||||
const string VoteKickEnded = "notification-vote-kick-ended";
|
||||
|
||||
readonly Dictionary<int, bool> voteTracker = new();
|
||||
readonly Dictionary<Session.Client, long> failedVoteKickers = new();
|
||||
readonly Dictionary<int, bool> voteTracker = [];
|
||||
readonly Dictionary<Session.Client, long> failedVoteKickers = [];
|
||||
readonly Server server;
|
||||
|
||||
Stopwatch voteKickTimer;
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA.Server
|
||||
if (!kickee.IsObserver && !server.HasClientWonOrLost(kickee))
|
||||
{
|
||||
// Vote kick cannot be the sole deciding factor for a game.
|
||||
server.SendFluentMessageTo(conn, InsufficientVotes, new object[] { "kickee", kickee.Name });
|
||||
server.SendFluentMessageTo(conn, InsufficientVotes, ["kickee", kickee.Name]);
|
||||
EndKickVote();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -66,16 +66,16 @@ namespace OpenRA
|
||||
public string Map = null;
|
||||
|
||||
[Desc("Takes a comma separated list of IP addresses that are not allowed to join.")]
|
||||
public string[] Ban = Array.Empty<string>();
|
||||
public string[] Ban = [];
|
||||
|
||||
[Desc("For dedicated servers only, allow anonymous clients to join.")]
|
||||
public bool RequireAuthentication = false;
|
||||
|
||||
[Desc("For dedicated servers only, if non-empty, only allow authenticated players with these profile IDs to join.")]
|
||||
public int[] ProfileIDWhitelist = Array.Empty<int>();
|
||||
public int[] ProfileIDWhitelist = [];
|
||||
|
||||
[Desc("For dedicated servers only, if non-empty, always reject players with these user IDs from joining.")]
|
||||
public int[] ProfileIDBlacklist = Array.Empty<int>();
|
||||
public int[] ProfileIDBlacklist = [];
|
||||
|
||||
[Desc("For dedicated servers only, controls whether a game can be started with just one human player in the lobby.")]
|
||||
public bool EnableSingleplayer = false;
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA
|
||||
public bool EnableLintChecks = true;
|
||||
|
||||
[Desc("For dedicated servers only, a comma separated list of map uids that are allowed to be used.")]
|
||||
public string[] MapPool = Array.Empty<string>();
|
||||
public string[] MapPool = [];
|
||||
|
||||
[Desc("Delay in milliseconds before newly joined players can send chat messages.")]
|
||||
public int FloodLimitJoinCooldown = 5000;
|
||||
@@ -248,7 +248,7 @@ namespace OpenRA
|
||||
public string Name = "Commander";
|
||||
public Color Color = Color.FromArgb(200, 32, 32);
|
||||
public string LastServer = "localhost:1234";
|
||||
public Color[] CustomColors = Array.Empty<Color>();
|
||||
public Color[] CustomColors = [];
|
||||
}
|
||||
|
||||
public class SinglePlayerGameSettings
|
||||
@@ -317,13 +317,13 @@ namespace OpenRA
|
||||
public readonly ServerSettings Server = new();
|
||||
public readonly DebugSettings Debug = new();
|
||||
public readonly SinglePlayerGameSettings SinglePlayerSettings = new();
|
||||
internal Dictionary<string, Hotkey> Keys = new();
|
||||
internal Dictionary<string, Hotkey> Keys = [];
|
||||
public readonly Dictionary<string, object> Sections;
|
||||
|
||||
// A direct clone of the file loaded from disk.
|
||||
// Any changed settings will be merged over this on save,
|
||||
// allowing us to persist any unknown configuration keys
|
||||
readonly List<MiniYamlNode> yamlCache = new();
|
||||
readonly List<MiniYamlNode> yamlCache = [];
|
||||
|
||||
public Settings(string file, Arguments args)
|
||||
{
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace OpenRA
|
||||
ISoundSource videoSource;
|
||||
ISound music;
|
||||
ISound video;
|
||||
readonly Dictionary<uint, ISound> currentSounds = new();
|
||||
readonly Dictionary<string, ISound> currentNotifications = new();
|
||||
readonly Dictionary<uint, ISound> currentSounds = [];
|
||||
readonly Dictionary<string, ISound> currentNotifications = [];
|
||||
public bool DummyEngine { get; }
|
||||
|
||||
public Sound(IPlatform platform, SoundSettings soundSettings)
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace OpenRA
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
bytes = encoding.GetBytes(text);
|
||||
else
|
||||
bytes = Array.Empty<byte>();
|
||||
bytes = [];
|
||||
|
||||
s.Write(bytes.Length);
|
||||
s.Write(bytes);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRA
|
||||
{
|
||||
public class Arguments
|
||||
{
|
||||
readonly Dictionary<string, string> args = new();
|
||||
readonly Dictionary<string, string> args = [];
|
||||
|
||||
public static Arguments Empty => new();
|
||||
|
||||
|
||||
@@ -105,34 +105,34 @@ namespace OpenRA.Support
|
||||
static readonly string[] NativeLibraryPrefixes;
|
||||
|
||||
static readonly string[] ManagedAssemblyExtensions =
|
||||
{
|
||||
[
|
||||
".dll",
|
||||
".ni.dll",
|
||||
".exe",
|
||||
".ni.exe"
|
||||
};
|
||||
];
|
||||
|
||||
static ManagedLoadContext()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
NativeLibraryPrefixes = new[] { "" };
|
||||
NativeLibraryExtensions = new[] { ".dll" };
|
||||
NativeLibraryPrefixes = [""];
|
||||
NativeLibraryExtensions = [".dll"];
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
NativeLibraryPrefixes = new[] { "", "lib", };
|
||||
NativeLibraryExtensions = new[] { ".dylib" };
|
||||
NativeLibraryPrefixes = ["", "lib",];
|
||||
NativeLibraryExtensions = [".dylib"];
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
NativeLibraryPrefixes = new[] { "", "lib" };
|
||||
NativeLibraryExtensions = new[] { ".so", ".so.1" };
|
||||
NativeLibraryPrefixes = ["", "lib"];
|
||||
NativeLibraryExtensions = [".so", ".so.1"];
|
||||
}
|
||||
else
|
||||
{
|
||||
NativeLibraryPrefixes = Array.Empty<string>();
|
||||
NativeLibraryExtensions = Array.Empty<string>();
|
||||
NativeLibraryPrefixes = [];
|
||||
NativeLibraryExtensions = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace OpenRA.Support
|
||||
|
||||
static IEnumerable<string> GetRids(RuntimeFallbacks runtimeGraph)
|
||||
{
|
||||
return Enumerable.Concat(new[] { runtimeGraph.Runtime }, runtimeGraph?.Fallbacks ?? Enumerable.Empty<string>());
|
||||
return Enumerable.Concat([runtimeGraph.Runtime], runtimeGraph?.Fallbacks ?? Enumerable.Empty<string>());
|
||||
}
|
||||
|
||||
static IEnumerable<string> SelectAssets(IEnumerable<string> rids, IReadOnlyCollection<RuntimeAssetGroup> groups)
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Support
|
||||
sealed class Benchmark
|
||||
{
|
||||
readonly string prefix;
|
||||
readonly Dictionary<string, List<BenchmarkPoint>> samples = new();
|
||||
readonly Dictionary<string, List<BenchmarkPoint>> samples = [];
|
||||
|
||||
public Benchmark(string prefix)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Support
|
||||
public class HttpQueryBuilder : IEnumerable<KeyValuePair<string, string>>
|
||||
{
|
||||
readonly string url;
|
||||
readonly List<KeyValuePair<string, string>> parameters = new();
|
||||
readonly List<KeyValuePair<string, string>> parameters = [];
|
||||
|
||||
public HttpQueryBuilder(string url)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA
|
||||
{
|
||||
const int CreateLogFileMaxRetryCount = 128;
|
||||
|
||||
static readonly ConcurrentDictionary<string, ChannelInfo> Channels = new();
|
||||
static readonly ConcurrentDictionary<string, ChannelInfo> Channels = [];
|
||||
static readonly Channel<ChannelData> Channel;
|
||||
static readonly ChannelWriter<ChannelData> ChannelWriter;
|
||||
static readonly CancellationTokenSource CancellationToken = new();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRA.Support
|
||||
public static class PerfHistory
|
||||
{
|
||||
static readonly Color[] Colors =
|
||||
{
|
||||
[
|
||||
Color.Red, Color.Green,
|
||||
Color.Orange, Color.Yellow,
|
||||
Color.Fuchsia, Color.Lime,
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Support
|
||||
Color.White, Color.Teal,
|
||||
Color.Pink, Color.MediumPurple,
|
||||
Color.Olive, Color.CornflowerBlue
|
||||
};
|
||||
];
|
||||
|
||||
static int nextColor;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Support
|
||||
Write();
|
||||
else if (ticks > thresholdTicks)
|
||||
{
|
||||
parent.children ??= new List<PerfTimer>();
|
||||
parent.children ??= [];
|
||||
parent.children.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Support
|
||||
public static readonly IReadOnlyDictionary<string, int> NoVariables = new ReadOnlyDictionary<string, int>(new Dictionary<string, int>());
|
||||
|
||||
public readonly string Expression;
|
||||
readonly HashSet<string> variables = new();
|
||||
readonly HashSet<string> variables = [];
|
||||
public IEnumerable<string> Variables => variables;
|
||||
|
||||
enum CharClass { Whitespace, Operator, Mixed, Id, Digit }
|
||||
@@ -717,8 +717,8 @@ namespace OpenRA.Support
|
||||
|
||||
sealed class AstStack
|
||||
{
|
||||
readonly List<Expression> expressions = new();
|
||||
readonly List<ExpressionType> types = new();
|
||||
readonly List<Expression> expressions = [];
|
||||
readonly List<ExpressionType> types = [];
|
||||
|
||||
public ExpressionType PeekType() { return types[^1]; }
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA
|
||||
|
||||
static Func<object, int> GenerateHashFunc(Type t)
|
||||
{
|
||||
var d = new DynamicMethod($"hash_{t.Name}", typeof(int), new Type[] { typeof(object) }, t);
|
||||
var d = new DynamicMethod($"hash_{t.Name}", typeof(int), [typeof(object)], t);
|
||||
var il = d.GetILGenerator();
|
||||
var this_ = il.DeclareLocal(t).LocalIndex;
|
||||
il.Emit(OpCodes.Ldarg_0);
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace OpenRA
|
||||
static readonly string SystemMessageLabel;
|
||||
|
||||
public static long ChatDisabledUntil { get; internal set; }
|
||||
public static readonly Dictionary<int, bool> MutedPlayers = new();
|
||||
public static readonly Dictionary<int, bool> MutedPlayers = [];
|
||||
|
||||
static readonly List<TextNotification> NotificationsCache = new();
|
||||
static readonly List<TextNotification> NotificationsCache = [];
|
||||
public static IReadOnlyList<TextNotification> Notifications => NotificationsCache;
|
||||
|
||||
static TextNotificationsManager()
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA
|
||||
static readonly Func<Type, ITraitContainer> CreateTraitContainer = t =>
|
||||
(ITraitContainer)typeof(TraitContainer<>).MakeGenericType(t).GetConstructor(Type.EmptyTypes).Invoke(null);
|
||||
|
||||
readonly Dictionary<Type, ITraitContainer> traits = new();
|
||||
readonly Dictionary<Type, ITraitContainer> traits = [];
|
||||
|
||||
ITraitContainer InnerGet(Type t)
|
||||
{
|
||||
@@ -143,8 +143,8 @@ namespace OpenRA
|
||||
|
||||
sealed class TraitContainer<T> : ITraitContainer
|
||||
{
|
||||
readonly List<Actor> actors = new();
|
||||
readonly List<T> traits = new();
|
||||
readonly List<Actor> actors = [];
|
||||
readonly List<T> traits = [];
|
||||
|
||||
public int Queries { get; private set; }
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Traits
|
||||
public ActorReferenceAttribute(Type requiredTrait = null,
|
||||
LintDictionaryReference dictionaryReference = LintDictionaryReference.None)
|
||||
{
|
||||
RequiredTraits = requiredTrait != null ? new[] { requiredTrait } : Array.Empty<Type>();
|
||||
RequiredTraits = requiredTrait != null ? [requiredTrait] : [];
|
||||
DictionaryReference = dictionaryReference;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Traits
|
||||
readonly Actor actor;
|
||||
readonly ICreatesFrozenActors frozenTrait;
|
||||
readonly Shroud shroud;
|
||||
readonly List<WPos> targetablePositions = new();
|
||||
readonly List<WPos> targetablePositions = [];
|
||||
|
||||
public Player Viewer { get; }
|
||||
public Player Owner { get; private set; }
|
||||
@@ -75,8 +75,8 @@ namespace OpenRA.Traits
|
||||
|
||||
public Polygon MouseBounds = Polygon.Empty;
|
||||
|
||||
static readonly IRenderable[] NoRenderables = Array.Empty<IRenderable>();
|
||||
static readonly Rectangle[] NoBounds = Array.Empty<Rectangle>();
|
||||
static readonly IRenderable[] NoRenderables = [];
|
||||
static readonly Rectangle[] NoBounds = [];
|
||||
|
||||
int flashTicks;
|
||||
TintModifiers flashModifiers;
|
||||
@@ -261,7 +261,7 @@ namespace OpenRA.Traits
|
||||
binSize = info.BinSize;
|
||||
world = self.World;
|
||||
owner = self.Owner;
|
||||
frozenActorsById = new Dictionary<uint, FrozenActor>();
|
||||
frozenActorsById = [];
|
||||
|
||||
partitionedFrozenActors = new SpatiallyPartitioned<FrozenActor>(
|
||||
world.Map.MapSize.X, world.Map.MapSize.Y, binSize);
|
||||
@@ -329,7 +329,7 @@ namespace OpenRA.Traits
|
||||
VisibilityHash += hash;
|
||||
else if (frozenActor.Actor == null)
|
||||
{
|
||||
frozenActorsToRemove ??= new List<FrozenActor>();
|
||||
frozenActorsToRemove ??= [];
|
||||
frozenActorsToRemove.Add(frozenActor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace OpenRA.Traits
|
||||
readonly Map map;
|
||||
|
||||
// Individual shroud modifier sources (type and area)
|
||||
readonly Dictionary<object, ShroudSource> sources = new();
|
||||
readonly Dictionary<object, ShroudSource> sources = [];
|
||||
|
||||
// Per-cell count of each source type, used to resolve the final cell type
|
||||
readonly ProjectedCellLayer<short> passiveVisibleCount;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Traits
|
||||
public enum TargetType : byte { Invalid, Actor, Terrain, FrozenActor }
|
||||
public readonly struct Target : IEquatable<Target>
|
||||
{
|
||||
public static readonly Target[] None = Array.Empty<Target>();
|
||||
public static readonly Target[] None = [];
|
||||
public static readonly Target Invalid = default;
|
||||
public Actor Actor { get; }
|
||||
public FrozenActor FrozenActor { get; }
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
type = TargetType.Terrain;
|
||||
this.terrainCenterPosition = terrainCenterPosition;
|
||||
this.terrainPositions = terrainPositions ?? new[] { terrainCenterPosition };
|
||||
this.terrainPositions = terrainPositions ?? [terrainCenterPosition];
|
||||
|
||||
Actor = null;
|
||||
FrozenActor = null;
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
type = TargetType.Terrain;
|
||||
terrainCenterPosition = w.Map.CenterOfSubCell(c, subCell);
|
||||
terrainPositions = new[] { terrainCenterPosition };
|
||||
terrainPositions = [terrainCenterPosition];
|
||||
cell = c;
|
||||
this.subCell = subCell;
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
// Positions available to target for range checks
|
||||
static readonly WPos[] NoPositions = Array.Empty<WPos>();
|
||||
static readonly WPos[] NoPositions = [];
|
||||
public IEnumerable<WPos> Positions
|
||||
{
|
||||
get
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Traits
|
||||
public readonly string InternalName = null;
|
||||
|
||||
[Desc("Pick a random faction as the player's faction out of this list.")]
|
||||
public readonly HashSet<string> RandomFactionMembers = new();
|
||||
public readonly HashSet<string> RandomFactionMembers = [];
|
||||
|
||||
[Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")]
|
||||
public readonly string Side = null;
|
||||
|
||||
@@ -41,21 +41,21 @@ namespace OpenRA.Traits
|
||||
|
||||
public class ScreenMap : IWorldLoaded
|
||||
{
|
||||
static readonly IEnumerable<FrozenActor> NoFrozenActors = Array.Empty<FrozenActor>();
|
||||
static readonly IEnumerable<FrozenActor> NoFrozenActors = [];
|
||||
readonly Func<FrozenActor, bool> frozenActorIsValid = fa => fa.IsValid;
|
||||
readonly Func<Actor, bool> actorIsInWorld = a => a.IsInWorld;
|
||||
readonly Func<Actor, ActorBoundsPair> selectActorAndBounds;
|
||||
readonly Cache<Player, SpatiallyPartitioned<FrozenActor>> partitionedMouseFrozenActors;
|
||||
readonly SpatiallyPartitioned<Actor> partitionedMouseActors;
|
||||
readonly Dictionary<Actor, ActorBoundsPair> partitionedMouseActorBounds = new();
|
||||
readonly Dictionary<Actor, ActorBoundsPair> partitionedMouseActorBounds = [];
|
||||
|
||||
readonly Cache<Player, SpatiallyPartitioned<FrozenActor>> partitionedRenderableFrozenActors;
|
||||
readonly SpatiallyPartitioned<Actor> partitionedRenderableActors;
|
||||
readonly SpatiallyPartitioned<IEffect> partitionedRenderableEffects;
|
||||
|
||||
// Updates are done in one pass to ensure all bound changes have been applied
|
||||
readonly HashSet<Actor> addOrUpdateActors = new();
|
||||
readonly HashSet<Actor> removeActors = new();
|
||||
readonly HashSet<Actor> addOrUpdateActors = [];
|
||||
readonly HashSet<Actor> removeActors = [];
|
||||
readonly Cache<Player, HashSet<FrozenActor>> addOrUpdateFrozenActors;
|
||||
readonly Cache<Player, HashSet<FrozenActor>> removeFrozenActors;
|
||||
|
||||
@@ -77,8 +77,8 @@ namespace OpenRA.Traits
|
||||
partitionedRenderableActors = new SpatiallyPartitioned<Actor>(width, height, info.BinSize);
|
||||
partitionedRenderableEffects = new SpatiallyPartitioned<IEffect>(width, height, info.BinSize);
|
||||
|
||||
addOrUpdateFrozenActors = new Cache<Player, HashSet<FrozenActor>>(_ => new HashSet<FrozenActor>());
|
||||
removeFrozenActors = new Cache<Player, HashSet<FrozenActor>>(_ => new HashSet<FrozenActor>());
|
||||
addOrUpdateFrozenActors = new Cache<Player, HashSet<FrozenActor>>(_ => []);
|
||||
removeFrozenActors = new Cache<Player, HashSet<FrozenActor>>(_ => []);
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w, WorldRenderer wr) { worldRenderer = wr; }
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
readonly ScreenShakerInfo info;
|
||||
WorldRenderer worldRenderer;
|
||||
readonly List<ShakeEffect> shakeEffects = new();
|
||||
readonly List<ShakeEffect> shakeEffects = [];
|
||||
int ticks = 0;
|
||||
|
||||
public ScreenShaker(ScreenShakerInfo info)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.UtilityCommands
|
||||
if (args[2] == "user" || args[2] == "both")
|
||||
type |= ModRegistration.User;
|
||||
|
||||
new ExternalMods().Register(utility.ModData.Manifest, args[1], Enumerable.Empty<string>(), type);
|
||||
new ExternalMods().Register(utility.ModData.Manifest, args[1], [], type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace OpenRA
|
||||
public override string ToString() { return Angle.ToStringInvariant(); }
|
||||
|
||||
static readonly int[] CosineTable =
|
||||
{
|
||||
[
|
||||
1024, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1022, 1022, 1022, 1021,
|
||||
1021, 1020, 1020, 1019, 1019, 1018, 1017, 1017, 1016, 1015, 1014, 1013,
|
||||
1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004, 1003, 1001, 1000,
|
||||
@@ -192,10 +192,10 @@ namespace OpenRA
|
||||
236, 230, 224, 218, 212, 205, 199, 193, 187, 181, 175, 168, 162, 156,
|
||||
150, 144, 137, 131, 125, 119, 112, 106, 100, 94, 87, 81, 75, 69, 62,
|
||||
56, 50, 43, 37, 31, 25, 18, 12, 6, 0
|
||||
};
|
||||
];
|
||||
|
||||
static readonly int[] TanTable =
|
||||
{
|
||||
[
|
||||
0, 6, 12, 18, 25, 31, 37, 44, 50, 56, 62, 69, 75, 81, 88, 94, 100, 107,
|
||||
113, 119, 126, 132, 139, 145, 151, 158, 164, 171, 177, 184, 190, 197,
|
||||
203, 210, 216, 223, 229, 236, 243, 249, 256, 263, 269, 276, 283, 290,
|
||||
@@ -216,7 +216,7 @@ namespace OpenRA
|
||||
5499, 5693, 5901, 6124, 6364, 6622, 6903, 7207, 7539, 7902, 8302, 8743,
|
||||
9233, 9781, 10396, 11094, 11891, 12810, 13882, 15148, 16667, 18524, 20843,
|
||||
23826, 27801, 33366, 41713, 55622, 83438, 166883, int.MaxValue
|
||||
};
|
||||
];
|
||||
|
||||
#region Scripting interface
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public static class ChromeMetrics
|
||||
{
|
||||
static Dictionary<string, string> data = new();
|
||||
static Dictionary<string, string> data = [];
|
||||
|
||||
public static void Initialize(ModData modData)
|
||||
{
|
||||
var stringPool = new HashSet<string>(); // Reuse common strings in YAML
|
||||
var metrics = MiniYaml.Merge(modData.Manifest.ChromeMetrics.Select(
|
||||
y => MiniYaml.FromStream(modData.DefaultFileSystem.Open(y), y, stringPool: stringPool)));
|
||||
data = new Dictionary<string, string>();
|
||||
data = [];
|
||||
foreach (var m in metrics)
|
||||
foreach (var n in m.Value.Nodes)
|
||||
data[n.Key] = n.Value.Value;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static TickTime LastTickTime = new(() => Timestep, Game.RunTime);
|
||||
|
||||
static readonly Stack<Widget> WindowList = new();
|
||||
static readonly Stack<Widget> WindowList = [];
|
||||
|
||||
public static Widget MouseFocusWidget;
|
||||
public static Widget KeyboardFocusWidget;
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public static Widget OpenWindow(string id)
|
||||
{
|
||||
return OpenWindow(id, new WidgetArgs());
|
||||
return OpenWindow(id, []);
|
||||
}
|
||||
|
||||
public static Widget OpenWindow(string id, WidgetArgs args)
|
||||
@@ -208,7 +208,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
string defaultCursor = null;
|
||||
|
||||
public readonly List<Widget> Children = new();
|
||||
public readonly List<Widget> Children = [];
|
||||
|
||||
// Info defined in YAML
|
||||
public string Id = null;
|
||||
@@ -216,7 +216,7 @@ namespace OpenRA.Widgets
|
||||
public IntegerExpression Y;
|
||||
public IntegerExpression Width;
|
||||
public IntegerExpression Height;
|
||||
public string[] Logic = Array.Empty<string>();
|
||||
public string[] Logic = [];
|
||||
public ChromeLogic[] LogicObjects { get; private set; }
|
||||
public bool Visible = true;
|
||||
public bool IgnoreMouseOver;
|
||||
@@ -288,7 +288,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
var substitutions = args.TryGetValue("substitutions", out var subs) ?
|
||||
new Dictionary<string, int>((Dictionary<string, int>)subs) :
|
||||
new Dictionary<string, int>();
|
||||
[];
|
||||
|
||||
substitutions.Add("WINDOW_WIDTH", Game.Renderer.Resolution.Width);
|
||||
substitutions.Add("WINDOW_HEIGHT", Game.Renderer.Resolution.Height);
|
||||
@@ -668,7 +668,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public sealed class Mediator
|
||||
{
|
||||
readonly TypeDictionary types = new();
|
||||
readonly TypeDictionary types = [];
|
||||
|
||||
public void Subscribe<T>(T instance)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA
|
||||
{
|
||||
public class WidgetLoader
|
||||
{
|
||||
readonly Dictionary<string, MiniYamlNode> widgets = new();
|
||||
readonly Dictionary<string, MiniYamlNode> widgets = [];
|
||||
readonly ModData modData;
|
||||
|
||||
public WidgetLoader(ModData modData)
|
||||
|
||||
@@ -29,14 +29,14 @@ namespace OpenRA
|
||||
public sealed class World : IDisposable
|
||||
{
|
||||
internal readonly TraitDictionary TraitDict = new();
|
||||
readonly SortedDictionary<uint, Actor> actors = new();
|
||||
readonly List<IEffect> effects = new();
|
||||
readonly List<IEffect> unpartitionedEffects = new();
|
||||
readonly List<ISync> syncedEffects = new();
|
||||
readonly SortedDictionary<uint, Actor> actors = [];
|
||||
readonly List<IEffect> effects = [];
|
||||
readonly List<IEffect> unpartitionedEffects = [];
|
||||
readonly List<ISync> syncedEffects = [];
|
||||
readonly GameSettings gameSettings;
|
||||
readonly ModData modData;
|
||||
|
||||
readonly Queue<Action<World>> frameEndActions = new();
|
||||
readonly Queue<Action<World>> frameEndActions = [];
|
||||
|
||||
public readonly GameSpeed GameSpeed;
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA
|
||||
public LongBitSet<PlayerBitMask> AllPlayersMask = default;
|
||||
public readonly LongBitSet<PlayerBitMask> NoPlayersMask = default;
|
||||
|
||||
public Player[] Players = Array.Empty<Player>();
|
||||
public Player[] Players = [];
|
||||
|
||||
public event Action<Player> RenderPlayerChanged;
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace OpenRA
|
||||
LocalRandom = new MersenneTwister();
|
||||
|
||||
var worldActorType = type == WorldType.Editor ? SystemActors.EditorWorld : SystemActors.World;
|
||||
WorldActor = CreateActor(worldActorType.ToString(), new TypeDictionary());
|
||||
WorldActor = CreateActor(worldActorType.ToString(), []);
|
||||
ActorMap = WorldActor.Trait<IActorMap>();
|
||||
ScreenMap = WorldActor.Trait<ScreenMap>();
|
||||
Selection = WorldActor.Trait<ISelection>();
|
||||
@@ -399,7 +399,7 @@ namespace OpenRA
|
||||
|
||||
public int WorldTick { get; private set; }
|
||||
|
||||
readonly Dictionary<int, MiniYaml> gameSaveTraitData = new();
|
||||
readonly Dictionary<int, MiniYaml> gameSaveTraitData = [];
|
||||
internal void AddGameSaveTraitData(int traitIndex, MiniYaml yaml)
|
||||
{
|
||||
gameSaveTraitData[traitIndex] = yaml;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user