fix client join/leave race with master server ping

This commit is contained in:
Chris Forbes
2014-01-16 09:36:12 +13:00
parent f053379458
commit abaed4e8be

View File

@@ -51,6 +51,12 @@ namespace OpenRA.Mods.RA.Server
isBusy = true; isBusy = true;
var mod = server.ModData.Manifest.Mod; var mod = server.ModData.Manifest.Mod;
// important to grab these on the main server thread, not in the worker we're about to spawn -- they may be modified
// by the main thread as clients join and leave.
var numPlayers = server.LobbyInfo.Clients.Where(c1 => c1.Bot == null).Count();
var numBots = server.LobbyInfo.Clients.Where(c1 => c1.Bot != null).Count();
Action a = () => Action a = () =>
{ {
try try
@@ -65,8 +71,8 @@ namespace OpenRA.Mods.RA.Server
server.Settings.MasterServer + url.F( server.Settings.MasterServer + url.F(
server.Settings.ExternalPort, Uri.EscapeUriString(server.Settings.Name), server.Settings.ExternalPort, Uri.EscapeUriString(server.Settings.Name),
(int)server.State, (int)server.State,
server.LobbyInfo.Clients.Where(c1 => c1.Bot == null).Count(), numPlayers,
server.LobbyInfo.Clients.Where(c1 => c1.Bot != null).Count(), numBots,
"{0}@{1}".F(mod.Id, mod.Version), "{0}@{1}".F(mod.Id, mod.Version),
server.LobbyInfo.GlobalSettings.Map, server.LobbyInfo.GlobalSettings.Map,
server.Map.PlayerCount)); server.Map.PlayerCount));