diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 233b8c4fa1..fe37cc87c9 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -559,6 +559,7 @@ + diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/IgnoreAbstractActors.cs b/OpenRA.Mods.Common/UpdateRules/Rules/IgnoreAbstractActors.cs new file mode 100644 index 0000000000..162bedce29 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/IgnoreAbstractActors.cs @@ -0,0 +1,60 @@ +#region Copyright & License Information +/* + * Copyright 2007-2018 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class IgnoreAbstractActors : UpdateRule + { + readonly Dictionary> actors = new Dictionary>(); + + public override string Name { get { return "Abstract actors are ignored while parsing rules"; } } + public override string Description + { + get + { + return "Actor ids starting with '^' are now reserved for abstract\n" + + "inheritance templates, and will not be parsed by the game."; + } + } + + public override IEnumerable BeforeUpdate(ModData modData) + { + actors.Clear(); + yield break; + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + if (!actorNode.Key.StartsWith("^", StringComparison.Ordinal)) + yield break; + + var name = actorNode.Key; + if (!actors.ContainsKey(name)) + actors[name] = new List(); + + actors[name].Add(actorNode); + } + + public override IEnumerable AfterUpdate(ModData modData) + { + if (actors.Any()) + 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())))); + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index 4e83d69d5b..4deed58287 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -44,7 +44,8 @@ namespace OpenRA.Mods.Common.UpdateRules new SplitTurretAimAnimation(), new DefineSoundDefaults(), new RenameWormSpawner(), - new RemoveWithReloadingSpriteTurret() + new RemoveWithReloadingSpriteTurret(), + new IgnoreAbstractActors() }) };