Apply map upgrade rules without instantiating the Map object.

This avoids a crash that stops the maps from being updated
when the base mod ruleset is not valid (e.g. a trait is missing a
FieldLoader.Required property).  This also significantly improves the
upgrade performance.
This commit is contained in:
Paul Chote
2018-03-19 06:00:26 +00:00
committed by abcdefg30
parent d2ff5b49fd
commit 8ea1da1046
3 changed files with 55 additions and 19 deletions

View File

@@ -77,16 +77,16 @@ namespace OpenRA.Mods.Common.UtilityCommands
// The map cache won't be valid if there was a map format upgrade, so walk the map packages manually
// Only upgrade system maps - user maps must be updated manually using --upgrade-map
Console.WriteLine("Processing System Maps:");
foreach (var map in modData.MapCache.EnumerateMapsWithoutCaching())
foreach (var package in modData.MapCache.EnumerateMapPackagesWithoutCaching())
{
try
{
Console.WriteLine(map.Package.Name);
UpgradeMapCommand.UpgradeMap(modData, (IReadWritePackage)map.Package, engineDate);
Console.WriteLine(package.Name);
UpgradeMapCommand.UpgradeMap(modData, package, engineDate);
}
catch (Exception e)
{
Console.WriteLine("Failed to upgrade map {0}", map);
Console.WriteLine("Failed to upgrade map {0}", package.Name);
Console.WriteLine("Error was: {0}", e.ToString());
}
}