Ensure editorconfig naming styles align with StyleCop SA13XX style rules.
Aligns the naming conventions defined in editorconfig (dotnet_naming_style, dotnet_naming_symbols, dotnet_naming_rule) which are reported under the IDE1006 rule with the existing StyleCop rules from the SA13XX range. This ensures the two rulesets agree when rejecting and accepting naming conventions within the IDE, with a few edges cases where only one ruleset can enforce the convention. IDE1006 allows use to specify a naming convention for type parameters, const locals and protected readonly fields which SA13XX cannot enforce. Some StyleCop SA13XX rules such as SA1309 'Field names should not begin with underscore' are not possible to enforce with the naming rules of IDE1006. Therefore we enable the IDE1006 as a build time warning to enforce conventions and extend them. We disable SA13XX rules that can now be covered by IDE1006 to avoid double-reporting but leave the remaining SA13XX rules that cover additional cases enabled. We also re-enable the SA1311 rule convention but enforce it via IDE1006, requiring some violations to be fixed or duplication of existing suppressions. Most violations fixes are trivial renames with the following exception. In ActorInitializer.cs, we prefer to make the fields private instead. ValueActorInit provides a publicly accessible property for access and OwnerInit provides a publicly accessible method. Health.cs is adjusted to access the property base instead when overriding. The reflection calls must be adjusted to target the base class specifically, as searching for a private field from the derived class will fail to locate it on the base class. Unused suppressions were removed.
This commit is contained in:
@@ -28,64 +28,75 @@ csharp_space_around_binary_operators = before_and_after
|
|||||||
## Naming styles:
|
## Naming styles:
|
||||||
|
|
||||||
dotnet_naming_style.camel_case.capitalization = camel_case
|
dotnet_naming_style.camel_case.capitalization = camel_case
|
||||||
|
|
||||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style.i_prefix_pascal_case.capitalization = pascal_case
|
||||||
|
dotnet_naming_style.i_prefix_pascal_case.required_prefix = I
|
||||||
|
|
||||||
## Symbol specifications:
|
## Symbol specifications:
|
||||||
|
|
||||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
dotnet_naming_symbols.const_locals.applicable_kinds = local
|
||||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal
|
dotnet_naming_symbols.const_locals.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.const_locals.required_modifiers = const
|
||||||
|
|
||||||
dotnet_naming_symbols.const_private_field.applicable_kinds = field
|
dotnet_naming_symbols.const_fields.applicable_kinds = field
|
||||||
dotnet_naming_symbols.const_private_field.required_modifiers = const
|
dotnet_naming_symbols.const_fields.applicable_accessibilities = *
|
||||||
dotnet_naming_symbols.const_private_field.applicable_accessibilities = private
|
dotnet_naming_symbols.const_fields.required_modifiers = const
|
||||||
|
|
||||||
dotnet_naming_symbols.internal_field.applicable_kinds = field
|
dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
|
||||||
dotnet_naming_symbols.internal_field.applicable_accessibilities = internal
|
dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly
|
||||||
|
|
||||||
dotnet_naming_symbols.static_private_or_internal_field.required_modifiers = static
|
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
|
||||||
dotnet_naming_symbols.static_private_or_internal_field.applicable_accessibilities = internal, private
|
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
|
||||||
|
|
||||||
dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
|
dotnet_naming_symbols.private_or_protected_fields.applicable_kinds = field
|
||||||
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private
|
dotnet_naming_symbols.private_or_protected_fields.applicable_accessibilities = private, protected, private_protected
|
||||||
|
|
||||||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
|
dotnet_naming_symbols.interfaces.applicable_kinds = interface
|
||||||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal
|
dotnet_naming_symbols.interfaces.applicable_accessibilities = *
|
||||||
|
|
||||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
dotnet_naming_symbols.parameters_and_locals.applicable_kinds = parameter, local
|
||||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal
|
dotnet_naming_symbols.parameters_and_locals.applicable_accessibilities = *
|
||||||
|
|
||||||
dotnet_naming_symbols.parameters.applicable_kinds = parameter
|
dotnet_naming_symbols.most_symbols.applicable_kinds = namespace, class, struct, enum, field, property, method, local_function, event, delegate, type_parameter
|
||||||
|
dotnet_naming_symbols.most_symbols.applicable_accessibilities = *
|
||||||
|
|
||||||
## Naming rules:
|
## Naming rules:
|
||||||
|
|
||||||
# IDE1006, IDE-only counterpart of StyleCopAnalyzers - SA1300: ElementMustBeginWithUpperCaseLetter.
|
dotnet_naming_rule.const_locals_should_be_pascal_case.symbols = const_locals
|
||||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
|
dotnet_naming_rule.const_locals_should_be_pascal_case.style = pascal_case
|
||||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
dotnet_naming_rule.const_locals_should_be_pascal_case.severity = warning
|
||||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
|
||||||
|
|
||||||
# IDE1006, IDE-only counterpart of StyleCopAnalyzers - SA1311: StaticReadonlyFieldsMustBeginWithUpperCaseLetter (silenced in OpenRA.ruleset).
|
dotnet_naming_rule.const_fields_should_be_pascal_case.symbols = const_fields
|
||||||
dotnet_naming_rule.static_private_or_internal_field_should_be_pascal_case.severity = none
|
dotnet_naming_rule.const_fields_should_be_pascal_case.style = pascal_case
|
||||||
dotnet_naming_rule.static_private_or_internal_field_should_be_pascal_case.symbols = static_private_or_internal_field
|
dotnet_naming_rule.const_fields_should_be_pascal_case.severity = warning
|
||||||
dotnet_naming_rule.static_private_or_internal_field_should_be_pascal_case.style = pascal_case
|
|
||||||
|
|
||||||
# IDE1006, IDE-only counterpart of StyleCopAnalyzers - SA1303: ConstFieldNamesMustBeginWithUpperCaseLetter.
|
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.symbols = static_readonly_fields
|
||||||
dotnet_naming_rule.const_private_field_should_be_pascal_case.severity = warning
|
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.style = pascal_case
|
||||||
dotnet_naming_rule.const_private_field_should_be_pascal_case.symbols = const_private_field
|
dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = warning
|
||||||
dotnet_naming_rule.const_private_field_should_be_pascal_case.style = pascal_case
|
|
||||||
|
|
||||||
dotnet_naming_rule.const_private_or_internal_field_should_be_pascal_case.severity = warning
|
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
|
||||||
dotnet_naming_rule.const_private_or_internal_field_should_be_pascal_case.symbols = internal_field
|
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = pascal_case
|
||||||
dotnet_naming_rule.const_private_or_internal_field_should_be_pascal_case.style = pascal_case
|
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = warning
|
||||||
|
|
||||||
# IDE1006, IDE-only counterpart of StyleCopAnalyzers - SA1306: FieldNamesMustBeginWithLowerCaseLetter.
|
dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.symbols = private_or_protected_fields
|
||||||
dotnet_naming_rule.private_or_internal_field_should_be_camel_case.severity = warning
|
dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.style = camel_case
|
||||||
dotnet_naming_rule.private_or_internal_field_should_be_camel_case.symbols = private_or_internal_field
|
dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.severity = warning
|
||||||
dotnet_naming_rule.private_or_internal_field_should_be_camel_case.style = camel_case
|
|
||||||
|
|
||||||
# IDE1006, IDE-only counterpart of StyleCopAnalyzers - SA1313: ParameterNamesMustBeginWithLowerCaseLetter.
|
dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.symbols = interfaces
|
||||||
dotnet_naming_rule.parameters.severity = warning
|
dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.style = i_prefix_pascal_case
|
||||||
dotnet_naming_rule.parameters.symbols = parameters
|
dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.severity = warning
|
||||||
dotnet_naming_rule.parameters.style = camel_case
|
|
||||||
|
dotnet_naming_rule.parameters_and_locals_should_be_camel_case.symbols = parameters_and_locals
|
||||||
|
dotnet_naming_rule.parameters_and_locals_should_be_camel_case.style = camel_case
|
||||||
|
dotnet_naming_rule.parameters_and_locals_should_be_camel_case.severity = warning
|
||||||
|
|
||||||
|
dotnet_naming_rule.most_symbols_should_be_pascal_case.symbols = most_symbols
|
||||||
|
dotnet_naming_rule.most_symbols_should_be_pascal_case.style = pascal_case
|
||||||
|
dotnet_naming_rule.most_symbols_should_be_pascal_case.severity = warning
|
||||||
|
|
||||||
## Formatting:
|
## Formatting:
|
||||||
|
|
||||||
@@ -130,6 +141,9 @@ dotnet_diagnostic.IDE0040.severity = warning
|
|||||||
# Make field readonly.
|
# Make field readonly.
|
||||||
dotnet_diagnostic.IDE0044.severity = warning
|
dotnet_diagnostic.IDE0044.severity = warning
|
||||||
|
|
||||||
|
# Naming rule violation.
|
||||||
|
dotnet_diagnostic.IDE1006.severity = warning
|
||||||
|
|
||||||
# Avoid unnecessary zero-length array allocations.
|
# Avoid unnecessary zero-length array allocations.
|
||||||
dotnet_diagnostic.CA1825.severity = warning
|
dotnet_diagnostic.CA1825.severity = warning
|
||||||
|
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// More accurate replacement for Environment.TickCount
|
// More accurate replacement for Environment.TickCount
|
||||||
static readonly Stopwatch stopwatch = Stopwatch.StartNew();
|
static readonly Stopwatch Stopwatch = Stopwatch.StartNew();
|
||||||
public static long RunTime => stopwatch.ElapsedMilliseconds;
|
public static long RunTime => Stopwatch.ElapsedMilliseconds;
|
||||||
|
|
||||||
public static int RenderFrame = 0;
|
public static int RenderFrame = 0;
|
||||||
public static int NetFrameNumber => OrderManager.NetFrameNumber;
|
public static int NetFrameNumber => OrderManager.NetFrameNumber;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public abstract class ValueActorInit<T> : ActorInit
|
public abstract class ValueActorInit<T> : ActorInit
|
||||||
{
|
{
|
||||||
protected readonly T value;
|
readonly T value;
|
||||||
|
|
||||||
protected ValueActorInit(TraitInfo info, T value)
|
protected ValueActorInit(TraitInfo info, T value)
|
||||||
: base(info.InstanceName) { this.value = value; }
|
: base(info.InstanceName) { this.value = value; }
|
||||||
@@ -159,7 +159,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public virtual void Initialize(T value)
|
public virtual void Initialize(T value)
|
||||||
{
|
{
|
||||||
var field = GetType().GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance);
|
var field = typeof(ValueActorInit<T>).GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
if (field != null)
|
if (field != null)
|
||||||
field.SetValue(this, value);
|
field.SetValue(this, value);
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ namespace OpenRA
|
|||||||
public class OwnerInit : ActorInit, ISingleInstanceInit
|
public class OwnerInit : ActorInit, ISingleInstanceInit
|
||||||
{
|
{
|
||||||
public readonly string InternalName;
|
public readonly string InternalName;
|
||||||
protected readonly Player value;
|
readonly Player value;
|
||||||
|
|
||||||
public OwnerInit(Player value)
|
public OwnerInit(Player value)
|
||||||
{
|
{
|
||||||
@@ -246,14 +246,14 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Initialize(MiniYaml yaml)
|
public void Initialize(MiniYaml yaml)
|
||||||
{
|
{
|
||||||
var field = GetType().GetField(nameof(InternalName), BindingFlags.Public | BindingFlags.Instance);
|
var field = typeof(OwnerInit).GetField(nameof(InternalName), BindingFlags.Public | BindingFlags.Instance);
|
||||||
if (field != null)
|
if (field != null)
|
||||||
field.SetValue(this, yaml.Value);
|
field.SetValue(this, yaml.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(Player player)
|
public void Initialize(Player player)
|
||||||
{
|
{
|
||||||
var field = GetType().GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance);
|
var field = typeof(OwnerInit).GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
if (field != null)
|
if (field != null)
|
||||||
field.SetValue(this, player);
|
field.SetValue(this, player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ namespace OpenRA
|
|||||||
/// <summary>Gets or sets the <see cref="CellLayer"/> using cell coordinates</summary>
|
/// <summary>Gets or sets the <see cref="CellLayer"/> using cell coordinates</summary>
|
||||||
public T this[CPos cell]
|
public T this[CPos cell]
|
||||||
{
|
{
|
||||||
get => entries[Index(cell)];
|
get => Entries[Index(cell)];
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
entries[Index(cell)] = value;
|
Entries[Index(cell)] = value;
|
||||||
|
|
||||||
CellEntryChanged?.Invoke(cell);
|
CellEntryChanged?.Invoke(cell);
|
||||||
}
|
}
|
||||||
@@ -88,11 +88,11 @@ namespace OpenRA
|
|||||||
/// <summary>Gets or sets the layer contents using raw map coordinates (not CPos!)</summary>
|
/// <summary>Gets or sets the layer contents using raw map coordinates (not CPos!)</summary>
|
||||||
public T this[MPos uv]
|
public T this[MPos uv]
|
||||||
{
|
{
|
||||||
get => entries[Index(uv)];
|
get => Entries[Index(uv)];
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
entries[Index(uv)] = value;
|
Entries[Index(uv)] = value;
|
||||||
|
|
||||||
CellEntryChanged?.Invoke(uv.ToCPos(GridType));
|
CellEntryChanged?.Invoke(uv.ToCPos(GridType));
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool Contains(MPos uv)
|
public bool Contains(MPos uv)
|
||||||
{
|
{
|
||||||
return bounds.Contains(uv.U, uv.V);
|
return Bounds.Contains(uv.U, uv.V);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPos Clamp(CPos uv)
|
public CPos Clamp(CPos uv)
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ namespace OpenRA
|
|||||||
public readonly Size Size;
|
public readonly Size Size;
|
||||||
public readonly MapGridType GridType;
|
public readonly MapGridType GridType;
|
||||||
|
|
||||||
protected readonly T[] entries;
|
protected readonly T[] Entries;
|
||||||
protected readonly Rectangle bounds;
|
protected readonly Rectangle Bounds;
|
||||||
|
|
||||||
public CellLayerBase(Map map)
|
public CellLayerBase(Map map)
|
||||||
: this(map.Grid.Type, new Size(map.MapSize.X, map.MapSize.Y)) { }
|
: this(map.Grid.Type, new Size(map.MapSize.X, map.MapSize.Y)) { }
|
||||||
@@ -30,9 +30,9 @@ namespace OpenRA
|
|||||||
public CellLayerBase(MapGridType gridType, Size size)
|
public CellLayerBase(MapGridType gridType, Size size)
|
||||||
{
|
{
|
||||||
Size = size;
|
Size = size;
|
||||||
bounds = new Rectangle(0, 0, Size.Width, Size.Height);
|
Bounds = new Rectangle(0, 0, Size.Width, Size.Height);
|
||||||
GridType = gridType;
|
GridType = gridType;
|
||||||
entries = new T[size.Width * size.Height];
|
Entries = new T[size.Width * size.Height];
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void CopyValuesFrom(CellLayerBase<T> anotherLayer)
|
public virtual void CopyValuesFrom(CellLayerBase<T> anotherLayer)
|
||||||
@@ -40,24 +40,24 @@ namespace OpenRA
|
|||||||
if (Size != anotherLayer.Size || GridType != anotherLayer.GridType)
|
if (Size != anotherLayer.Size || GridType != anotherLayer.GridType)
|
||||||
throw new ArgumentException("Layers must have a matching size and shape (grid type).", nameof(anotherLayer));
|
throw new ArgumentException("Layers must have a matching size and shape (grid type).", nameof(anotherLayer));
|
||||||
|
|
||||||
Array.Copy(anotherLayer.entries, entries, entries.Length);
|
Array.Copy(anotherLayer.Entries, Entries, Entries.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Clears the layer contents with their default value</summary>
|
/// <summary>Clears the layer contents with their default value</summary>
|
||||||
public virtual void Clear()
|
public virtual void Clear()
|
||||||
{
|
{
|
||||||
Array.Clear(entries, 0, entries.Length);
|
Array.Clear(Entries, 0, Entries.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Clears the layer contents with a known value</summary>
|
/// <summary>Clears the layer contents with a known value</summary>
|
||||||
public virtual void Clear(T clearValue)
|
public virtual void Clear(T clearValue)
|
||||||
{
|
{
|
||||||
Array.Fill(entries, clearValue);
|
Array.Fill(Entries, clearValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<T> GetEnumerator()
|
public IEnumerator<T> GetEnumerator()
|
||||||
{
|
{
|
||||||
return ((IEnumerable<T>)entries).GetEnumerator();
|
return ((IEnumerable<T>)Entries).GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
|||||||
@@ -38,15 +38,12 @@ namespace OpenRA
|
|||||||
Remote = 4
|
Remote = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules",
|
|
||||||
"SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter",
|
|
||||||
Justification = "Fields names must match the with the remote API.")]
|
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules",
|
|
||||||
"SA1304:NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter",
|
|
||||||
Justification = "Fields names must match the with the remote API.")]
|
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules",
|
[SuppressMessage("StyleCop.CSharp.NamingRules",
|
||||||
"SA1310:FieldNamesMustNotContainUnderscore",
|
"SA1310:FieldNamesMustNotContainUnderscore",
|
||||||
Justification = "Fields names must match the with the remote API.")]
|
Justification = "Fields names must match the with the remote API.")]
|
||||||
|
[SuppressMessage("Style",
|
||||||
|
"IDE1006:Naming Styles",
|
||||||
|
Justification = "Fields names must match the with the remote API.")]
|
||||||
public class RemoteMapData
|
public class RemoteMapData
|
||||||
{
|
{
|
||||||
public readonly string title;
|
public readonly string title;
|
||||||
|
|||||||
@@ -36,22 +36,22 @@ namespace OpenRA
|
|||||||
|
|
||||||
public T this[int index]
|
public T this[int index]
|
||||||
{
|
{
|
||||||
get => entries[index];
|
get => Entries[index];
|
||||||
|
|
||||||
set => entries[index] = value;
|
set => Entries[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets or sets the layer contents using projected map coordinates.</summary>
|
/// <summary>Gets or sets the layer contents using projected map coordinates.</summary>
|
||||||
public T this[PPos uv]
|
public T this[PPos uv]
|
||||||
{
|
{
|
||||||
get => entries[Index(uv)];
|
get => Entries[Index(uv)];
|
||||||
|
|
||||||
set => entries[Index(uv)] = value;
|
set => Entries[Index(uv)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(PPos uv)
|
public bool Contains(PPos uv)
|
||||||
{
|
{
|
||||||
return bounds.Contains(uv.U, uv.V);
|
return Bounds.Contains(uv.U, uv.V);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Network
|
|||||||
class SyncReport
|
class SyncReport
|
||||||
{
|
{
|
||||||
const int NumSyncReports = 5;
|
const int NumSyncReports = 5;
|
||||||
static readonly Cache<Type, TypeInfo> typeInfoCache = new Cache<Type, TypeInfo>(t => new TypeInfo(t));
|
static readonly Cache<Type, TypeInfo> TypeInfoCache = new Cache<Type, TypeInfo>(t => new TypeInfo(t));
|
||||||
|
|
||||||
readonly OrderManager orderManager;
|
readonly OrderManager orderManager;
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ namespace OpenRA.Network
|
|||||||
{
|
{
|
||||||
var type = sync.GetType();
|
var type = sync.GetType();
|
||||||
TypeInfo typeInfo;
|
TypeInfo typeInfo;
|
||||||
lock (typeInfoCache)
|
lock (TypeInfoCache)
|
||||||
typeInfo = typeInfoCache[type];
|
typeInfo = TypeInfoCache[type];
|
||||||
var values = new Values(typeInfo.Names.Length);
|
var values = new Values(typeInfo.Names.Length);
|
||||||
var index = 0;
|
var index = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static class Platform
|
public static class Platform
|
||||||
{
|
{
|
||||||
public static PlatformType CurrentPlatform => currentPlatform.Value;
|
public static PlatformType CurrentPlatform => LazyCurrentPlatform.Value;
|
||||||
public static readonly Guid SessionGUID = Guid.NewGuid();
|
public static readonly Guid SessionGUID = Guid.NewGuid();
|
||||||
|
|
||||||
static readonly Lazy<PlatformType> currentPlatform = Exts.Lazy(GetCurrentPlatform);
|
static readonly Lazy<PlatformType> LazyCurrentPlatform = Exts.Lazy(GetCurrentPlatform);
|
||||||
|
|
||||||
static bool engineDirAccessed;
|
static bool engineDirAccessed;
|
||||||
static string engineDir;
|
static string engineDir;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
|
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Mimic a built-in type alias.")]
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public readonly struct float2 : IEquatable<float2>
|
public readonly struct float2 : IEquatable<float2>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
|
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Mimic a built-in type alias.")]
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public readonly struct float3 : IEquatable<float3>
|
public readonly struct float3 : IEquatable<float3>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
|
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Mimic a built-in type alias.")]
|
||||||
public readonly struct int2 : IEquatable<int2>
|
public readonly struct int2 : IEquatable<int2>
|
||||||
{
|
{
|
||||||
public readonly int X, Y;
|
public readonly int X, Y;
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ namespace OpenRA.Support
|
|||||||
List<PerfTimer> children;
|
List<PerfTimer> children;
|
||||||
long ticks;
|
long ticks;
|
||||||
|
|
||||||
static readonly ThreadLocal<PerfTimer> parentThreadLocal = new ThreadLocal<PerfTimer>();
|
static readonly ThreadLocal<PerfTimer> ParentThreadLocal = new ThreadLocal<PerfTimer>();
|
||||||
|
|
||||||
public PerfTimer(string name, float thresholdMs = 0)
|
public PerfTimer(string name, float thresholdMs = 0)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.thresholdMs = thresholdMs;
|
this.thresholdMs = thresholdMs;
|
||||||
|
|
||||||
parent = parentThreadLocal.Value;
|
parent = ParentThreadLocal.Value;
|
||||||
depth = parent == null ? (byte)0 : (byte)(parent.depth + 1);
|
depth = parent == null ? (byte)0 : (byte)(parent.depth + 1);
|
||||||
parentThreadLocal.Value = this;
|
ParentThreadLocal.Value = this;
|
||||||
|
|
||||||
ticks = Stopwatch.GetTimestamp();
|
ticks = Stopwatch.GetTimestamp();
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Support
|
|||||||
{
|
{
|
||||||
ticks = Stopwatch.GetTimestamp() - ticks;
|
ticks = Stopwatch.GetTimestamp() - ticks;
|
||||||
|
|
||||||
parentThreadLocal.Value = parent;
|
ParentThreadLocal.Value = parent;
|
||||||
|
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
Write();
|
Write();
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public interface ILobbyCustomRulesIgnore { }
|
public interface ILobbyCustomRulesIgnore { }
|
||||||
|
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:InterfaceNamesMustBeginWithI", Justification = "Not a real interface, but more like a tag.")]
|
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Not a real interface, but more like a tag.")]
|
||||||
public interface Requires<T> where T : class, ITraitInfoInterface { }
|
public interface Requires<T> where T : class, ITraitInfoInterface { }
|
||||||
|
|
||||||
public interface IActivityInterface { }
|
public interface IActivityInterface { }
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (names.TryGetValue(Hash, out var filename))
|
if (Names.TryGetValue(Hash, out var filename))
|
||||||
return $"{filename} - offset 0x{Offset:x8} - length 0x{Length:x8}";
|
return $"{filename} - offset 0x{Offset:x8} - length 0x{Length:x8}";
|
||||||
else
|
else
|
||||||
return $"0x{Hash:x8} - offset 0x{Offset:x8} - length 0x{Length:x8}";
|
return $"0x{Hash:x8} - offset 0x{Offset:x8} - length 0x{Length:x8}";
|
||||||
@@ -105,14 +105,14 @@ namespace OpenRA.Mods.Cnc.FileSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly Dictionary<uint, string> names = new Dictionary<uint, string>();
|
static readonly Dictionary<uint, string> Names = new Dictionary<uint, string>();
|
||||||
|
|
||||||
public static void AddStandardName(string s)
|
public static void AddStandardName(string s)
|
||||||
{
|
{
|
||||||
var hash = HashFilename(s, PackageHashType.Classic); // RA1 and TD
|
var hash = HashFilename(s, PackageHashType.Classic); // RA1 and TD
|
||||||
names.Add(hash, s);
|
Names.Add(hash, s);
|
||||||
var crcHash = HashFilename(s, PackageHashType.CRC32); // TS
|
var crcHash = HashFilename(s, PackageHashType.CRC32); // TS
|
||||||
names.Add(crcHash, s);
|
Names.Add(crcHash, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
{
|
{
|
||||||
class TeslaZapRenderable : IPalettedRenderable, IFinalizedRenderable
|
class TeslaZapRenderable : IPalettedRenderable, IFinalizedRenderable
|
||||||
{
|
{
|
||||||
static readonly int[][] steps = new[]
|
static readonly int[][] Steps = new[]
|
||||||
{
|
{
|
||||||
new int[] { 8, 8, 4, 4, 0 },
|
new int[] { 8, 8, 4, 4, 0 },
|
||||||
new int[] { -8, -8, -4, -4, 0 },
|
new int[] { -8, -8, -4, -4, 0 },
|
||||||
@@ -144,7 +144,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
|
|
||||||
while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5)
|
while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5)
|
||||||
{
|
{
|
||||||
var step = steps.Where(t => (to - (z + new float2(t[0], t[1]))).LengthSquared < (to - z).LengthSquared)
|
var step = Steps.Where(t => (to - (z + new float2(t[0], t[1]))).LengthSquared < (to - z).LengthSquared)
|
||||||
.MinBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c));
|
.MinBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c));
|
||||||
|
|
||||||
var pos = wr.ProjectedPosition((z + new float2(step[2], step[3])).ToInt2());
|
var pos = wr.ProjectedPosition((z + new float2(step[2], step[3])).ToInt2());
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mapping from RA95 overlay index to type string
|
// Mapping from RA95 overlay index to type string
|
||||||
static readonly string[] redAlertOverlayNames =
|
static readonly string[] RedAlertOverlayNames =
|
||||||
{
|
{
|
||||||
"sbag", "cycl", "brik", "fenc", "wood",
|
"sbag", "cycl", "brik", "fenc", "wood",
|
||||||
"gold01", "gold02", "gold03", "gold04",
|
"gold01", "gold02", "gold03", "gold04",
|
||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
"fpls", "wcrate", "scrate", "barb", "sbag",
|
"fpls", "wcrate", "scrate", "barb", "sbag",
|
||||||
};
|
};
|
||||||
|
|
||||||
static readonly Dictionary<string, (byte Type, byte Index)> overlayResourceMapping = new Dictionary<string, (byte, byte)>()
|
static readonly Dictionary<string, (byte Type, byte Index)> OverlayResourceMapping = new Dictionary<string, (byte, byte)>()
|
||||||
{
|
{
|
||||||
// RA ore & crystals
|
// RA ore & crystals
|
||||||
{ "gold01", (1, 0) },
|
{ "gold01", (1, 0) },
|
||||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
Map.Tiles[new CPos(i, j)] = new TerrainTile(types[i, j], ms.ReadUInt8());
|
Map.Tiles[new CPos(i, j)] = new TerrainTile(types[i, j], ms.ReadUInt8());
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly string[] overlayActors = new string[]
|
static readonly string[] OverlayActors = new string[]
|
||||||
{
|
{
|
||||||
// Fences
|
// Fences
|
||||||
"sbag", "cycl", "brik", "fenc", "wood",
|
"sbag", "cycl", "brik", "fenc", "wood",
|
||||||
@@ -102,15 +102,15 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
var o = ms.ReadUInt8();
|
var o = ms.ReadUInt8();
|
||||||
var res = (Type: (byte)0, Index: (byte)0);
|
var res = (Type: (byte)0, Index: (byte)0);
|
||||||
|
|
||||||
if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o]))
|
if (o != 255 && OverlayResourceMapping.ContainsKey(RedAlertOverlayNames[o]))
|
||||||
res = overlayResourceMapping[redAlertOverlayNames[o]];
|
res = OverlayResourceMapping[RedAlertOverlayNames[o]];
|
||||||
|
|
||||||
var cell = new CPos(i, j);
|
var cell = new CPos(i, j);
|
||||||
Map.Resources[cell] = new ResourceTile(res.Type, res.Index);
|
Map.Resources[cell] = new ResourceTile(res.Type, res.Index);
|
||||||
|
|
||||||
if (o != 255 && overlayActors.Contains(redAlertOverlayNames[o]))
|
if (o != 255 && OverlayActors.Contains(RedAlertOverlayNames[o]))
|
||||||
{
|
{
|
||||||
var ar = new ActorReference(redAlertOverlayNames[o])
|
var ar = new ActorReference(RedAlertOverlayNames[o])
|
||||||
{
|
{
|
||||||
new LocationInit(cell),
|
new LocationInit(cell),
|
||||||
new OwnerInit("Neutral")
|
new OwnerInit("Neutral")
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly Dictionary<string, (byte Type, byte Index)> overlayResourceMapping = new Dictionary<string, (byte, byte)>()
|
static readonly Dictionary<string, (byte Type, byte Index)> OverlayResourceMapping = new Dictionary<string, (byte, byte)>()
|
||||||
{
|
{
|
||||||
// Tiberium
|
// Tiberium
|
||||||
{ "ti1", (1, 0) },
|
{ "ti1", (1, 0) },
|
||||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly string[] overlayActors = new string[]
|
static readonly string[] OverlayActors = new string[]
|
||||||
{
|
{
|
||||||
// Fences
|
// Fences
|
||||||
"sbag", "cycl", "brik", "fenc", "wood",
|
"sbag", "cycl", "brik", "fenc", "wood",
|
||||||
@@ -94,11 +94,11 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
|
|
||||||
var res = (Type: (byte)0, Index: (byte)0);
|
var res = (Type: (byte)0, Index: (byte)0);
|
||||||
var type = kv.Value.ToLowerInvariant();
|
var type = kv.Value.ToLowerInvariant();
|
||||||
if (overlayResourceMapping.ContainsKey(type))
|
if (OverlayResourceMapping.ContainsKey(type))
|
||||||
res = overlayResourceMapping[type];
|
res = OverlayResourceMapping[type];
|
||||||
|
|
||||||
Map.Resources[cell] = new ResourceTile(res.Type, res.Index);
|
Map.Resources[cell] = new ResourceTile(res.Type, res.Index);
|
||||||
if (overlayActors.Contains(type))
|
if (OverlayActors.Contains(type))
|
||||||
{
|
{
|
||||||
var ar = new ActorReference(type)
|
var ar = new ActorReference(type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
|||||||
public static readonly int MAXBITS = 13; // maximum code length
|
public static readonly int MAXBITS = 13; // maximum code length
|
||||||
public static readonly int MAXWIN = 4096; // maximum window size
|
public static readonly int MAXWIN = 4096; // maximum window size
|
||||||
|
|
||||||
static readonly byte[] litlen =
|
static readonly byte[] LitLen =
|
||||||
{
|
{
|
||||||
11, 124, 8, 7, 28, 7, 188, 13, 76, 4,
|
11, 124, 8, 7, 28, 7, 188, 13, 76, 4,
|
||||||
10, 8, 12, 10, 12, 10, 8, 23, 8, 9,
|
10, 8, 12, 10, 12, 10, 8, 23, 8, 9,
|
||||||
@@ -40,28 +40,28 @@ namespace OpenRA.Mods.Common.FileFormats
|
|||||||
};
|
};
|
||||||
|
|
||||||
// bit lengths of length codes 0..15
|
// bit lengths of length codes 0..15
|
||||||
static readonly byte[] lenlen = { 2, 35, 36, 53, 38, 23 };
|
static readonly byte[] LenLen = { 2, 35, 36, 53, 38, 23 };
|
||||||
|
|
||||||
// bit lengths of distance codes 0..63
|
// bit lengths of distance codes 0..63
|
||||||
static readonly byte[] distlen = { 2, 20, 53, 230, 247, 151, 248 };
|
static readonly byte[] DistLen = { 2, 20, 53, 230, 247, 151, 248 };
|
||||||
|
|
||||||
// base for length codes
|
// base for length codes
|
||||||
static readonly short[] lengthbase =
|
static readonly short[] LengthBase =
|
||||||
{
|
{
|
||||||
3, 2, 4, 5, 6, 7, 8, 9, 10, 12,
|
3, 2, 4, 5, 6, 7, 8, 9, 10, 12,
|
||||||
16, 24, 40, 72, 136, 264
|
16, 24, 40, 72, 136, 264
|
||||||
};
|
};
|
||||||
|
|
||||||
// extra bits for length codes
|
// extra bits for length codes
|
||||||
static readonly byte[] extra =
|
static readonly byte[] Extra =
|
||||||
{
|
{
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
|
||||||
3, 4, 5, 6, 7, 8
|
3, 4, 5, 6, 7, 8
|
||||||
};
|
};
|
||||||
|
|
||||||
static readonly Huffman litcode = new Huffman(litlen, litlen.Length, 256);
|
static readonly Huffman LitCode = new Huffman(LitLen, LitLen.Length, 256);
|
||||||
static readonly Huffman lencode = new Huffman(lenlen, lenlen.Length, 16);
|
static readonly Huffman LenCode = new Huffman(LenLen, LenLen.Length, 16);
|
||||||
static readonly Huffman distcode = new Huffman(distlen, distlen.Length, 64);
|
static readonly Huffman DistCode = new Huffman(DistLen, DistLen.Length, 64);
|
||||||
|
|
||||||
/// <summary>PKWare Compression Library stream.</summary>
|
/// <summary>PKWare Compression Library stream.</summary>
|
||||||
/// <param name="input">Compressed input stream.</param>
|
/// <param name="input">Compressed input stream.</param>
|
||||||
@@ -98,8 +98,8 @@ namespace OpenRA.Mods.Common.FileFormats
|
|||||||
if (br.ReadBits(1) == 1)
|
if (br.ReadBits(1) == 1)
|
||||||
{
|
{
|
||||||
// Length
|
// Length
|
||||||
var symbol = Decode(lencode, br);
|
var symbol = Decode(LenCode, br);
|
||||||
var len = lengthbase[symbol] + br.ReadBits(extra[symbol]);
|
var len = LengthBase[symbol] + br.ReadBits(Extra[symbol]);
|
||||||
|
|
||||||
// Magic number for "done"
|
// Magic number for "done"
|
||||||
if (len == 519)
|
if (len == 519)
|
||||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
|||||||
|
|
||||||
// Distance
|
// Distance
|
||||||
symbol = len == 2 ? 2 : dict;
|
symbol = len == 2 ? 2 : dict;
|
||||||
var dist = Decode(distcode, br) << symbol;
|
var dist = Decode(DistCode, br) << symbol;
|
||||||
dist += br.ReadBits(symbol);
|
dist += br.ReadBits(symbol);
|
||||||
dist++;
|
dist++;
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// literal value
|
// literal value
|
||||||
var symbol = encodedLiterals ? Decode(litcode, br) : br.ReadBits(8);
|
var symbol = encodedLiterals ? Decode(LitCode, br) : br.ReadBits(8);
|
||||||
outBuffer[next++] = (byte)symbol;
|
outBuffer[next++] = (byte)symbol;
|
||||||
if (next == MAXWIN)
|
if (next == MAXWIN)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
: base(wr, ai, info, init)
|
: base(wr, ai, info, init)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
var previewInit = new ActorPreviewInitializer(actorInfo, wr, init);
|
var previewInit = new ActorPreviewInitializer(ActorInfo, wr, init);
|
||||||
preview = actorInfo.TraitInfos<IRenderActorPreviewInfo>()
|
preview = ActorInfo.TraitInfos<IRenderActorPreviewInfo>()
|
||||||
.SelectMany(rpi => rpi.RenderPreview(previewInit))
|
.SelectMany(rpi => rpi.RenderPreview(previewInit))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override IEnumerable<IRenderable> RenderInner(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint)
|
protected override IEnumerable<IRenderable> RenderInner(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint)
|
||||||
{
|
{
|
||||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + CenterOffset;
|
||||||
var previewRenderables = preview
|
var previewRenderables = preview
|
||||||
.SelectMany(p => p.Render(wr, centerPosition));
|
.SelectMany(p => p.Render(wr, centerPosition));
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public class FootprintPlaceBuildingPreviewPreview : IPlaceBuildingPreview
|
public class FootprintPlaceBuildingPreviewPreview : IPlaceBuildingPreview
|
||||||
{
|
{
|
||||||
protected readonly ActorInfo actorInfo;
|
protected readonly ActorInfo ActorInfo;
|
||||||
protected readonly WVec centerOffset;
|
protected readonly WVec CenterOffset;
|
||||||
readonly FootprintPlaceBuildingPreviewInfo info;
|
readonly FootprintPlaceBuildingPreviewInfo info;
|
||||||
readonly IPlaceBuildingDecorationInfo[] decorations;
|
readonly IPlaceBuildingDecorationInfo[] decorations;
|
||||||
readonly int2 topLeftScreenOffset;
|
readonly int2 topLeftScreenOffset;
|
||||||
@@ -56,13 +56,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public FootprintPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, FootprintPlaceBuildingPreviewInfo info, TypeDictionary init)
|
public FootprintPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, FootprintPlaceBuildingPreviewInfo info, TypeDictionary init)
|
||||||
{
|
{
|
||||||
actorInfo = ai;
|
ActorInfo = ai;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
decorations = actorInfo.TraitInfos<IPlaceBuildingDecorationInfo>().ToArray();
|
decorations = ActorInfo.TraitInfos<IPlaceBuildingDecorationInfo>().ToArray();
|
||||||
|
|
||||||
var world = wr.World;
|
var world = wr.World;
|
||||||
centerOffset = actorInfo.TraitInfo<BuildingInfo>().CenterOffset(world);
|
CenterOffset = ActorInfo.TraitInfo<BuildingInfo>().CenterOffset(world);
|
||||||
topLeftScreenOffset = -wr.ScreenPxOffset(centerOffset);
|
topLeftScreenOffset = -wr.ScreenPxOffset(CenterOffset);
|
||||||
|
|
||||||
var tileset = world.Map.Tileset.ToLowerInvariant();
|
var tileset = world.Map.Tileset.ToLowerInvariant();
|
||||||
if (world.Map.Rules.Sequences.HasSequence("overlay", $"build-valid-{tileset}"))
|
if (world.Map.Rules.Sequences.HasSequence("overlay", $"build-valid-{tileset}"))
|
||||||
@@ -106,9 +106,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected virtual IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, CPos topLeft)
|
protected virtual IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, CPos topLeft)
|
||||||
{
|
{
|
||||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + CenterOffset;
|
||||||
foreach (var d in decorations)
|
foreach (var d in decorations)
|
||||||
foreach (var r in d.RenderAnnotations(wr, wr.World, actorInfo, centerPosition))
|
foreach (var r in d.RenderAnnotations(wr, wr.World, ActorInfo, centerPosition))
|
||||||
yield return r;
|
yield return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return parents;
|
return parents;
|
||||||
|
|
||||||
var sma = world.WorldActor.Trait<SpawnMapActors>();
|
var sma = world.WorldActor.Trait<SpawnMapActors>();
|
||||||
return value.Select(n => sma.Actors[n]).ToArray();
|
return Value.Select(n => sma.Actors[n]).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
foreach (var r in RenderFootprint(wr, topLeft, footprint, info.FootprintUnderPreview))
|
foreach (var r in RenderFootprint(wr, topLeft, footprint, info.FootprintUnderPreview))
|
||||||
yield return r;
|
yield return r;
|
||||||
|
|
||||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + CenterOffset;
|
||||||
foreach (var r in preview.Render(centerPosition, WVec.Zero, 0, palette))
|
foreach (var r in preview.Render(centerPosition, WVec.Zero, 0, palette))
|
||||||
{
|
{
|
||||||
if (info.SequenceAlpha < 1f && r is IModifyableRenderable mr)
|
if (info.SequenceAlpha < 1f && r is IModifyableRenderable mr)
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
var value = base.Value;
|
||||||
if (value < 0 || (value == 0 && !allowZero))
|
if (value < 0 || (value == 0 && !allowZero))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
IDecoration[] decorations;
|
IDecoration[] decorations;
|
||||||
IDecoration[] selectedDecorations;
|
IDecoration[] selectedDecorations;
|
||||||
|
|
||||||
protected readonly SelectionDecorationsBaseInfo info;
|
protected readonly SelectionDecorationsBaseInfo Info;
|
||||||
|
|
||||||
public SelectionDecorationsBase(SelectionDecorationsBaseInfo info)
|
public SelectionDecorationsBase(SelectionDecorationsBaseInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
var displayExtra = selected || rollover || (regularWorld && statusBars != StatusBarsType.Standard);
|
var displayExtra = selected || rollover || (regularWorld && statusBars != StatusBarsType.Standard);
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
foreach (var r in RenderSelectionBox(self, wr, info.SelectionBoxColor))
|
foreach (var r in RenderSelectionBox(self, wr, Info.SelectionBoxColor))
|
||||||
yield return r;
|
yield return r;
|
||||||
|
|
||||||
if (displayHealth || displayExtra)
|
if (displayHealth || displayExtra)
|
||||||
|
|||||||
@@ -57,14 +57,14 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
|
|
||||||
public abstract class WithDecorationBase<InfoType> : ConditionalTrait<InfoType>, IDecoration where InfoType : WithDecorationBaseInfo
|
public abstract class WithDecorationBase<InfoType> : ConditionalTrait<InfoType>, IDecoration where InfoType : WithDecorationBaseInfo
|
||||||
{
|
{
|
||||||
protected readonly Actor self;
|
protected readonly Actor Self;
|
||||||
int2 conditionalOffset;
|
int2 conditionalOffset;
|
||||||
BlinkState[] blinkPattern;
|
BlinkState[] blinkPattern;
|
||||||
|
|
||||||
public WithDecorationBase(Actor self, InfoType info)
|
public WithDecorationBase(Actor self, InfoType info)
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
this.self = self;
|
Self = self;
|
||||||
blinkPattern = info.BlinkPattern;
|
blinkPattern = info.BlinkPattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.UpdateRules.Rules;
|
using OpenRA.Mods.Common.UpdateRules.Rules;
|
||||||
|
|
||||||
@@ -30,8 +29,6 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
// can be merged back into bleed by replacing the forking-playtest-to-bleed path
|
// can be merged back into bleed by replacing the forking-playtest-to-bleed path
|
||||||
// with the prep playtest-to-playtest-to-release paths and finally a new/modified
|
// with the prep playtest-to-playtest-to-release paths and finally a new/modified
|
||||||
// release-to-bleed path.
|
// release-to-bleed path.
|
||||||
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1118:ParameterMustNotSpanMultipleLines",
|
|
||||||
Justification = "Extracting update lists to temporary variables obfuscates the definitions.")]
|
|
||||||
static readonly UpdatePath[] Paths =
|
static readonly UpdatePath[] Paths =
|
||||||
{
|
{
|
||||||
new UpdatePath("release-20200202", "release-20200503", new UpdateRule[]
|
new UpdatePath("release-20200202", "release-20200503", new UpdateRule[]
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix this -- will have bitrotted pretty badly.
|
// TODO: fix this -- will have bitrotted pretty badly.
|
||||||
static readonly Dictionary<string, Color> namedColorMapping = new Dictionary<string, Color>()
|
static readonly Dictionary<string, Color> NamedColorMapping = new Dictionary<string, Color>()
|
||||||
{
|
{
|
||||||
{ "gold", Color.FromArgb(246, 214, 121) },
|
{ "gold", Color.FromArgb(246, 214, 121) },
|
||||||
{ "blue", Color.FromArgb(226, 230, 246) },
|
{ "blue", Color.FromArgb(226, 230, 246) },
|
||||||
@@ -353,7 +353,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
OwnsWorld = section == "Neutral",
|
OwnsWorld = section == "Neutral",
|
||||||
NonCombatant = section == "Neutral",
|
NonCombatant = section == "Neutral",
|
||||||
Faction = faction,
|
Faction = faction,
|
||||||
Color = namedColorMapping[color]
|
Color = NamedColorMapping[color]
|
||||||
};
|
};
|
||||||
|
|
||||||
var neutral = new[] { "Neutral" };
|
var neutral = new[] { "Neutral" };
|
||||||
|
|||||||
@@ -11,15 +11,12 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||||
{
|
{
|
||||||
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1203:ConstantsMustAppearBeforeFields",
|
|
||||||
Justification = "SystemInformation version should be defined next to the dictionary it refers to.")]
|
|
||||||
public class SystemInfoPromptLogic : ChromeLogic
|
public class SystemInfoPromptLogic : ChromeLogic
|
||||||
{
|
{
|
||||||
// Increment the version number when adding new stats
|
// Increment the version number when adding new stats
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA.Platforms.Default
|
namespace OpenRA.Platforms.Default
|
||||||
{
|
{
|
||||||
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter",
|
|
||||||
Justification = "C-style naming is kept for consistency with the underlying native API.")]
|
|
||||||
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore",
|
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore",
|
||||||
Justification = "C-style naming is kept for consistency with the underlying native API.")]
|
Justification = "C-style naming is kept for consistency with the underlying native API.")]
|
||||||
static class FreeType
|
static class FreeType
|
||||||
|
|||||||
@@ -16,29 +16,29 @@ namespace OpenRA.Platforms.Default
|
|||||||
{
|
{
|
||||||
static class MultiTapDetection
|
static class MultiTapDetection
|
||||||
{
|
{
|
||||||
static readonly Cache<(Keycode Key, Modifiers Mods), TapHistory> keyHistoryCache =
|
static readonly Cache<(Keycode Key, Modifiers Mods), TapHistory> KeyHistoryCache =
|
||||||
new Cache<(Keycode, Modifiers), TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
|
new Cache<(Keycode, Modifiers), TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
|
||||||
static readonly Cache<byte, TapHistory> clickHistoryCache =
|
static readonly Cache<byte, TapHistory> ClickHistoryCache =
|
||||||
new Cache<byte, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
|
new Cache<byte, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
|
||||||
|
|
||||||
public static int DetectFromMouse(byte button, int2 xy)
|
public static int DetectFromMouse(byte button, int2 xy)
|
||||||
{
|
{
|
||||||
return clickHistoryCache[button].GetTapCount(xy);
|
return ClickHistoryCache[button].GetTapCount(xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int InfoFromMouse(byte button)
|
public static int InfoFromMouse(byte button)
|
||||||
{
|
{
|
||||||
return clickHistoryCache[button].LastTapCount();
|
return ClickHistoryCache[button].LastTapCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int DetectFromKeyboard(Keycode key, Modifiers mods)
|
public static int DetectFromKeyboard(Keycode key, Modifiers mods)
|
||||||
{
|
{
|
||||||
return keyHistoryCache[(key, mods)].GetTapCount(int2.Zero);
|
return KeyHistoryCache[(key, mods)].GetTapCount(int2.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int InfoFromKeyboard(Keycode key, Modifiers mods)
|
public static int InfoFromKeyboard(Keycode key, Modifiers mods)
|
||||||
{
|
{
|
||||||
return keyHistoryCache[(key, mods)].LastTapCount();
|
return KeyHistoryCache[(key, mods)].LastTapCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,10 @@ using SDL2;
|
|||||||
|
|
||||||
namespace OpenRA.Platforms.Default
|
namespace OpenRA.Platforms.Default
|
||||||
{
|
{
|
||||||
#pragma warning disable IDE1006 // Naming Styles
|
|
||||||
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter",
|
|
||||||
Justification = "C-style naming is kept for consistency with the underlying native API.")]
|
|
||||||
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore",
|
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore",
|
||||||
Justification = "C-style naming is kept for consistency with the underlying native API.")]
|
Justification = "C-style naming is kept for consistency with the underlying native API.")]
|
||||||
|
[SuppressMessage("Style", "IDE1006:Naming Styles",
|
||||||
|
Justification = "C-style naming is kept for consistency with the underlying native API.")]
|
||||||
static class OpenGL
|
static class OpenGL
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|||||||
@@ -18,6 +18,17 @@
|
|||||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
|
||||||
<Rule Id="SX1101" Action="Warning" /><!-- DoNotPrefixLocalMembersWithThis -->
|
<Rule Id="SX1101" Action="Warning" /><!-- DoNotPrefixLocalMembersWithThis -->
|
||||||
|
|
||||||
|
<!-- Rules that are covered by IDE1006 -->
|
||||||
|
<Rule Id="SA1300" Action="None" /><!-- ElementMustBeginWithUpperCaseLetter -->
|
||||||
|
<Rule Id="SA1302" Action="None" /><!-- InterfaceNamesMustBeginWithI -->
|
||||||
|
<Rule Id="SA1303" Action="None" /><!-- ConstFieldNamesMustBeginWithUpperCaseLetter -->
|
||||||
|
<Rule Id="SA1304" Action="None" /><!-- NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter -->
|
||||||
|
<Rule Id="SA1306" Action="None" /><!-- FieldNamesMustBeginWithLowerCaseLetter -->
|
||||||
|
<Rule Id="SA1307" Action="None" /><!-- AccessibleFieldsMustBeginWithUpperCaseLetter -->
|
||||||
|
<Rule Id="SA1311" Action="None" /><!-- StaticReadonlyFieldsMustBeginWithUpperCaseLetter -->
|
||||||
|
<Rule Id="SA1312" Action="None" /><!-- VariableNamesMustBeginWithLowerCaseLetter -->
|
||||||
|
<Rule Id="SA1313" Action="None" /><!-- ParameterNamesMustBeginWithLowerCaseLetter -->
|
||||||
|
|
||||||
<!-- Rules that conflict with OpenRA project style conventions -->
|
<!-- Rules that conflict with OpenRA project style conventions -->
|
||||||
<Rule Id="SA0001" Action="None" /><!-- XmlCommentAnalysisDisabled -->
|
<Rule Id="SA0001" Action="None" /><!-- XmlCommentAnalysisDisabled -->
|
||||||
<Rule Id="SA1101" Action="None" /><!-- PrefixLocalCallsWithThis -->
|
<Rule Id="SA1101" Action="None" /><!-- PrefixLocalCallsWithThis -->
|
||||||
@@ -55,7 +66,6 @@
|
|||||||
<Rule Id="SA1132" Action="None" /><!-- DoNotCombineFields -->
|
<Rule Id="SA1132" Action="None" /><!-- DoNotCombineFields -->
|
||||||
<Rule Id="SA1204" Action="None" /><!-- StaticElementsMustAppearBeforeInstanceElements -->
|
<Rule Id="SA1204" Action="None" /><!-- StaticElementsMustAppearBeforeInstanceElements -->
|
||||||
<Rule Id="SA1214" Action="None" /><!-- ReadonlyElementsMustAppearBeforeNonReadonlyElements -->
|
<Rule Id="SA1214" Action="None" /><!-- ReadonlyElementsMustAppearBeforeNonReadonlyElements -->
|
||||||
<Rule Id="SA1311" Action="None" /><!-- StaticReadonlyFieldsMustBeginWithUpperCaseLetter - silenced to match IDE1006 in .editorconfig -->
|
|
||||||
<Rule Id="SA1413" Action="None" /><!-- UseTrailingCommasInMultiLineInitializers -->
|
<Rule Id="SA1413" Action="None" /><!-- UseTrailingCommasInMultiLineInitializers -->
|
||||||
<Rule Id="SA1516" Action="None" /><!-- ElementsMustBeSeparatedByBlankLine -->
|
<Rule Id="SA1516" Action="None" /><!-- ElementsMustBeSeparatedByBlankLine -->
|
||||||
<Rule Id="SA1604" Action="None" /><!-- ElementDocumentationShouldHaveSummary -->
|
<Rule Id="SA1604" Action="None" /><!-- ElementDocumentationShouldHaveSummary -->
|
||||||
|
|||||||
Reference in New Issue
Block a user