Merge branch '2.3' into 2.4-pr
This commit is contained in:
commit
dcd1c97d37
@ -222,8 +222,15 @@ namespace IW4MAdmin.Application
|
||||
{
|
||||
await Task.Delay(ConfigHandler.Configuration().RConPollRate, _tokenSource.Token);
|
||||
}
|
||||
// if a cancellation is received, we want to return immediately
|
||||
catch { break; }
|
||||
// if a cancellation is received, we want to return immediately after shutting down
|
||||
catch
|
||||
{
|
||||
foreach (var server in Servers.Where(s => serverIds.Contains(s.EndPoint)))
|
||||
{
|
||||
await server.ProcessUpdatesAsync(_tokenSource.Token);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,6 +579,30 @@ namespace IW4MAdmin
|
||||
};
|
||||
}
|
||||
|
||||
private async Task ShutdownInternal()
|
||||
{
|
||||
foreach (var client in GetClientsAsList())
|
||||
{
|
||||
await client.OnDisconnect();
|
||||
|
||||
var e = new GameEvent()
|
||||
{
|
||||
Type = GameEvent.EventType.Disconnect,
|
||||
Owner = this,
|
||||
Origin = client
|
||||
};
|
||||
|
||||
Manager.GetEventHandler().AddEvent(e);
|
||||
|
||||
await e.WaitAsync(Utilities.DefaultCommandTimeout, new CancellationTokenRegistration().Token);
|
||||
}
|
||||
|
||||
foreach (var plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
|
||||
{
|
||||
await plugin.OnUnloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
DateTime playerCountStart = DateTime.Now;
|
||||
DateTime lastCount = DateTime.Now;
|
||||
@ -587,17 +611,11 @@ namespace IW4MAdmin
|
||||
{
|
||||
try
|
||||
{
|
||||
#region SHUTDOWN
|
||||
if (Manager.CancellationToken.IsCancellationRequested)
|
||||
if (cts.IsCancellationRequested)
|
||||
{
|
||||
foreach (var plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
|
||||
{
|
||||
await plugin.OnUnloadAsync();
|
||||
}
|
||||
|
||||
await ShutdownInternal();
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
try
|
||||
{
|
||||
@ -745,6 +763,12 @@ namespace IW4MAdmin
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
await ShutdownInternal();
|
||||
return true;
|
||||
}
|
||||
|
||||
// this one is ok
|
||||
catch (ServerException e)
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ namespace AutomessageFeed
|
||||
|
||||
public Task OnUnloadAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -437,15 +437,19 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
|
||||
// sync their stats before they leave
|
||||
clientStats = UpdateStats(clientStats);
|
||||
await SaveClientStats(clientStats);
|
||||
|
||||
// increment the total play time
|
||||
serverStats.TotalPlayTime += pl.ConnectionLength;
|
||||
}
|
||||
|
||||
private static async Task SaveClientStats(EFClientStatistics clientStats)
|
||||
{
|
||||
using (var ctx = new DatabaseContext(disableTracking: true))
|
||||
{
|
||||
ctx.Update(clientStats);
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// increment the total play time
|
||||
serverStats.TotalPlayTime += pl.ConnectionLength;
|
||||
}
|
||||
|
||||
public void AddDamageEvent(string eventLine, int attackerClientId, int victimClientId, long serverId)
|
||||
@ -551,6 +555,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
clientStats.HitLocations.Single(hl => hl.Location == hit.HitLoc).HitCount += 1;
|
||||
}
|
||||
|
||||
if (clientStats.SessionKills % Detection.MAX_TRACKED_HIT_COUNT == 0)
|
||||
{
|
||||
await SaveClientStats(clientStats);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (Plugin.Config.Configuration().StoreClientKills)
|
||||
|
Loading…
Reference in New Issue
Block a user