fix for issue #50
This commit is contained in:
parent
4a46abc46d
commit
0f9d2e92e1
@ -107,7 +107,7 @@ namespace IW4MAdmin.Application
|
||||
|
||||
// todo: this is a hacky mess
|
||||
if (newEvent.Origin?.DelayedEvents.Count > 0 &&
|
||||
(newEvent.Origin?.State == Player.ClientState.Connected ||
|
||||
(//newEvent.Origin?.State == Player.ClientState.Connected ||
|
||||
newEvent.Type == GameEvent.EventType.Connect))
|
||||
{
|
||||
var events = newEvent.Origin.DelayedEvents;
|
||||
|
@ -504,8 +504,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
|
||||
async Task ApplyPenalty(Cheat.DetectionPenaltyResult penalty, Cheat.Detection clientDetection, Player attacker)
|
||||
{
|
||||
await OnProcessingPenalty.WaitAsync();
|
||||
|
||||
try
|
||||
{
|
||||
switch (penalty.ClientPenalty)
|
||||
@ -564,22 +562,22 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
await new CFlag().ExecuteAsync(e);
|
||||
break;
|
||||
}
|
||||
OnProcessingPenalty.Release(1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
OnProcessingPenalty.Release(1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async Task SaveTrackedSnapshots(Cheat.Detection clientDetection)
|
||||
{
|
||||
await OnProcessingPenalty.WaitAsync();
|
||||
|
||||
using (var ctx = new DatabaseContext(true))
|
||||
{
|
||||
// todo: why does this cause duplicate primary key
|
||||
foreach (var change in clientDetection.Tracker
|
||||
.GetChanges()
|
||||
.Where(c => c.SnapshotId == 0))
|
||||
var change = clientDetection.Tracker.GetNextChange();
|
||||
while ((change = clientDetection.Tracker.GetNextChange()) != default(EFACSnapshot))
|
||||
{
|
||||
ctx.Add(change);
|
||||
}
|
||||
@ -587,7 +585,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
try
|
||||
{
|
||||
await ctx.SaveChangesAsync();
|
||||
clientDetection.Tracker.ClearChanges();
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
@ -595,6 +592,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
Log.WriteWarning(ex.GetExceptionInfo());
|
||||
}
|
||||
}
|
||||
|
||||
OnProcessingPenalty.Release(1);
|
||||
}
|
||||
|
||||
public async Task AddStandardKill(Player attacker, Player victim)
|
||||
|
@ -591,7 +591,7 @@ namespace SharedLibraryCore.Commands
|
||||
{
|
||||
foreach (string line in OnlineAdmins(E.Owner).Split(Environment.NewLine))
|
||||
{
|
||||
var t = E.Message.IsBroadcastCommand() ? E.Owner.Broadcast(line) : E.Origin.Tell(line);
|
||||
var t = E.Message.IsBroadcastCommand() ? E.Owner.Broadcast(line) : E.Origin.Tell(line);
|
||||
await t;
|
||||
|
||||
await Task.Delay(FloodProtectionInterval);
|
||||
@ -1370,11 +1370,7 @@ namespace SharedLibraryCore.Commands
|
||||
// the current map is not in rotation
|
||||
if (currentMap.Count() == 0)
|
||||
{
|
||||
nextMap = new Map()
|
||||
{
|
||||
// this happens if it's an unknown custom or DLC map
|
||||
Alias = "Unknown"
|
||||
};
|
||||
return Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_NOT_IN_ROTATION"];
|
||||
}
|
||||
|
||||
// there's duplicate maps in rotation
|
||||
|
@ -1,5 +1,6 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@ -11,32 +12,26 @@ namespace SharedLibraryCore.Helpers
|
||||
/// <typeparam name="T">Type of entity to keep track of changes to</typeparam>
|
||||
public class ChangeTracking<T>
|
||||
{
|
||||
List<T> Values;
|
||||
ConcurrentQueue<T> Values;
|
||||
|
||||
public ChangeTracking()
|
||||
{
|
||||
Values = new List<T>();
|
||||
Values = new ConcurrentQueue<T>();
|
||||
}
|
||||
|
||||
public void OnChange(T value)
|
||||
{
|
||||
lock (value)
|
||||
{
|
||||
// clear the first value when count max count reached
|
||||
if (Values.Count > 30)
|
||||
Values.RemoveAt(0);
|
||||
Values.Add(value);
|
||||
}
|
||||
if (Values.Count > 30)
|
||||
Values.TryDequeue(out T throwAway);
|
||||
Values.Enqueue(value);
|
||||
}
|
||||
|
||||
public T[] GetChanges() => Values.ToArray();
|
||||
public T GetNextChange()
|
||||
{
|
||||
bool itemDequeued = Values.TryDequeue(out T val);
|
||||
return itemDequeued ? val : default(T);
|
||||
}
|
||||
|
||||
public bool HasChanges => Values.Count > 0;
|
||||
|
||||
public void ClearChanges()
|
||||
{
|
||||
lock (Values)
|
||||
Values.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user