From 5bacf6944585a126034afb6472072f8fb16cb16d Mon Sep 17 00:00:00 2001 From: Igor Popov Date: Mon, 11 Jun 2012 05:07:19 +0400 Subject: [PATCH] dedicated: cleaner --- OpenRA.Game/Server/Server.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 185dca1b21..663d479254 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -309,8 +309,7 @@ namespace OpenRA.Server if(lobbyInfo.Clients.Count==1) client.IsAdmin=true; - OpenRA.Network.Session.Client cli = lobbyInfo.Clients.Where(c1 => c1.IsAdmin).Last(); - string adminName = cli.Name; + OpenRA.Network.Session.Client clientAdmin = lobbyInfo.Clients.Where(c1 => c1.IsAdmin).Single(); Log.Write("server", "Client {0}: Accepted connection from {1}", newConn.PlayerIndex, newConn.socket.RemoteEndPoint); @@ -327,7 +326,7 @@ namespace OpenRA.Server if (client.IsAdmin) SendChatTo(newConn, " You are admin now!"); else - SendChatTo(newConn, " Current admin is "+adminName); + SendChatTo(newConn, " Current admin is {0}".F(clientAdmin.Name)); } if (mods.Any(m => m.Contains("{DEV_VERSION}"))) @@ -484,7 +483,7 @@ namespace OpenRA.Server conns.Remove(toDrop); SendChat(toDrop, "Connection Dropped"); - OpenRA.Network.Session.Client oldCli = lobbyInfo.Clients.Where(c1 => c1.Index == toDrop.PlayerIndex).Last(); + OpenRA.Network.Session.Client dropClient = lobbyInfo.Clients.Where(c1 => c1.Index == toDrop.PlayerIndex).Single(); if (GameStarted) SendDisconnected(toDrop); /* Report disconnection */ @@ -492,14 +491,14 @@ namespace OpenRA.Server lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex); // reassign admin if necessary - if ( lobbyInfo.GlobalSettings.Dedicated && oldCli.IsAdmin && !GameStarted) + if ( lobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin && !GameStarted) { if (lobbyInfo.Clients.Count() > 0) { // client was not alone on the server but he was admin: set admin to the last connected client - OpenRA.Network.Session.Client newCli = lobbyInfo.Clients.Last(); - newCli.IsAdmin = true; - SendChat(toDrop, "Admin left! "+newCli.Name+" is a new admin now!"); + OpenRA.Network.Session.Client lastClient = lobbyInfo.Clients.Last(); + lastClient.IsAdmin = true; + SendChat(toDrop, "Admin left! {0} is a new admin now!".F(lastClient.Name)); } }