From a3af1d91ccb2271b1eeffb974e8386af7d713ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 5 Jun 2016 11:53:26 +0200 Subject: [PATCH 1/3] Don't add mpspawns when importing single-player maps. --- .../UtilityCommands/ImportLegacyMapCommand.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs index 4a84c92d43..ae3dfaf712 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs @@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.UtilityCommands public Map Map; public List Players = new List(); public MapPlayers MapPlayers; + bool singlePlayer; int spawnCount; public bool ValidateArguments(string[] args) @@ -55,6 +56,11 @@ namespace OpenRA.Mods.Common.UtilityCommands { var file = new IniFile(stream); var basic = file.GetSection("Basic"); + + var player = basic.GetValue("Player", string.Empty); + if (!string.IsNullOrEmpty(player)) + singlePlayer = !player.StartsWith("Multi"); + var mapSection = file.GetSection("Map"); var format = GetMapFormatVersion(basic); @@ -252,7 +258,7 @@ namespace OpenRA.Mods.Common.UtilityCommands // Add waypoint actors foreach (var kv in wps) { - if (kv.First <= 7) + if (!singlePlayer && kv.First <= 7) { var ar = new ActorReference("mpspawn") { From d76a344ebe401a9021d76b1e83dbfd2b20104e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 5 Jun 2016 11:54:01 +0200 Subject: [PATCH 2/3] Give hard-coded special case waypoints a descriptive name. --- .../ImportTiberianDawnLegacyMapCommand.cs | 12 ++++++++++++ .../UtilityCommands/ImportLegacyMapCommand.cs | 8 +++++++- OpenRA.Mods.RA/ImportRedAlertLegacyMapCommand.cs | 8 ++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs b/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs index f7280b7aed..fbe3f74235 100644 --- a/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs +++ b/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs @@ -148,5 +148,17 @@ namespace OpenRA.Mods.Cnc.UtilityCommands ReadOverlay(file); } + + public override void SaveWaypoint(int waypointNumber, ActorReference waypointReference) + { + var waypointName = "waypoint" + waypointNumber; + if (waypointNumber == 25) + waypointName = "DefaultFlareLocation"; + else if (waypointNumber == 26) + waypointName = "DefaultCameraPosition"; + else if (waypointNumber == 27) + waypointName = "DefaultChinookTarget"; + Map.ActorDefinitions.Add(new MiniYamlNode(waypointName, waypointReference.Save())); + } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs index ae3dfaf712..6837451240 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs @@ -277,11 +277,17 @@ namespace OpenRA.Mods.Common.UtilityCommands new OwnerInit("Neutral") }; - Map.ActorDefinitions.Add(new MiniYamlNode("waypoint" + kv.First, ar.Save())); + SaveWaypoint(kv.First, ar); } } } + public virtual void SaveWaypoint(int waypointNumber, ActorReference waypointReference) + { + var waypointName = "waypoint" + waypointNumber; + Map.ActorDefinitions.Add(new MiniYamlNode(waypointName, waypointReference.Save())); + } + void LoadSmudges(IniFile file, string section) { var scorches = new List(); diff --git a/OpenRA.Mods.RA/ImportRedAlertLegacyMapCommand.cs b/OpenRA.Mods.RA/ImportRedAlertLegacyMapCommand.cs index cd4db44f71..38d7bc7f7f 100644 --- a/OpenRA.Mods.RA/ImportRedAlertLegacyMapCommand.cs +++ b/OpenRA.Mods.RA/ImportRedAlertLegacyMapCommand.cs @@ -228,5 +228,13 @@ namespace OpenRA.Mods.RA.UtilityCommands base.ReadActors(file); LoadActors(file, "SHIPS", Players, MapSize, Map); } + + public override void SaveWaypoint(int waypointNumber, ActorReference waypointReference) + { + var waypointName = "waypoint" + waypointNumber; + if (waypointNumber == 98) + waypointName = "DefaultCameraPosition"; + Map.ActorDefinitions.Add(new MiniYamlNode(waypointName, waypointReference.Save())); + } } } From 89cefbea50e8e873e10e22488d07bb1c09c73ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 5 Jun 2016 11:55:52 +0200 Subject: [PATCH 3/3] Allow map imports from directories other than game root. --- OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs b/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs index fbe3f74235..ba17efd028 100644 --- a/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs +++ b/OpenRA.Mods.Cnc/ImportTiberianDawnLegacyMapCommand.cs @@ -143,7 +143,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands public override void ReadPacks(IniFile file, string filename) { - using (var s = ModData.DefaultFileSystem.Open(filename.Substring(0, filename.Length - 4) + ".bin")) + using (var s = File.OpenRead(filename.Substring(0, filename.Length - 4) + ".bin")) UnpackTileData(s); ReadOverlay(file); diff --git a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs index 6837451240..c0c5a1ca82 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ImportLegacyMapCommand.cs @@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.UtilityCommands Game.ModData = modData; var filename = args[1]; - using (var stream = modData.DefaultFileSystem.Open(filename)) + using (var stream = File.OpenRead(filename)) { var file = new IniFile(stream); var basic = file.GetSection("Basic");