diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 5044694ce..3039a49c0 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -312,6 +312,7 @@ namespace IW4MAdmin // this happens for some reason rarely where the client spots get out of order // possible a connect/reconnect game event before we get to process it here + // it appears that new games decide to switch client slots between maps (even if the clients aren't disconnecting) else if (existingClient != null && existingClient.ClientNumber != E.Origin.ClientNumber) { Logger.WriteWarning($"client {E.Origin} is trying to connect in client slot {E.Origin.ClientNumber}, but they are already registed in client slot {existingClient.ClientNumber}, swapping..."); @@ -764,6 +765,7 @@ namespace IW4MAdmin foreach (var disconnectingClient in polledClients[1]) { + disconnectingClient.CurrentServer = this; var e = new GameEvent() { Type = GameEvent.EventType.PreDisconnect, @@ -784,6 +786,7 @@ namespace IW4MAdmin continue; } + client.CurrentServer = this; var e = new GameEvent() { Type = GameEvent.EventType.PreConnect, @@ -799,6 +802,7 @@ namespace IW4MAdmin // these are the clients that have updated foreach (var client in polledClients[2]) { + client.CurrentServer = this; var e = new GameEvent() { Type = GameEvent.EventType.Update, diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index f62515844..e8f295985 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -741,7 +741,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers // kill event is not designated as blocking, so we should be able to enter and exit // we need to make this thread safe because we can potentially have kills qualify // for stat history update, but one is already processing that invalidates the original - await attacker.Lock(); + await attackerStats.ProcessingHit.WaitAsync(Utilities.DefaultCommandTimeout, Plugin.ServerManager.CancellationToken); await UpdateStatHistory(attacker, attackerStats); attackerStats.LastStatHistoryUpdate = DateTime.UtcNow; } @@ -754,7 +754,10 @@ namespace IW4MAdmin.Plugins.Stats.Helpers finally { - attacker.Unlock(); + if (attackerStats.ProcessingHit.CurrentCount == 0) + { + attackerStats.ProcessingHit.Release(1); + } } } }