Also check for a missing UpgradeManager trait

as optional upgrades will otherwise be silently non-functional.
This commit is contained in:
Matthias Mailänder
2016-06-05 17:37:36 +02:00
parent bec879cf7c
commit 3b27975b33

View File

@@ -40,8 +40,14 @@ namespace OpenRA.Mods.Common.Lint
foreach (var field in fields.Where(x => x.HasAttribute<UpgradeUsedReferenceAttribute>()))
{
var values = LintExts.GetFieldValues(trait, field, emitError);
foreach (var value in values.Where(x => !upgradesGranted.Contains(x)))
emitError("Actor type `{0}` uses upgrade `{1}` that is not granted by anything!".F(actorInfo.Key, value));
foreach (var value in values)
{
if (!upgradesGranted.Contains(value))
emitError("Actor type `{0}` uses upgrade `{1}` that is not granted by anything!".F(actorInfo.Key, value));
if (actorInfo.Value.TraitInfoOrDefault<UpgradeManagerInfo>() == null)
emitError("Actor type `{0}` uses upgrade `{1}`, but doesn't have the UpgradeManager trait.".F(actorInfo.Key, value));
}
}
}
}