fix for issue #50
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user