Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,35 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
using System.Collections.Concurrent;
namespace VitaNex.Collections
{
public sealed class ConcurrentBagPool<T> : ObjectPool<ConcurrentBag<T>>
{
public ConcurrentBagPool()
{ }
public ConcurrentBagPool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(ConcurrentBag<T> o)
{
while (!o.IsEmpty)
{
o.TryTake(out _);
}
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,32 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
using System.Collections.Concurrent;
namespace VitaNex.Collections
{
public sealed class ConcurrentDictionaryPool<TKey, TVal> : ObjectPool<ConcurrentDictionary<TKey, TVal>>
{
public ConcurrentDictionaryPool()
{ }
public ConcurrentDictionaryPool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(ConcurrentDictionary<TKey, TVal> o)
{
o.Clear();
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,35 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
using System.Collections.Concurrent;
namespace VitaNex.Collections
{
public sealed class ConcurrentQueuePool<T> : ObjectPool<ConcurrentQueue<T>>
{
public ConcurrentQueuePool()
{ }
public ConcurrentQueuePool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(ConcurrentQueue<T> o)
{
while (!o.IsEmpty)
{
o.TryDequeue(out _);
}
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,32 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
using System.Collections.Concurrent;
namespace VitaNex.Collections
{
public sealed class ConcurrentStackPool<T> : ObjectPool<ConcurrentStack<T>>
{
public ConcurrentStackPool()
{ }
public ConcurrentStackPool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(ConcurrentStack<T> o)
{
o.Clear();
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,34 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System.Collections.Generic;
#endregion
namespace VitaNex.Collections
{
public sealed class DictionaryPool<TKey, TVal> : ObjectPool<Dictionary<TKey, TVal>>
{
public DictionaryPool()
{ }
public DictionaryPool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(Dictionary<TKey, TVal> o)
{
o.Clear();
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,33 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
#endregion
namespace VitaNex.Collections
{
public sealed class GridPool<T> : ObjectPool<Grid<T>>
{
public GridPool()
{ }
public GridPool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(Grid<T> o)
{
o.Resize(0, 0);
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,39 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System.Collections.Generic;
#endregion
namespace VitaNex.Collections
{
public sealed class ListPool<T> : ObjectPool<List<T>>
{
public ListPool()
{ }
public ListPool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(List<T> o)
{
o.Clear();
if (o.Capacity > 0x1000)
{
o.Capacity = 0x1000;
}
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,209 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System;
using System.Collections;
using System.Collections.Concurrent;
#endregion
namespace VitaNex.Collections
{
public static class ObjectPool
{
public static T Acquire<T>() where T : class, new()
{
return ObjectPool<T>.AcquireObject();
}
public static void Acquire<T>(out T o) where T : class, new()
{
ObjectPool<T>.AcquireObject(out o);
}
public static void Free<T>(T o) where T : class, new()
{
ObjectPool<T>.FreeObject(o);
}
public static void Free<T>(ref T o) where T : class, new()
{
ObjectPool<T>.FreeObject(ref o);
}
}
public class ObjectPool<T> where T : class, new()
{
private static readonly ObjectPool<T> _Instance;
static ObjectPool()
{
_Instance = new ObjectPool<T>();
}
public static T AcquireObject()
{
return _Instance.Acquire();
}
public static void AcquireObject(out T o)
{
o = _Instance.Acquire();
}
public static void FreeObject(T o)
{
_Instance.Free(o);
}
public static void FreeObject(ref T o)
{
_Instance.Free(ref o);
}
protected readonly ConcurrentQueue<T> _Pool;
private volatile int _Capacity;
public int Capacity
{
get => _Capacity;
set
{
if (value < 0)
{
value = DefaultCapacity;
}
_Capacity = value;
}
}
public int Count => _Pool.Count;
public bool IsEmpty => _Pool.IsEmpty;
public bool IsOverflow => _Pool.Count > _Capacity;
public bool IsFull => _Capacity > 0 && _Pool.Count >= _Capacity;
public virtual int DefaultCapacity => 64;
public ObjectPool()
{
_Capacity = DefaultCapacity;
_Pool = new ConcurrentQueue<T>();
}
public ObjectPool(int capacity)
{
_Capacity = capacity;
_Pool = new ConcurrentQueue<T>();
}
public virtual T Acquire()
{
if (!_Pool.TryDequeue(out var o) || o == null)
{
o = new T();
}
return o;
}
public virtual void Free(T o)
{
if (o == null)
{
return;
}
try
{
if (!Sanitize(o))
{
return;
}
}
catch
{
return;
}
if (!IsFull)
{
_Pool.Enqueue(o);
}
}
public void Free(ref T o)
{
Free(o);
o = default(T);
}
protected virtual bool Sanitize(T o)
{
if (o is IList l)
{
l.Clear();
return l.Count == 0;
}
o.InvokeMethod("Clear");
return true;
}
public void Clear()
{
while (!IsEmpty)
{
_Pool.TryDequeue(out _);
}
}
public virtual int Trim()
{
var c = 0;
while (IsOverflow)
{
_Pool.TryDequeue(out _);
++c;
}
return c;
}
public virtual int Fill()
{
var c = 0;
while (!IsFull)
{
_Pool.Enqueue(new T());
++c;
}
return c;
}
public virtual void Free()
{
Clear();
}
}
}

View File

@@ -0,0 +1,34 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System.Collections.Generic;
#endregion
namespace VitaNex.Collections
{
public sealed class QueuePool<T> : ObjectPool<Queue<T>>
{
public QueuePool()
{ }
public QueuePool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(Queue<T> o)
{
o.Clear();
return o.Count == 0;
}
}
}

View File

@@ -0,0 +1,34 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System.Collections.Generic;
#endregion
namespace VitaNex.Collections
{
public sealed class SetPool<T> : ObjectPool<HashSet<T>>
{
public SetPool()
{ }
public SetPool(int capacity)
: base(capacity)
{ }
protected override bool Sanitize(HashSet<T> o)
{
o.Clear();
return o.Count == 0;
}
}
}