Replace F extension with string interpolation

This commit is contained in:
teinarss
2021-04-24 17:46:24 +02:00
committed by reaperrr
parent 1385aca783
commit 10676be377
300 changed files with 752 additions and 799 deletions

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets
public void Do()
{
editorActorPreview = editorLayer.Add(actor);
Text = "Added {0} ({1})".F(editorActorPreview.Info.Name, editorActorPreview.ID);
Text = $"Added {editorActorPreview.Info.Name} ({editorActorPreview.ID})";
}
public void Undo()

View File

@@ -204,7 +204,7 @@ namespace OpenRA.Mods.Common.Widgets
mapHeight = map.Height;
mapResources = map.Resources;
Text = "Copied {0} tiles".F(tiles.Count);
Text = $"Copied {tiles.Count} tiles";
}
public void Execute()

View File

@@ -122,7 +122,7 @@ namespace OpenRA.Mods.Common.Widgets
this.editorActorLayer = editorActorLayer;
this.actor = actor;
Text = "Removed {0} ({1})".F(actor.Info.Name, actor.ID);
Text = $"Removed {actor.Info.Name} ({actor.ID})";
}
public void Execute()
@@ -155,7 +155,7 @@ namespace OpenRA.Mods.Common.Widgets
this.resourceLayer = resourceLayer;
this.cell = cell;
Text = "Removed {0}".F(resourceType);
Text = $"Removed {resourceType}";
}
public void Execute()

View File

@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Widgets
cellResources.Add(resourceCell);
var cellText = cellResources.Count != 1 ? "cells" : "cell";
Text = "Added {0} {1} of {2}".F(cellResources.Count, cellText, resourceType);
Text = $"Added {cellResources.Count} {cellText} of {resourceType}";
}
}
}

View File

@@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Widgets
var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo;
terrainTemplate = terrainInfo.Templates[template];
Text = "Added tile {0}".F(terrainTemplate.Id);
Text = $"Added tile {terrainTemplate.Id}";
}
public void Execute()
@@ -239,7 +239,7 @@ namespace OpenRA.Mods.Common.Widgets
var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo;
terrainTemplate = terrainInfo.Templates[template];
Text = "Filled with tile {0}".F(terrainTemplate.Id);
Text = $"Filled with tile {terrainTemplate.Id}";
}
public void Execute()

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Effects
public static string FormatCashTick(int cashAmount)
{
return "{0}${1}".F(cashAmount < 0 ? "-" : "+", Math.Abs(cashAmount));
return $"{(cashAmount < 0 ? "-" : "+")}${Math.Abs(cashAmount)}";
}
}
}

View File

@@ -292,7 +292,7 @@ namespace OpenRA.Mods.Common.FileFormats
{
currentVolumeID = newVolume;
if (!volumes.TryGetValue(currentVolumeID, out currentVolume))
throw new FileNotFoundException("Volume {0} is not available".F(currentVolumeID));
throw new FileNotFoundException($"Volume {currentVolumeID} is not available");
currentVolume.Position = 0;
if (currentVolume.ReadUInt32() != 0x28635349)
@@ -385,7 +385,7 @@ namespace OpenRA.Mods.Common.FileFormats
{
header.Position = cabDescriptorOffset + cabDescriptor.FileTableOffset + cabDescriptor.FileTableOffset2 + i * 0x57;
var file = new FileDescriptor(header, i, cabDescriptorOffset + cabDescriptor.FileTableOffset);
var path = "{0}\\{1}\\{2}".F(fileGroup.Name, directories[file.DirectoryIndex].Name, file.Filename);
var path = $"{fileGroup.Name}\\{directories[file.DirectoryIndex].Name}\\{file.Filename}";
index[path] = file;
}
}
@@ -418,7 +418,7 @@ namespace OpenRA.Mods.Common.FileFormats
extracter.CopyTo(output, onProgress);
if (output.Length != file.ExpandedSize)
throw new InvalidDataException("File expanded to wrong length. Expected = {0}, Got = {1}".F(file.ExpandedSize, output.Length));
throw new InvalidDataException($"File expanded to wrong length. Expected = {file.ExpandedSize}, Got = {output.Length}");
}
public IReadOnlyDictionary<int, IEnumerable<string>> Contents

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.FileFormats
audioType = (WaveType)audioFormat;
if (!Enum.IsDefined(typeof(WaveType), audioType))
throw new NotSupportedException("Compression type {0} is not supported.".F(audioFormat));
throw new NotSupportedException($"Compression type {audioFormat} is not supported.");
channels = s.ReadInt16();
sampleRate = s.ReadInt32();

View File

@@ -67,12 +67,12 @@ namespace OpenRA.Mods.Common.Graphics
}
catch (Exception e)
{
throw new InvalidDataException("Error occurred while parsing {0}".F(node.Key), e);
throw new InvalidDataException($"Error occurred while parsing {node.Key}", e);
}
foreach (var kvp in nodes)
{
using (new Support.PerfTimer("new Sequence(\"{0}\")".F(node.Key), 20))
using (new Support.PerfTimer($"new Sequence(\"{node.Key}\")", 20))
{
try
{
@@ -223,32 +223,26 @@ namespace OpenRA.Mods.Common.Graphics
Stride = LoadField(d, "Stride", Length);
if (Length > Stride)
throw new YamlException("Sequence {0}.{1}: Length must be <= stride"
.F(sequence, animation));
throw new YamlException($"Sequence {sequence}.{animation}: Length must be <= stride");
if (Frames != null && Length > Frames.Length)
throw new YamlException("Sequence {0}.{1}: Length must be <= Frames.Length"
.F(sequence, animation));
throw new YamlException($"Sequence {sequence}.{animation}: Length must be <= Frames.Length");
var end = Start + (Facings - 1) * Stride + Length - 1;
if (Frames != null)
{
foreach (var f in Frames)
if (f < 0 || f >= frameCount)
throw new YamlException("Sequence {0}.{1} defines a Frames override that references frame {2}, but only [{3}..{4}] actually exist"
.F(sequence, animation, f, Start, end));
throw new YamlException($"Sequence {sequence}.{animation} defines a Frames override that references frame {f}, but only [{Start}..{end}] actually exist");
if (Start < 0 || end >= Frames.Length)
throw new YamlException("Sequence {0}.{1} uses indices [{2}..{3}] of the Frames list, but only {4} frames are defined"
.F(sequence, animation, Start, end, Frames.Length));
throw new YamlException($"Sequence {sequence}.{animation} uses indices [{Start}..{end}] of the Frames list, but only {Frames.Length} frames are defined");
}
else if (Start < 0 || end >= frameCount)
throw new YamlException("Sequence {0}.{1} uses frames [{2}..{3}], but only [0..{4}] actually exist"
.F(sequence, animation, Start, end, frameCount - 1));
throw new YamlException($"Sequence {sequence}.{animation} uses frames [{Start}..{end}], but only [0..{frameCount - 1}] actually exist");
if (ShadowStart >= 0 && ShadowStart + (Facings - 1) * Stride + Length > frameCount)
throw new YamlException("Sequence {0}.{1}'s shadow frames use frames [{2}..{3}], but only [0..{4}] actually exist"
.F(sequence, animation, ShadowStart, ShadowStart + (Facings - 1) * Stride + Length - 1, frameCount - 1));
throw new YamlException($"Sequence {sequence}.{animation}'s shadow frames use frames [{ShadowStart}..{ShadowStart + (Facings - 1) * Stride + Length - 1}], but only [0..{frameCount - 1}] actually exist");
var usedFrames = new List<int>();
for (var facing = 0; facing < Facings; facing++)
@@ -325,13 +319,13 @@ namespace OpenRA.Mods.Common.Graphics
if (alpha.Length == 1)
alpha = Exts.MakeArray(Length, _ => alpha[0]);
else if (alpha.Length != Length)
throw new YamlException("Sequence {0}.{1} must define either 1 or {2} Alpha values.".F(sequence, animation, Length));
throw new YamlException($"Sequence {sequence}.{animation} must define either 1 or {Length} Alpha values.");
}
if (LoadField(d, "AlphaFade", false))
{
if (alpha != null)
throw new YamlException("Sequence {0}.{1} cannot define both AlphaFade and Alpha.".F(sequence, animation));
throw new YamlException($"Sequence {sequence}.{animation} cannot define both AlphaFade and Alpha.");
alpha = Exts.MakeArray(Length, i => float2.Lerp(1f, 0f, i / (Length - 1f)));
}
@@ -368,7 +362,7 @@ namespace OpenRA.Mods.Common.Graphics
var i = Frames != null ? Frames[0] : Start;
var palettes = metadata != null ? metadata.GetOrDefault<EmbeddedSpritePalette>() : null;
if (palettes == null || !palettes.TryGetPaletteForFrame(i, out EmbeddedPalette))
throw new YamlException("Cannot export palettes from {0}: frame {1} does not define an embedded palette".F(src, i));
throw new YamlException($"Cannot export palettes from {src}: frame {i} does not define an embedded palette");
}
var boundSprites = SpriteBounds(sprites, Frames, Start, Facings, Length, Stride, transpose);
@@ -379,7 +373,7 @@ namespace OpenRA.Mods.Common.Graphics
}
catch (FormatException f)
{
throw new FormatException("Failed to parse sequences for {0}.{1} at {2}:\n{3}".F(sequence, animation, info.Nodes[0].Location, f));
throw new FormatException($"Failed to parse sequences for {sequence}.{animation} at {info.Nodes[0].Location}:\n{f}");
}
}
@@ -428,8 +422,7 @@ namespace OpenRA.Mods.Common.Graphics
var j = Frames != null ? Frames[i] : start + i;
if (sprites[j] == null)
throw new InvalidOperationException("Attempted to query unloaded sprite from {0}.{1}".F(Name, sequence) +
" start={0} frame={1} facing={2}".F(start, frame, facing));
throw new InvalidOperationException($"Attempted to query unloaded sprite from {Name}.{sequence} start={start} frame={frame} facing={facing}");
return sprites[j];
}

View File

@@ -68,16 +68,14 @@ namespace OpenRA.Mods.Common.Lint
if (!dict.ContainsKey(v))
{
emitError("{0}.{1}.{2}: Missing actor `{3}`."
.F(actorInfo.Name, traitInfo.GetType().Name, fieldInfo.Name, value));
emitError($"{actorInfo.Name}.{traitInfo.GetType().Name}.{fieldInfo.Name}: Missing actor `{value}`.");
continue;
}
foreach (var requiredTrait in attribute.RequiredTraits)
if (!dict[v].TraitsInConstructOrder().Any(t => t.GetType() == requiredTrait || t.GetType().IsSubclassOf(requiredTrait)))
emitError("Actor type {0} does not have trait {1} which is required by {2}.{3}."
.F(value, requiredTrait.Name, traitInfo.GetType().Name, fieldInfo.Name));
emitError($"Actor type {value} does not have trait {requiredTrait.Name} which is required by {traitInfo.GetType().Name}.{fieldInfo.Name}.");
}
}
@@ -91,8 +89,7 @@ namespace OpenRA.Mods.Common.Lint
continue;
if (!dict.ContainsKey(value.ToLowerInvariant()))
emitError("{0}.{1}.{2}: Missing weapon `{3}`."
.F(actorInfo.Name, traitInfo.GetType().Name, fieldInfo.Name, value));
emitError($"{actorInfo.Name}.{traitInfo.GetType().Name}.{fieldInfo.Name}: Missing weapon `{value}`.");
}
}
@@ -106,8 +103,7 @@ namespace OpenRA.Mods.Common.Lint
continue;
if (!dict.ContainsKey(value.ToLowerInvariant()))
emitError("{0}.{1}.{2}: Missing voice `{3}`."
.F(actorInfo.Name, traitInfo.GetType().Name, fieldInfo.Name, value));
emitError($"{actorInfo.Name}.{traitInfo.GetType().Name}.{fieldInfo.Name}: Missing voice `{value}`.");
}
}
}

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Lint
var actorTypes = map.ActorDefinitions.Select(a => a.Value.Value);
foreach (var actor in actorTypes)
if (!map.Rules.Actors.Keys.Contains(actor.ToLowerInvariant()))
emitError("Actor {0} is not defined by any rule.".F(actor));
emitError($"Actor {actor} is not defined by any rule.");
}
}
}

View File

@@ -61,16 +61,16 @@ namespace OpenRA.Mods.Common.Lint
static void CheckLaunchAngles(string weaponInfo, int minAngle, bool testMaxAngle, int maxAngle, Action<string> emitError)
{
if (InvalidAngle(minAngle))
emitError("Weapon `{0}`: Projectile minimum LaunchAngle must not exceed (-)255!".F(weaponInfo));
emitError($"Weapon `{weaponInfo}`: Projectile minimum LaunchAngle must not exceed (-)255!");
if (testMaxAngle && InvalidAngle(maxAngle))
emitError("Weapon `{0}`: Projectile maximum LaunchAngle must not exceed (-)255!".F(weaponInfo));
emitError($"Weapon `{weaponInfo}`: Projectile maximum LaunchAngle must not exceed (-)255!");
if ((minAngle < 256) && (maxAngle < 256) && (minAngle > maxAngle))
emitError("Weapon `{0}`: Projectile minimum LaunchAngle must not exceed maximum LaunchAngle!".F(weaponInfo));
emitError($"Weapon `{weaponInfo}`: Projectile minimum LaunchAngle must not exceed maximum LaunchAngle!");
if ((minAngle > 768) && (maxAngle > 768) && (minAngle > maxAngle))
emitError("Weapon `{0}`: Projectile minimum LaunchAngle must not exceed maximum LaunchAngle!".F(weaponInfo));
emitError($"Weapon `{weaponInfo}`: Projectile minimum LaunchAngle must not exceed maximum LaunchAngle!");
if ((minAngle < 256) && (maxAngle > 768))
emitError("Weapon `{0}`: Projectile minimum LaunchAngle must not exceed maximum LaunchAngle!".F(weaponInfo));
emitError($"Weapon `{weaponInfo}`: Projectile minimum LaunchAngle must not exceed maximum LaunchAngle!");
}
}
}

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Lint
{
// Keys are valid if they refer to a named key or can be parsed as a regular Hotkey.
if (!namedKeys.Contains(node.Value.Value) && !Hotkey.TryParse(node.Value.Value, out var unused))
emitError("{0} refers to a Key named `{1}` that does not exist".F(node.Location, node.Value.Value));
emitError($"{node.Location} refers to a Key named `{node.Value.Value}` that does not exist");
}
}
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var name in keyNames)
if (!namedKeys.Contains(name) && !Hotkey.TryParse(name, out var unused))
emitError("{0} refers to a Key named `{1}` that does not exist".F(node.Location, name));
emitError($"{node.Location} refers to a Key named `{name}` that does not exist");
}
// Logic classes can declare the data key names that specify hotkeys
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var n in node.Value.Nodes)
if (checkArgKeys.Contains(n.Key))
if (!namedKeys.Contains(n.Value.Value) && !Hotkey.TryParse(n.Value.Value, out var unused))
emitError("{0} {1}:{2} refers to a Key named `{3}` that does not exist".F(filename, node.Value.Value, n.Key, n.Value.Value));
emitError($"{filename} {node.Value.Value}:{n.Key} refers to a Key named `{n.Value.Value}` that does not exist");
}
if (node.Value.Nodes != null)

View File

@@ -37,9 +37,9 @@ namespace OpenRA.Mods.Common.Lint
{
var type = Game.ModData.ObjectCreator.FindType(typeName);
if (type == null)
emitError("{0} refers to a logic object `{1}` that does not exist".F(filename, typeName));
emitError($"{filename} refers to a logic object `{typeName}` that does not exist");
else if (!typeof(ChromeLogic).IsAssignableFrom(type))
emitError("{0} refers to a logic object `{1}` that does not inherit from ChromeLogic".F(filename, typeName));
emitError($"{filename} refers to a logic object `{typeName}` that does not inherit from ChromeLogic");
}
}

View File

@@ -65,11 +65,11 @@ namespace OpenRA.Mods.Common.Lint
var unconsumed = granted.Except(consumed);
if (unconsumed.Any())
emitWarning("Actor type `{0}` grants conditions that are not consumed: {1}".F(actorInfo.Key, unconsumed.JoinWith(", ")));
emitWarning($"Actor type `{actorInfo.Key}` grants conditions that are not consumed: {unconsumed.JoinWith(", ")}");
var ungranted = consumed.Except(granted);
if (ungranted.Any())
emitError("Actor type `{0}` consumes conditions that are not granted: {1}".F(actorInfo.Key, ungranted.JoinWith(", ")));
emitError($"Actor type `{actorInfo.Key}` consumes conditions that are not granted: {ungranted.JoinWith(", ")}");
}
}
}

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Lint
var selectable = actorInfo.Value.TraitInfos<SelectableInfo>().Count();
var interactable = actorInfo.Value.TraitInfos<InteractableInfo>().Count();
if (selectable > 0 && selectable != interactable)
emitWarning("Actor {0} defines both Interactable and Selectable traits. This may cause unexpected results.".F(actorInfo.Value.Name));
emitWarning($"Actor {actorInfo.Value.Name} defines both Interactable and Selectable traits. This may cause unexpected results.");
}
}
}

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Lint
continue;
if (!cursors.Contains(cursor))
emitError("Undefined cursor {0} for actor {1} with trait {2}.".F(cursor, actorInfo.Value.Name, traitInfo));
emitError($"Undefined cursor {cursor} for actor {actorInfo.Value.Name} with trait {traitInfo}.");
}
}
}

View File

@@ -36,9 +36,9 @@ namespace OpenRA.Mods.Common.Lint
var count = actorInfo.Value.TraitInfos<IDefaultVisibilityInfo>().Count();
if (count == 0)
emitError("Actor type `{0}` does not define a default visibility type!".F(actorInfo.Key));
emitError($"Actor type `{actorInfo.Key}` does not define a default visibility type!");
else if (count > 1)
emitError("Actor type `{0}` defines multiple default visibility types!".F(actorInfo.Key));
emitError($"Actor type `{actorInfo.Key}` defines multiple default visibility types!");
else
{
var vis = actorInfo.Value.TraitInfoOrDefault<HiddenUnderShroudInfo>();
@@ -46,9 +46,9 @@ namespace OpenRA.Mods.Common.Lint
{
var ios = actorInfo.Value.TraitInfoOrDefault<IOccupySpaceInfo>();
if (ios == null)
emitError("Actor type `{0}` defines VisibilityType.Footprint in `{1}` but has no IOccupySpace traits!".F(actorInfo.Key, vis.GetType()));
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{vis.GetType()}` but has no IOccupySpace traits!");
else if (!ios.OccupiedCells(actorInfo.Value, CPos.Zero).Any())
emitError("Actor type `{0}` defines VisibilityType.Footprint in `{1}` but does not have any footprint cells!".F(actorInfo.Key, vis.GetType()));
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{vis.GetType()}` but does not have any footprint cells!");
}
}
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Lint
var hitShapes = actorInfo.Value.TraitInfos<HitShapeInfo>();
if (!hitShapes.Any())
emitError("Actor type `{0}` has a Health trait but no HitShape trait!".F(actorInfo.Key));
emitError($"Actor type `{actorInfo.Key}` has a Health trait but no HitShape trait!");
}
}
}

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var li in locomotorInfos)
foreach (var otherLocomotor in locomotorInfos)
if (li != otherLocomotor && li.Name == otherLocomotor.Name)
emitError("There is more than one Locomotor with name {0}!".F(li.Name));
emitError($"There is more than one Locomotor with name {li.Name}!");
foreach (var actorInfo in rules.Actors)
{
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Lint
void CheckLocomotors(ActorInfo actorInfo, Action<string> emitError, Ruleset rules, LocomotorInfo[] locomotorInfos, string locomotor)
{
if (!locomotorInfos.Any(l => l.Name == locomotor))
emitError("Actor {0} defines Locomotor {1} not found on World actor.".F(actorInfo.Name, locomotor));
emitError($"Actor {actorInfo.Name} defines Locomotor {locomotor} not found on World actor.");
}
}
}

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Lint
void Run(Action<string> emitError, int mapFormat, string author, string title, string[] categories)
{
if (mapFormat != Map.SupportedMapFormat)
emitError("Map format {0} does not match the supported version {1}.".F(mapFormat, Map.SupportedMapFormat));
emitError($"Map format {mapFormat} does not match the supported version {Map.SupportedMapFormat}.");
if (author == null)
emitError("Map does not define a valid author.");

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Lint
public void Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Map map)
{
foreach (var kv in map.ReplacedInvalidTerrainTiles)
emitError("Cell {0} references invalid terrain tile {1}.".F(kv.Key, kv.Value));
emitError($"Cell {kv.Key} references invalid terrain tile {kv.Value}.");
}
}
}

View File

@@ -56,8 +56,7 @@ namespace OpenRA.Mods.Common.Lint
if (string.IsNullOrEmpty(type) || !rules.Notifications.TryGetValue(type.ToLowerInvariant(), out var soundInfo) ||
!soundInfo.Notifications.ContainsKey(notification))
emitError("Undefined notification reference {0}.{1} detected at {2} for {3}".F(
type ?? "(null)", notification, traitInfo.GetType().Name, actorInfo.Key));
emitError($"Undefined notification reference {type ?? "(null)"}.{notification} detected at {traitInfo.GetType().Name} for {actorInfo.Key}");
}
}
}

View File

@@ -35,16 +35,16 @@ namespace OpenRA.Mods.Common.Lint
var actorReference = new ActorReference(kv.Value.Value, kv.Value.ToDictionary());
var ownerInit = actorReference.GetOrDefault<OwnerInit>();
if (ownerInit == null)
emitError("Actor {0} is not owned by any player.".F(kv.Key));
emitError($"Actor {kv.Key} is not owned by any player.");
else
{
var ownerName = ownerInit.InternalName;
if (!playerNames.Contains(ownerName))
emitError("Actor {0} is owned by unknown player {1}.".F(kv.Key, ownerName));
emitError($"Actor {kv.Key} is owned by unknown player {ownerName}.");
if (actorsWithRequiredOwner.TryGetValue(kv.Value.Value, out var info))
if (!info.ValidOwnerNames.Contains(ownerName))
emitError("Actor {0} owner {1} is not one of ValidOwnerNames: {2}".F(kv.Key, ownerName, info.ValidOwnerNames.JoinWith(", ")));
emitError($"Actor {kv.Key} owner {ownerName} is not one of ValidOwnerNames: {info.ValidOwnerNames.JoinWith(", ")}");
}
}
}

View File

@@ -65,12 +65,12 @@ namespace OpenRA.Mods.Common.Lint
if (isPlayerPalette)
{
if (!playerPalettes.Contains(reference))
emitError("Undefined player palette reference {0} detected at {1} for {2}".F(reference, traitInfo, actorInfo.Key));
emitError($"Undefined player palette reference {reference} detected at {traitInfo} for {actorInfo.Key}");
}
else
{
if (!palettes.Contains(reference))
emitError("Undefined palette reference {0} detected at {1} for {2}".F(reference, traitInfo, actorInfo.Key));
emitError($"Undefined palette reference {reference} detected at {traitInfo} for {actorInfo.Key}");
}
}
}
@@ -109,12 +109,12 @@ namespace OpenRA.Mods.Common.Lint
if (isPlayerPalette)
{
if (!playerPalettes.Contains(reference))
emitError("Undefined player palette reference {0} detected at weapon {1}.".F(reference, weaponInfo.Key));
emitError($"Undefined player palette reference {reference} detected at weapon {weaponInfo.Key}.");
}
else
{
if (!palettes.Contains(reference))
emitError("Undefined palette reference {0} detected at weapon {1}.".F(reference, weaponInfo.Key));
emitError($"Undefined palette reference {reference} detected at weapon {weaponInfo.Key}.");
}
}
}

View File

@@ -49,25 +49,25 @@ namespace OpenRA.Mods.Common.Lint
{
foreach (var ally in player.Allies)
if (!playerNames.Contains(ally))
emitError("Allies contains player {0} that is not in list.".F(ally));
emitError($"Allies contains player {ally} that is not in list.");
foreach (var enemy in player.Enemies)
if (!playerNames.Contains(enemy))
emitError("Enemies contains player {0} that is not in list.".F(enemy));
emitError($"Enemies contains player {enemy} that is not in list.");
if (player.OwnsWorld)
{
worldOwnerFound = true;
if (player.Enemies.Any() || player.Allies.Any())
emitWarning("The player {0} owning the world should not have any allies or enemies.".F(player.Name));
emitWarning($"The player {player.Name} owning the world should not have any allies or enemies.");
if (player.Playable)
emitError("The player {0} owning the world can't be playable.".F(player.Name));
emitError($"The player {player.Name} owning the world can't be playable.");
}
else if (visibility == MapVisibility.MissionSelector && player.Playable && !player.LockFaction)
{
// Missions must lock the faction of the player to force the server to override the default Random faction
emitError("The player {0} must specify LockFaction: True.".F(player.Name));
emitError($"The player {player.Name} must specify LockFaction: True.");
}
}
@@ -77,13 +77,13 @@ namespace OpenRA.Mods.Common.Lint
var factions = worldActorInfo.TraitInfos<FactionInfo>().Select(f => f.InternalName).ToHashSet();
foreach (var player in players.Players.Values)
if (!string.IsNullOrWhiteSpace(player.Faction) && !factions.Contains(player.Faction))
emitError("Invalid faction {0} chosen for player {1}.".F(player.Faction, player.Name));
emitError($"Invalid faction {player.Faction} chosen for player {player.Name}.");
if (worldActorInfo.HasTraitInfo<MapStartingLocationsInfo>())
{
var playerCount = players.Players.Count(p => p.Value.Playable);
if (playerCount > spawnPoints.Length)
emitError("The map allows {0} possible players, but defines only {1} spawn points".F(playerCount, spawnPoints.Length));
emitError($"The map allows {playerCount} possible players, but defines only {spawnPoints.Length} spawn points");
if (spawnPoints.Distinct().Count() != spawnPoints.Length)
emitError("Duplicate spawn point locations detected.");

View File

@@ -34,8 +34,7 @@ namespace OpenRA.Mods.Common.Lint
var range = weaponInfo.Value.Range;
if (weaponInfo.Value.Projectile is MissileInfo missile && missile.RangeLimit > WDist.Zero && missile.RangeLimit < range)
emitError("Weapon `{0}`: projectile RangeLimit lower than weapon range!"
.F(weaponInfo.Key));
emitError($"Weapon `{weaponInfo.Key}`: projectile RangeLimit lower than weapon range!");
}
}
}

View File

@@ -40,9 +40,9 @@ namespace OpenRA.Mods.Common.Lint
continue;
if (ios == null)
emitError("Actor type `{0}` defines VisibilityType.Footprint in `{1}` but has no IOccupySpace traits!".F(actorInfo.Key, rsi.GetType()));
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{rsi.GetType()}` but has no IOccupySpace traits!");
else if (!ios.OccupiedCells(actorInfo.Value, CPos.Zero).Any())
emitError("Actor type `{0}` defines VisibilityType.Footprint in `{1}` but does not have any footprint cells!".F(actorInfo.Key, rsi.GetType()));
emitError($"Actor type `{actorInfo.Key}` defines VisibilityType.Footprint in `{rsi.GetType()}` but does not have any footprint cells!");
}
}
}

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Lint
if (string.IsNullOrEmpty(imageOverride))
{
if (!sequenceReference.AllowNullImage)
emitError("Actor type `{0}` trait `{1}` must define a value for `{2}`".F(actorInfo.Value.Name, traitName, sequenceReference.ImageReference));
emitError($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` must define a value for `{sequenceReference.ImageReference}`");
continue;
}
@@ -95,10 +95,10 @@ namespace OpenRA.Mods.Common.Lint
{
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence)))
emitWarning("Actor type `{0}` trait `{1}` field `{2}` defines a prefix `{3}` that does not match any sequences on image `{4}`.".F(actorInfo.Value.Name, traitName, field.Name, sequence, i));
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
}
else if (!sequences.HasSequence(i, sequence))
emitError("Actor type `{0}` trait `{1}` field `{2}` references an undefined sequence `{3}` on image `{4}`.".F(actorInfo.Value.Name, traitName, field.Name, sequence, i));
emitError($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` references an undefined sequence `{sequence}` on image `{i}`.");
}
}
}
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Lint
if (string.IsNullOrEmpty(image))
{
if (!sequenceReference.AllowNullImage)
emitError("Weapon type `{0}` projectile field `{1}` must define a value".F(weaponInfo.Key, sequenceReference.ImageReference));
emitError($"Weapon type `{weaponInfo.Key}` projectile field `{sequenceReference.ImageReference}` must define a value");
continue;
}
@@ -138,10 +138,10 @@ namespace OpenRA.Mods.Common.Lint
{
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references
if (!sequences.Sequences(image).Any(s => s.StartsWith(sequence)))
emitWarning("Weapon type `{0}` projectile field `{1}` defines a prefix `{2}` that does not match any sequences on image `{3}`.".F(weaponInfo.Key, field.Name, sequence, image));
emitWarning($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{image}`.");
}
else if (!sequences.HasSequence(image, sequence))
emitError("Weapon type `{0}` projectile field `{1}` references an undefined sequence `{2}` on image `{3}`.".F(weaponInfo.Key, field.Name, sequence, image));
emitError($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` references an undefined sequence `{sequence}` on image `{image}`.");
}
}
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Lint
var wsbs = actorInfo.Value.TraitInfos<WithSpriteBodyInfo>();
foreach (var wsb in wsbs)
if (wsbs.Any(w => w != wsb && w.Name == wsb.Name))
emitError("Actor type `{0}` has more than one *SpriteBody with Name: {1}!".F(actorInfo.Key, wsb.Name));
emitError($"Actor type `{actorInfo.Key}` has more than one *SpriteBody with Name: {wsb.Name}!");
}
}
}

View File

@@ -49,14 +49,14 @@ namespace OpenRA.Mods.Common.Lint
{
foreach (var type in types)
if (!TypeImplementsSync(type) && AnyTypeMemberIsSynced(type))
emitWarning("{0} has members with the Sync attribute but does not implement ISync".F(type.FullName));
emitWarning($"{type.FullName} has members with the Sync attribute but does not implement ISync");
}
static void CheckTypesImplementingSyncInterfaceHaveSyncableMembers(IEnumerable<Type> types, Action<string> emitWarning)
{
foreach (var type in types)
if (TypeImplementsSync(type) && !AnyTypeMemberIsSynced(type))
emitWarning("{0} implements ISync but does not use the Sync attribute on any members.".F(type.FullName));
emitWarning($"{type.FullName} implements ISync but does not use the Sync attribute on any members.");
}
}
}

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Lint
var traitName = traitInfo.GetType().Name;
traitName = traitName.Remove(traitName.Length - 4);
var locations = traitLocation.SystemActors.ToString().Replace(", ", " or ");
emitError("{0} does not belong on {1}. It is a system trait meant for {2}.".F(traitName, actorInfo.Key, locations));
emitError($"{traitName} does not belong on {actorInfo.Key}. It is a system trait meant for {locations}.");
}
}
}

View File

@@ -35,11 +35,11 @@ namespace OpenRA.Mods.Common.Lint
{
var hasTraits = actorInfo.Value.TraitsInConstructOrder().Any();
if (!hasTraits)
emitWarning("Actor {0} has no traits. Is this intended?".F(actorInfo.Key));
emitWarning($"Actor {actorInfo.Key} has no traits. Is this intended?");
}
catch (Exception e)
{
emitError("Actor {0} is not constructible; failure: {1}".F(actorInfo.Key, e.Message));
emitError($"Actor {actorInfo.Key} is not constructible; failure: {e.Message}");
}
}
}

View File

@@ -54,10 +54,10 @@ namespace OpenRA.Mods.Common.Lint
if (t.Key.StartsWith("-", StringComparison.Ordinal))
{
if (t.Value.Nodes.Any())
emitError("{0} {1} defines child nodes, which are not valid for removals.".F(t.Location, t.Key));
emitError($"{t.Location} {t.Key} defines child nodes, which are not valid for removals.");
if (!string.IsNullOrEmpty(t.Value.Value))
emitError("{0} {1} defines a value, which is not valid for removals.".F(t.Location, t.Key));
emitError($"{t.Location} {t.Key} defines a value, which is not valid for removals.");
continue;
}
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Lint
// Inherits can never define children
if (traitName == "Inherits" && t.Value.Nodes.Any())
{
emitError("{0} defines child nodes, which are not valid for Inherits.".F(t.Location));
emitError($"{t.Location} defines child nodes, which are not valid for Inherits.");
continue;
}
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Lint
{
var fieldName = NormalizeName(field.Key);
if (traitInfo.GetField(fieldName) == null)
emitError("{0} refers to a trait field `{1}` that does not exist on `{2}`.".F(field.Location, fieldName, traitName));
emitError($"{field.Location} refers to a trait field `{fieldName}` that does not exist on `{traitName}`.");
}
}
}

View File

@@ -56,10 +56,10 @@ namespace OpenRA.Mods.Common.Lint
if (field.Key.StartsWith("-", StringComparison.Ordinal))
{
if (field.Value.Nodes.Any())
emitError("{0} {1} defines child nodes, which is not valid for removals.".F(field.Location, field.Key));
emitError($"{field.Location} {field.Key} defines child nodes, which is not valid for removals.");
if (!string.IsNullOrEmpty(field.Value.Value))
emitError("{0} {1} defines a value, which is not valid for removals.".F(field.Location, field.Key));
emitError($"{field.Location} {field.Key} defines a value, which is not valid for removals.");
continue;
}
@@ -73,14 +73,14 @@ namespace OpenRA.Mods.Common.Lint
{
var projectileFieldName = NormalizeName(projectileField.Key);
if (projectileInfo.GetField(projectileFieldName) == null)
emitError("{0} refers to a projectile field `{1}` that does not exist on `{2}`.".F(projectileField.Location, projectileFieldName, projectileName));
emitError($"{projectileField.Location} refers to a projectile field `{projectileFieldName}` that does not exist on `{projectileName}`.");
}
}
else if (fieldName == "Warhead")
{
if (string.IsNullOrEmpty(field.Value.Value))
{
emitWarning("{0} does not define a warhead type. Skipping unknown field check.".F(field.Location));
emitWarning($"{field.Location} does not define a warhead type. Skipping unknown field check.");
continue;
}
@@ -90,11 +90,11 @@ namespace OpenRA.Mods.Common.Lint
{
var warheadFieldName = NormalizeName(warheadField.Key);
if (warheadInfo.GetField(warheadFieldName) == null)
emitError("{0} refers to a warhead field `{1}` that does not exist on `{2}`.".F(warheadField.Location, warheadFieldName, warheadName));
emitError($"{warheadField.Location} refers to a warhead field `{warheadFieldName}` that does not exist on `{warheadName}`.");
}
}
else if (fieldName != "Inherits" && weaponInfo.GetField(fieldName) == null)
emitError("{0} refers to a weapon field `{1}` that does not exist.".F(field.Location, fieldName));
emitError($"{field.Location} refers to a weapon field `{fieldName}` that does not exist.");
}
}
}

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Lint
continue;
if (!soundInfo.Voices.Keys.Contains(voice))
emitError("Actor {0} using voice set {1} does not define {2} voice required by {3}.".F(actorInfo.Name, voiceSet, voice, traitInfo));
emitError($"Actor {actorInfo.Name} using voice set {voiceSet} does not define {voice} voice required by {traitInfo}.");
}
}
}

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var inherit in inherits)
{
if (inherit[0] != '^')
emitError("{0} definition inherits from {1}, which is not an abstract template.".F(actor, inherit));
emitError($"{actor} definition inherits from {inherit}, which is not an abstract template.");
toResolve.Enqueue(inherit);
}

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var prereq in bi.Prerequisites)
if (!prereq.StartsWith("~disabled"))
if (!providedPrereqs.Contains(prereq.Replace("!", "").Replace("~", "")))
emitError("Buildable actor {0} has prereq {1} not provided by anything.".F(i.Key, prereq));
emitError($"Buildable actor {i.Key} has prereq {prereq} not provided by anything.");
}
}
}

View File

@@ -63,8 +63,7 @@ namespace OpenRA.Mods.Common.Lint
"BooleanExpression", "IntegerExpression"
};
throw new InvalidOperationException("Bad type for reference on {0}.{1}. Supported types: {2}"
.F(ruleInfo.GetType().Name, fieldInfo.Name, supportedTypes.JoinWith(", ")));
throw new InvalidOperationException($"Bad type for reference on {ruleInfo.GetType().Name}.{fieldInfo.Name}. Supported types: {supportedTypes.JoinWith(", ")}");
}
public static IEnumerable<string> GetPropertyValues(object ruleInfo, PropertyInfo propertyInfo, Action<string> emitError,
@@ -109,8 +108,7 @@ namespace OpenRA.Mods.Common.Lint
"BooleanExpression", "IntegerExpression"
};
throw new InvalidOperationException("Bad type for reference on {0}.{1}. Supported types: {2}"
.F(ruleInfo.GetType().Name, propertyInfo.Name, supportedTypes.JoinWith(", ")));
throw new InvalidOperationException($"Bad type for reference on {ruleInfo.GetType().Name}.{propertyInfo.Name}. Supported types: {supportedTypes.JoinWith(", ")}");
}
}
}

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.LoadScreens
if (!string.IsNullOrEmpty(Launch.Benchmark))
{
Console.WriteLine("Saving benchmark data into {0}".F(Path.Combine(Platform.SupportDir, "Logs")));
Console.WriteLine($"Saving benchmark data into {Path.Combine(Platform.SupportDir, "Logs")}");
Game.BenchmarkMode(Launch.Benchmark);
}

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
var initInstance = initName.Split(ActorInfo.TraitInstanceSeparator);
var initType = Game.ModData.ObjectCreator.FindType(initInstance[0] + "Init");
if (initType == null)
throw new LuaException("Unknown initializer type '{0}'".F(initInstance[0]));
throw new LuaException($"Unknown initializer type '{initInstance[0]}'");
// Construct the ActorInit.
var init = (ActorInit)FormatterServices.GetUninitializedObject(initType);
@@ -51,14 +51,14 @@ namespace OpenRA.Mods.Common.Scripting
{
var key = kv.Key.ToString();
if (!args.TryGetValue(key, out var type))
throw new LuaException("Unknown initializer type '{0}.{1}'".F(initInstance[0], key));
throw new LuaException($"Unknown initializer type '{initInstance[0]}.{key}'");
var isActorReference = type == typeof(ActorInitActorReference);
if (isActorReference)
type = kv.Value is LuaString ? typeof(string) : typeof(Actor);
if (!kv.Value.TryGetClrValue(type, out var clrValue))
throw new LuaException("Invalid data type for '{0}.{1}' (expected {2}, got {3})".F(initInstance[0], key, type.Name, kv.Value.WrappedClrType()));
throw new LuaException($"Invalid data type for '{initInstance[0]}.{key}' (expected {type.Name}, got {kv.Value.WrappedClrType()})");
if (isActorReference)
clrValue = type == typeof(string) ? new ActorInitActorReference((string)clrValue) : new ActorInitActorReference((Actor)clrValue);
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Scripting
}
var types = initializers.Select(y => y.GetParameters()[0].ParameterType.Name).JoinWith(", ");
throw new LuaException("Invalid data type for '{0}' (expected one of {1})".F(initInstance[0], types));
throw new LuaException($"Invalid data type for '{initInstance[0]}' (expected one of {types})");
}
[Desc("Create a new actor. initTable specifies a list of key-value pairs that defines the initial parameters for the actor's traits.")]
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Scripting
var owner = initDict.GetOrDefault<OwnerInit>();
if (owner == null)
throw new LuaException("Tried to create actor '{0}' with an invalid or no owner init!".F(type));
throw new LuaException($"Tried to create actor '{type}' with an invalid or no owner init!");
// The actor must be added to the world at the end of the tick
var a = Context.World.CreateActor(false, type, initDict);
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Scripting
public int BuildTime(string type, string queue = null)
{
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out var ai))
throw new LuaException("Unknown actor type '{0}'".F(type));
throw new LuaException($"Unknown actor type '{type}'");
var bi = ai.TraitInfoOrDefault<BuildableInfo>();
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Scripting
.Where(x => x.Type == queue)).FirstOrDefault();
if (pqueue == null)
throw new LuaException("The specified queue '{0}' does not exist!".F(queue));
throw new LuaException($"The specified queue '{queue}' does not exist!");
pbi = pqueue.BuildDurationModifier;
}
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Scripting
.Where(x => bi.Queue.Contains(x.Type))).FirstOrDefault();
if (pqueue == null)
throw new LuaException("No actors can produce actor '{0}'!".F(type));
throw new LuaException($"No actors can produce actor '{type}'!");
pbi = pqueue.BuildDurationModifier;
}
@@ -180,7 +180,7 @@ namespace OpenRA.Mods.Common.Scripting
public int CruiseAltitude(string type)
{
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out var ai))
throw new LuaException("Unknown actor type '{0}'".F(type));
throw new LuaException($"Unknown actor type '{type}'");
var pi = ai.TraitInfoOrDefault<ICruiseAltitudeInfo>();
return pi != null ? pi.GetCruiseAltitude().Length : 0;
@@ -189,11 +189,11 @@ namespace OpenRA.Mods.Common.Scripting
public int Cost(string type)
{
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out var ai))
throw new LuaException("Unknown actor type '{0}'".F(type));
throw new LuaException($"Unknown actor type '{type}'");
var vi = ai.TraitInfoOrDefault<ValuedInfo>();
if (vi == null)
throw new LuaException("Actor type '{0}' does not have the Valued trait required to get the Cost.".F(type));
throw new LuaException($"Actor type '{type}' does not have the Valued trait required to get the Cost.");
return vi.Cost;
}

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Scripting
Actor CreateActor(Player owner, string actorType, bool addToWorld, CPos? entryLocation = null, CPos? nextLocation = null)
{
if (!Context.World.Map.Rules.Actors.TryGetValue(actorType, out var ai))
throw new LuaException("Unknown actor type '{0}'".F(actorType));
throw new LuaException($"Unknown actor type '{actorType}'");
var initDict = new TypeDictionary();

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Scripting
{
var events = a.TraitOrDefault<ScriptTriggers>();
if (events == null)
throw new LuaException("Actor '{0}' requires the ScriptTriggers trait before attaching a trigger".F(a.Info.Name));
throw new LuaException($"Actor '{a.Info.Name}' requires the ScriptTriggers trait before attaching a trigger");
return events;
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Scripting
{
var pool = ammoPools.FirstOrDefault(a => a.Info.Name == poolName);
if (pool == null)
throw new LuaException("Invalid ammopool name {0} queried on actor {1}.".F(poolName, self));
throw new LuaException($"Invalid ammopool name {poolName} queried on actor {self}.");
return pool.CurrentAmmoCount;
}
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Scripting
{
var pool = ammoPools.FirstOrDefault(a => a.Info.Name == poolName);
if (pool == null)
throw new LuaException("Invalid ammopool name {0} queried on actor {1}.".F(poolName, self));
throw new LuaException($"Invalid ammopool name {poolName} queried on actor {self}.");
return pool.Info.Ammo;
}
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Scripting
{
var pool = ammoPools.FirstOrDefault(a => a.Info.Name == poolName);
if (pool == null)
throw new LuaException("Invalid ammopool name {0} queried on actor {1}.".F(poolName, self));
throw new LuaException($"Invalid ammopool name {poolName} queried on actor {self}.");
if (amount > 0)
pool.GiveAmmo(self, amount);

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
{
var targetManager = target.TraitOrDefault<CaptureManager>();
if (targetManager == null || !targetManager.CanBeTargetedBy(target, Self, captureManager))
throw new LuaException("Actor '{0}' cannot capture actor '{1}'!".F(Self, target));
throw new LuaException($"Actor '{Self}' cannot capture actor '{target}'!");
// NB: Scripted actions get no visible targetlines.
Self.QueueActivity(new CaptureActor(Self, Target.FromActor(target), null));

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Scripting
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(Self, this));
if (external == null)
throw new LuaException("Condition `{0}` has not been listed on an enabled ExternalCondition trait".F(condition));
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");
return external.GrantCondition(Self, this, duration);
}

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Scripting
{
var targetGainsExperience = target.TraitOrDefault<GainsExperience>();
if (targetGainsExperience == null)
throw new LuaException("Actor '{0}' cannot gain experience!".F(target));
throw new LuaException($"Actor '{target}' cannot gain experience!");
if (targetGainsExperience.Level == targetGainsExperience.MaxLevel)
return;

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Scripting
set
{
if (value == null)
throw new LuaException("Attempted to change the owner of actor '{0}' to nil value.".F(Self));
throw new LuaException($"Attempted to change the owner of actor '{Self}' to nil value.");
if (Self.Owner != value)
Self.ChangeOwner(value);
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Scripting
get
{
if (facing == null)
throw new LuaException("Actor '{0}' doesn't define a facing".F(Self));
throw new LuaException($"Actor '{Self}' doesn't define a facing");
return facing.Facing;
}
@@ -172,7 +172,7 @@ namespace OpenRA.Mods.Common.Scripting
return;
if (!Enum<UnitStance>.TryParse(value, true, out var stance))
throw new LuaException("Unknown stance type '{0}'".F(value));
throw new LuaException($"Unknown stance type '{value}'");
autotarget.PredictedStance = stance;
autotarget.SetStance(Self, stance);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Scripting
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(Player.PlayerActor, this));
if (external == null)
throw new LuaException("Condition `{0}` has not been listed on an enabled ExternalCondition trait".F(condition));
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");
return external.GrantCondition(Player.PlayerActor, this, duration);
}

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Scripting
var result = new List<Actor>();
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out var ai))
throw new LuaException("Unknown actor type '{0}'".F(type));
throw new LuaException($"Unknown actor type '{type}'");
result.AddRange(Player.World.Actors
.Where(actor => actor.Owner == Player && !actor.IsDead && actor.IsInWorld && actor.Info.Name == ai.Name));
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Scripting
foreach (var type in types)
if (!Context.World.Map.Rules.Actors.ContainsKey(type))
throw new LuaException("Unknown actor type '{0}'".F(type));
throw new LuaException($"Unknown actor type '{type}'");
result.AddRange(Player.World.Actors
.Where(actor => actor.Owner == Player && !actor.IsDead && actor.IsInWorld && types.Contains(actor.Info.Name)));
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Scripting
{
var tt = Player.PlayerActor.TraitOrDefault<TechTree>();
if (tt == null)
throw new LuaException("Missing TechTree trait on player {0}!".F(Player));
throw new LuaException($"Missing TechTree trait on player {Player}!");
return tt.HasPrerequisites(type);
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Scripting
public void Produce(string actorType, string factionVariant = null, string productionType = null)
{
if (!Self.World.Map.Rules.Actors.TryGetValue(actorType, out var actorInfo))
throw new LuaException("Unknown actor type '{0}'".F(actorType));
throw new LuaException($"Unknown actor type '{actorType}'");
var bi = actorInfo.TraitInfo<BuildableInfo>();
Self.QueueActivity(new WaitFor(() =>
@@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Scripting
var bi = ri.TraitInfoOrDefault<BuildableInfo>();
if (bi == null)
throw new LuaException("Actor of type {0} cannot be produced".F(actorType));
throw new LuaException($"Actor of type {actorType} cannot be produced");
else
return bi;
}
@@ -304,7 +304,7 @@ namespace OpenRA.Mods.Common.Scripting
var bi = ri.TraitInfoOrDefault<BuildableInfo>();
if (bi == null)
throw new LuaException("Actor of type {0} cannot be produced".F(actorType));
throw new LuaException($"Actor of type {actorType} cannot be produced");
else
return bi;
}

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Server
if (server.State == ServerState.GameStarted)
{
server.SendOrderTo(conn, "Message", "Cannot change state when game started. ({0})".F(cmd));
server.SendOrderTo(conn, "Message", $"Cannot change state when game started. ({cmd})");
return false;
}
else if (client.State == Session.ClientState.Ready && !(cmd.StartsWith("state") || cmd == "startgame"))
@@ -491,7 +491,7 @@ namespace OpenRA.Mods.Common.Server
server.SyncLobbyInfo();
server.SendMessage("{0} changed the map to {1}.".F(client.Name, server.Map.Title));
server.SendMessage($"{client.Name} changed the map to {server.Map.Title}.");
if ((server.LobbyInfo.GlobalSettings.MapStatus & Session.MapStatus.UnsafeCustomRules) != 0)
server.SendMessage("This map contains custom rules. Game experience may change.");
@@ -554,7 +554,7 @@ namespace OpenRA.Mods.Common.Server
if (option.IsLocked)
{
server.SendOrderTo(conn, "Message", "{0} cannot be changed.".F(option.Name));
server.SendOrderTo(conn, "Message", $"{option.Name} cannot be changed.");
return true;
}
@@ -588,7 +588,7 @@ namespace OpenRA.Mods.Common.Server
if (!Exts.TryParseIntegerInvariant(s, out var teamCount))
{
server.SendOrderTo(conn, "Message", "Number of teams could not be parsed: {0}".F(s));
server.SendOrderTo(conn, "Message", $"Number of teams could not be parsed: {s}");
return true;
}
@@ -653,7 +653,7 @@ namespace OpenRA.Mods.Common.Server
}
Log.Write("server", "Kicking client {0}.", kickClientID);
server.SendMessage("{0} kicked {1} from the server.".F(client.Name, kickClient.Name));
server.SendMessage($"{client.Name} kicked {kickClient.Name} from the server.");
server.SendOrderTo(kickConn, "ServerError", "You have been kicked from the server.");
server.DropClient(kickConn);
@@ -661,7 +661,7 @@ namespace OpenRA.Mods.Common.Server
if (tempBan)
{
Log.Write("server", "Temporarily banning client {0} ({1}).", kickClientID, kickClient.IPAddress);
server.SendMessage("{0} temporarily banned {1} from the server.".F(client.Name, kickClient.Name));
server.SendMessage($"{client.Name} temporarily banned {kickClient.Name} from the server.");
server.TempBans.Add(kickClient.IPAddress);
}
@@ -701,8 +701,8 @@ namespace OpenRA.Mods.Common.Server
foreach (var b in bots)
b.BotControllerClientIndex = newAdminId;
server.SendMessage("{0} is now the admin.".F(newAdminClient.Name));
Log.Write("server", "{0} is now the admin.".F(newAdminClient.Name));
server.SendMessage($"{newAdminClient.Name} is now the admin.");
Log.Write("server", $"{newAdminClient.Name} is now the admin.");
server.SyncLobbyClients();
return true;
@@ -735,8 +735,8 @@ namespace OpenRA.Mods.Common.Server
targetClient.Handicap = 0;
targetClient.Color = Color.White;
targetClient.State = Session.ClientState.NotReady;
server.SendMessage("{0} moved {1} to spectators.".F(client.Name, targetClient.Name));
Log.Write("server", "{0} moved {1} to spectators.".F(client.Name, targetClient.Name));
server.SendMessage($"{client.Name} moved {targetClient.Name} to spectators.");
Log.Write("server", $"{client.Name} moved {targetClient.Name} to spectators.");
server.SyncLobbyClients();
CheckAutoStart(server);
@@ -753,7 +753,7 @@ namespace OpenRA.Mods.Common.Server
return true;
Log.Write("server", "Player@{0} is now known as {1}.", conn.Socket.RemoteEndPoint, sanitizedName);
server.SendMessage("{0} is now known as {1}.".F(client.Name, sanitizedName));
server.SendMessage($"{client.Name} is now known as {sanitizedName}.");
client.Name = sanitizedName;
server.SyncLobbyClients();
@@ -781,8 +781,8 @@ namespace OpenRA.Mods.Common.Server
if (!factions.Contains(parts[1]))
{
server.SendOrderTo(conn, "Message", "Invalid faction selected: {0}".F(parts[1]));
server.SendOrderTo(conn, "Message", "Supported values: {0}".F(factions.JoinWith(", ")));
server.SendOrderTo(conn, "Message", $"Invalid faction selected: {parts[1]}");
server.SendOrderTo(conn, "Message", $"Supported values: {factions.JoinWith(", ")}");
return true;
}
@@ -1012,7 +1012,7 @@ namespace OpenRA.Mods.Common.Server
var uid = server.LobbyInfo.GlobalSettings.Map;
server.Map = server.ModData.MapCache[uid];
if (server.Map.Status != MapStatus.Available)
throw new InvalidOperationException("Map {0} not found".F(uid));
throw new InvalidOperationException($"Map {uid} not found");
server.LobbyInfo.Slots = server.Map.Players.Players
.Select(p => MakeSlotFromPlayerReference(p.Value))

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Server
var client = server.GetClient(c);
if (client != null)
server.SendMessage("{0} will be dropped in {1} seconds.".F(client.Name, (ConnTimeout - c.TimeSinceLastResponse) / 1000));
server.SendMessage($"{client.Name} will be dropped in {(ConnTimeout - c.TimeSinceLastResponse) / 1000} seconds.");
}
}
}

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
// SpriteFrameType refers to the channel byte order, which is reversed from the little-endian bit order
case ImageFormat.Rgba32: Type = SpriteFrameType.Bgra32; break;
case ImageFormat.Rgb24: Type = SpriteFrameType.Bgr24; break;
default: throw new InvalidDataException("Unhandled ImageFormat {0}".F(dds.Format));
default: throw new InvalidDataException($"Unhandled ImageFormat {dds.Format}");
}
}
}

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
var coords = frame.Split(';');
var region = FieldLoader.GetValue<Rectangle>("Region", coords[0]);
if (!pngRectangle.Contains(region))
throw new InvalidDataException("Invalid frame regions {0} defined.".F(region));
throw new InvalidDataException($"Invalid frame regions {region} defined.");
regions.Add(region);
offsets.Add(FieldLoader.GetValue<float2>("Offset", coords[1]));
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
var rows = (frameAmount + framesPerRow - 1) / framesPerRow;
if (png.Width < frameSize.Width * frameAmount / rows || png.Height < frameSize.Height * rows)
throw new InvalidDataException("Invalid frame size {0} and frame amount {1} defined.".F(frameSize, frameAmount));
throw new InvalidDataException($"Invalid frame size {frameSize} and frame amount {frameAmount} defined.");
regions = new List<Rectangle>();
offsets = new List<float2>();

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
// SpriteFrameType refers to the channel byte order, which is reversed from the little-endian bit order
case ImageFormat.Rgba32: Type = SpriteFrameType.Bgra32; break;
case ImageFormat.Rgb24: Type = SpriteFrameType.Bgr24; break;
default: throw new InvalidDataException("Unhandled ImageFormat {0}".F(tga.Format));
default: throw new InvalidDataException($"Unhandled ImageFormat {tga.Format}");
}
}
}

View File

@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Terrain
var tt = TerrainInfo[i].Type;
if (terrainIndexByType.ContainsKey(tt))
throw new YamlException("Duplicate terrain type '{0}' in '{1}'.".F(tt, filepath));
throw new YamlException($"Duplicate terrain type '{tt}' in '{filepath}'.");
terrainIndexByType.Add(tt, i);
}
@@ -125,7 +125,7 @@ namespace OpenRA.Mods.Common.Terrain
if (terrainIndexByType.TryGetValue(type, out var index))
return index;
throw new InvalidDataException("Tileset '{0}' lacks terrain type '{1}'".F(Id, type));
throw new InvalidDataException($"Tileset '{Id}' lacks terrain type '{type}'");
}
public byte GetTerrainIndex(TerrainTile r)

View File

@@ -99,8 +99,7 @@ namespace OpenRA.Mods.Common.Terrain
var start = indices.Min();
var end = indices.Max();
if (start < 0 || end >= frameCount)
throw new YamlException("Template `{0}` uses frames [{1}..{2}] of {3}, but only [0..{4}] actually exist"
.F(t.Key, start, end, i, frameCount - 1));
throw new YamlException($"Template `{t.Key}` uses frames [{start}..{end}] of {i}, but only [0..{frameCount - 1}] actually exist");
variants.Add(indices.Select(j =>
{

View File

@@ -45,10 +45,10 @@ namespace OpenRA.Mods.Common.Terrain
foreach (var node in nodes)
{
if (!int.TryParse(node.Key, out var key))
throw new YamlException("Tileset `{0}` template `{1}` defines a frame `{2}` that is not a valid integer.".F(terrainInfo.Id, Id, node.Key));
throw new YamlException($"Tileset `{terrainInfo.Id}` template `{Id}` defines a frame `{node.Key}` that is not a valid integer.");
if (key < 0 || key >= tileInfo.Length)
throw new YamlException("Tileset `{0}` template `{1}` references frame {2}, but only [0..{3}] are valid for a {4}x{5} Size template.".F(terrainInfo.Id, Id, key, tileInfo.Length - 1, Size.X, Size.Y));
throw new YamlException($"Tileset `{terrainInfo.Id}` template `{Id}` references frame {key}, but only [0..{tileInfo.Length - 1}] are valid for a {Size.X}x{Size.Y} Size template.");
tileInfo[key] = LoadTileInfo(terrainInfo, node.Value);
}
@@ -61,10 +61,10 @@ namespace OpenRA.Mods.Common.Terrain
foreach (var node in nodes)
{
if (!int.TryParse(node.Key, out var key))
throw new YamlException("Tileset `{0}` template `{1}` defines a frame `{2}` that is not a valid integer.".F(terrainInfo.Id, Id, node.Key));
throw new YamlException($"Tileset `{terrainInfo.Id}` template `{Id}` defines a frame `{node.Key}` that is not a valid integer.");
if (key != i++)
throw new YamlException("Tileset `{0}` template `{1}` is missing a definition for frame {2}.".F(terrainInfo.Id, Id, i - 1));
throw new YamlException($"Tileset `{terrainInfo.Id}` template `{Id}` is missing a definition for frame {i - 1}.");
tileInfo[key] = LoadTileInfo(terrainInfo, node.Value);
}

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
var weaponToLower = Explosion.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
ExplosionWeapon = weapon;
}

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits
{
var weaponToLower = Weapon.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weaponInfo))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
WeaponInfo = weaponInfo;
ModifiedRange = new WDist(Util.ApplyPercentageModifiers(
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
ai.TraitInfos<IRangeModifierInfo>().Select(m => m.GetRangeModifierDefault())));
if (WeaponInfo.Burst > 1 && WeaponInfo.BurstDelays.Length > 1 && (WeaponInfo.BurstDelays.Length != WeaponInfo.Burst - 1))
throw new YamlException("Weapon '{0}' has an invalid number of BurstDelays, must be single entry or Burst - 1.".F(weaponToLower));
throw new YamlException($"Weapon '{weaponToLower}' has an invalid number of BurstDelays, must be single entry or Burst - 1.");
base.RulesetLoaded(rules, ai);
}

View File

@@ -166,7 +166,7 @@ namespace OpenRA.Mods.Common.Traits
if (location == null)
{
AIUtils.BotDebug("{0} has nowhere to place {1}".F(player, currentBuilding.Item));
AIUtils.BotDebug($"{player} has nowhere to place {currentBuilding.Item}");
bot.QueueOrder(Order.CancelProduction(queue.Actor, currentBuilding.Item, 1));
failCount += failCount;

View File

@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
// Tell the idle harvester to quit slacking:
var newSafeResourcePatch = FindNextResource(h.Key, h.Value);
AIUtils.BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(h.Key, newSafeResourcePatch));
AIUtils.BotDebug($"AI: Harvester {h.Key} is idle. Ordering to {newSafeResourcePatch} in search for new resources.");
bot.QueueOrder(new Order("Harvest", h.Key, newSafeResourcePatch, false));
}

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
var weaponToLower = DemolishWeapon.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
DemolishWeaponInfo = weapon;
}

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits
{
var fp = footprintYaml.Value.Value;
var dims = dim.X + "x" + dim.Y;
throw new YamlException("Invalid footprint: {0} does not match dimensions {1}".F(fp, dims));
throw new YamlException($"Invalid footprint: {fp} does not match dimensions {dims}");
}
var index = 0;
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
{
var c = footprintChars[index++];
if (!Enum.IsDefined(typeof(FootprintCellType), (FootprintCellType)c))
throw new YamlException("Invalid footprint cell type '{0}'".F(c));
throw new YamlException($"Invalid footprint cell type '{c}'");
ret[new CVec(x, y)] = (FootprintCellType)c;
}

View File

@@ -65,9 +65,9 @@ namespace OpenRA.Mods.Common.Traits
topLeftScreenOffset = -wr.ScreenPxOffset(centerOffset);
var tileset = world.Map.Tileset.ToLowerInvariant();
if (world.Map.Rules.Sequences.HasSequence("overlay", "build-valid-{0}".F(tileset)))
if (world.Map.Rules.Sequences.HasSequence("overlay", $"build-valid-{tileset}"))
{
var validSequence = world.Map.Rules.Sequences.GetSequence("overlay", "build-valid-{0}".F(tileset));
var validSequence = world.Map.Rules.Sequences.GetSequence("overlay", $"build-valid-{tileset}");
validTile = validSequence.GetSprite(0);
validAlpha = validSequence.GetAlpha(0);
}

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
{
var weaponToLower = (DemolishWeapon ?? string.Empty).ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
DemolishWeaponInfo = weapon;
}

View File

@@ -61,8 +61,7 @@ namespace OpenRA.Mods.Common.Traits
{
if (Game.IsCurrentWorld(self.World))
throw new InvalidOperationException(
"Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})".F(
forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID));
$"Attempted to finalize an undisposed DisposableAction. {forActor.Info.Name} ({forActor.ActorID}) reserved {self.Info.Name} ({self.ActorID})");
}));
}

View File

@@ -56,9 +56,9 @@ namespace OpenRA.Mods.Common.Traits
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>();
LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor);
if (LocomotorInfo == null)
throw new YamlException("A locomotor named '{0}' doesn't exist.".F(Locomotor));
throw new YamlException($"A locomotor named '{Locomotor}' doesn't exist.");
else if (locomotorInfos.Count(li => li.Name == Locomotor) > 1)
throw new YamlException("There is more than one locomotor named '{0}'.".F(Locomotor));
throw new YamlException($"There is more than one locomotor named '{Locomotor}'.");
base.RulesetLoaded(rules, ai);
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
{
if (ShowTicks && !info.HasTraitInfo<IOccupySpaceInfo>())
throw new YamlException("CashTrickler is defined with ShowTicks 'true' but actor '{0}' occupies no space.".F(info.Name));
throw new YamlException($"CashTrickler is defined with ShowTicks 'true' but actor '{info.Name}' occupies no space.");
}
public override object Create(ActorInitializer init) { return new CashTrickler(this); }

View File

@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits
return;
var maxHP = healthInfo.MaxHP > 0 ? healthInfo.MaxHP : 1;
var damageText = "{0} ({1}%)".F(-e.Damage.Value, e.Damage.Value * 100 / maxHP);
var damageText = $"{-e.Damage.Value} ({e.Damage.Value * 100 / maxHP}%)";
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color, damageText, 30)));
}

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
{
var health = ai.TraitInfo<IHealthInfo>();
if (health.MaxHP < MinHP)
throw new YamlException("Minimum HP ({0}) for GrantConditionOnHealth can't be more than actor's Maximum HP ({1})".F(MinHP, health.MaxHP));
throw new YamlException($"Minimum HP ({MinHP}) for GrantConditionOnHealth can't be more than actor's Maximum HP ({health.MaxHP})");
}
}

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
{
var weaponToLower = Weapon.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
WeaponInfo = weapon;
}
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
{
var emptyWeaponToLower = EmptyWeapon.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(emptyWeaponToLower, out var emptyWeapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(emptyWeaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{emptyWeaponToLower}'");
EmptyWeaponInfo = emptyWeapon;
}

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
var weaponToLower = Weapon.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
WeaponInfo = weapon;
}

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
}
catch (YamlException e)
{
throw new YamlException("HitShape {0}: {1}".F(shape, e.Message));
throw new YamlException($"HitShape {shape}: {e.Message}");
}
}
else

View File

@@ -90,9 +90,9 @@ namespace OpenRA.Mods.Common.Traits
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>();
LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor);
if (LocomotorInfo == null)
throw new YamlException("A locomotor named '{0}' doesn't exist.".F(Locomotor));
throw new YamlException($"A locomotor named '{Locomotor}' doesn't exist.");
else if (locomotorInfos.Count(li => li.Name == Locomotor) > 1)
throw new YamlException("There is more than one locomotor named '{0}'.".F(Locomotor));
throw new YamlException($"There is more than one locomotor named '{Locomotor}'.");
// We need to reset the reference to the locomotor between each worlds, otherwise we are reference the previous state.
locomotor = null;

View File

@@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Traits
var amount = order.ExtraData != 0 ? (int)order.ExtraData : info.Cash;
self.Trait<PlayerResources>().ChangeCash(amount);
debugSuffix = " ({0} credits)".F(amount);
debugSuffix = $" ({amount} credits)";
break;
}
@@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var player in receivingPlayers)
player.PlayerActor.Trait<PlayerResources>().ChangeCash(amount);
debugSuffix = " ({0} credits)".F(amount);
debugSuffix = $" ({amount} credits)";
break;
}

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
if (c == 0)
return "No limit";
else
return c.ToString() + " minute{0}".F(c > 1 ? "s" : null);
return c.ToString() + $" minute{(c > 1 ? "s" : null)}";
});
yield return new LobbyOption("timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder,

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
return forPlayer == self.Owner;
}
public string TooltipText => "Power Usage: {0}{1}".F(powerManager.PowerDrained, developerMode.UnlimitedPower ? "" : "/" + powerManager.PowerProvided);
public string TooltipText => $"Power Usage: {powerManager.PowerDrained}{(developerMode.UnlimitedPower ? "" : "/" + powerManager.PowerProvided)}";
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Render
queue = rules.Actors[SystemActors.Player].TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
if (queue == null)
throw new YamlException("Can't find a queue with ProductionType '{0}'".F(ProductionType));
throw new YamlException($"Can't find a queue with ProductionType '{ProductionType}'");
base.RulesetLoaded(rules, ai);
}

View File

@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits.Render
if (squad == null)
yield break;
var aiSquadInfo = "{0}, {1}".F(squad.Type, squad.TargetActor);
var aiSquadInfo = $"{squad.Type}, {squad.TargetActor}";
yield return new TextAnnotationRenderable(font, self.CenterPosition + offset, 0, color, aiSquadInfo);
}

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (!Game.ModData.Manifest.Get<Fonts>().FontList.ContainsKey(Font))
throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font));
throw new YamlException($"Font '{Font}' is not listed in the mod.yaml's Fonts section");
base.RulesetLoaded(rules, ai);
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits.Render
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
{
if (!Game.ModData.Manifest.Get<Fonts>().FontList.ContainsKey(Font))
throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font));
throw new YamlException($"Font '{Font}' is not listed in the mod.yaml's Fonts section");
}
public override object Create(ActorInitializer init) { return new WithTextControlGroupDecoration(init.Self, this); }

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (!Game.ModData.Manifest.Get<Fonts>().FontList.ContainsKey(Font))
throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font));
throw new YamlException($"Font '{Font}' is not listed in the mod.yaml's Fonts section");
base.RulesetLoaded(rules, ai);
}

View File

@@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Traits
var weaponToLower = (MissileWeapon ?? string.Empty).ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
WeaponInfo = weapon;

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits
var utLower = info.UnitType.ToLowerInvariant();
if (!self.World.Map.Rules.Actors.TryGetValue(utLower, out var unitType))
throw new YamlException("Actors ruleset does not include the entry '{0}'".F(utLower));
throw new YamlException($"Actors ruleset does not include the entry '{utLower}'");
var altitude = unitType.TraitInfo<AircraftInfo>().CruiseAltitude.Length;
var dropRotation = WRot.FromYaw(facing.Value);

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
{
var weaponToLower = w.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
return weapon;
}).ToArray();
}

View File

@@ -45,13 +45,13 @@ namespace OpenRA.Mods.Common.Traits
base.RulesetLoaded(rules, ai);
if (SpawnInterval.Length == 0 || SpawnInterval.Length > 2)
throw new YamlException("{0}.{1} must be either 1 or 2 values".F(nameof(ActorSpawnManager), nameof(SpawnInterval)));
throw new YamlException($"{nameof(ActorSpawnManager)}.{nameof(SpawnInterval)} must be either 1 or 2 values");
if (SpawnInterval.Length == 2 && SpawnInterval[0] >= SpawnInterval[1])
throw new YamlException("{0}.{1}'s first value must be less than the second value".F(nameof(ActorSpawnManager), nameof(SpawnInterval)));
throw new YamlException($"{nameof(ActorSpawnManager)}.{nameof(SpawnInterval)}'s first value must be less than the second value");
if (SpawnInterval.Any(it => it < 0))
throw new YamlException("{0}.{1}'s value(s) must not be less than 0".F(nameof(ActorSpawnManager), nameof(SpawnInterval)));
throw new YamlException($"{nameof(ActorSpawnManager)}.{nameof(SpawnInterval)}'s value(s) must not be less than 0");
}
public override object Create(ActorInitializer init) { return new ActorSpawnManager(init.Self, this); }

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits
}
if (!worldOwnerFound)
throw new InvalidOperationException("Map {0} does not define a player actor owning the world.".F(w.Map.Title));
throw new InvalidOperationException($"Map {w.Map.Title} does not define a player actor owning the world.");
Player localPlayer = null;

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits
domains = new CellLayer<ushort>(world.Map);
transientConnections = new Dictionary<ushort, HashSet<ushort>>();
using (new PerfTimer("BuildDomains: {0} for movement class {1}".F(world.Map.Title, movementClass)))
using (new PerfTimer($"BuildDomains: {world.Map.Title} for movement class {movementClass}"))
BuildDomains(world);
}

View File

@@ -205,12 +205,12 @@ namespace OpenRA.Mods.Common.Traits
for (var index = 0; index < newCount; index++)
{
if (Players.Players.ContainsKey("Multi{0}".F(index)))
if (Players.Players.ContainsKey($"Multi{index}"))
continue;
var pr = new PlayerReference
{
Name = "Multi{0}".F(index),
Name = $"Multi{index}",
Faction = "Random",
Playable = true,
Enemies = new[] { "Creeps" }

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
var world = worldRenderer.World;
if (!world.Map.Rules.Actors.TryGetValue(reference.Type.ToLowerInvariant(), out Info))
throw new InvalidDataException("Actor {0} of unknown type {1}".F(id, reference.Type.ToLowerInvariant()));
throw new InvalidDataException($"Actor {id} of unknown type {reference.Type.ToLowerInvariant()}");
CenterPosition = PreviewPosition(world, reference);
@@ -241,7 +241,7 @@ namespace OpenRA.Mods.Common.Traits
return world.Map.CenterOfSubCell(cell, subCell) + offset;
}
else
throw new InvalidDataException("Actor {0} must define Location or CenterPosition".F(ID));
throw new InvalidDataException($"Actor {ID} must define Location or CenterPosition");
}
void GeneratePreviews()
@@ -259,7 +259,7 @@ namespace OpenRA.Mods.Common.Traits
public override string ToString()
{
return "{0} {1}".F(Info.Name, ID);
return $"{Info.Name} {ID}";
}
public bool Equals(EditorActorPreview other)

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
Info = info;
if (!Game.Renderer.Fonts.TryGetValue(info.Font, out Font))
throw new YamlException("Could not find font '{0}'".F(info.Font));
throw new YamlException($"Could not find font '{info.Font}'");
}
void IWorldLoaded.WorldLoaded(World w, WorldRenderer wr)

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (Index.Length != ReplaceIndex.Length)
throw new YamlException("ReplaceIndex length does not match Index length for palette {0}".F(Name));
throw new YamlException($"ReplaceIndex length does not match Index length for palette {Name}");
}
}

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common
{
foreach (var p in PlayerIndex)
if (p.Value.Length != RemapIndex.Length)
throw new YamlException("PlayerIndex for player `{0}` length does not match RemapIndex!".F(p.Key));
throw new YamlException($"PlayerIndex for player `{p.Key}` length does not match RemapIndex!");
}
}

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
{
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds;
if (GameSpeed != null && !gameSpeeds.ContainsKey(GameSpeed))
throw new YamlException("Invalid default game speed '{0}'.".F(GameSpeed));
throw new YamlException($"Invalid default game speed '{GameSpeed}'.");
}
public override object Create(ActorInitializer init) { return new MapOptions(this); }

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
using (var lines = s.ReadAllLines().GetEnumerator())
{
if (!lines.MoveNext() || (lines.Current != "GIMP Palette" && lines.Current != "JASC-PAL"))
throw new InvalidDataException("File `{0}` is not a valid GIMP or JASC palette.".F(Filename));
throw new InvalidDataException($"File `{Filename}` is not a valid GIMP or JASC palette.");
byte a;
a = 255;
@@ -76,16 +76,16 @@ namespace OpenRA.Mods.Common.Traits
var rgba = lines.Current.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
if (rgba.Length < 3)
throw new InvalidDataException("Invalid RGB(A) triplet/quartet: ({0})".F(string.Join(" ", rgba)));
throw new InvalidDataException($"Invalid RGB(A) triplet/quartet: ({string.Join(" ", rgba)})");
if (!byte.TryParse(rgba[0], out var r))
throw new InvalidDataException("Invalid R value: {0}".F(rgba[0]));
throw new InvalidDataException($"Invalid R value: {rgba[0]}");
if (!byte.TryParse(rgba[1], out var g))
throw new InvalidDataException("Invalid G value: {0}".F(rgba[1]));
throw new InvalidDataException($"Invalid G value: {rgba[1]}");
if (!byte.TryParse(rgba[2], out var b))
throw new InvalidDataException("Invalid B value: {0}".F(rgba[2]));
throw new InvalidDataException($"Invalid B value: {rgba[2]}");
// Check if color has a (valid) alpha value.
// Note: We can't throw on "rgba.Length > 3 but parse failed", because in GIMP palettes the 'invalid' value is probably a color name string.

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
var png = new Png(fileSystem.Open(Filename));
if (png.Palette == null)
throw new InvalidOperationException("Unable to load palette `{0}` from non-paletted png `{1}`".F(Name, Filename));
throw new InvalidOperationException($"Unable to load palette `{Name}` from non-paletted png `{Filename}`");
var colors = new uint[Palette.Size];

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
.RandomOrDefault(w.SharedRandom);
if (unitGroup == null)
throw new InvalidOperationException("No starting units defined for faction {0} with class {1}".F(p.Faction.InternalName, spawnClass));
throw new InvalidOperationException($"No starting units defined for faction {p.Faction.InternalName} with class {spawnClass}");
if (unitGroup.BaseActor != null)
{
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
if (validCell == CPos.Zero)
{
Log.Write("debug", "No cells available to spawn starting unit {0} for player {1}".F(s, p));
Log.Write("debug", $"No cells available to spawn starting unit {s} for player {p}");
continue;
}

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
var failed = false;
Action<uint, string> onMissingImage = (id, f) =>
{
onError("\tTemplate `{0}` references sprite `{1}` that does not exist.".F(id, f));
onError($"\tTemplate `{id}` references sprite `{f}` that does not exist.");
missingImages.Add(f);
failed = true;
};
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
if (t.Value[i] == null || tileCache.HasTileSprite(new TerrainTile(t.Key, (byte)i), v))
continue;
onError("\tTemplate `{0}` references frame {1} that does not exist in sprite `{2}`.".F(t.Key, i, templateInfo.Images[v]));
onError($"\tTemplate `{t.Key}` references frame {i} that does not exist in sprite `{templateInfo.Images[v]}`.");
failed = true;
}
}

Some files were not shown because too many files have changed in this diff Show More