Switch other struct types to default(T).

This commit is contained in:
Paul Chote
2019-06-07 21:28:38 +01:00
committed by abcdefg30
parent dba1301b61
commit ebd36891dc
13 changed files with 15 additions and 15 deletions

View File

@@ -160,7 +160,7 @@ namespace OpenRA
}
innerState = LinkState.Uninitialized;
parameters = new RSAParameters();
parameters = default(RSAParameters);
innerFingerprint = null;
innerData = null;
}

View File

@@ -303,7 +303,7 @@ namespace OpenRA
foreach (var kv in tree)
{
var inherited = new Dictionary<string, MiniYamlNode.SourceLocation>();
inherited.Add(kv.Key, new MiniYamlNode.SourceLocation());
inherited.Add(kv.Key, default(MiniYamlNode.SourceLocation));
var children = ResolveInherits(kv.Key, kv.Value, tree, inherited);
resolved.Add(kv.Key, new MiniYaml(kv.Value.Value, children));

View File

@@ -119,7 +119,7 @@ namespace OpenRA.Primitives
public static bool TryParse(string value, out Color color)
{
color = new Color();
color = default(Color);
value = value.Trim();
if (value.Length != 6 && value.Length != 8)
return false;

View File

@@ -52,7 +52,7 @@ namespace OpenRA
if (string.IsNullOrEmpty(baseFilename))
{
Channels.Add(channelName, new ChannelInfo());
Channels.Add(channelName, default(ChannelInfo));
return;
}

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Traits
public struct Target
{
public static readonly Target[] None = { };
public static readonly Target Invalid = new Target();
public static readonly Target Invalid = default(Target);
readonly TargetType type;
readonly Actor actor;

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc.Graphics
for (var i = 0; i < vxl.LimbCount; i++)
{
var vl = vxl.Limbs[i];
var l = new Limb();
var l = default(Limb);
l.Scale = vl.Scale;
l.Bounds = (float[])vl.Bounds.Clone();
l.Size = (byte[])vl.Size.Clone();

View File

@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.AudioLoaders
while (true)
{
VocBlock block = new VocBlock();
var block = default(VocBlock);
try
{
block.Code = stream.ReadByte();

View File

@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Widgets
editorLayer.Remove(underCursor);
if (mapResources.Contains(cell) && mapResources[cell].Type != 0)
mapResources[cell] = new ResourceTile();
mapResources[cell] = default(ResourceTile);
}
return true;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public class AppearsOnMapPreviewInfo : TraitInfo<AppearsOnMapPreview>, IMapPreviewSignatureInfo, Requires<IOccupySpaceInfo>
{
[Desc("Use this color to render the actor, instead of owner player color.")]
public readonly Color Color = new Color();
public readonly Color Color = default(Color);
[Desc("Use this terrain color to render the actor, instead of owner player color.",
"Overrides `Color` if both set.")]
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
{
color = tileSet[tileSet.GetTerrainIndex(Terrain)].Color;
}
else if (Color != new Color())
else if (Color != default(Color))
{
color = Color;
}

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var halfSize = font.Measure(number) / 2;
var boundsOffset = new int2(bounds.Left + bounds.Right, bounds.Top + bounds.Bottom) / 2;
var sizeOffset = new int2();
var sizeOffset = int2.Zero;
if (info.ReferencePoint.HasFlag(ReferencePoints.Top))
{
boundsOffset -= new int2(0, bounds.Height / 2);

View File

@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var halfSize = font.Measure(Info.Text) / 2;
var boundsOffset = new int2(bounds.Left + bounds.Right, bounds.Top + bounds.Bottom) / 2;
var sizeOffset = new int2();
var sizeOffset = int2.Zero;
if (Info.ReferencePoint.HasFlag(ReferencePoints.Top))
{
boundsOffset -= new int2(0, bounds.Height / 2);

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public class ResourceLayer : IRenderOverlay, IWorldLoaded, ITickRender, INotifyActorDisposing
{
static readonly CellContents EmptyCell = new CellContents();
static readonly CellContents EmptyCell = default(CellContents);
readonly World world;
readonly BuildingInfluence buildingInfluence;
@@ -310,7 +310,7 @@ namespace OpenRA.Mods.Common.Traits
public struct CellContents
{
public static readonly CellContents Empty = new CellContents();
public static readonly CellContents Empty = default(CellContents);
public ResourceType Type;
public int Density;
public string Variant;

View File

@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Traits
if (!world.Map.Contains(loc))
return;
var tile = dirty.ContainsKey(loc) ? dirty[loc] : new Smudge();
var tile = dirty.ContainsKey(loc) ? dirty[loc] : default(Smudge);
// Setting Sprite to null to indicate a deleted smudge.
tile.Sprite = null;