From d4f43a399e4c4659035eafe301c58505a832d060 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 24 Aug 2010 17:16:01 +1200 Subject: [PATCH] add slot open/close server commands with boot on close --- OpenRA.Game/Server/Server.cs | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 341d642818..0c8328c4e2 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -384,6 +384,59 @@ namespace OpenRA.Server return false; GetClient(conn).Slot = slot; + SyncLobbyInfo(); + return true; + }}, + { "slot_close", + s => + { + int slot; + if (!int.TryParse(s, out slot)) { Log.Write("server", "Invalid slot: {0}", s ); return false; } + + var slotData = lobbyInfo.Slots.FirstOrDefault( x => x.Index == slot ); + if (slotData == null) + return false; + + if (conn.PlayerIndex != 0) + { + SendChatTo( conn, "Only the host can alter slots" ); + return true; + } + + slotData.Closed = true; + slotData.Bot = null; + + /* kick any player that's in the slot */ + var occupant = lobbyInfo.Clients.FirstOrDefault( c => c.Slot == slotData.Index ); + if (occupant != null) + { + var occupantConn = conns.FirstOrDefault( c => c.PlayerIndex == occupant.Index ); + if (occupantConn != null) + DropClient( occupantConn, new Exception() ); + } + + SyncLobbyInfo(); + return true; + }}, + { "slot_open", + s => + { + int slot; + if (!int.TryParse(s, out slot)) { Log.Write("server", "Invalid slot: {0}", s ); return false; } + + var slotData = lobbyInfo.Slots.FirstOrDefault( x => x.Index == slot ); + if (slotData == null) + return false; + + if (conn.PlayerIndex != 0) + { + SendChatTo( conn, "Only the host can alter slots" ); + return true; + } + + slotData.Closed = false; + slotData.Bot = null; + SyncLobbyInfo(); return true; }},