Core/Refactor: Part 1
This commit is contained in:
@@ -369,7 +369,7 @@ namespace System.Collections
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
public virtual bool MoveNext()
|
||||
public bool MoveNext()
|
||||
{
|
||||
//if (version != bitarray._version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
|
||||
if (index < (bitarray.Count - 1))
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace Framework.Configuration
|
||||
int lineCounter = 0;
|
||||
try
|
||||
{
|
||||
string name = string.Empty;
|
||||
foreach (var line in ConfigContent)
|
||||
{
|
||||
lineCounter++;
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
@@ -46,6 +48,7 @@ namespace Framework.Constants
|
||||
SumChildrenWeight = 9
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum AchievementFlags
|
||||
{
|
||||
Counter = 0x01,
|
||||
@@ -71,6 +74,7 @@ namespace Framework.Constants
|
||||
TrackingFlag = 0x00100000
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CriteriaFlagsCu
|
||||
{
|
||||
Player = 0x1,
|
||||
|
||||
@@ -849,7 +849,7 @@ namespace Framework.Constants
|
||||
FlyWarriorChargeEnd = 821
|
||||
}
|
||||
|
||||
public enum AreaFlags : int
|
||||
public enum AreaFlags
|
||||
{
|
||||
Snow = 0x01, // Snow (Only Dun Morogh, Naxxramas, Razorfen Downs And Winterspring)
|
||||
Unk1 = 0x02, // Razorfen Downs, Naxxramas And Acherus: The Ebon Hold (3.3.5a)
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Framework.Constants
|
||||
InvalidVendor = 5
|
||||
}
|
||||
|
||||
public enum GuildBankRights : int
|
||||
public enum GuildBankRights
|
||||
{
|
||||
ViewTab = 0x01,
|
||||
PutItem = 0x02,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum Language : int
|
||||
public enum Language
|
||||
{
|
||||
Universal = 0,
|
||||
Orcish = 1,
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Framework.Constants
|
||||
|
||||
public const int ReqPrimaryTreeTalents = 31;
|
||||
public const int ExploredZonesSize = 320;
|
||||
public const ulong MaxMoneyAmount = ulong.MaxValue;
|
||||
public const ulong MaxMoneyAmount = 99999999999UL;
|
||||
public const int MaxActionButtons = 132;
|
||||
public const int MaxActionButtonActionValue = 0x00FFFFFF + 1;
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace Framework.Constants
|
||||
}
|
||||
|
||||
// Spell mechanics
|
||||
public enum Mechanics : int
|
||||
public enum Mechanics
|
||||
{
|
||||
None = 0,
|
||||
Charm = 1,
|
||||
@@ -277,7 +277,7 @@ namespace Framework.Constants
|
||||
Fear = 5,
|
||||
Grip = 6,
|
||||
Root = 7,
|
||||
Slow_Attack = 8,
|
||||
SlowAttack = 8,
|
||||
Silence = 9,
|
||||
Sleep = 10,
|
||||
Snare = 11,
|
||||
|
||||
@@ -450,6 +450,8 @@ namespace Framework.Constants
|
||||
Dead = 3,
|
||||
JustRespawned = 4
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum UnitState : uint
|
||||
{
|
||||
Died = 0x01, // Player Has Fake Death Aura
|
||||
|
||||
@@ -114,11 +114,6 @@ namespace Framework.Cryptography
|
||||
|
||||
public class HmacSha256 : HMACSHA256
|
||||
{
|
||||
public HmacSha256() : base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public HmacSha256(byte[] key) : base(key)
|
||||
{
|
||||
Initialize();
|
||||
|
||||
@@ -54,8 +54,7 @@ namespace Framework.Database
|
||||
{
|
||||
QueryCallbackData callback = _callbacks.Dequeue();
|
||||
|
||||
bool hasNext = true;
|
||||
while (hasNext)
|
||||
while (true)
|
||||
{
|
||||
if (_result != null && _result.Wait(0))
|
||||
{
|
||||
@@ -65,7 +64,7 @@ namespace Framework.Database
|
||||
|
||||
cb(this, f.Result);
|
||||
|
||||
hasNext = _result != null;
|
||||
bool hasNext = _result != null;
|
||||
if (_callbacks.Count == 0)
|
||||
{
|
||||
Contract.Assert(!hasNext);
|
||||
@@ -81,8 +80,6 @@ namespace Framework.Database
|
||||
else
|
||||
return QueryCallbackStatus.NotReady;
|
||||
}
|
||||
|
||||
return QueryCallbackStatus.Completed;
|
||||
}
|
||||
|
||||
Task<SQLResult> _result;
|
||||
|
||||
@@ -28,16 +28,6 @@ namespace Framework.Dynamic
|
||||
_values[i] = parts[i];
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public bool IsEqual(params uint[] parts)
|
||||
{
|
||||
for (var i = 0; i < _values.Length; ++i)
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace Framework.IO
|
||||
/// <summary>
|
||||
/// Writes a string to the packet with a null terminated (0)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="str"></param>
|
||||
public void WriteCString(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
@@ -281,6 +281,9 @@ namespace Framework.IO
|
||||
|
||||
public void WriteString(string str)
|
||||
{
|
||||
if (str.IsEmpty())
|
||||
return;
|
||||
|
||||
byte[] sBytes = Encoding.UTF8.GetBytes(str);
|
||||
WriteBytes(sBytes);
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ class FileAppender : Appender, IDisposable
|
||||
}
|
||||
|
||||
#region IDisposable Support
|
||||
private bool disposedValue = false;
|
||||
private bool disposedValue;
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ using System.Threading;
|
||||
|
||||
namespace Framework.Networking
|
||||
{
|
||||
public class NetworkThread<SocketType> where SocketType : ISocket
|
||||
public class NetworkThread<TSocketType> where TSocketType : ISocket
|
||||
{
|
||||
public void Stop()
|
||||
{
|
||||
@@ -43,15 +43,15 @@ namespace Framework.Networking
|
||||
return _connections;
|
||||
}
|
||||
|
||||
public virtual void AddSocket(SocketType sock)
|
||||
public virtual void AddSocket(TSocketType sock)
|
||||
{
|
||||
Interlocked.Increment(ref _connections);
|
||||
_newSockets.Add(sock);
|
||||
SocketAdded(sock);
|
||||
}
|
||||
|
||||
public virtual void SocketAdded(SocketType sock) { }
|
||||
public virtual void SocketRemoved(SocketType sock) { }
|
||||
protected virtual void SocketAdded(TSocketType sock) { }
|
||||
protected virtual void SocketRemoved(TSocketType sock) { }
|
||||
|
||||
void AddNewSockets()
|
||||
{
|
||||
@@ -78,12 +78,11 @@ namespace Framework.Networking
|
||||
Log.outDebug(LogFilter.Network, "Network Thread Starting");
|
||||
|
||||
int sleepTime = 10;
|
||||
uint tickStart = 0, diff = 0;
|
||||
while (!_stopped)
|
||||
{
|
||||
Thread.Sleep(sleepTime);
|
||||
|
||||
tickStart = Time.GetMSTime();
|
||||
uint tickStart = Time.GetMSTime();
|
||||
|
||||
AddNewSockets();
|
||||
|
||||
@@ -101,7 +100,7 @@ namespace Framework.Networking
|
||||
}
|
||||
}
|
||||
|
||||
diff = Time.GetMSTimeDiffToNow(tickStart);
|
||||
uint diff = Time.GetMSTimeDiffToNow(tickStart);
|
||||
sleepTime = (int)(diff > 10 ? 0 : 10 - diff);
|
||||
}
|
||||
|
||||
@@ -110,12 +109,12 @@ namespace Framework.Networking
|
||||
_Sockets.Clear();
|
||||
}
|
||||
|
||||
volatile int _connections;
|
||||
int _connections;
|
||||
volatile bool _stopped;
|
||||
|
||||
Thread _thread;
|
||||
|
||||
List<SocketType> _Sockets = new List<SocketType>();
|
||||
List<SocketType> _newSockets = new List<SocketType>();
|
||||
List<TSocketType> _Sockets = new List<TSocketType>();
|
||||
List<TSocketType> _newSockets = new List<TSocketType>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ using System.Net.Sockets;
|
||||
|
||||
namespace Framework.Networking
|
||||
{
|
||||
public class SocketManager<SocketType> where SocketType : ISocket
|
||||
public class SocketManager<TSocketType> where TSocketType : ISocket
|
||||
{
|
||||
public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1)
|
||||
{
|
||||
@@ -30,11 +30,11 @@ namespace Framework.Networking
|
||||
Acceptor = new AsyncAcceptor(bindIp, port);
|
||||
|
||||
_threadCount = threadCount;
|
||||
_threads = new NetworkThread<SocketType>[GetNetworkThreadCount()];
|
||||
_threads = new NetworkThread<TSocketType>[GetNetworkThreadCount()];
|
||||
|
||||
for (int i = 0; i < _threadCount; ++i)
|
||||
{
|
||||
_threads[i] = new NetworkThread<SocketType>();
|
||||
_threads[i] = new NetworkThread<TSocketType>();
|
||||
_threads[i].Start();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Framework.Networking
|
||||
{
|
||||
try
|
||||
{
|
||||
SocketType newSocket = (SocketType)Activator.CreateInstance(typeof(SocketType), sock);
|
||||
TSocketType newSocket = (TSocketType)Activator.CreateInstance(typeof(TSocketType), sock);
|
||||
newSocket.Start();
|
||||
|
||||
_threads[SelectThreadWithMinConnections()].AddSocket(newSocket);
|
||||
@@ -94,7 +94,7 @@ namespace Framework.Networking
|
||||
}
|
||||
|
||||
public AsyncAcceptor Acceptor;
|
||||
NetworkThread<SocketType>[] _threads;
|
||||
NetworkThread<TSocketType>[] _threads;
|
||||
int _threadCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +168,13 @@ public static partial class Detour
|
||||
private class dtQueryData
|
||||
{
|
||||
public dtStatus status;
|
||||
public dtNode lastBestNode = null;
|
||||
public dtNode lastBestNode;
|
||||
public float lastBestNodeCost;
|
||||
public dtPolyRef startRef;
|
||||
public dtPolyRef endRef;
|
||||
public float[] startPos = new float[3];
|
||||
public float[] endPos = new float[3];
|
||||
public dtQueryFilter filter = null;
|
||||
public dtQueryFilter filter;
|
||||
|
||||
public void dtcsClear()
|
||||
{
|
||||
|
||||
@@ -289,6 +289,9 @@ namespace System
|
||||
|
||||
public static int GetByteCount(this string str)
|
||||
{
|
||||
if (str.IsEmpty())
|
||||
return 0;
|
||||
|
||||
return Encoding.UTF8.GetByteCount(str);
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user