Fix Waypoint == Startpoint assumption in MapFormat 5.
This commit is contained in:
@@ -264,7 +264,6 @@ namespace OpenRA.Editor
|
||||
SaveAsClicked(sender, e);
|
||||
else
|
||||
{
|
||||
surface1.Map.PlayerCount = surface1.Map.Waypoints.Count;
|
||||
surface1.Map.Save(loadedMapName);
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
// Yaml map data
|
||||
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<string, int2> Waypoints = new Dictionary<string, int2>();
|
||||
public IEnumerable<int2> SpawnPoints { get { return Waypoints.Select(kv => kv.Value); } }
|
||||
|
||||
|
||||
public IEnumerable<int2> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ namespace OpenRA
|
||||
public class Map : MapStub
|
||||
{
|
||||
// Yaml map data
|
||||
[FieldLoader.Load] public int MapFormat;
|
||||
|
||||
public Dictionary<string, PlayerReference> Players = new Dictionary<string, PlayerReference>();
|
||||
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
|
||||
public List<SmudgeReference> Smudges = new List<SmudgeReference>();
|
||||
@@ -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<byte, byte>[1, 1],
|
||||
MapTiles = new TileReference<ushort, byte>[1, 1]
|
||||
@@ -229,7 +226,24 @@ namespace OpenRA
|
||||
MapFormat = 5;
|
||||
|
||||
var root = new List<MiniYamlNode>();
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user