Promote oldest player to admin, not newest.

This commit is contained in:
Paul Chote
2013-05-10 04:05:05 +12:00
parent 500c24fbaf
commit 818876a451

View File

@@ -493,18 +493,20 @@ namespace OpenRA.Server
lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex); lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex);
// reassign admin if necessary // Client was the server admin
// TODO: Reassign admin for game in progress via an order
if (lobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin && State == ServerState.WaitingPlayers) if (lobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin && State == ServerState.WaitingPlayers)
{ {
// clean up the bots that were added by the last admin // Remove any bots controlled by the admin
lobbyInfo.Clients.RemoveAll(c => c.Bot != null && c.BotControllerClientIndex == toDrop.PlayerIndex); lobbyInfo.Clients.RemoveAll(c => c.Bot != null && c.BotControllerClientIndex == toDrop.PlayerIndex);
if (lobbyInfo.Clients.Any(c1 => c1.Bot == null)) OpenRA.Network.Session.Client nextAdmin = lobbyInfo.Clients.Where(c1 => c1.Bot == null)
.OrderBy(c => c.Index).FirstOrDefault();
if (nextAdmin != null)
{ {
// client was not alone on the server but he was admin: set admin to the last connected client nextAdmin.IsAdmin = true;
OpenRA.Network.Session.Client lastClient = lobbyInfo.Clients.Where(c1 => c1.Bot == null).Last(); SendMessage("{0} is now the admin.".F(nextAdmin.Name));
lastClient.IsAdmin = true;
SendMessage("{0} is now the admin.".F(lastClient.Name));
} }
} }
@@ -512,6 +514,7 @@ namespace OpenRA.Server
if (conns.Count != 0 || lobbyInfo.GlobalSettings.Dedicated) if (conns.Count != 0 || lobbyInfo.GlobalSettings.Dedicated)
SyncLobbyInfo(); SyncLobbyInfo();
if (!lobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin) if (!lobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin)
Shutdown(); Shutdown();
} }