Strengthen ordering of TraitsInConstructOrder.

All types that are dependencies of a trait must now occur before it in the construct ordering. Previously, only one type that was a dependency of a trait needed to occur before it.
This commit is contained in:
RoosterDragon
2016-03-11 21:40:07 +00:00
parent b3b816fcc6
commit 3192432a5c
2 changed files with 16 additions and 11 deletions

View File

@@ -100,7 +100,7 @@ namespace OpenRA
var unresolved = source.Except(resolved);
var testResolve = new Func<Type, Type, bool>((a, b) => a == b || a.IsAssignableFrom(b));
var more = unresolved.Where(u => u.Dependencies.All(d => resolved.Exists(r => testResolve(d, r.Type))));
var more = unresolved.Where(u => u.Dependencies.All(d => resolved.Exists(r => testResolve(d, r.Type)) && !unresolved.Any(u1 => testResolve(d, u1.Type))));
// Re-evaluate the vars above until sorted
while (more.Any())
@@ -122,14 +122,14 @@ namespace OpenRA
exceptionString += u.Type + ": { " + string.Join(", ", deps) + " }\r\n";
}
throw new Exception(exceptionString);
throw new YamlException(exceptionString);
}
constructOrderCache = resolved.Select(r => r.Trait).ToList();
return constructOrderCache;
}
static IEnumerable<Type> PrerequisitesOf(ITraitInfo info)
public static IEnumerable<Type> PrerequisitesOf(ITraitInfo info)
{
return info
.GetType()