diff --git a/OpenRA.FileFormats/Map/MapStub.cs b/OpenRA.FileFormats/Map/MapStub.cs index bada08356d..5dd7cd73d9 100644 --- a/OpenRA.FileFormats/Map/MapStub.cs +++ b/OpenRA.FileFormats/Map/MapStub.cs @@ -20,7 +20,7 @@ namespace OpenRA.FileFormats public readonly IFolder Package; // Yaml map data - public readonly string Uid; + public string Uid { get; protected set; } [FieldLoader.Load] public bool Selectable; [FieldLoader.Load] public string Title; @@ -37,7 +37,8 @@ namespace OpenRA.FileFormats [FieldLoader.Load] public int2 BottomRight; public int Width { get { return BottomRight.X - TopLeft.X; } } public int Height { get { return BottomRight.Y - TopLeft.Y; } } - + + public MapStub() {} // Hack for the editor - not used for anything important public MapStub(IFolder package) { Package = package; diff --git a/OpenRA.FileFormats/Map/PlayerReference.cs b/OpenRA.FileFormats/Map/PlayerReference.cs index fe92ce41e9..7f315e468f 100644 --- a/OpenRA.FileFormats/Map/PlayerReference.cs +++ b/OpenRA.FileFormats/Map/PlayerReference.cs @@ -21,6 +21,7 @@ namespace OpenRA.FileFormats public bool NonCombatant = false; public bool Playable = false; public bool DefaultStartingUnits = false; + public bool AllowBots = true; public Color Color = Color.FromArgb(238,238,238); public Color Color2 = Color.FromArgb(44,28,24); diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index cc456aa894..b65c197265 100755 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -19,24 +19,14 @@ using OpenRA.FileFormats; namespace OpenRA { - public class Map + public class Map : MapStub { - public IFolder Package; - public string Uid; - // Yaml map data - [FieldLoader.Load] public bool Selectable = true; [FieldLoader.Load] public int MapFormat; - [FieldLoader.Load] public string Title; - [FieldLoader.Load] public string Description; - [FieldLoader.Load] public string Author; - [FieldLoader.Load] public int PlayerCount; - [FieldLoader.Load] public string Tileset; public Dictionary Players = new Dictionary(); public Dictionary Actors = new Dictionary(); public List Smudges = new List(); - public Dictionary Waypoints = new Dictionary(); // Rules overrides public List Rules = new List(); @@ -45,8 +35,6 @@ namespace OpenRA public byte TileFormat = 1; [FieldLoader.Load] public int2 MapSize; - [FieldLoader.Load] public int2 TopLeft; - [FieldLoader.Load] public int2 BottomRight; public TileReference[,] MapTiles; public TileReference[,] MapResources; @@ -55,10 +43,7 @@ namespace OpenRA // Temporary compat hacks public int XOffset { get { return TopLeft.X; } } public int YOffset { get { return TopLeft.Y; } } - public int Width { get { return BottomRight.X - TopLeft.X; } } - public int Height { get { return BottomRight.Y - TopLeft.Y; } } public string Theater { get { return Tileset; } } - public IEnumerable SpawnPoints { get { return Waypoints.Select(kv => kv.Value); } } public Rectangle Bounds { get { return Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y); } } public Map() @@ -97,19 +82,13 @@ namespace OpenRA } public Map(IFolder package) + : base(package) { - Package = package; var yaml = new MiniYaml( null, MiniYaml.FromStream( Package.GetContent( "map.yaml" ) ) ); // 'Simple' metadata FieldLoader.Load( this, yaml ); - // Waypoints - foreach (var wp in yaml.NodesDict["Waypoints"].NodesDict) - { - string[] loc = wp.Value.Value.Split(','); - Waypoints.Add(wp.Key, new int2(int.Parse(loc[0]), int.Parse(loc[1]))); - } // Players & Actors -- this has changed several times. // - Be backwards compatible wherever possible. @@ -199,7 +178,6 @@ namespace OpenRA Rules = yaml.NodesDict["Rules"].Nodes; CustomTerrain = new string[MapSize.X, MapSize.Y]; - LoadUid(); LoadBinaryData(); } @@ -314,11 +292,6 @@ namespace OpenRA File.Move(filepath + ".tmp", filepath); } - public void LoadUid() - { - Uid = Package.GetContent("map.uid").ReadAllText(); - } - public void SaveUid(string filename) { // UID is calculated by taking an SHA1 of the yaml and binary data diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 7b668bad2b..ab9469eb80 100755 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -23,7 +23,7 @@ namespace OpenRA.Widgets.Delegates Dictionary CountryNames; string MapUid; - MapStub Map; + Map Map; public static Color CurrentColorPreview1; public static Color CurrentColorPreview2; @@ -109,6 +109,8 @@ namespace OpenRA.Widgets.Delegates orderManager.IssueOrder(Order.Command("startgame")); return true; }; + + // Todo: Only show if the map requirements are met for player slots startGameButton.IsVisible = () => Game.IsHost; Game.LobbyInfoChanged += JoinedServer; @@ -179,7 +181,7 @@ namespace OpenRA.Widgets.Delegates { if (MapUid == orderManager.LobbyInfo.GlobalSettings.Map) return; MapUid = orderManager.LobbyInfo.GlobalSettings.Map; - Map = Game.modData.AvailableMaps[MapUid]; + Map = new Map(Game.modData.AvailableMaps[MapUid].Package); var title = Widget.RootWidget.GetWidget("LOBBY_TITLE"); title.Text = "OpenRA Multiplayer Lobby - " + orderManager.LobbyInfo.GlobalSettings.ServerName; @@ -242,7 +244,7 @@ namespace OpenRA.Widgets.Delegates } else { - if (s.Bot == null) + if (s.Bot == null && Map.Players[s.MapPlayer].AllowBots) orderManager.IssueOrder(Order.Command("slot_bot {0} HackyAI".F(s.Index))); else orderManager.IssueOrder(Order.Command("slot_close " + s.Index));