Removed Connection.PlayerIndex == 0 checks if favor of Session.Player.IsAdmin
This commit is contained in:
@@ -220,7 +220,12 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static bool IsHost
|
public static bool IsHost
|
||||||
{
|
{
|
||||||
get { return orderManager.Connection.LocalClientId == 0; }
|
get
|
||||||
|
{
|
||||||
|
var client= orderManager.LobbyInfo.ClientWithIndex (
|
||||||
|
orderManager.Connection.LocalClientId);
|
||||||
|
return ((client!=null) && client.IsAdmin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<String, Mod> CurrentMods
|
public static Dictionary<String, Mod> CurrentMods
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Network
|
|||||||
public int Team;
|
public int Team;
|
||||||
public string Slot; // slot ID, or null for observer
|
public string Slot; // slot ID, or null for observer
|
||||||
public string Bot; // Bot type, null for real clients
|
public string Bot; // Bot type, null for real clients
|
||||||
|
public bool IsAdmin;
|
||||||
public bool IsReady { get { return State == ClientState.Ready; } }
|
public bool IsReady { get { return State == ClientState.Ready; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace OpenRA.Server
|
|||||||
catch { }
|
catch { }
|
||||||
} ) { IsBackground = true }.Start();
|
} ) { IsBackground = true }.Start();
|
||||||
}
|
}
|
||||||
|
int nextPlayerIndex;
|
||||||
/* lobby rework todo:
|
/* lobby rework todo:
|
||||||
* - "teams together" option for team games -- will eliminate most need
|
* - "teams together" option for team games -- will eliminate most need
|
||||||
* for manual spawnpoint choosing.
|
* for manual spawnpoint choosing.
|
||||||
@@ -129,12 +129,8 @@ namespace OpenRA.Server
|
|||||||
*/
|
*/
|
||||||
public int ChooseFreePlayerIndex()
|
public int ChooseFreePlayerIndex()
|
||||||
{
|
{
|
||||||
for (var i = 0; i < 256; i++)
|
nextPlayerIndex++;
|
||||||
if (conns.All(c => c.PlayerIndex != i) && preConns.All(c => c.PlayerIndex != i)
|
return nextPlayerIndex;
|
||||||
&& lobbyInfo.Clients.All(c => c.Index != i))
|
|
||||||
return i;
|
|
||||||
|
|
||||||
throw new InvalidOperationException("Already got 256 players");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AcceptConnection()
|
void AcceptConnection()
|
||||||
@@ -221,6 +217,9 @@ namespace OpenRA.Server
|
|||||||
SyncClientToPlayerReference(client, Map.Players[client.Slot]);
|
SyncClientToPlayerReference(client, Map.Players[client.Slot]);
|
||||||
|
|
||||||
lobbyInfo.Clients.Add(client);
|
lobbyInfo.Clients.Add(client);
|
||||||
|
//Assume that first validated client is server admin
|
||||||
|
if(lobbyInfo.Clients.Count==1)
|
||||||
|
client.IsAdmin=true;
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
{
|
{
|
||||||
public class LobbyCommands : ServerTrait, IInterpretCommand, INotifyServerStart
|
public class LobbyCommands : ServerTrait, IInterpretCommand, INotifyServerStart
|
||||||
{
|
{
|
||||||
static bool ValidateSlotCommand(S server, Connection conn, string arg, bool requiresHost)
|
static bool ValidateSlotCommand(S server, Connection conn, Session.Client client, string arg, bool requiresHost)
|
||||||
{
|
{
|
||||||
if (!server.lobbyInfo.Slots.ContainsKey(arg))
|
if (!server.lobbyInfo.Slots.ContainsKey(arg))
|
||||||
{
|
{
|
||||||
Log.Write("server", "Invalid slot: {0}", arg );
|
Log.Write("server", "Invalid slot: {0}", arg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiresHost && conn.PlayerIndex != 0)
|
if (requiresHost && !client.IsAdmin)
|
||||||
{
|
{
|
||||||
server.SendChatTo( conn, "Only the host can do that" );
|
server.SendChatTo( conn, "Only the host can do that" );
|
||||||
return false;
|
return false;
|
||||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
{ "slot_close",
|
{ "slot_close",
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
if (!ValidateSlotCommand( server, conn, s, true ))
|
if (!ValidateSlotCommand( server, conn, client, s, true ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// kick any player that's in the slot
|
// kick any player that's in the slot
|
||||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
{ "slot_open",
|
{ "slot_open",
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
if (!ValidateSlotCommand( server, conn, s, true ))
|
if (!ValidateSlotCommand( server, conn, client, s, true ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var slot = server.lobbyInfo.Slots[s];
|
var slot = server.lobbyInfo.Slots[s];
|
||||||
@@ -179,7 +179,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ValidateSlotCommand( server, conn, parts[0], true ))
|
if (!ValidateSlotCommand( server, conn, client, parts[0], true ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var slot = server.lobbyInfo.Slots[parts[0]];
|
var slot = server.lobbyInfo.Slots[parts[0]];
|
||||||
@@ -231,7 +231,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
{ "map",
|
{ "map",
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
if (conn.PlayerIndex != 0)
|
if (!client.IsAdmin)
|
||||||
{
|
{
|
||||||
server.SendChatTo( conn, "Only the host can change the map" );
|
server.SendChatTo( conn, "Only the host can change the map" );
|
||||||
return true;
|
return true;
|
||||||
@@ -267,7 +267,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
{ "lockteams",
|
{ "lockteams",
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
if (conn.PlayerIndex != 0)
|
if (!client.IsAdmin)
|
||||||
{
|
{
|
||||||
server.SendChatTo( conn, "Only the host can set that option" );
|
server.SendChatTo( conn, "Only the host can set that option" );
|
||||||
return true;
|
return true;
|
||||||
@@ -280,7 +280,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
{ "allowcheats",
|
{ "allowcheats",
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
if (conn.PlayerIndex != 0)
|
if (!client.IsAdmin)
|
||||||
{
|
{
|
||||||
server.SendChatTo( conn, "Only the host can set that option" );
|
server.SendChatTo( conn, "Only the host can set that option" );
|
||||||
return true;
|
return true;
|
||||||
@@ -294,7 +294,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
|
|
||||||
if (conn.PlayerIndex != 0)
|
if (!client.IsAdmin)
|
||||||
{
|
{
|
||||||
server.SendChatTo( conn, "Only the host can kick players" );
|
server.SendChatTo( conn, "Only the host can kick players" );
|
||||||
return true;
|
return true;
|
||||||
@@ -330,7 +330,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
||||||
|
|
||||||
// Only the host can change other client's info
|
// Only the host can change other client's info
|
||||||
if (targetClient.Index != client.Index && conn.PlayerIndex != 0)
|
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Map has disabled race changes
|
// Map has disabled race changes
|
||||||
@@ -348,7 +348,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
||||||
|
|
||||||
// Only the host can change other client's info
|
// Only the host can change other client's info
|
||||||
if (targetClient.Index != client.Index && conn.PlayerIndex != 0)
|
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Map has disabled team changes
|
// Map has disabled team changes
|
||||||
@@ -369,7 +369,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
||||||
|
|
||||||
// Only the host can change other client's info
|
// Only the host can change other client's info
|
||||||
if (targetClient.Index != client.Index && conn.PlayerIndex != 0)
|
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Spectators don't need a spawnpoint
|
// Spectators don't need a spawnpoint
|
||||||
@@ -404,7 +404,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
var targetClient = server.lobbyInfo.ClientWithIndex(int.Parse(parts[0]));
|
||||||
|
|
||||||
// Only the host can change other client's info
|
// Only the host can change other client's info
|
||||||
if (targetClient.Index != client.Index && conn.PlayerIndex != 0)
|
if (targetClient.Index != client.Index && !client.IsAdmin)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Map has disabled color changes
|
// Map has disabled color changes
|
||||||
|
|||||||
Reference in New Issue
Block a user