Kick clients who don't have the map when the host force-starts.

This commit is contained in:
Paul Chote
2014-03-13 17:07:41 +13:00
parent f5f84244eb
commit fcb3d7347a
6 changed files with 41 additions and 18 deletions

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Network
get { return Clients.Count(c => c.Bot == null) == 1; }
}
public enum ClientState { NotReady, Ready, Disconnected = 1000 }
public enum ClientState { NotReady, Invalid, Ready, Disconnected = 1000 }
public class Client
{
@@ -93,13 +93,14 @@ namespace OpenRA.Network
public int SpawnPoint;
public string Name;
public string IpAddress;
public ClientState State;
public ClientState State = ClientState.Invalid;
public int Team;
public string Slot; // slot ID, or null for observer
public string Bot; // Bot type, null for real clients
public int BotControllerClientIndex; // who added the bot to the slot
public bool IsAdmin;
public bool IsReady { get { return State == ClientState.Ready; } }
public bool IsInvalid { get { return State == ClientState.Invalid; } }
public bool IsObserver { get { return Slot == null; } }
public int Latency = -1;
public int LatencyJitter = -1;

View File

@@ -130,7 +130,7 @@ namespace OpenRA.Network
Country = "random",
SpawnPoint = 0,
Team = 0,
State = Session.ClientState.NotReady
State = Session.ClientState.Invalid
};
var response = new HandshakeResponse()

View File

@@ -272,7 +272,7 @@ namespace OpenRA.Server
Country = "random",
SpawnPoint = 0,
Team = 0,
State = Session.ClientState.NotReady,
State = Session.ClientState.Invalid,
IsAdmin = !LobbyInfo.Clients.Any(c1 => c1.IsAdmin)
};
@@ -572,19 +572,31 @@ namespace OpenRA.Server
public void StartGame()
{
State = ServerState.GameStarted;
listener.Stop();
Console.WriteLine("Game started");
foreach (var c in Conns)
foreach (var d in Conns)
DispatchOrdersToClient(c, d.PlayerIndex, 0x7FFFFFFF, new byte[] { 0xBF });
// Drop any unvalidated clients
foreach (var c in PreConns.ToArray())
DropClient(c);
// Drop any players who are not ready
foreach (var c in Conns.ToArray())
{
if (GetClient(c).IsInvalid)
{
SendOrderTo(c, "ServerError", "You have been kicked from the server");
DropClient(c);
}
}
SyncLobbyInfo();
State = ServerState.GameStarted;
foreach (var c in Conns)
foreach (var d in Conns)
DispatchOrdersToClient(c, d.PlayerIndex, 0x7FFFFFFF, new byte[] { 0xBF });
DispatchOrders(null, 0,
new ServerOrder("StartGame", "").Serialize());