small tweak for preconnect events

This commit is contained in:
RaidMax 2020-04-26 12:32:41 -05:00
parent 5529858edd
commit 8a98ed7c50
2 changed files with 9 additions and 2 deletions

View File

@ -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,

View File

@ -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);
}
}
}
}