Reset slot configuration when all players leave a dedicated server.
This commit is contained in:
@@ -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<INotifyServerEmpty>())
|
||||
t.ServerEmpty(this);
|
||||
|
||||
if (Conns.Any() || Dedicated)
|
||||
SyncLobbyClients();
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user