diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 96f8af04ac..d8fc8ad550 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -590,8 +590,10 @@ namespace OpenRA.Server DispatchOrders(toDrop, frame, new byte[] { 0xbf }); + // All clients have left: clean up if (!Conns.Any()) - TempBans.Clear(); + foreach (var t in serverTraits.WithInterface()) + t.ServerEmpty(this); if (Conns.Any() || Dedicated) SyncLobbyClients(); diff --git a/OpenRA.Game/Server/TraitInterfaces.cs b/OpenRA.Game/Server/TraitInterfaces.cs index 8f3c0cc707..8065bc9424 100644 --- a/OpenRA.Game/Server/TraitInterfaces.cs +++ b/OpenRA.Game/Server/TraitInterfaces.cs @@ -18,6 +18,7 @@ namespace OpenRA.Server public interface IInterpretCommand { bool InterpretCommand(Server server, Connection conn, Session.Client client, string cmd); } public interface INotifySyncLobbyInfo { void LobbyInfoSynced(Server server); } public interface INotifyServerStart { void ServerStarted(Server server); } + public interface INotifyServerEmpty { void ServerEmpty(Server server); } public interface INotifyServerShutdown { void ServerShutdown(Server server); } public interface IStartGame { void GameStarted(Server server); } public interface IClientJoined { void ClientJoined(Server server, Connection conn); } diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index ba15c6ddf9..2238b75053 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -11,9 +11,7 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; -using System.Threading; using OpenRA.Graphics; using OpenRA.Mods.Common.Traits; using OpenRA.Network; @@ -23,7 +21,7 @@ using S = OpenRA.Server.Server; namespace OpenRA.Mods.Common.Server { - public class LobbyCommands : ServerTrait, IInterpretCommand, INotifyServerStart, IClientJoined + public class LobbyCommands : ServerTrait, IInterpretCommand, INotifyServerStart, INotifyServerEmpty, IClientJoined { static bool ValidateSlotCommand(S server, Connection conn, Session.Client client, string arg, bool requiresHost) { @@ -871,6 +869,21 @@ namespace OpenRA.Mods.Common.Server server.SendOrderTo(conn, "Message", briefing); } + void INotifyServerEmpty.ServerEmpty(S server) + { + // Expire any temporary bans + server.TempBans.Clear(); + + // Re-enable spectators + server.LobbyInfo.GlobalSettings.AllowSpectators = true; + + // Reset player slots + server.LobbyInfo.Slots = server.Map.Players.Players + .Select(p => MakeSlotFromPlayerReference(p.Value)) + .Where(ss => ss != null) + .ToDictionary(ss => ss.PlayerReference, ss => ss); + } + public PlayerReference PlayerReferenceForSlot(S server, Session.Slot slot) { if (slot == null)