Remove explicit line numbers from update rule reports.

Additions/removals by other rules in the set will almost certainly
invalidate these.  Reporting the block and file is the best we can
reasonably do.
This commit is contained in:
Paul Chote
2018-04-28 18:49:46 +01:00
committed by abcdefg30
parent 677d004cfa
commit 8c2f25e249
4 changed files with 37 additions and 41 deletions

View File

@@ -27,37 +27,32 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
}
}
Tuple<string, string, string, List<MiniYamlNode>>[] fields =
Tuple<string, string, string, List<string>>[] fields =
{
Tuple.Create("ParaDrop", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
Tuple.Create("EjectOnDeath", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
Tuple.Create("ProductionParadrop", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
Tuple.Create("Building", "BuildSounds", "placbldg.aud, build5.aud", new List<MiniYamlNode>()),
Tuple.Create("Building", "UndeploySounds", "cashturn.aud", new List<MiniYamlNode>())
Tuple.Create("ParaDrop", "ChuteSound", "chute1.aud", new List<string>()),
Tuple.Create("EjectOnDeath", "ChuteSound", "chute1.aud", new List<string>()),
Tuple.Create("ProductionParadrop", "ChuteSound", "chute1.aud", new List<string>()),
Tuple.Create("Building", "BuildSounds", "placbldg.aud, build5.aud", new List<string>()),
Tuple.Create("Building", "UndeploySounds", "cashturn.aud", new List<string>())
};
public override IEnumerable<string> BeforeUpdate(ModData modData)
{
// Reset state for each mod/map
foreach (var field in fields)
field.Item4.Clear();
yield break;
}
string BuildMessage(Tuple<string, string, string, List<MiniYamlNode>> field)
string BuildMessage(Tuple<string, string, string, List<string>> field)
{
return "The default value for {0}.{1} has been removed.\n".F(field.Item1, field.Item2)
+ "You may wish to explicitly define `{0}: {1}` at the following\n".F(field.Item2, field.Item3)
+ "locations if the sound has not already been inherited from a parent definition.\n"
+ UpdateUtils.FormatMessageList(field.Item4.Select(n => n.Location.ToString()));
+ "You may wish to explicitly define `{0}: {1}` on the `{2}` trait \n".F(field.Item2, field.Item3, field.Item1)
+ "definitions on the following actors (if they have not already been inherited from a parent).\n"
+ UpdateUtils.FormatMessageList(field.Item4);
}
public override IEnumerable<string> AfterUpdate(ModData modData)
{
foreach (var field in fields)
{
if (field.Item4.Any())
yield return BuildMessage(field);
field.Item4.Clear();
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
@@ -68,7 +63,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
var node = traitNode.LastChildMatching(field.Item2);
if (node == null)
field.Item4.Add(traitNode);
field.Item4.Add("{0} ({1})".F(actorNode.Key, traitNode.Location.Filename));
}
}

View File

@@ -26,34 +26,23 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
}
}
readonly List<MiniYamlNode.SourceLocation> locations = new List<MiniYamlNode.SourceLocation>();
public override IEnumerable<string> BeforeUpdate(ModData modData)
{
// Reset state for each mod/map
locations.Clear();
yield break;
}
readonly List<string> locations = new List<string>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (locations.Any())
yield return "The automatic exclusion of harvesters from AI squads has been removed.\n"
+ "You may wish to add your harvester-type actors to `ExcludeFromSquads` under `UnitCommonNames`\n"
+ "at the following locations.\n"
+ UpdateUtils.FormatMessageList(locations.Select(l => l.ToString()));
+ "on the following definitions:\n"
+ UpdateUtils.FormatMessageList(locations);
locations.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var hackyAINode in actorNode.ChildrenMatching("HackyAI"))
{
var commonNamesNode = hackyAINode.LastChildMatching("UnitsCommonNames");
if (commonNamesNode != null)
locations.Add(commonNamesNode.Location);
else
locations.Add(hackyAINode.Location);
}
locations.Add("{0} ({1})".F(hackyAINode.Key, hackyAINode.Location.Filename));
yield break;
}

View File

@@ -53,8 +53,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
yield return "Actor ids starting with '^' are now reserved for abstract\n" +
"inheritance templates, and will not be parsed by the game.\n" +
"Check the following definitions and rename them if they are not used for inheritance:\n" +
UpdateUtils.FormatMessageList(actors.Select(n => n.Key + ":\n" +
UpdateUtils.FormatMessageList(n.Value.Select(v => v.Location.ToString()))));
UpdateUtils.FormatMessageList(actors.Select(n => n.Key + " (" + n.Value.Select(v => v.Location.Filename).JoinWith(", ") + ")"));
}
}
}

View File

@@ -10,6 +10,7 @@
#endregion
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
@@ -25,13 +26,25 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
}
}
readonly List<string> locations = new List<string>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (locations.Any())
yield return "WithReloadingSpriteTurret has been replaced by WithSpriteTurret\n"
+ "You should use AmmoPool.AmmoConditions to switch turret type when reloading\n"
+ "to restore the previous behaviour on the following actors:"
+ UpdateUtils.FormatMessageList(locations);
locations.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var turret in actorNode.ChildrenMatching("WithReloadingSpriteTurret"))
{
turret.RenameKeyPreservingSuffix("WithSpriteTurret");
yield return turret.Location.ToString() + ": WithReloadingSpriteTurret has been replaced by WithSpriteTurret.\n" +
"You should use AmmoPool.AmmoConditions to switch turret type when reloading to restore the previous behaviour.";
locations.Add("{0} ({1})".F(actorNode.Key, turret.Location.Filename));
}
yield break;