dedicated: cleaner

This commit is contained in:
Igor Popov
2012-06-11 05:07:19 +04:00
committed by Chris Forbes
parent 0a858ac353
commit 5bacf69445

View File

@@ -309,8 +309,7 @@ namespace OpenRA.Server
if(lobbyInfo.Clients.Count==1) if(lobbyInfo.Clients.Count==1)
client.IsAdmin=true; client.IsAdmin=true;
OpenRA.Network.Session.Client cli = lobbyInfo.Clients.Where(c1 => c1.IsAdmin).Last(); OpenRA.Network.Session.Client clientAdmin = lobbyInfo.Clients.Where(c1 => c1.IsAdmin).Single();
string adminName = cli.Name;
Log.Write("server", "Client {0}: Accepted connection from {1}", Log.Write("server", "Client {0}: Accepted connection from {1}",
newConn.PlayerIndex, newConn.socket.RemoteEndPoint); newConn.PlayerIndex, newConn.socket.RemoteEndPoint);
@@ -327,7 +326,7 @@ namespace OpenRA.Server
if (client.IsAdmin) if (client.IsAdmin)
SendChatTo(newConn, " You are admin now!"); SendChatTo(newConn, " You are admin now!");
else else
SendChatTo(newConn, " Current admin is "+adminName); SendChatTo(newConn, " Current admin is {0}".F(clientAdmin.Name));
} }
if (mods.Any(m => m.Contains("{DEV_VERSION}"))) if (mods.Any(m => m.Contains("{DEV_VERSION}")))
@@ -484,7 +483,7 @@ namespace OpenRA.Server
conns.Remove(toDrop); conns.Remove(toDrop);
SendChat(toDrop, "Connection Dropped"); 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) if (GameStarted)
SendDisconnected(toDrop); /* Report disconnection */ SendDisconnected(toDrop); /* Report disconnection */
@@ -492,14 +491,14 @@ namespace OpenRA.Server
lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex); lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex);
// reassign admin if necessary // reassign admin if necessary
if ( lobbyInfo.GlobalSettings.Dedicated && oldCli.IsAdmin && !GameStarted) if ( lobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin && !GameStarted)
{ {
if (lobbyInfo.Clients.Count() > 0) if (lobbyInfo.Clients.Count() > 0)
{ {
// client was not alone on the server but he was admin: set admin to the last connected client // 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(); OpenRA.Network.Session.Client lastClient = lobbyInfo.Clients.Last();
newCli.IsAdmin = true; lastClient.IsAdmin = true;
SendChat(toDrop, "Admin left! "+newCli.Name+" is a new admin now!"); SendChat(toDrop, "Admin left! {0} is a new admin now!".F(lastClient.Name));
} }
} }