diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 740c7e01fa..fb8b79833a 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -264,7 +264,6 @@ namespace OpenRA.Editor SaveAsClicked(sender, e); else { - surface1.Map.PlayerCount = surface1.Map.Waypoints.Count; surface1.Map.Save(loadedMapName); dirty = false; } diff --git a/OpenRA.Editor/LegacyMapImporter.cs b/OpenRA.Editor/LegacyMapImporter.cs index 40bb9a5bba..bdfbabe089 100644 --- a/OpenRA.Editor/LegacyMapImporter.cs +++ b/OpenRA.Editor/LegacyMapImporter.cs @@ -163,8 +163,6 @@ namespace OpenRA.Editor LocationFromMapOffset(int.Parse(kv.Value), MapSize))) .ToArray(); - Map.PlayerCount = wp.Count(); - foreach (var kv in wp) Map.Waypoints.Add("spawn" + kv.First, kv.Second); } diff --git a/OpenRA.FileFormats/Map/MapStub.cs b/OpenRA.FileFormats/Map/MapStub.cs index b96d79c016..9d071bb0a3 100644 --- a/OpenRA.FileFormats/Map/MapStub.cs +++ b/OpenRA.FileFormats/Map/MapStub.cs @@ -22,7 +22,8 @@ namespace OpenRA.FileFormats public string Path {get; protected set;} // Yaml map data - public string Uid { get; protected set; } + public string Uid { get; protected set; } + [FieldLoader.Load] public int MapFormat; [FieldLoader.Load] public bool Selectable; [FieldLoader.Load] public bool UseAsShellmap; [FieldLoader.Load] public string RequiresMod; @@ -31,12 +32,15 @@ namespace OpenRA.FileFormats [FieldLoader.Load] public string Type = "Conquest"; [FieldLoader.Load] public string Description; [FieldLoader.Load] public string Author; - [FieldLoader.Load] public int PlayerCount; [FieldLoader.Load] public string Tileset; - + + [FieldLoader.Load] public string[] StartPoints; + public int PlayerCount { get { return StartPoints.Count(); } } [FieldLoader.LoadUsing( "LoadWaypoints" )] public Dictionary Waypoints = new Dictionary(); - public IEnumerable SpawnPoints { get { return Waypoints.Select(kv => kv.Value); } } + + + public IEnumerable SpawnPoints{ get { return Waypoints.Where(kv => StartPoints.Contains(kv.Key)).Select(kv => kv.Value); } } [FieldLoader.Load] public int2 TopLeft; [FieldLoader.Load] public int2 BottomRight; @@ -53,6 +57,10 @@ namespace OpenRA.FileFormats Bounds = Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); Uid = ComputeHash(); + + // Upgrade maps to define StartPoints + if (MapFormat < 5) + StartPoints = Waypoints.Select(kv => kv.Key).ToArray(); } string ComputeHash() @@ -75,6 +83,7 @@ namespace OpenRA.FileFormats string[] loc = wp.Value.Value.Split( ',' ); ret.Add( wp.Key, new int2( int.Parse( loc[ 0 ] ), int.Parse( loc[ 1 ] ) ) ); } + return ret; } } diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index f7be3e5a21..57fd8197d2 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -23,8 +23,6 @@ namespace OpenRA public class Map : MapStub { // Yaml map data - [FieldLoader.Load] public int MapFormat; - public Dictionary Players = new Dictionary(); public Dictionary Actors = new Dictionary(); public List Smudges = new List(); @@ -63,7 +61,6 @@ namespace OpenRA Description = "Describe your map here", Author = "Your name here", MapSize = new int2(1, 1), - PlayerCount = 0, Tileset = tileset, MapResources = new TileReference[1, 1], MapTiles = new TileReference[1, 1] @@ -229,7 +226,24 @@ namespace OpenRA MapFormat = 5; var root = new List(); - foreach (var field in new string[] {"Selectable", "MapFormat", "RequiresMod", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight", "UseAsShellmap", "Type"}) + var fields = new string[] + { + "Selectable", + "MapFormat", + "RequiresMod", + "Title", + "Description", + "Author", + "Tileset", + "MapSize", + "TopLeft", + "BottomRight", + "UseAsShellmap", + "Type", + "StartPoints" + }; + + foreach (var field in fields) { var f = this.GetType().GetField(field); if (f.GetValue(this) == null) continue;