Add plumbing for trait-defined lobby options.

This commit is contained in:
Paul Chote
2016-04-20 00:40:49 -04:00
parent d27d265bdd
commit 3e92c1944a
4 changed files with 175 additions and 2 deletions

View File

@@ -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));