diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeMapCommand.cs index a45c24e93d..862084c89e 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeMapCommand.cs @@ -25,9 +25,9 @@ namespace OpenRA.Mods.Common.UtilityCommands return args.Length >= 3; } - delegate void UpgradeAction(int engineVersion, ref List nodes, MiniYamlNode parent, int depth); + delegate void UpgradeAction(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth); - static void ProcessYaml(Map map, MiniYaml yaml, int engineDate, UpgradeAction processYaml) + static void ProcessYaml(ModData modData, Map map, MiniYaml yaml, int engineDate, UpgradeAction processYaml) { if (yaml == null) return; @@ -38,12 +38,12 @@ namespace OpenRA.Mods.Common.UtilityCommands foreach (var filename in files) { var fileNodes = MiniYaml.FromStream(map.Package.GetStream(filename), filename); - processYaml(engineDate, ref fileNodes, null, 0); + processYaml(modData, engineDate, ref fileNodes, null, 0); ((IReadWritePackage)map.Package).Update(filename, Encoding.ASCII.GetBytes(fileNodes.WriteToString())); } } - processYaml(engineDate, ref yaml.Nodes, null, 1); + processYaml(modData, engineDate, ref yaml.Nodes, null, 1); } public static void UpgradeMap(ModData modData, IReadWritePackage package, int engineDate) @@ -58,10 +58,10 @@ namespace OpenRA.Mods.Common.UtilityCommands } var map = new Map(modData, package); - ProcessYaml(map, map.WeaponDefinitions, engineDate, UpgradeRules.UpgradeWeaponRules); - ProcessYaml(map, map.RuleDefinitions, engineDate, UpgradeRules.UpgradeActorRules); - UpgradeRules.UpgradePlayers(engineDate, ref map.PlayerDefinitions, null, 0); - UpgradeRules.UpgradeActors(engineDate, ref map.ActorDefinitions, null, 0); + ProcessYaml(modData, map, map.WeaponDefinitions, engineDate, UpgradeRules.UpgradeWeaponRules); + ProcessYaml(modData, map, map.RuleDefinitions, engineDate, UpgradeRules.UpgradeActorRules); + UpgradeRules.UpgradePlayers(modData, engineDate, ref map.PlayerDefinitions, null, 0); + UpgradeRules.UpgradeActors(modData, engineDate, ref map.ActorDefinitions, null, 0); map.Save(package); } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeModCommand.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeModCommand.cs index a21b0a6822..a47da3e330 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeModCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeModCommand.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.UtilityCommands return args.Length >= 2; } - delegate void UpgradeAction(int engineVersion, ref List nodes, MiniYamlNode parent, int depth); + delegate void UpgradeAction(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth); void ProcessYaml(string type, IEnumerable files, ModData modData, int engineDate, UpgradeAction processFile) { @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.UtilityCommands } var yaml = MiniYaml.FromStream(package.GetStream(name), name); - processFile(engineDate, ref yaml, null, 0); + processFile(modData, engineDate, ref yaml, null, 0); // Generate the on-disk path var path = Path.Combine(package.Name, name); diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index c64ca21234..c6827b04ae 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.UtilityCommands catch { } } - internal static void UpgradeActorRules(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradeActorRules(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { var addNodes = new List(); @@ -185,14 +185,14 @@ namespace OpenRA.Mods.Common.UtilityCommands } } - UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } foreach (var a in addNodes) nodes.Add(a); } - internal static void UpgradeWeaponRules(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradeWeaponRules(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { foreach (var node in nodes) { @@ -240,61 +240,61 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Key = "Speed"; } - UpgradeWeaponRules(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradeWeaponRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } - internal static void UpgradeTileset(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradeTileset(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { foreach (var node in nodes) { // Add rules here - UpgradeTileset(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradeTileset(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } - internal static void UpgradeCursors(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradeCursors(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { foreach (var node in nodes) { // Add rules here - UpgradeCursors(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradeCursors(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } - internal static void UpgradePlayers(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradePlayers(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { foreach (var node in nodes) { // Add rules here - UpgradePlayers(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradePlayers(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } - internal static void UpgradeChromeMetrics(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradeChromeMetrics(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { foreach (var node in nodes) { // Add rules here - UpgradeChromeMetrics(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradeChromeMetrics(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } - internal static void UpgradeChromeLayout(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradeChromeLayout(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { foreach (var node in nodes) { // Add rules here - UpgradeChromeLayout(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradeChromeLayout(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } - internal static void UpgradeActors(int engineVersion, ref List nodes, MiniYamlNode parent, int depth) + internal static void UpgradeActors(ModData modData, int engineVersion, ref List nodes, MiniYamlNode parent, int depth) { foreach (var node in nodes) { // Add rules here - UpgradeActors(engineVersion, ref node.Value.Nodes, node, depth + 1); + UpgradeActors(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } }