diff --git a/OpenRA.FileFormats/Map/PlayerReference.cs b/OpenRA.FileFormats/Map/PlayerReference.cs index 75bfc19a4f..bf8c04a552 100644 --- a/OpenRA.FileFormats/Map/PlayerReference.cs +++ b/OpenRA.FileFormats/Map/PlayerReference.cs @@ -18,7 +18,8 @@ namespace OpenRA.FileFormats public string Palette; public string Race; public bool OwnsWorld = false; - public bool NonCombatant = false; + public bool NonCombatant = false; + public bool Playable = false; public Color Color = Color.FromArgb(238,238,238); public Color Color2 = Color.FromArgb(44,28,24); diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index d3552b0449..321d59e82d 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -43,6 +43,7 @@ namespace OpenRA.Network public int Index; public string Bot; // trait name of the bot to initialize in this slot, or null otherwise. public bool Closed; // host has explicitly closed this slot. + public string MapPlayer; // playerReference to bind against. // todo: more stuff? } diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index c0b318ea79..47f57bfecc 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -115,9 +115,25 @@ namespace OpenRA.Server } ) { IsBackground = true }.Start(); } + static Session.Slot MakeSlotFromPlayerReference(PlayerReference pr) + { + if (!pr.Playable) return null; + return new Session.Slot + { + MapPlayer = pr.Name, + Bot = null, /* todo: allow the map to specify a bot class? */ + Closed = false, + }; + } + static void LoadMap() { Map = new Map(ModData.AvailableMaps[lobbyInfo.GlobalSettings.Map].Package); + lobbyInfo.Slots = Map.Players + .Select(p => MakeSlotFromPlayerReference(p.Value)) + .Where(s => s != null) + .Select((s, i) => { s.Index = i; return s; }) + .ToList(); } static int ChooseFreePlayerIndex() @@ -423,7 +439,9 @@ namespace OpenRA.Server }; } break; - case "Chat": case "TeamChat": + + case "Chat": + case "TeamChat": foreach (var c in conns.Except(conn).ToArray()) DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize()); break; diff --git a/OpenRA.Mods.RA/CreateMapPlayers.cs b/OpenRA.Mods.RA/CreateMapPlayers.cs index 9e07f36eae..9500670223 100644 --- a/OpenRA.Mods.RA/CreateMapPlayers.cs +++ b/OpenRA.Mods.RA/CreateMapPlayers.cs @@ -8,8 +8,7 @@ */ #endregion -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using OpenRA.Traits; namespace OpenRA.Mods.RA diff --git a/OpenRA.Mods.RA/LocalPlayerFromMap.cs b/OpenRA.Mods.RA/LocalPlayerFromMap.cs index 2a842b071e..182df4364f 100644 --- a/OpenRA.Mods.RA/LocalPlayerFromMap.cs +++ b/OpenRA.Mods.RA/LocalPlayerFromMap.cs @@ -6,9 +6,8 @@ * as published by the Free Software Foundation. For more information, * see LICENSE. */ -#endregion - -using System.Collections.Generic; +#endregion + using System.Linq; using OpenRA.Traits;