Add plumbing for trait-defined lobby options.
This commit is contained in:
@@ -13,6 +13,7 @@ using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Server;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Server
|
||||
{
|
||||
@@ -26,6 +27,18 @@ namespace OpenRA.Mods.Common.Server
|
||||
var defaults = new Session.Global();
|
||||
LobbyCommands.LoadMapSettings(defaults, server.Map.Rules);
|
||||
|
||||
var options = server.Map.Rules.Actors["player"].TraitInfos<ILobbyOptions>()
|
||||
.Concat(server.Map.Rules.Actors["world"].TraitInfos<ILobbyOptions>())
|
||||
.SelectMany(t => t.LobbyOptions(server.Map.Rules))
|
||||
.ToDictionary(o => o.Id, o => o);
|
||||
|
||||
foreach (var kv in server.LobbyInfo.GlobalSettings.LobbyOptions)
|
||||
{
|
||||
Session.LobbyOptionState def;
|
||||
if (!defaults.LobbyOptions.TryGetValue(kv.Key, out def) || kv.Value.Value != def.Value)
|
||||
server.SendOrderTo(conn, "Message", options[kv.Key].Name + ": " + kv.Value.Value);
|
||||
}
|
||||
|
||||
if (server.LobbyInfo.GlobalSettings.AllowCheats != defaults.AllowCheats)
|
||||
server.SendOrderTo(conn, "Message", "Allow Cheats: {0}".F(server.LobbyInfo.GlobalSettings.AllowCheats));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user