dedicated: handle admin
This commit is contained in:
@@ -266,7 +266,7 @@ namespace OpenRA.Server
|
|||||||
(kv.Second == "{DEV_VERSION}" || Game.CurrentMods[kv.First].Version == "{DEV_VERSION}" || kv.Second == Game.CurrentMods[kv.First].Version));
|
(kv.Second == "{DEV_VERSION}" || Game.CurrentMods[kv.First].Version == "{DEV_VERSION}" || kv.Second == Game.CurrentMods[kv.First].Version));
|
||||||
|
|
||||||
// Drop DEV_VERSION if it's a Dedicated
|
// Drop DEV_VERSION if it's a Dedicated
|
||||||
if ( lobbyInfo.GlobalSettings.Dedicated && mods.Any(m => m.Contains("{DEV_VERSION}"))) { valid = false; }
|
if ( lobbyInfo.GlobalSettings.Dedicated && mods.Any(m => m.Contains("{DEV_VERSION}")) ) { valid = false; }
|
||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
@@ -309,6 +309,9 @@ 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();
|
||||||
|
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);
|
||||||
|
|
||||||
@@ -317,6 +320,15 @@ namespace OpenRA.Server
|
|||||||
|
|
||||||
SyncLobbyInfo();
|
SyncLobbyInfo();
|
||||||
SendChat(newConn, "has joined the game.");
|
SendChat(newConn, "has joined the game.");
|
||||||
|
|
||||||
|
if ( lobbyInfo.GlobalSettings.Dedicated )
|
||||||
|
{
|
||||||
|
SendChatTo(newConn, "You have joined the dedicated server!");
|
||||||
|
if (client.IsAdmin == true)
|
||||||
|
SendChatTo(newConn, " You are admin now!");
|
||||||
|
else
|
||||||
|
SendChatTo(newConn, " Current admin is "+adminName);
|
||||||
|
}
|
||||||
|
|
||||||
if (mods.Any(m => m.Contains("{DEV_VERSION}")))
|
if (mods.Any(m => m.Contains("{DEV_VERSION}")))
|
||||||
SendChat(newConn, "is running a development version, "+
|
SendChat(newConn, "is running a development version, "+
|
||||||
@@ -471,12 +483,26 @@ 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();
|
||||||
|
|
||||||
if (GameStarted)
|
if (GameStarted)
|
||||||
SendDisconnected(toDrop); /* Report disconnection */
|
SendDisconnected(toDrop); /* Report disconnection */
|
||||||
|
|
||||||
lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex);
|
lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex);
|
||||||
|
|
||||||
|
// reassign admin if necessary
|
||||||
|
if ( lobbyInfo.GlobalSettings.Dedicated && oldCli.IsAdmin == true && !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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DispatchOrders( toDrop, toDrop.MostRecentFrame, new byte[] { 0xbf } );
|
DispatchOrders( toDrop, toDrop.MostRecentFrame, new byte[] { 0xbf } );
|
||||||
|
|
||||||
if (conns.Count != 0)
|
if (conns.Count != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user