diff --git a/OpenRA.FileFormats/Manifest.cs b/OpenRA.FileFormats/Manifest.cs index 5cbac2313b..e029c08a95 100644 --- a/OpenRA.FileFormats/Manifest.cs +++ b/OpenRA.FileFormats/Manifest.cs @@ -18,7 +18,7 @@ namespace OpenRA.FileFormats public class Manifest { public readonly string[] - Mods, Folders, Packages, Rules, + Mods, Folders, Packages, Rules, ServerTraits, Sequences, Cursors, Chrome, Assemblies, ChromeLayout, Weapons, Voices, Music, Movies, TileSets; public readonly string ShellmapUid, LoadScreen; @@ -35,6 +35,7 @@ namespace OpenRA.FileFormats Folders = YamlList(yaml, "Folders"); Packages = YamlList(yaml, "Packages"); Rules = YamlList(yaml, "Rules"); + ServerTraits = YamlList(yaml, "ServerTraits"); Sequences = YamlList(yaml, "Sequences"); Cursors = YamlList(yaml, "Cursors"); Chrome = YamlList(yaml, "Chrome"); diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 12a35f3e91..9af82e93d3 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -55,16 +55,14 @@ namespace OpenRA.Server { Log.AddChannel("server", "server.log"); - ServerTraits.Add( new DebugServerTrait() ); - ServerTraits.Add( new PlayerCommands() ); - ServerTraits.Add( new LobbyCommands() ); - ServerTraits.Add( new MasterServerPinger() ); - listener = new TcpListener(IPAddress.Any, settings.Server.ListenPort); Name = settings.Server.Name; randomSeed = (int)DateTime.Now.ToBinary(); ModData = modData; + foreach (var trait in modData.Manifest.ServerTraits) + ServerTraits.Add( modData.ObjectCreator.CreateObject(trait) ); + lobbyInfo = new Session( settings.Game.Mods ); lobbyInfo.GlobalSettings.RandomSeed = randomSeed; lobbyInfo.GlobalSettings.Map = map; diff --git a/OpenRA.Game/ServerTraits/LobbyCommands.cs b/OpenRA.Game/ServerTraits/LobbyCommands.cs index caca3925bf..cf75203fcd 100644 --- a/OpenRA.Game/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Game/ServerTraits/LobbyCommands.cs @@ -16,7 +16,7 @@ using OpenRA.FileFormats; namespace OpenRA.Server.Traits { - public class LobbyCommands : IInterpretCommand, INotifyServerStart, IClientJoined + public class LobbyCommands : ServerTrait, IInterpretCommand, INotifyServerStart, IClientJoined { public static int MaxSpectators = 4; // How many spectators to allow // @todo Expose this as an option diff --git a/OpenRA.Game/ServerTraits/MasterServerPinger.cs b/OpenRA.Game/ServerTraits/MasterServerPinger.cs index 0f9b6b3822..8b700bd64b 100644 --- a/OpenRA.Game/ServerTraits/MasterServerPinger.cs +++ b/OpenRA.Game/ServerTraits/MasterServerPinger.cs @@ -14,7 +14,7 @@ using System.Net; namespace OpenRA.Server.Traits { - public class MasterServerPinger : ITick, INotifySyncLobbyInfo, IStartGame + public class MasterServerPinger : ServerTrait, ITick, INotifySyncLobbyInfo, IStartGame { const int MasterPingInterval = 60 * 3; // 3 minutes. server has a 5 minute TTL for games, so give ourselves a bit // of leeway. diff --git a/OpenRA.Game/ServerTraits/PlayerCommands.cs b/OpenRA.Game/ServerTraits/PlayerCommands.cs index bba283c99f..81e54e93c5 100644 --- a/OpenRA.Game/ServerTraits/PlayerCommands.cs +++ b/OpenRA.Game/ServerTraits/PlayerCommands.cs @@ -16,7 +16,7 @@ using OpenRA.Network; namespace OpenRA.Server.Traits { - public class PlayerCommands : IInterpretCommand + public class PlayerCommands : ServerTrait, IInterpretCommand { public bool InterpretCommand(Connection conn, Session.Client client, string cmd) { diff --git a/OpenRA.Game/ServerTraits/TraitInterfaces.cs b/OpenRA.Game/ServerTraits/TraitInterfaces.cs index d77d9f213a..7018d96b20 100644 --- a/OpenRA.Game/ServerTraits/TraitInterfaces.cs +++ b/OpenRA.Game/ServerTraits/TraitInterfaces.cs @@ -25,8 +25,9 @@ namespace OpenRA.Server.Traits int TickTimeout { get; } } + public abstract class ServerTrait {} - public class DebugServerTrait : IInterpretCommand, IStartGame, INotifySyncLobbyInfo, INotifyServerStart, INotifyServerShutdown + public class DebugServerTrait : ServerTrait, IInterpretCommand, IStartGame, INotifySyncLobbyInfo, INotifyServerStart, INotifyServerShutdown { public bool InterpretCommand(Connection conn, Session.Client client, string cmd) { diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 41222aed54..9edd27eb3d 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -83,3 +83,7 @@ TileSets: LoadScreen: CncLoadScreen ShellmapUid:e7b9badb3b7d49ccc773a7aa086c0ff9a1136b77 +ServerTraits: + PlayerCommands + LobbyCommands + MasterServerPinger diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 49f18eb9d8..6726528409 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -78,3 +78,7 @@ Movies: LoadScreen: RALoadScreen ShellmapUid:f1e5ed95dccfa5ba9c61f1263adffe17635ec069 +ServerTraits: + PlayerCommands + LobbyCommands + MasterServerPinger