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