Ported .Net Core commits:
hondacrx: - Initial commit: Switch to .Net Core 2.0 - Fix build and removed not needed files Fabi: - Updated solution platforms. - Changed folder structure. - Change library target framework to netstandard2.0. - Updated solution platforms again... - Removed windows specific kernel32 function usage (Ctrl-C handler).
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.IO;
|
||||
|
||||
namespace System.Collections.Generic
|
||||
{
|
||||
public class Array<T> : List<T>
|
||||
{
|
||||
public Array(int size) : base(size)
|
||||
{
|
||||
_limit = size;
|
||||
}
|
||||
|
||||
public Array(params T[] args) : base(args)
|
||||
{
|
||||
_limit = args.Length;
|
||||
}
|
||||
|
||||
public Array(int size, T defaultFillValue) : this(size)
|
||||
{
|
||||
Fill(defaultFillValue);
|
||||
}
|
||||
|
||||
public void Fill(T value)
|
||||
{
|
||||
for (var i = 0; i < _limit; ++i)
|
||||
Add(value);
|
||||
}
|
||||
|
||||
public new void Add(T value)
|
||||
{
|
||||
if (base.Count >= _limit)
|
||||
throw new InternalBufferOverflowException("Attempted to read more array elements from packet " + base.Count + 1 + " than allowed " + _limit);
|
||||
|
||||
base.Add(value);
|
||||
}
|
||||
|
||||
public new T this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return base[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index >= Count)
|
||||
{
|
||||
if (Count >= _limit)
|
||||
throw new InternalBufferOverflowException("Attempted to read more array elements from packet " + base.Count + 1 + " than allowed " + _limit);
|
||||
base.Insert(index, value);
|
||||
}
|
||||
else
|
||||
base[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetLimit() { return _limit; }
|
||||
|
||||
public static implicit operator T[] (Array<T> array)
|
||||
{
|
||||
return array.ToArray();
|
||||
}
|
||||
|
||||
int _limit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Diagnostics.Contracts;
|
||||
|
||||
namespace System.Collections
|
||||
{
|
||||
public class BitSet : ICollection, ICloneable
|
||||
{
|
||||
public BitSet(int length, bool defaultValue = false)
|
||||
{
|
||||
if (length < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
m_array = new uint[GetArrayLength(length, BitsPerInt32)];
|
||||
m_length = length;
|
||||
|
||||
uint fillValue = defaultValue ? 0xffffffff : 0;
|
||||
for (int i = 0; i < m_array.Length; i++)
|
||||
{
|
||||
m_array[i] = fillValue;
|
||||
}
|
||||
|
||||
_version = 0;
|
||||
}
|
||||
|
||||
public BitSet(uint[] values)
|
||||
{
|
||||
if (values == null)
|
||||
{
|
||||
throw new ArgumentNullException("values");
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
// this value is chosen to prevent overflow when computing m_length
|
||||
if (values.Length > UInt32.MaxValue / BitsPerInt32)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
m_array = new uint[values.Length];
|
||||
m_length = values.Length * BitsPerInt32;
|
||||
|
||||
Array.Copy(values, m_array, values.Length);
|
||||
|
||||
_version = 0;
|
||||
}
|
||||
|
||||
public BitSet(BitSet bits)
|
||||
{
|
||||
if (bits == null)
|
||||
{
|
||||
throw new ArgumentNullException("bits");
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int arrayLength = GetArrayLength(bits.m_length, BitsPerInt32);
|
||||
m_array = new uint[arrayLength];
|
||||
m_length = bits.m_length;
|
||||
|
||||
Array.Copy(bits.m_array, m_array, arrayLength);
|
||||
|
||||
_version = bits._version;
|
||||
}
|
||||
|
||||
public bool this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return Get(index);
|
||||
}
|
||||
set
|
||||
{
|
||||
Set(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Get(int index)
|
||||
{
|
||||
if (index < 0 || index >= Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
return (Convert.ToInt64(m_array[index / 32]) & (1 << (index % 32))) != 0;
|
||||
}
|
||||
|
||||
public void Set(int index, bool value)
|
||||
{
|
||||
if (index < 0 || index >= Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
if (value)
|
||||
{
|
||||
m_array[index / 32] |= (1u << (index % 32));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_array[index / 32] &= ~(1u << (index % 32));
|
||||
}
|
||||
|
||||
_version++;
|
||||
}
|
||||
|
||||
public void SetAll(bool value)
|
||||
{
|
||||
uint fillValue = value ? 0xffffffff : 0u;
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] = fillValue;
|
||||
}
|
||||
|
||||
_version++;
|
||||
}
|
||||
|
||||
public BitSet And(BitSet value)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
if (Length != value.Length)
|
||||
throw new ArgumentException();
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] &= value.m_array[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BitSet Or(BitSet value)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
if (Length != value.Length)
|
||||
throw new ArgumentException();
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] |= value.m_array[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BitSet Xor(BitSet value)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
if (Length != value.Length)
|
||||
throw new ArgumentException();
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] ^= value.m_array[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BitSet Not()
|
||||
{
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] = ~m_array[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<int>() >= 0);
|
||||
return m_length;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int newints = GetArrayLength(value, BitsPerInt32);
|
||||
if (newints > m_array.Length || newints + _ShrinkThreshold < m_array.Length)
|
||||
{
|
||||
// grow or shrink (if wasting more than _ShrinkThreshold ints)
|
||||
uint[] newarray = new uint[newints];
|
||||
Array.Copy(m_array, newarray, newints > m_array.Length ? m_array.Length : newints);
|
||||
m_array = newarray;
|
||||
}
|
||||
|
||||
if (value > m_length)
|
||||
{
|
||||
// clear high bit values in the last int
|
||||
int last = GetArrayLength(m_length, BitsPerInt32) - 1;
|
||||
int bits = m_length % 32;
|
||||
if (bits > 0)
|
||||
{
|
||||
m_array[last] &= (1u << bits) - 1;
|
||||
}
|
||||
|
||||
// clear remaining int values
|
||||
Array.Clear(m_array, last + 1, newints - last - 1);
|
||||
}
|
||||
|
||||
m_length = value;
|
||||
_version++;
|
||||
}
|
||||
}
|
||||
|
||||
// ICollection implementation
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
if (array == null)
|
||||
throw new ArgumentNullException("array");
|
||||
|
||||
if (index < 0)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
|
||||
if (array.Rank != 1)
|
||||
throw new ArgumentException();
|
||||
|
||||
Contract.EndContractBlock();
|
||||
|
||||
if (array is uint[])
|
||||
{
|
||||
Array.Copy(m_array, 0, array, index, GetArrayLength(m_length, BitsPerInt32));
|
||||
}
|
||||
else if (array is byte[])
|
||||
{
|
||||
int arrayLength = GetArrayLength(m_length, BitsPerByte);
|
||||
if ((array.Length - index) < arrayLength)
|
||||
throw new ArgumentException();
|
||||
|
||||
byte[] b = (byte[])array;
|
||||
for (int i = 0; i < arrayLength; i++)
|
||||
b[index + i] = (byte)((m_array[i / 4] >> ((i % 4) * 8)) & 0x000000FF); // Shift to bring the required byte to LSB, then mask
|
||||
}
|
||||
else if (array is bool[])
|
||||
{
|
||||
if (array.Length - index < m_length)
|
||||
throw new ArgumentException();
|
||||
|
||||
bool[] b = (bool[])array;
|
||||
for (int i = 0; i < m_length; i++)
|
||||
b[index + i] = ((m_array[i / 32] >> (i % 32)) & 0x00000001) != 0;
|
||||
}
|
||||
else
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<int>() >= 0);
|
||||
|
||||
return (int)m_length;
|
||||
}
|
||||
}
|
||||
|
||||
public Object Clone()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Object>() != null);
|
||||
Contract.Ensures(((BitArray)Contract.Result<Object>()).Length == this.Length);
|
||||
|
||||
BitSet bitArray = new BitSet(m_array);
|
||||
bitArray._version = _version;
|
||||
bitArray.m_length = m_length;
|
||||
return bitArray;
|
||||
}
|
||||
|
||||
public Object SyncRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_syncRoot == null)
|
||||
{
|
||||
System.Threading.Interlocked.CompareExchange<Object>(ref _syncRoot, new Object(), null);
|
||||
}
|
||||
return _syncRoot;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSynchronized
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return new BitArrayEnumeratorSimple(this);
|
||||
}
|
||||
|
||||
// XPerY=n means that n Xs can be stored in 1 Y.
|
||||
private const int BitsPerInt32 = 32;
|
||||
private const int BytesPerInt32 = 4;
|
||||
private const int BitsPerByte = 8;
|
||||
|
||||
private static int GetArrayLength(int n, int div)
|
||||
{
|
||||
Contract.Assert(div > 0, "GetArrayLength: div arg must be greater than 0");
|
||||
return n > 0 ? (((n - 1) / div) + 1) : 0;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private class BitArrayEnumeratorSimple : IEnumerator, ICloneable
|
||||
{
|
||||
private BitSet bitarray;
|
||||
private int index;
|
||||
private int version;
|
||||
private bool currentElement;
|
||||
|
||||
internal BitArrayEnumeratorSimple(BitSet bitarray)
|
||||
{
|
||||
this.bitarray = bitarray;
|
||||
this.index = -1;
|
||||
version = bitarray._version;
|
||||
}
|
||||
|
||||
public Object Clone()
|
||||
{
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
public virtual bool MoveNext()
|
||||
{
|
||||
//if (version != bitarray._version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
|
||||
if (index < (bitarray.Count - 1))
|
||||
{
|
||||
index++;
|
||||
currentElement = bitarray.Get(index);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
index = bitarray.Count;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual Object Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index == -1)
|
||||
throw new InvalidOperationException();
|
||||
if (index >= bitarray.Count)
|
||||
throw new InvalidOperationException();
|
||||
return currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
//if (version != bitarray._version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
|
||||
index = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private uint[] m_array;
|
||||
private int m_length;
|
||||
private int _version;
|
||||
[NonSerialized]
|
||||
private Object _syncRoot;
|
||||
|
||||
private const int _ShrinkThreshold = 256;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace System.Collections.Generic
|
||||
{
|
||||
public interface IMultiMap<TKey, TValue>
|
||||
{
|
||||
void AddRange(TKey key, IEnumerable<TValue> valueList);
|
||||
List<TValue> this[TKey key] { get; set;}
|
||||
bool Remove(TKey key, TValue value);
|
||||
void Add(TKey key, TValue value);
|
||||
bool ContainsKey(TKey key);
|
||||
|
||||
ICollection<TKey> Keys {get;}
|
||||
bool Remove(TKey key);
|
||||
ICollection<TValue> Values{get;}
|
||||
|
||||
void Add(KeyValuePair<TKey, TValue> item);
|
||||
void Clear();
|
||||
bool Contains(TKey key, TValue item);
|
||||
void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex);
|
||||
int Count {get;}
|
||||
bool Remove(KeyValuePair<TKey, TValue> item);
|
||||
|
||||
List<TValue> LookupByKey(TKey key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Collections
|
||||
{
|
||||
public class LinkedListElement
|
||||
{
|
||||
internal LinkedListElement iNext;
|
||||
internal LinkedListElement iPrev;
|
||||
|
||||
public LinkedListElement()
|
||||
{
|
||||
iNext = iPrev = null;
|
||||
}
|
||||
|
||||
~LinkedListElement() { delink(); }
|
||||
|
||||
bool hasNext() { return (iNext != null && iNext.iNext != null); }
|
||||
bool hasPrev() { return (iPrev != null && iPrev.iPrev != null); }
|
||||
public bool isInList() { return (iNext != null && iPrev != null); }
|
||||
|
||||
public LinkedListElement GetNextElement() { return hasNext() ? iNext : null; }
|
||||
public LinkedListElement GetPrevElement() { return hasPrev() ? iPrev : null; }
|
||||
|
||||
public void delink()
|
||||
{
|
||||
if (!isInList())
|
||||
return;
|
||||
|
||||
iNext.iPrev = iPrev;
|
||||
iPrev.iNext = iNext;
|
||||
iNext = null;
|
||||
iPrev = null;
|
||||
}
|
||||
|
||||
public void insertBefore(LinkedListElement pElem)
|
||||
{
|
||||
pElem.iNext = this;
|
||||
pElem.iPrev = iPrev;
|
||||
iPrev.iNext = pElem;
|
||||
iPrev = pElem;
|
||||
}
|
||||
|
||||
public void insertAfter(LinkedListElement pElem)
|
||||
{
|
||||
pElem.iPrev = this;
|
||||
pElem.iNext = iNext;
|
||||
iNext.iPrev = pElem;
|
||||
iNext = pElem;
|
||||
}
|
||||
}
|
||||
|
||||
public class LinkedListHead
|
||||
{
|
||||
LinkedListElement iFirst = new LinkedListElement();
|
||||
LinkedListElement iLast = new LinkedListElement();
|
||||
uint iSize;
|
||||
|
||||
public LinkedListHead()
|
||||
{
|
||||
iSize = 0;
|
||||
// create empty list
|
||||
|
||||
iFirst.iNext = iLast;
|
||||
iLast.iPrev = iFirst;
|
||||
}
|
||||
|
||||
public bool isEmpty() { return (!iFirst.iNext.isInList()); }
|
||||
|
||||
public LinkedListElement GetFirstElement() { return (isEmpty() ? null : iFirst.iNext); }
|
||||
public LinkedListElement GetLastElement() { return (isEmpty() ? null : iLast.iPrev); }
|
||||
|
||||
public void insertFirst(LinkedListElement pElem)
|
||||
{
|
||||
iFirst.insertAfter(pElem);
|
||||
}
|
||||
|
||||
public void insertLast(LinkedListElement pElem)
|
||||
{
|
||||
iLast.insertBefore(pElem);
|
||||
}
|
||||
|
||||
public uint getSize()
|
||||
{
|
||||
if (iSize == 0)
|
||||
{
|
||||
uint result = 0;
|
||||
LinkedListElement e = GetFirstElement();
|
||||
while (e != null)
|
||||
{
|
||||
++result;
|
||||
e = e.GetNextElement();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return iSize;
|
||||
}
|
||||
|
||||
public void incSize() { ++iSize; }
|
||||
public void decSize() { --iSize; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,508 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Linq;
|
||||
|
||||
namespace System.Collections.Generic
|
||||
{
|
||||
public sealed class MultiMap<TKey, TValue> : IMultiMap<TKey, TValue>, IDictionary<TKey, TValue>
|
||||
{
|
||||
public MultiMap() { }
|
||||
|
||||
public MultiMap(IEnumerable<KeyValuePair<TKey, TValue>> initialData)
|
||||
{
|
||||
foreach (var item in initialData)
|
||||
{
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
_interalStorage.Add(key, new List<TValue>());
|
||||
|
||||
_interalStorage[key].Add(value);
|
||||
}
|
||||
|
||||
public void AddRange(TKey key, IEnumerable<TValue> valueList)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
{
|
||||
_interalStorage.Add(key, new List<TValue>());
|
||||
}
|
||||
foreach (TValue value in valueList)
|
||||
{
|
||||
_interalStorage[key].Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(item.Key))
|
||||
{
|
||||
_interalStorage.Add(item.Key, new List<TValue>());
|
||||
}
|
||||
_interalStorage[item.Key].Add(item.Value);
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
return _interalStorage.Remove(key);
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
if (!ContainsKey(item.Key))
|
||||
return false;
|
||||
|
||||
bool val = _interalStorage[item.Key].Remove(item.Value);
|
||||
|
||||
if (!val)
|
||||
return false;
|
||||
|
||||
if (_interalStorage[item.Key].Empty())
|
||||
_interalStorage.Remove(item.Key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(TKey key, TValue value)
|
||||
{
|
||||
if (!ContainsKey(key))
|
||||
return false;
|
||||
|
||||
bool val = _interalStorage[key].Remove(value);
|
||||
|
||||
if (!val)
|
||||
return false;
|
||||
|
||||
if (_interalStorage[key].Empty())
|
||||
_interalStorage.Remove(key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return _interalStorage.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
List<TValue> valueList;
|
||||
if (_interalStorage.TryGetValue(item.Key, out valueList))
|
||||
return valueList.Contains(item.Value);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Contains(TKey key, TValue item)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key)) return false;
|
||||
return _interalStorage[key].Contains(item);
|
||||
}
|
||||
|
||||
public List<TValue> LookupByKey(TKey key)
|
||||
{
|
||||
if (_interalStorage.ContainsKey(key))
|
||||
return _interalStorage[key].ToList();
|
||||
|
||||
return new List<TValue>();
|
||||
}
|
||||
|
||||
public List<TValue> LookupByKey(object key)
|
||||
{
|
||||
TKey newkey = (TKey)Convert.ChangeType(key, typeof(TKey));
|
||||
if (_interalStorage.ContainsKey(newkey))
|
||||
return _interalStorage[newkey].ToList();
|
||||
|
||||
return new List<TValue>();
|
||||
}
|
||||
|
||||
bool IDictionary<TKey, TValue>.TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
{
|
||||
value = default(TValue);
|
||||
return false;
|
||||
}
|
||||
value = _interalStorage[key].Last();
|
||||
return true;
|
||||
}
|
||||
|
||||
TValue IDictionary<TKey, TValue>.this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _interalStorage[key].LastOrDefault();
|
||||
}
|
||||
set
|
||||
{
|
||||
Add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public List<TValue> this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
return new List<TValue>();
|
||||
return _interalStorage[key];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
_interalStorage.Add(key, value);
|
||||
else
|
||||
_interalStorage[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<TKey> Keys
|
||||
{
|
||||
get { return _interalStorage.Keys; }
|
||||
}
|
||||
|
||||
public ICollection<TValue> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
List<TValue> retVal = new List<TValue>();
|
||||
foreach (var item in _interalStorage)
|
||||
{
|
||||
retVal.AddRange(item.Value);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
public List<KeyValuePair<TKey, TValue>> KeyValueList
|
||||
{
|
||||
get
|
||||
{
|
||||
List<KeyValuePair<TKey, TValue>> retVal = new List<KeyValuePair<TKey, TValue>>();
|
||||
foreach (var pair in _interalStorage)
|
||||
{
|
||||
foreach (var value in pair.Value)
|
||||
retVal.Add(new KeyValuePair<TKey, TValue>(pair.Key, value));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_interalStorage.Clear();
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
throw new ArgumentNullException("array");
|
||||
|
||||
if (arrayIndex < 0)
|
||||
throw new ArgumentOutOfRangeException("arrayIndex", arrayIndex, "argument 'arrayIndex' cannot be negative");
|
||||
|
||||
if (arrayIndex >= array.Length || Count > array.Length - arrayIndex)
|
||||
array = new KeyValuePair<TKey, TValue>[Count];
|
||||
|
||||
int index = arrayIndex;
|
||||
foreach (KeyValuePair<TKey, TValue> pair in this)
|
||||
array[index++] = new KeyValuePair<TKey, TValue>(pair.Key, pair.Value);
|
||||
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var item in _interalStorage)
|
||||
{
|
||||
count += item.Value.Count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
int ICollection<KeyValuePair<TKey, TValue>>.Count
|
||||
{
|
||||
get { return _interalStorage.Count; }
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
|
||||
{
|
||||
return new MultiMapEnumerator<TKey, TValue>(this);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return new MultiMapEnumerator<TKey, TValue>(this);
|
||||
}
|
||||
|
||||
private Dictionary<TKey, List<TValue>> _interalStorage = new Dictionary<TKey, List<TValue>>();
|
||||
}
|
||||
|
||||
public sealed class SortedMultiMap<TKey, TValue> : IMultiMap<TKey, TValue>, IDictionary<TKey, TValue>
|
||||
{
|
||||
public SortedMultiMap() { }
|
||||
|
||||
public SortedMultiMap(IEnumerable<KeyValuePair<TKey, TValue>> initialData)
|
||||
{
|
||||
foreach (var item in initialData)
|
||||
{
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
_interalStorage.Add(key, new List<TValue>());
|
||||
|
||||
_interalStorage[key].Add(value);
|
||||
}
|
||||
|
||||
public void AddRange(TKey key, IEnumerable<TValue> valueList)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
{
|
||||
_interalStorage.Add(key, new List<TValue>());
|
||||
}
|
||||
foreach (TValue value in valueList)
|
||||
{
|
||||
_interalStorage[key].Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(item.Key))
|
||||
{
|
||||
_interalStorage.Add(item.Key, new List<TValue>());
|
||||
}
|
||||
_interalStorage[item.Key].Add(item.Value);
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
return _interalStorage.Remove(key);
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
if (!ContainsKey(item.Key))
|
||||
return false;
|
||||
|
||||
bool val = _interalStorage[item.Key].Remove(item.Value);
|
||||
|
||||
if (!val)
|
||||
return false;
|
||||
|
||||
if (_interalStorage[item.Key].Empty())
|
||||
_interalStorage.Remove(item.Key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(TKey key, TValue value)
|
||||
{
|
||||
if (!ContainsKey(key))
|
||||
return false;
|
||||
|
||||
bool val = _interalStorage[key].Remove(value);
|
||||
|
||||
if (!val)
|
||||
return false;
|
||||
|
||||
if (_interalStorage[key].Empty())
|
||||
_interalStorage.Remove(key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return _interalStorage.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
List<TValue> valueList;
|
||||
if (_interalStorage.TryGetValue(item.Key, out valueList))
|
||||
return valueList.Contains(item.Value);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Contains(TKey key, TValue item)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key)) return false;
|
||||
return _interalStorage[key].Contains(item);
|
||||
}
|
||||
|
||||
public List<TValue> LookupByKey(TKey key)
|
||||
{
|
||||
if (_interalStorage.ContainsKey(key))
|
||||
return _interalStorage[key].ToList();
|
||||
|
||||
return new List<TValue>();
|
||||
}
|
||||
|
||||
public List<TValue> LookupByKey(object key)
|
||||
{
|
||||
TKey newkey = (TKey)Convert.ChangeType(key, typeof(TKey));
|
||||
if (_interalStorage.ContainsKey(newkey))
|
||||
return _interalStorage[newkey].ToList();
|
||||
|
||||
return new List<TValue>();
|
||||
}
|
||||
|
||||
bool IDictionary<TKey, TValue>.TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
{
|
||||
value = default(TValue);
|
||||
return false;
|
||||
}
|
||||
value = _interalStorage[key].Last();
|
||||
return true;
|
||||
}
|
||||
|
||||
TValue IDictionary<TKey, TValue>.this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _interalStorage[key].LastOrDefault();
|
||||
}
|
||||
set
|
||||
{
|
||||
Add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public List<TValue> this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
return new List<TValue>();
|
||||
return _interalStorage[key];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!_interalStorage.ContainsKey(key))
|
||||
_interalStorage.Add(key, value);
|
||||
else _interalStorage[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<TKey> Keys
|
||||
{
|
||||
get { return _interalStorage.Keys; }
|
||||
}
|
||||
|
||||
public ICollection<TValue> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
List<TValue> retVal = new List<TValue>();
|
||||
foreach (var item in _interalStorage)
|
||||
{
|
||||
retVal.AddRange(item.Value);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
public List<KeyValuePair<TKey, TValue>> KeyValueList
|
||||
{
|
||||
get
|
||||
{
|
||||
List<KeyValuePair<TKey, TValue>> retVal = new List<KeyValuePair<TKey, TValue>>();
|
||||
foreach (var pair in _interalStorage)
|
||||
{
|
||||
foreach (var value in pair.Value)
|
||||
retVal.Add(new KeyValuePair<TKey, TValue>(pair.Key, value));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_interalStorage.Clear();
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
throw new ArgumentNullException("array");
|
||||
|
||||
if (arrayIndex < 0)
|
||||
throw new ArgumentOutOfRangeException("arrayIndex", arrayIndex, "argument 'arrayIndex' cannot be negative");
|
||||
|
||||
if (arrayIndex >= array.Length || Count > array.Length - arrayIndex)
|
||||
array = new KeyValuePair<TKey, TValue>[Count];
|
||||
|
||||
int index = arrayIndex;
|
||||
foreach (KeyValuePair<TKey, TValue> pair in this)
|
||||
array[index++] = new KeyValuePair<TKey, TValue>(pair.Key, pair.Value);
|
||||
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var item in _interalStorage)
|
||||
{
|
||||
count += item.Value.Count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
int ICollection<KeyValuePair<TKey, TValue>>.Count
|
||||
{
|
||||
get { return _interalStorage.Count; }
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
|
||||
{
|
||||
return new SortedMultiMapEnumerator<TKey, TValue>(this);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return new SortedMultiMapEnumerator<TKey, TValue>(this);
|
||||
}
|
||||
|
||||
private SortedDictionary<TKey, List<TValue>> _interalStorage = new SortedDictionary<TKey, List<TValue>>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace System.Collections.Generic
|
||||
{
|
||||
public class MultiMapEnumerator<TKey, TValue> : IEnumerator<KeyValuePair<TKey, TValue>>
|
||||
{
|
||||
MultiMap<TKey, TValue> _map;
|
||||
IEnumerator<TKey> _keyEnumerator;
|
||||
IEnumerator<TValue> _valueEnumerator;
|
||||
|
||||
public MultiMapEnumerator(MultiMap<TKey, TValue> map)
|
||||
{
|
||||
_map = map;
|
||||
Reset();
|
||||
}
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public KeyValuePair<TKey, TValue> Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return new KeyValuePair<TKey, TValue>(_keyEnumerator.Current, _valueEnumerator.Current);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_keyEnumerator = null;
|
||||
_valueEnumerator = null;
|
||||
_map = null;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (!_valueEnumerator.MoveNext())
|
||||
{
|
||||
if (!_keyEnumerator.MoveNext())
|
||||
return false;
|
||||
_valueEnumerator = _map[_keyEnumerator.Current].GetEnumerator();
|
||||
_valueEnumerator.MoveNext();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_keyEnumerator = _map.Keys.GetEnumerator();
|
||||
_valueEnumerator = new List<TValue>().GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
public class SortedMultiMapEnumerator<TKey, TValue> : IEnumerator<KeyValuePair<TKey, TValue>>
|
||||
{
|
||||
SortedMultiMap<TKey, TValue> _map;
|
||||
IEnumerator<TKey> _keyEnumerator;
|
||||
IEnumerator<TValue> _valueEnumerator;
|
||||
|
||||
public SortedMultiMapEnumerator(SortedMultiMap<TKey, TValue> map)
|
||||
{
|
||||
_map = map;
|
||||
Reset();
|
||||
}
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public KeyValuePair<TKey, TValue> Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return new KeyValuePair<TKey, TValue>(_keyEnumerator.Current, _valueEnumerator.Current);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_keyEnumerator = null;
|
||||
_valueEnumerator = null;
|
||||
_map = null;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (!_valueEnumerator.MoveNext())
|
||||
{
|
||||
if (!_keyEnumerator.MoveNext())
|
||||
return false;
|
||||
_valueEnumerator = _map[_keyEnumerator.Current].GetEnumerator();
|
||||
_valueEnumerator.MoveNext();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_keyEnumerator = _map.Keys.GetEnumerator();
|
||||
_valueEnumerator = new List<TValue>().GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections;
|
||||
|
||||
namespace Framework.Collections
|
||||
{
|
||||
public class StringArray
|
||||
{
|
||||
public StringArray(int size)
|
||||
{
|
||||
_str = new string[size];
|
||||
|
||||
for (var i = 0; i < size; ++i)
|
||||
_str[i] = "";
|
||||
}
|
||||
|
||||
public StringArray(string str, params string[] separator)
|
||||
{
|
||||
_str = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public StringArray(string str, params char[] separator)
|
||||
{
|
||||
_str = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string this[int index]
|
||||
{
|
||||
get { return _str[index]; }
|
||||
set { _str[index] = value; }
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return _str.GetEnumerator();
|
||||
}
|
||||
|
||||
public int Length { get { return _str.Length; } }
|
||||
|
||||
string[] _str;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 Framework.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Framework.Configuration
|
||||
{
|
||||
public class ConfigMgr
|
||||
{
|
||||
public static bool Load(string fileName)
|
||||
{
|
||||
string path = AppContext.BaseDirectory + fileName;
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine("{0} doesn't exist!", fileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
string[] ConfigContent = File.ReadAllLines(path, Encoding.UTF8);
|
||||
|
||||
int lineCounter = 0;
|
||||
try
|
||||
{
|
||||
string name = string.Empty;
|
||||
foreach (var line in ConfigContent)
|
||||
{
|
||||
lineCounter++;
|
||||
if (string.IsNullOrEmpty(line) || line.StartsWith("#") || line.StartsWith("-"))
|
||||
continue;
|
||||
|
||||
var configOption = new StringArray(line, '=');
|
||||
_configList.Add(configOption[0].Trim(), configOption[1].Replace("\"", "").Trim());
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Error in {0} on Line {1}", fileName, lineCounter);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static T GetDefaultValue<T>(string name, T defaultValue)
|
||||
{
|
||||
string temp = _configList.LookupByKey(name);
|
||||
|
||||
var type = typeof(T).IsEnum ? typeof(T).GetEnumUnderlyingType() : typeof(T);
|
||||
|
||||
if (temp.IsEmpty())
|
||||
return (T)Convert.ChangeType(defaultValue, type);
|
||||
|
||||
if (Type.GetTypeCode(typeof(T)) == TypeCode.Boolean && temp.IsNumber())
|
||||
return (T)Convert.ChangeType(temp == "1", typeof(T));
|
||||
|
||||
return (T)Convert.ChangeType(temp, type);
|
||||
}
|
||||
|
||||
public static List<string> GetKeysByString(string name)
|
||||
{
|
||||
return _configList.Where(p => p.Key.Contains(name)).Select(p => p.Key).ToList();
|
||||
}
|
||||
|
||||
static Dictionary<string, string> _configList = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,762 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum AccountDataTypes
|
||||
{
|
||||
GlobalConfigCache = 0x00,
|
||||
PerCharacterConfigCache = 0x01,
|
||||
GlobalBindingsCache = 0x02,
|
||||
PerCharacterBindingsCache = 0x03,
|
||||
GlobalMacrosCache = 0x04,
|
||||
PerCharacterMacrosCache = 0x05,
|
||||
PerCharacterLayoutCache = 0x06,
|
||||
PerCharacterChatCache = 0x07,
|
||||
Max = 8,
|
||||
|
||||
GlobalCacheMask = 0x15,
|
||||
PerCharacterCacheMask = 0xEA
|
||||
}
|
||||
|
||||
public enum TutorialAction
|
||||
{
|
||||
Update = 0,
|
||||
Clear = 1,
|
||||
Reset = 2
|
||||
}
|
||||
|
||||
public enum AccountTypes
|
||||
{
|
||||
Player = 0,
|
||||
Moderator = 1,
|
||||
GameMaster = 2,
|
||||
Administrator = 3,
|
||||
Console = 4
|
||||
}
|
||||
|
||||
public enum RBACPermissions
|
||||
{
|
||||
None = 0,
|
||||
InstantLogout = 1,
|
||||
SkipQueue = 2,
|
||||
JoinNormalBg = 3,
|
||||
JoinRandomBg = 4,
|
||||
JoinArenas = 5,
|
||||
JoinDungeonFinder = 6,
|
||||
// 7 - Reuse
|
||||
// 8 - Reuse
|
||||
// 9 - Reuse
|
||||
UseCharacterTemplates = 10,
|
||||
LogGmTrade = 11,
|
||||
SkipCheckCharacterCreationDemonHunter = 12,
|
||||
SkipCheckInstanceRequiredBosses = 13,
|
||||
SkipCheckCharacterCreationTeammask = 14,
|
||||
SkipCheckCharacterCreationClassmask = 15,
|
||||
SkipCheckCharacterCreationRacemask = 16,
|
||||
SkipCheckCharacterCreationReservedname = 17,
|
||||
SkipCheckCharacterCreationDeathKnight = 18,
|
||||
SkipCheckChatChannelReq = 19,
|
||||
SkipCheckDisableMap = 20,
|
||||
SkipCheckMoreTalentsThanAllowed = 21,
|
||||
SkipCheckChatSpam = 22,
|
||||
SkipCheckOverspeedPing = 23,
|
||||
TwoSideCharacterCreation = 24,
|
||||
TwoSideInteractionChat = 25,
|
||||
TwoSideInteractionChannel = 26,
|
||||
TwoSideInteractionMail = 27,
|
||||
TwoSideWhoList = 28,
|
||||
TwoSideAddFriend = 29,
|
||||
CommandsSaveWithoutDelay = 30,
|
||||
CommandsUseUnstuckWithArgs = 31,
|
||||
CommandsBeAssignedTicket = 32,
|
||||
CommandsNotifyCommandNotFoundError = 33,
|
||||
CommandsAppearInGmList = 34,
|
||||
WhoSeeAllSecLevels = 35,
|
||||
CanFilterWhispers = 36,
|
||||
ChatUseStaffBadge = 37,
|
||||
ResurrectWithFullHps = 38,
|
||||
RestoreSavedGmState = 39,
|
||||
AllowGmFriend = 40,
|
||||
UseStartGmLevel = 41,
|
||||
OpcodeWorldTeleport = 42,
|
||||
OpcodeWhois = 43,
|
||||
ReceiveGlobalGmTextmessage = 44,
|
||||
SilentlyJoinChannel = 45,
|
||||
ChangeChannelNotModerator = 46,
|
||||
CheckForLowerSecurity = 47,
|
||||
CommandsPinfoCheckPersonalData = 48,
|
||||
EmailConfirmForPassChange = 49,
|
||||
MayCheckOwnEmail = 50,
|
||||
AllowTwoSideTrade = 51,
|
||||
|
||||
// Free Space For Core Permissions (Till 149)
|
||||
// Roles (Permissions With Delegated Permissions) Use 199 And Descending
|
||||
CommandRbac = 200,
|
||||
CommandRbacAcc = 201,
|
||||
CommandRbacAccPermList = 202,
|
||||
CommandRbacAccPermGrant = 203,
|
||||
CommandRbacAccPermDeny = 204,
|
||||
CommandRbacAccPermRevoke = 205,
|
||||
CommandRbacList = 206,
|
||||
CommandBnetAccount = 207,
|
||||
CommandBnetAccountCreate = 208,
|
||||
CommandBnetAccountLockCountry = 209,
|
||||
CommandBnetAccountLockIp = 210,
|
||||
CommandBnetAccountPassword = 211,
|
||||
CommandBnetAccountSet = 212,
|
||||
CommandBnetAccountSetPassword = 213,
|
||||
CommandBnetAccountLink = 214,
|
||||
CommandBnetAccountUnlink = 215,
|
||||
CommandBnetAccountCreateGame = 216,
|
||||
CommandAccount = 217,
|
||||
CommandAccountAddon = 218,
|
||||
CommandAccountCreate = 219,
|
||||
CommandAccountDelete = 220,
|
||||
CommandAccountLock = 221,
|
||||
CommandAccountLockCountry = 222,
|
||||
CommandAccountLockIp = 223,
|
||||
CommandAccountOnlineList = 224,
|
||||
CommandAccountPassword = 225,
|
||||
CommandAccountSet = 226,
|
||||
CommandAccountSetAddon = 227,
|
||||
CommandAccountSetGmlevel = 228,
|
||||
CommandAccountSetPassword = 229,
|
||||
CommandAchievement = 230,
|
||||
CommandAchievementAdd = 231,
|
||||
CommandArena = 232,
|
||||
CommandArenaCaptain = 233,
|
||||
CommandArenaCreate = 234,
|
||||
CommandArenaDisband = 235,
|
||||
CommandArenaInfo = 236,
|
||||
CommandArenaLookup = 237,
|
||||
CommandArenaRename = 238,
|
||||
CommandBan = 239,
|
||||
CommandBanAccount = 240,
|
||||
CommandBanCharacter = 241,
|
||||
CommandBanIp = 242,
|
||||
CommandBanPlayeraccount = 243,
|
||||
CommandBaninfo = 244,
|
||||
CommandBaninfoAccount = 245,
|
||||
CommandBaninfoCharacter = 246,
|
||||
CommandBaninfoIp = 247,
|
||||
CommandBanlist = 248,
|
||||
CommandBanlistAccount = 249,
|
||||
CommandBanlistCharacter = 250,
|
||||
CommandBanlistIp = 251,
|
||||
CommandUnban = 252,
|
||||
CommandUnbanAccount = 253,
|
||||
CommandUnbanCharacter = 254,
|
||||
CommandUnbanIp = 255,
|
||||
CommandUnbanPlayeraccount = 256,
|
||||
CommandBf = 257,
|
||||
CommandBfStart = 258,
|
||||
CommandBfStop = 259,
|
||||
CommandBfSwitch = 260,
|
||||
CommandBfTimer = 261,
|
||||
CommandBfEnable = 262,
|
||||
CommandAccountEmail = 263,
|
||||
CommandAccountSetSec = 264,
|
||||
CommandAccountSetSecEmail = 265,
|
||||
CommandAccountSetSecRegmail = 266,
|
||||
CommandCast = 267,
|
||||
CommandCastBack = 268,
|
||||
CommandCastDist = 269,
|
||||
CommandCastSelf = 270,
|
||||
CommandCastTarget = 271,
|
||||
CommandCastDest = 272,
|
||||
CommandCharacter = 273,
|
||||
CommandCharacterCustomize = 274,
|
||||
CommandCharacterChangefaction = 275,
|
||||
CommandCharacterChangerace = 276,
|
||||
CommandCharacterDeleted = 277,
|
||||
CommandCharacterDeletedDelete = 278,
|
||||
CommandCharacterDeletedList = 279,
|
||||
CommandCharacterDeletedRestore = 280,
|
||||
CommandCharacterDeletedOld = 281,
|
||||
CommandCharacterErase = 282,
|
||||
CommandCharacterLevel = 283,
|
||||
CommandCharacterRename = 284,
|
||||
CommandCharacterReputation = 285,
|
||||
CommandCharacterTitles = 286,
|
||||
CommandLevelup = 287,
|
||||
CommandPdump = 288,
|
||||
CommandPdumpLoad = 289,
|
||||
CommandPdumpWrite = 290,
|
||||
CommandCheat = 291,
|
||||
CommandCheatCasttime = 292,
|
||||
CommandCheatCooldown = 293,
|
||||
CommandCheatExplore = 294,
|
||||
CommandCheatGod = 295,
|
||||
CommandCheatPower = 296,
|
||||
CommandCheatStatus = 297,
|
||||
CommandCheatTaxi = 298,
|
||||
CommandCheatWaterwalk = 299,
|
||||
CommandDebug = 300,
|
||||
CommandDebugAnim = 301,
|
||||
CommandDebugAreatriggers = 302,
|
||||
CommandDebugArena = 303,
|
||||
CommandDebugBg = 304,
|
||||
CommandDebugEntervehicle = 305,
|
||||
CommandDebugGetitemstate = 306,
|
||||
CommandDebugGetitemvalue = 307,
|
||||
CommandDebugGetvalue = 308,
|
||||
CommandDebugHostil = 309,
|
||||
CommandDebugItemexpire = 310,
|
||||
CommandDebugLootrecipient = 311,
|
||||
CommandDebugLos = 312,
|
||||
CommandDebugMod32value = 313,
|
||||
CommandDebugMoveflags = 314,
|
||||
CommandDebugPlay = 315,
|
||||
CommandDebugPlayCinematic = 316,
|
||||
CommandDebugPlayMovie = 317,
|
||||
CommandDebugPlaySound = 318,
|
||||
CommandDebugSend = 319,
|
||||
CommandDebugSendBuyerror = 320,
|
||||
CommandDebugSendChannelnotify = 321,
|
||||
CommandDebugSendChatmessage = 322,
|
||||
CommandDebugSendEquiperror = 323,
|
||||
CommandDebugSendLargepacket = 324,
|
||||
CommandDebugSendOpcode = 325,
|
||||
CommandDebugSendQinvalidmsg = 326,
|
||||
CommandDebugSendQpartymsg = 327,
|
||||
CommandDebugSendSellerror = 328,
|
||||
CommandDebugSendSetphaseshift = 329,
|
||||
CommandDebugSendSpellfail = 330,
|
||||
CommandDebugSetaurastate = 331,
|
||||
CommandDebugSetbit = 332,
|
||||
CommandDebugSetitemvalue = 333,
|
||||
CommandDebugSetvalue = 334,
|
||||
CommandDebugSetvid = 335,
|
||||
CommandDebugSpawnvehicle = 336,
|
||||
CommandDebugThreat = 337,
|
||||
CommandDebugUpdate = 338,
|
||||
CommandDebugUws = 339,
|
||||
CommandWpgps = 340,
|
||||
CommandDeserter = 341,
|
||||
CommandDeserterBg = 342,
|
||||
CommandDeserterBgAdd = 343,
|
||||
CommandDeserterBgRemove = 344,
|
||||
CommandDeserterInstance = 345,
|
||||
CommandDeserterInstanceAdd = 346,
|
||||
CommandDeserterInstanceRemove = 347,
|
||||
CommandDisable = 348,
|
||||
CommandDisableAdd = 349,
|
||||
CommandDisableAddCriteria = 350,
|
||||
CommandDisableAddBattleground = 351,
|
||||
CommandDisableAddMap = 352,
|
||||
CommandDisableAddMmap = 353,
|
||||
CommandDisableAddOutdoorpvp = 354,
|
||||
CommandDisableAddQuest = 355,
|
||||
CommandDisableAddSpell = 356,
|
||||
CommandDisableAddVmap = 357,
|
||||
CommandDisableRemove = 358,
|
||||
CommandDisableRemoveCriteria = 359,
|
||||
CommandDisableRemoveBattleground = 360,
|
||||
CommandDisableRemoveMap = 361,
|
||||
CommandDisableRemoveMmap = 362,
|
||||
CommandDisableRemoveOutdoorpvp = 363,
|
||||
CommandDisableRemoveQuest = 364,
|
||||
CommandDisableRemoveSpell = 365,
|
||||
CommandDisableRemoveVmap = 366,
|
||||
CommandEvent = 367,
|
||||
CommandEventActivelist = 368,
|
||||
CommandEventStart = 369,
|
||||
CommandEventStop = 370,
|
||||
CommandGm = 371,
|
||||
CommandGmChat = 372,
|
||||
CommandGmFly = 373,
|
||||
CommandGmIngame = 374,
|
||||
CommandGmList = 375,
|
||||
CommandGmVisible = 376,
|
||||
CommandGo = 377,
|
||||
CommandGoCreature = 378,
|
||||
CommandGoGraveyard = 379,
|
||||
CommandGoGrid = 380,
|
||||
CommandGoObject = 381,
|
||||
CommandGoTaxinode = 382,
|
||||
// 383 reuse
|
||||
CommandGoTrigger = 384,
|
||||
CommandGoXyz = 385,
|
||||
CommandGoZonexy = 386,
|
||||
CommandGobject = 387,
|
||||
CommandGobjectActivate = 388,
|
||||
CommandGobjectAdd = 389,
|
||||
CommandGobjectAddTemp = 390,
|
||||
CommandGobjectDelete = 391,
|
||||
CommandGobjectInfo = 392,
|
||||
CommandGobjectMove = 393,
|
||||
CommandGobjectNear = 394,
|
||||
CommandGobjectSet = 395,
|
||||
CommandGobjectSetPhase = 396,
|
||||
CommandGobjectSetState = 397,
|
||||
CommandGobjectTarget = 398,
|
||||
CommandGobjectTurn = 399,
|
||||
CommandDebugTransport = 400,
|
||||
CommandGuild = 401,
|
||||
CommandGuildCreate = 402,
|
||||
CommandGuildDelete = 403,
|
||||
CommandGuildInvite = 404,
|
||||
CommandGuildUninvite = 405,
|
||||
CommandGuildRank = 406,
|
||||
CommandGuildRename = 407,
|
||||
CommandHonor = 408,
|
||||
CommandHonorAdd = 409,
|
||||
CommandHonorAddKill = 410,
|
||||
CommandHonorUpdate = 411,
|
||||
CommandInstance = 412,
|
||||
CommandInstanceListbinds = 413,
|
||||
CommandInstanceUnbind = 414,
|
||||
CommandInstanceStats = 415,
|
||||
CommandInstanceSavedata = 416,
|
||||
CommandLearn = 417,
|
||||
CommandLearnAll = 418,
|
||||
CommandLearnAllMy = 419,
|
||||
CommandLearnAllMyClass = 420,
|
||||
CommandLearnAllMyPettalents = 421,
|
||||
CommandLearnAllMySpells = 422,
|
||||
CommandLearnAllMyTalents = 423,
|
||||
CommandLearnAllGm = 424,
|
||||
CommandLearnAllCrafts = 425,
|
||||
CommandLearnAllDefault = 426,
|
||||
CommandLearnAllLang = 427,
|
||||
CommandLearnAllRecipes = 428,
|
||||
CommandUnlearn = 429,
|
||||
CommandLfg = 430,
|
||||
CommandLfgPlayer = 431,
|
||||
CommandLfgGroup = 432,
|
||||
CommandLfgQueue = 433,
|
||||
CommandLfgClean = 434,
|
||||
CommandLfgOptions = 435,
|
||||
CommandList = 436,
|
||||
CommandListCreature = 437,
|
||||
CommandListItem = 438,
|
||||
CommandListObject = 439,
|
||||
CommandListAuras = 440,
|
||||
CommandListMail = 441,
|
||||
CommandLookup = 442,
|
||||
CommandLookupArea = 443,
|
||||
CommandLookupCreature = 444,
|
||||
CommandLookupEvent = 445,
|
||||
CommandLookupFaction = 446,
|
||||
CommandLookupItem = 447,
|
||||
CommandLookupItemset = 448,
|
||||
CommandLookupObject = 449,
|
||||
CommandLookupQuest = 450,
|
||||
CommandLookupPlayer = 451,
|
||||
CommandLookupPlayerIp = 452,
|
||||
CommandLookupPlayerAccount = 453,
|
||||
CommandLookupPlayerEmail = 454,
|
||||
CommandLookupSkill = 455,
|
||||
CommandLookupSpell = 456,
|
||||
CommandLookupSpellId = 457,
|
||||
CommandLookupTaxinode = 458,
|
||||
CommandLookupTele = 459,
|
||||
CommandLookupTitle = 460,
|
||||
CommandLookupMap = 461,
|
||||
CommandAnnounce = 462,
|
||||
CommandChannel = 463,
|
||||
CommandChannelSet = 464,
|
||||
CommandChannelSetOwnership = 465,
|
||||
CommandGmannounce = 466,
|
||||
CommandGmnameannounce = 467,
|
||||
CommandGmnotify = 468,
|
||||
CommandNameannounce = 469,
|
||||
CommandNotify = 470,
|
||||
CommandWhispers = 471,
|
||||
CommandGroup = 472,
|
||||
CommandGroupLeader = 473,
|
||||
CommandGroupDisband = 474,
|
||||
CommandGroupRemove = 475,
|
||||
CommandGroupJoin = 476,
|
||||
CommandGroupList = 477,
|
||||
CommandGroupSummon = 478,
|
||||
CommandPet = 479,
|
||||
CommandPetCreate = 480,
|
||||
CommandPetLearn = 481,
|
||||
CommandPetUnlearn = 482,
|
||||
CommandSend = 483,
|
||||
CommandSendItems = 484,
|
||||
CommandSendMail = 485,
|
||||
CommandSendMessage = 486,
|
||||
CommandSendMoney = 487,
|
||||
CommandAdditem = 488,
|
||||
CommandAdditemset = 489,
|
||||
CommandAppear = 490,
|
||||
CommandAura = 491,
|
||||
CommandBank = 492,
|
||||
CommandBindsight = 493,
|
||||
CommandCombatstop = 494,
|
||||
CommandCometome = 495,
|
||||
CommandCommands = 496,
|
||||
CommandCooldown = 497,
|
||||
CommandDamage = 498,
|
||||
CommandDev = 499,
|
||||
CommandDie = 500,
|
||||
CommandDismount = 501,
|
||||
CommandDistance = 502,
|
||||
CommandFlusharenapoints = 503,
|
||||
CommandFreeze = 504,
|
||||
CommandGps = 505,
|
||||
CommandGuid = 506,
|
||||
CommandHelp = 507,
|
||||
CommandHidearea = 508,
|
||||
CommandItemmove = 509,
|
||||
CommandKick = 510,
|
||||
CommandLinkgrave = 511,
|
||||
CommandListfreeze = 512,
|
||||
CommandMaxskill = 513,
|
||||
CommandMovegens = 514,
|
||||
CommandMute = 515,
|
||||
CommandNeargrave = 516,
|
||||
CommandPinfo = 517,
|
||||
CommandPlayall = 518,
|
||||
CommandPossess = 519,
|
||||
CommandRecall = 520,
|
||||
CommandRepairitems = 521,
|
||||
CommandRespawn = 522,
|
||||
CommandRevive = 523,
|
||||
CommandSaveall = 524,
|
||||
CommandSave = 525,
|
||||
CommandSetskill = 526,
|
||||
CommandShowarea = 527,
|
||||
CommandSummon = 528,
|
||||
CommandUnaura = 529,
|
||||
CommandUnbindsight = 530,
|
||||
CommandUnfreeze = 531,
|
||||
CommandUnmute = 532,
|
||||
CommandUnpossess = 533,
|
||||
CommandUnstuck = 534,
|
||||
CommandWchange = 535,
|
||||
CommandMmap = 536,
|
||||
CommandMmapLoadedtiles = 537,
|
||||
CommandMmapLoc = 538,
|
||||
CommandMmapPath = 539,
|
||||
CommandMmapStats = 540,
|
||||
CommandMmapTestarea = 541,
|
||||
CommandMorph = 542,
|
||||
CommandDemorph = 543,
|
||||
CommandModify = 544,
|
||||
CommandModifyArenapoints = 545,
|
||||
CommandModifyBit = 546,
|
||||
CommandModifyDrunk = 547,
|
||||
CommandModifyEnergy = 548,
|
||||
CommandModifyFaction = 549,
|
||||
CommandModifyGender = 550,
|
||||
CommandModifyHonor = 551,
|
||||
CommandModifyHp = 552,
|
||||
CommandModifyMana = 553,
|
||||
CommandModifyMoney = 554,
|
||||
CommandModifyMount = 555,
|
||||
CommandModifyPhase = 556,
|
||||
CommandModifyRage = 557,
|
||||
CommandModifyReputation = 558,
|
||||
CommandModifyRunicpower = 559,
|
||||
CommandModifyScale = 560,
|
||||
CommandModifySpeed = 561,
|
||||
CommandModifySpeedAll = 562,
|
||||
CommandModifySpeedBackwalk = 563,
|
||||
CommandModifySpeedFly = 564,
|
||||
CommandModifySpeedWalk = 565,
|
||||
CommandModifySpeedSwim = 566,
|
||||
CommandModifySpell = 567,
|
||||
CommandModifyStandstate = 568,
|
||||
CommandModifyTalentpoints = 569,
|
||||
CommandNpc = 570,
|
||||
CommandNpcAdd = 571,
|
||||
CommandNpcAddFormation = 572,
|
||||
CommandNpcAddItem = 573,
|
||||
CommandNpcAddMove = 574,
|
||||
CommandNpcAddTemp = 575,
|
||||
CommandNpcDelete = 576,
|
||||
CommandNpcDeleteItem = 577,
|
||||
CommandNpcFollow = 578,
|
||||
CommandNpcFollowStop = 579,
|
||||
CommandNpcSet = 580,
|
||||
CommandNpcSetAllowmove = 581,
|
||||
CommandNpcSetEntry = 582,
|
||||
CommandNpcSetFactionid = 583,
|
||||
CommandNpcSetFlag = 584,
|
||||
CommandNpcSetLevel = 585,
|
||||
CommandNpcSetLink = 586,
|
||||
CommandNpcSetModel = 587,
|
||||
CommandNpcSetMovetype = 588,
|
||||
CommandNpcSetPhase = 589,
|
||||
CommandNpcSetSpawndist = 590,
|
||||
CommandNpcSetSpawntime = 591,
|
||||
CommandNpcSetData = 592,
|
||||
CommandNpcInfo = 593,
|
||||
CommandNpcNear = 594,
|
||||
CommandNpcMove = 595,
|
||||
CommandNpcPlayemote = 596,
|
||||
CommandNpcSay = 597,
|
||||
CommandNpcTextemote = 598,
|
||||
CommandNpcWhisper = 599,
|
||||
CommandNpcYell = 600,
|
||||
CommandNpcTame = 601,
|
||||
CommandQuest = 602,
|
||||
CommandQuestAdd = 603,
|
||||
CommandQuestComplete = 604,
|
||||
CommandQuestRemove = 605,
|
||||
CommandQuestReward = 606,
|
||||
CommandReload = 607,
|
||||
CommandReloadAccessRequirement = 608,
|
||||
CommandReloadCriteriaData = 609,
|
||||
CommandReloadAchievementReward = 610,
|
||||
CommandReloadAll = 611,
|
||||
CommandReloadAllAchievement = 612,
|
||||
CommandReloadAllArea = 613,
|
||||
CommandReloadBroadcastText = 614,
|
||||
CommandReloadAllGossip = 615,
|
||||
CommandReloadAllItem = 616,
|
||||
CommandReloadAllLocales = 617,
|
||||
CommandReloadAllLoot = 618,
|
||||
CommandReloadAllNpc = 619,
|
||||
CommandReloadAllQuest = 620,
|
||||
CommandReloadAllScripts = 621,
|
||||
CommandReloadAllSpell = 622,
|
||||
CommandReloadAreatriggerInvolvedrelation = 623,
|
||||
CommandReloadAreatriggerTavern = 624,
|
||||
CommandReloadAreatriggerTeleport = 625,
|
||||
CommandReloadAuctions = 626,
|
||||
CommandReloadAutobroadcast = 627,
|
||||
CommandReloadCommand = 628,
|
||||
CommandReloadConditions = 629,
|
||||
CommandReloadConfig = 630,
|
||||
CommandReloadBattlegroundTemplate = 631,
|
||||
CommandMutehistory = 632,
|
||||
CommandReloadCreatureLinkedRespawn = 633,
|
||||
CommandReloadCreatureLootTemplate = 634,
|
||||
CommandReloadCreatureOnkillReputation = 635,
|
||||
CommandReloadCreatureQuestender = 636,
|
||||
CommandReloadCreatureQueststarter = 637,
|
||||
CommandReloadCreatureSummonGroups = 638,
|
||||
CommandReloadCreatureTemplate = 639,
|
||||
CommandReloadCreatureText = 640,
|
||||
CommandReloadDisables = 641,
|
||||
CommandReloadDisenchantLootTemplate = 642,
|
||||
CommandReloadEventScripts = 643,
|
||||
CommandReloadFishingLootTemplate = 644,
|
||||
CommandReloadGraveyardZone = 645,
|
||||
CommandReloadGameTele = 646,
|
||||
CommandReloadGameobjectQuestender = 647,
|
||||
CommandReloadGameobjectQuestLootTemplate = 648,
|
||||
CommandReloadGameobjectQueststarter = 649,
|
||||
CommandReloadSupportSystem = 650,
|
||||
CommandReloadGossipMenu = 651,
|
||||
CommandReloadGossipMenuOption = 652,
|
||||
CommandReloadItemEnchantmentTemplate = 653,
|
||||
CommandReloadItemLootTemplate = 654,
|
||||
CommandReloadItemSetNames = 655,
|
||||
CommandReloadLfgDungeonRewards = 656,
|
||||
CommandReloadLocalesAchievementReward = 657,
|
||||
CommandReloadLocalesCreature = 658,
|
||||
CommandReloadLocalesCreatureText = 659,
|
||||
CommandReloadLocalesGameobject = 660,
|
||||
CommandReloadLocalesGossipMenuOption = 661,
|
||||
// 662 Unused
|
||||
CommandReloadLocalesItemSetName = 663,
|
||||
// 664 Unused
|
||||
CommandReloadLocalesPageText = 665,
|
||||
CommandReloadLocalesPointsOfInterest = 666,
|
||||
CommandReloadQuestLocale = 667,
|
||||
CommandReloadMailLevelReward = 668,
|
||||
CommandReloadMailLootTemplate = 669,
|
||||
CommandReloadMillingLootTemplate = 670,
|
||||
CommandReloadNpcSpellclickSpells = 671,
|
||||
CommandReloadTrainer = 672,
|
||||
CommandReloadNpcVendor = 673,
|
||||
CommandReloadPageText = 674,
|
||||
CommandReloadPickpocketingLootTemplate = 675,
|
||||
CommandReloadPointsOfInterest = 676,
|
||||
CommandReloadProspectingLootTemplate = 677,
|
||||
CommandReloadQuestPoi = 678,
|
||||
CommandReloadQuestTemplate = 679,
|
||||
CommandReloadRbac = 680,
|
||||
CommandReloadReferenceLootTemplate = 681,
|
||||
CommandReloadReservedName = 682,
|
||||
CommandReloadReputationRewardRate = 683,
|
||||
CommandReloadSpilloverTemplate = 684,
|
||||
CommandReloadSkillDiscoveryTemplate = 685,
|
||||
CommandReloadSkillExtraItemTemplate = 686,
|
||||
CommandReloadSkillFishingBaseLevel = 687,
|
||||
CommandReloadSkinningLootTemplate = 688,
|
||||
CommandReloadSmartScripts = 689,
|
||||
CommandReloadSpellRequired = 690,
|
||||
CommandReloadSpellArea = 691,
|
||||
// 692 Unused
|
||||
CommandReloadSpellGroup = 693,
|
||||
CommandReloadSpellLearnSpell = 694,
|
||||
CommandReloadSpellLootTemplate = 695,
|
||||
CommandReloadSpellLinkedSpell = 696,
|
||||
CommandReloadSpellPetAuras = 697,
|
||||
// 698 - reuse
|
||||
CommandReloadSpellProc = 699,
|
||||
CommandReloadSpellScripts = 700,
|
||||
CommandReloadSpellTargetPosition = 701,
|
||||
CommandReloadSpellThreats = 702,
|
||||
CommandReloadSpellGroupStackRules = 703,
|
||||
CommandReloadCypherString = 704,
|
||||
CommandReloadWardenAction = 705,
|
||||
CommandReloadWaypointScripts = 706,
|
||||
CommandReloadWaypointData = 707,
|
||||
CommandReloadVehicleAccesory = 708,
|
||||
CommandReloadVehicleTemplateAccessory = 709,
|
||||
CommandReset = 710,
|
||||
CommandResetAchievements = 711,
|
||||
CommandResetHonor = 712,
|
||||
CommandResetLevel = 713,
|
||||
CommandResetSpells = 714,
|
||||
CommandResetStats = 715,
|
||||
CommandResetTalents = 716,
|
||||
CommandResetAll = 717,
|
||||
CommandServer = 718,
|
||||
CommandServerCorpses = 719,
|
||||
CommandServerExit = 720,
|
||||
CommandServerIdlerestart = 721,
|
||||
CommandServerIdlerestartCancel = 722,
|
||||
CommandServerIdleshutdown = 723,
|
||||
CommandServerIdleshutdownCancel = 724,
|
||||
CommandServerInfo = 725,
|
||||
CommandServerPlimit = 726,
|
||||
CommandServerRestart = 727,
|
||||
CommandServerRestartCancel = 728,
|
||||
CommandServerSet = 729,
|
||||
CommandServerSetClosed = 730,
|
||||
CommandServerSetDifftime = 731,
|
||||
CommandServerSetLoglevel = 732,
|
||||
CommandServerSetMotd = 733,
|
||||
CommandServerShutdown = 734,
|
||||
CommandServerShutdownCancel = 735,
|
||||
CommandServerMotd = 736,
|
||||
CommandTele = 737,
|
||||
CommandTeleAdd = 738,
|
||||
CommandTeleDel = 739,
|
||||
CommandTeleName = 740,
|
||||
CommandTeleGroup = 741,
|
||||
CommandTicket = 742,
|
||||
// 743 - 752 reuse
|
||||
CommandTicketReset = 753,
|
||||
// 754 - 756 reuse
|
||||
CommandTicketTogglesystem = 757,
|
||||
// 758 - 760 reuse
|
||||
CommandTitles = 761,
|
||||
CommandTitlesAdd = 762,
|
||||
CommandTitlesCurrent = 763,
|
||||
CommandTitlesRemove = 764,
|
||||
CommandTitlesSet = 765,
|
||||
CommandTitlesSetMask = 766,
|
||||
CommandWp = 767,
|
||||
CommandWpAdd = 768,
|
||||
CommandWpEvent = 769,
|
||||
CommandWpLoad = 770,
|
||||
CommandWpModify = 771,
|
||||
CommandWpUnload = 772,
|
||||
CommandWpReload = 773,
|
||||
CommandWpShow = 774,
|
||||
CommandModifyCurrency = 775, // Only 4.3.4
|
||||
CommandDebugPhase = 776, // Only 4.3.4
|
||||
CommandMailbox = 777,
|
||||
CommandAhbot = 778,
|
||||
CommandAhbotItems = 779,
|
||||
CommandAhbotItemsGray = 780,
|
||||
CommandAhbotItemsWhite = 781,
|
||||
CommandAhbotItemsGreen = 782,
|
||||
CommandAhbotItemsBlue = 783,
|
||||
CommandAhbotItemsPurple = 784,
|
||||
CommandAhbotItemsOrange = 785,
|
||||
CommandAhbotItemsYellow = 786,
|
||||
CommandAhbotRatio = 787,
|
||||
CommandAhbotRatioAlliance = 788,
|
||||
CommandAhbotRatioHorde = 789,
|
||||
CommandAhbotRatioNeutral = 790,
|
||||
CommandAhbotRebuild = 791,
|
||||
CommandAhbotReload = 792,
|
||||
CommandAhbotStatus = 793,
|
||||
CommandGuildInfo = 794,
|
||||
CommandInstanceSetBossState = 795,
|
||||
CommandInstanceGetBossState = 796,
|
||||
CommandPvpstats = 797,
|
||||
CommandModifyXp = 798,
|
||||
CommandGoBugTicket = 799,
|
||||
CommandGoComplaintTicket = 800,
|
||||
CommandGoSuggestionTicket = 801,
|
||||
CommandTicketBug = 802,
|
||||
CommandTicketComplaint = 803,
|
||||
CommandTicketSuggestion = 804,
|
||||
CommandTicketBugAssign = 805,
|
||||
CommandTicketBugClose = 806,
|
||||
CommandTicketBugClosedlist = 807,
|
||||
CommandTicketBugComment = 808,
|
||||
CommandTicketBugDelete = 809,
|
||||
CommandTicketBugList = 810,
|
||||
CommandTicketBugUnassign = 811,
|
||||
CommandTicketBugView = 812,
|
||||
CommandTicketComplaintAssign = 813,
|
||||
CommandTicketComplaintClose = 814,
|
||||
CommandTicketComplaintClosedlist = 815,
|
||||
CommandTicketComplaintComment = 816,
|
||||
CommandTicketComplaintDelete = 817,
|
||||
CommandTicketComplaintList = 818,
|
||||
CommandTicketComplaintUnassign = 819,
|
||||
CommandTicketComplaintView = 820,
|
||||
CommandTicketSuggestionAssign = 821,
|
||||
CommandTicketSuggestionClose = 822,
|
||||
CommandTicketSuggestionClosedlist = 823,
|
||||
CommandTicketSuggestionComment = 824,
|
||||
CommandTicketSuggestionDelete = 825,
|
||||
CommandTicketSuggestionList = 826,
|
||||
CommandTicketSuggestionUnassign = 827,
|
||||
CommandTicketSuggestionView = 828,
|
||||
CommandTicketResetAll = 829,
|
||||
CommandBnetAccountListGameAccounts = 830,
|
||||
CommandTicketResetBug = 831,
|
||||
CommandTicketResetComplaint = 832,
|
||||
CommandTicketResetSuggestion = 833,
|
||||
CommandGoQuest = 834,
|
||||
CommandDebugLoadcells = 835,
|
||||
CommandDebugBoundary = 836,
|
||||
CommandNpcEvade = 837,
|
||||
CommandPetLevel = 838,
|
||||
CommandServerShutdownForce = 839,
|
||||
CommandServerRestartForce = 840,
|
||||
CommandNearGraveyard = 841,
|
||||
CommandReloadCharacterTemplate = 842,
|
||||
CommandReloadQuestGreeting = 843,
|
||||
CommandScene = 844,
|
||||
CommandSceneDedug = 845,
|
||||
CommandScenePlay = 846,
|
||||
CommandScenePlayPackage = 847,
|
||||
CommandSceneCancel = 848,
|
||||
CommandListScenes = 849,
|
||||
CommandReloacSceneTemplate = 850,
|
||||
CommandReloadAreatriggerTemplate = 851,
|
||||
CommandGoOffset = 852,
|
||||
CommandReloadConversationTemplate = 853,
|
||||
CommandDebugConversation = 854,
|
||||
|
||||
// Custom Permissions 1000+
|
||||
Max
|
||||
}
|
||||
|
||||
public enum MountStatusFlags
|
||||
{
|
||||
None = 0x00,
|
||||
NeedsFanfare = 0x01,
|
||||
IsFavorite = 0x02
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum AchievementFaction : sbyte
|
||||
{
|
||||
Horde = 0,
|
||||
Alliance = 1,
|
||||
Any = -1,
|
||||
}
|
||||
|
||||
public enum CriteriaTreeFlags : ushort
|
||||
{
|
||||
ProgressBar = 0x0001,
|
||||
ProgressIsDate = 0x0004,
|
||||
ShowCurrencyIcon = 0x0008,
|
||||
AllianceOnly = 0x0200,
|
||||
HordeOnly = 0x0400,
|
||||
ShowRequiredCount = 0x0800
|
||||
}
|
||||
|
||||
public enum CriteriaTreeOperator
|
||||
{
|
||||
Single = 0,
|
||||
SinglerNotCompleted = 1,
|
||||
All = 4,
|
||||
SumChildren = 5,
|
||||
MaxChild = 6,
|
||||
CountDirectChildren = 7,
|
||||
Any = 8,
|
||||
SumChildrenWeight = 9
|
||||
}
|
||||
|
||||
public enum AchievementFlags
|
||||
{
|
||||
Counter = 0x01,
|
||||
Hidden = 0x02,
|
||||
PlayNoVisual = 0x04,
|
||||
Summ = 0x08,
|
||||
MaxUsed = 0x10,
|
||||
ReqCount = 0x20,
|
||||
Average = 0x40,
|
||||
Bar = 0x80,
|
||||
RealmFirstReach = 0x100,
|
||||
RealmFirstKill = 0x200,
|
||||
Unk3 = 0x400,
|
||||
HideIncomplete = 0x800,
|
||||
ShowInGuildNews = 0x1000,
|
||||
ShowInGuildHeader = 0x2000,
|
||||
Guild = 0x4000,
|
||||
ShowGuildMembers = 0x8000,
|
||||
ShowCriteriaMembers = 0x10000,
|
||||
Account = 0x20000,
|
||||
Unk5 = 0x00040000,
|
||||
HideZeroCounter = 0x00080000,
|
||||
TrackingFlag = 0x00100000
|
||||
}
|
||||
|
||||
public enum CriteriaFlagsCu
|
||||
{
|
||||
Player = 0x1,
|
||||
Account = 0x2,
|
||||
Guild = 0x4,
|
||||
Scenario = 0x8,
|
||||
QuestObjective = 0x10
|
||||
}
|
||||
|
||||
public enum CriteriaCondition
|
||||
{
|
||||
None = 0,
|
||||
NoDeath = 1,
|
||||
Unk2 = 2,
|
||||
BgMap = 3,
|
||||
NoLose = 4,
|
||||
Unk5 = 5,
|
||||
Unk8 = 8,
|
||||
NoSpellHit = 9,
|
||||
NotInGroup = 10,
|
||||
Unk13 = 13
|
||||
}
|
||||
|
||||
public enum CriteriaAdditionalCondition
|
||||
{
|
||||
SourceDrunkValue = 1,
|
||||
Unk2 = 2,
|
||||
ItemLevel = 3,
|
||||
TargetCreatureEntry = 4,
|
||||
TargetMustBePlayer = 5,
|
||||
TargetMustBeDead = 6,
|
||||
TargetMustBeEnemy = 7,
|
||||
SourceHasAura = 8,
|
||||
TargetHasAura = 10,
|
||||
TargetHasAuraType = 11,
|
||||
ItemQualityMin = 14,
|
||||
ItemQualityEquals = 15,
|
||||
Unk16 = 16,
|
||||
SourceAreaOrZone = 17,
|
||||
TargetAreaOrZone = 18,
|
||||
MapDifficultyOld = 20,
|
||||
TargetCreatureYieldsXp = 21,
|
||||
ArenaType = 24,
|
||||
SourceRace = 25,
|
||||
SourceClass = 26,
|
||||
TargetRace = 27,
|
||||
TargetClass = 28,
|
||||
MaxGroupMembers = 29,
|
||||
TargetCreatureType = 30,
|
||||
SourceMap = 32,
|
||||
ItemClass = 33,
|
||||
ItemSubclass = 34,
|
||||
CompleteQuestNotInGroup = 35,
|
||||
MinPersonalRating = 37,
|
||||
TitleBitIndex = 38,
|
||||
SourceLevel = 39,
|
||||
TargetLevel = 40,
|
||||
TargetZone = 41,
|
||||
TargetHealthPercentBelow = 46,
|
||||
Unk55 = 55,
|
||||
MinAchievementPoints = 56,
|
||||
RequiresLfgGroup = 58,
|
||||
Unk60 = 60,
|
||||
RequiresGuildGroup = 61,
|
||||
GuildReputation = 62,
|
||||
RatedBattleground = 63,
|
||||
RatedBattlegroundRating = 64,
|
||||
ProjectRarity = 65,
|
||||
ProjectRace = 66,
|
||||
WorldState = 67, // Nyi
|
||||
MapDifficulty = 68, // Nyi
|
||||
PlayerLevel = 69, // Nyi
|
||||
TargetPlayerLevel = 70, // Nyi
|
||||
//PlayerLevelOnAccount = 71, // Not Verified
|
||||
//Unk73 = 73, // References Another Modifier Tree Id
|
||||
ScenarioId = 74, // Nyi
|
||||
BattlePetFamily = 78, // Nyi
|
||||
BattlePetHealthPct = 79, // Nyi
|
||||
//Unk80 = 80 // Something To Do With World Bosses
|
||||
BattlePetEntry = 81, // Nyi
|
||||
//BattlePetEntryId = 82, // Some Sort Of Data Id?
|
||||
ChallengeModeMedal = 83, // NYI
|
||||
//CRITERIA_ADDITIONAL_CONDITION_UNK84 = 84, // Quest id
|
||||
//CRITERIA_ADDITIONAL_CONDITION_UNK86 = 86, // Some external event id
|
||||
//CRITERIA_ADDITIONAL_CONDITION_UNK87 = 87, // Achievement id
|
||||
BattlePetSpecies = 91,
|
||||
GarrisonFollowerEntry = 144,
|
||||
GarrisonFollowerQuality = 145,
|
||||
GarrisonFollowerLevel = 146,
|
||||
GarrisonRareMission = 147, // NYI
|
||||
GarrisonBuildingLevel = 149, // NYI
|
||||
GarrisonMissionType = 167, // NYI
|
||||
PLayerItemLevel = 169, // NYI
|
||||
GarrisonFollowILvl = 184,
|
||||
HonorLevel = 193,
|
||||
PrestigeLevel = 194
|
||||
}
|
||||
|
||||
public enum CriteriaFlags
|
||||
{
|
||||
ShowProgressBar = 0x01,
|
||||
Hidden = 0x02,
|
||||
FailAchievement = 0x04,
|
||||
ResetOnStart = 0x08,
|
||||
IsDate = 0x10,
|
||||
MoneyCounter = 0x20
|
||||
}
|
||||
|
||||
public enum CriteriaTimedTypes : byte
|
||||
{
|
||||
Event = 1, // Timer Is Started By Internal Event With Id In Timerstartevent
|
||||
Quest = 2, // Timer Is Started By Accepting Quest With Entry In Timerstartevent
|
||||
SpellCaster = 5, // Timer Is Started By Casting A Spell With Entry In Timerstartevent
|
||||
SpellTarget = 6, // Timer Is Started By Being Target Of Spell With Entry In Timerstartevent
|
||||
Creature = 7, // Timer Is Started By Killing Creature With Entry In Timerstartevent
|
||||
Item = 9, // Timer Is Started By Using Item With Entry In Timerstartevent
|
||||
Unk = 10, // Unknown
|
||||
Unk2 = 13, // Unknown
|
||||
ScenarioStage = 14, // Timer is started by changing stages in a scenario
|
||||
|
||||
Max
|
||||
}
|
||||
|
||||
public enum CriteriaTypes : byte
|
||||
{
|
||||
KillCreature = 0,
|
||||
WinBg = 1,
|
||||
// 2 - unused (Legion - 23420)
|
||||
CompleteArchaeologyProjects = 3, // Struct { Uint32 Itemcount; }
|
||||
SurveyGameobject = 4,
|
||||
ReachLevel = 5,
|
||||
ClearDigsite = 6,
|
||||
ReachSkillLevel = 7,
|
||||
CompleteAchievement = 8,
|
||||
CompleteQuestCount = 9,
|
||||
CompleteDailyQuestDaily = 10, // You Have To Complete A Daily Quest X Times In A Row
|
||||
CompleteQuestsInZone = 11,
|
||||
Currency = 12,
|
||||
DamageDone = 13,
|
||||
CompleteDailyQuest = 14,
|
||||
CompleteBattleground = 15,
|
||||
DeathAtMap = 16,
|
||||
Death = 17,
|
||||
DeathInDungeon = 18,
|
||||
CompleteRaid = 19,
|
||||
KilledByCreature = 20,
|
||||
ManualCompleteCriteria = 21,
|
||||
CompleteChallengeModeGuild = 22,
|
||||
KilledByPlayer = 23,
|
||||
FallWithoutDying = 24,
|
||||
// 25 - unused (Legion - 23420)
|
||||
DeathsFrom = 26,
|
||||
CompleteQuest = 27,
|
||||
BeSpellTarget = 28,
|
||||
CastSpell = 29,
|
||||
BgObjectiveCapture = 30,
|
||||
HonorableKillAtArea = 31,
|
||||
WinArena = 32,
|
||||
PlayArena = 33,
|
||||
LearnSpell = 34,
|
||||
HonorableKill = 35,
|
||||
OwnItem = 36,
|
||||
WinRatedArena = 37,
|
||||
HighestTeamRating = 38,
|
||||
HighestPersonalRating = 39,
|
||||
LearnSkillLevel = 40,
|
||||
UseItem = 41,
|
||||
LootItem = 42,
|
||||
ExploreArea = 43,
|
||||
OwnRank = 44,
|
||||
BuyBankSlot = 45,
|
||||
GainReputation = 46,
|
||||
GainExaltedReputation = 47,
|
||||
VisitBarberShop = 48,
|
||||
EquipEpicItem = 49,
|
||||
RollNeedOnLoot = 50, /// Todo Itemlevel Is Mentioned In Text But Not Present In Dbc
|
||||
RollGreedOnLoot = 51,
|
||||
HkClass = 52,
|
||||
HkRace = 53,
|
||||
DoEmote = 54,
|
||||
HealingDone = 55,
|
||||
GetKillingBlows = 56, /// Todo In Some Cases Map Not Present, And In Some Cases Need Do Without Die
|
||||
EquipItem = 57,
|
||||
// 58 - unused (Legion - 23420)
|
||||
MoneyFromVendors = 59,
|
||||
GoldSpentForTalents = 60,
|
||||
NumberOfTalentResets = 61,
|
||||
MoneyFromQuestReward = 62,
|
||||
GoldSpentForTravelling = 63,
|
||||
DefeatCreatureGroup = 64,
|
||||
GoldSpentAtBarber = 65,
|
||||
GoldSpentForMail = 66,
|
||||
LootMoney = 67,
|
||||
UseGameobject = 68,
|
||||
BeSpellTarget2 = 69,
|
||||
SpecialPvpKill = 70,
|
||||
CompleteChallengeMode = 71,
|
||||
FishInGameobject = 72,
|
||||
SendEvent = 73,
|
||||
OnLogin = 74,
|
||||
LearnSkilllineSpells = 75,
|
||||
WinDuel = 76,
|
||||
LoseDuel = 77,
|
||||
KillCreatureType = 78,
|
||||
CookRecipesGuild = 79,
|
||||
GoldEarnedByAuctions = 80,
|
||||
EarnPetBattleAchievementPoints = 81,
|
||||
CreateAuction = 82,
|
||||
HighestAuctionBid = 83,
|
||||
WonAuctions = 84,
|
||||
HighestAuctionSold = 85,
|
||||
HighestGoldValueOwned = 86,
|
||||
GainReveredReputation = 87,
|
||||
GainHonoredReputation = 88,
|
||||
KnownFactions = 89,
|
||||
LootEpicItem = 90,
|
||||
ReceiveEpicItem = 91,
|
||||
SendEventScenario = 92,
|
||||
RollNeed = 93,
|
||||
RollGreed = 94,
|
||||
ReleaseSpirit = 95,
|
||||
OwnPet = 96,
|
||||
GarrisonCompleteDungeonEncounter = 97,
|
||||
// 98 - unused (Legion - 23420)
|
||||
// 99 - unused (Legion - 23420)
|
||||
// 100 - unused (Legion - 23420)
|
||||
HighestHitDealt = 101,
|
||||
HighestHitReceived = 102,
|
||||
TotalDamageReceived = 103,
|
||||
HighestHealCasted = 104,
|
||||
TotalHealingReceived = 105,
|
||||
HighestHealingReceived = 106,
|
||||
QuestAbandoned = 107,
|
||||
FlightPathsTaken = 108,
|
||||
LootType = 109,
|
||||
CastSpell2 = 110, /// Todo Target Entry Is Missing
|
||||
// 111 - unused (Legion - 23420)
|
||||
LearnSkillLine = 112,
|
||||
EarnHonorableKill = 113,
|
||||
AcceptedSummonings = 114,
|
||||
EarnAchievementPoints = 115,
|
||||
// 116 - unused (Legion - 23420)
|
||||
// 117 - unused (Legion - 23420)
|
||||
CompleteLfgDungeon = 118,
|
||||
UseLfdToGroupWithPlayers = 119,
|
||||
LfgVoteKicksInitiatedByPlayer = 120,
|
||||
LfgVoteKicksNotInitByPlayer = 121,
|
||||
BeKickedFromLfg = 122,
|
||||
LfgLeaves = 123,
|
||||
SpentGoldGuildRepairs = 124,
|
||||
ReachGuildLevel = 125,
|
||||
CraftItemsGuild = 126,
|
||||
CatchFromPool = 127,
|
||||
BuyGuildBankSlots = 128,
|
||||
EarnGuildAchievementPoints = 129,
|
||||
WinRatedBattleground = 130,
|
||||
// 131 - unused (Legion - 23420)
|
||||
ReachBgRating = 132,
|
||||
BuyGuildTabard = 133,
|
||||
CompleteQuestsGuild = 134,
|
||||
HonorableKillsGuild = 135,
|
||||
KillCreatureTypeGuild = 136,
|
||||
CountOfLfgQueueBoostsByTank = 137,
|
||||
CompleteGuildChallengeType = 138, //Struct { Flag Flag; Uint32 Count; } 1: Guild Dungeon, 2:Guild Challenge, 3:Guild Battlefield
|
||||
CompleteGuildChallenge = 139, //Struct { Uint32 Count; } Guild Challenge
|
||||
// 140 - 1 criteria (16883), unused (Legion - 23420)
|
||||
// 141 - 1 criteria (16884), unused (Legion - 23420)
|
||||
// 142 - 1 criteria (16881), unused (Legion - 23420)
|
||||
// 143 - 1 criteria (16882), unused (Legion - 23420)
|
||||
// 144 - 1 criteria (17386), unused (Legion - 23420)
|
||||
LfrDungeonsCompleted = 145,
|
||||
LfrLeaves = 146,
|
||||
LfrVoteKicksInitiatedByPlayer = 147,
|
||||
LfrVoteKicksNotInitByPlayer = 148,
|
||||
BeKickedFromLfr = 149,
|
||||
CountOfLfrQueueBoostsByTank = 150,
|
||||
CompleteScenarioCount = 151,
|
||||
CompleteScenario = 152,
|
||||
ReachAreatriggerWithActionset = 153,
|
||||
// 154 - unused (Legion - 23420)
|
||||
OwnBattlePet = 155,
|
||||
OwnBattlePetCount = 156,
|
||||
CaptureBattlePet = 157,
|
||||
WinPetBattle = 158,
|
||||
// 159 - 2 criterias (22312,22314), unused (Legion - 23420)
|
||||
LevelBattlePet = 160,
|
||||
CaptureBattlePetCredit = 161, // Triggers A Quest Credit
|
||||
LevelBattlePetCredit = 162, // Triggers A Quest Credit
|
||||
EnterArea = 163, // Triggers A Quest Credit
|
||||
LeaveArea = 164, // Triggers A Quest Credit
|
||||
CompleteDungeonEncounter = 165,
|
||||
// 166 - unused (Legion - 23420)
|
||||
PlaceGarrisonBuilding = 167,
|
||||
UpgradeGarrisonBuilding = 168,
|
||||
ConstructGarrisonBuilding = 169,
|
||||
UpgradeGarrison = 170,
|
||||
StartGarrisonMission = 171,
|
||||
StartOrderHallMission = 172,
|
||||
CompleteGarrisonMissionCount = 173,
|
||||
CompleteGarrisonMission = 174,
|
||||
RecruitGarrisonFollowerCount = 175,
|
||||
RecruitGarrisonFollower = 176,
|
||||
// 177 - 0 criterias (Legion - 23420)
|
||||
LearnGarrisonBlueprintCount = 178,
|
||||
// 179 - 0 criterias (Legion - 23420)
|
||||
// 180 - 0 criterias (Legion - 23420)
|
||||
// 181 - 0 criterias (Legion - 23420)
|
||||
CompleteGarrisonShipment = 182,
|
||||
RaiseGarrisonFollowerItemLevel = 183,
|
||||
RaiseGarrisonFollowerLevel = 184,
|
||||
OwnToy = 185,
|
||||
OwnToyCount = 186,
|
||||
RecruitGarrisonFollowerWithQuality = 187,
|
||||
// 188 - 0 criterias (Legion - 23420)
|
||||
OwnHeirlooms = 189,
|
||||
ArtifactPowerEarned = 190,
|
||||
ArtifactTraitsUnlocked = 191,
|
||||
HonorLevelReached = 194,
|
||||
PrestigeReached = 195,
|
||||
// 196 - CRITERIA_TYPE_REACH_LEVEL_2 or something
|
||||
// 197 - Order Hall Advancement related
|
||||
OrderHallTalentLearned = 198,
|
||||
AppearanceUnlockedBySlot = 199,
|
||||
OrderHallRecruitTyoop = 200,
|
||||
// 201 - 0 criterias (Legion - 23420)
|
||||
// 202 - 0 criterias (Legion - 23420)
|
||||
CompleteWorldQuest = 203,
|
||||
// 204 - Special criteria type to award players for some external events? Comes with what looks like an identifier, so guessing it's not unique.
|
||||
TransmogSetUnlocked = 205,
|
||||
TotalTypes = 208
|
||||
}
|
||||
|
||||
public enum CriteriaDataType
|
||||
{
|
||||
None = 0,
|
||||
TCreature = 1,
|
||||
TPlayerClassRace = 2,
|
||||
TPlayerLessHealth = 3,
|
||||
SAura = 5,
|
||||
TAura = 7,
|
||||
Value = 8,
|
||||
TLevel = 9,
|
||||
TGender = 10,
|
||||
Script = 11,
|
||||
// Reuse
|
||||
MapPlayerCount = 13,
|
||||
TTeam = 14,
|
||||
SDrunk = 15,
|
||||
Holiday = 16,
|
||||
BgLossTeamScore = 17,
|
||||
InstanceScript = 18,
|
||||
SEquippedItem = 19,
|
||||
MapId = 20,
|
||||
SPlayerClassRace = 21,
|
||||
// Reuse
|
||||
SKnownTitle = 23,
|
||||
GameEvent = 24,
|
||||
SItemQuality = 25,
|
||||
|
||||
Max = 25
|
||||
}
|
||||
|
||||
public enum ProgressType
|
||||
{
|
||||
Set,
|
||||
Accumulate,
|
||||
Highest
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum AreaTriggerFlags
|
||||
{
|
||||
HasAbsoluteOrientation = 0x01, // Nyi
|
||||
HasDynamicShape = 0x02, // Implemented For Spheres
|
||||
HasAttached = 0x04,
|
||||
HasFaceMovementDir = 0x08,
|
||||
HasFollowsTerrain = 0x010, // Nyi
|
||||
Unk1 = 0x020,
|
||||
HasTargetRollPitchYaw = 0x040, // Nyi
|
||||
Unk2 = 0x080,
|
||||
Unk3 = 0x100,
|
||||
Unk4 = 0x200,
|
||||
Unk5 = 0x400
|
||||
}
|
||||
|
||||
public enum AreaTriggerTypes
|
||||
{
|
||||
Sphere = 0,
|
||||
Box = 1,
|
||||
Unk = 2,
|
||||
Polygon = 3,
|
||||
Cylinder = 4,
|
||||
Max = 5
|
||||
}
|
||||
|
||||
public enum AreaTriggerActionTypes
|
||||
{
|
||||
Cast = 0,
|
||||
AddAura = 1,
|
||||
Max = 2
|
||||
}
|
||||
|
||||
public enum AreaTriggerActionUserTypes
|
||||
{
|
||||
Any = 0,
|
||||
Friend = 1,
|
||||
Enemy = 2,
|
||||
Raid = 3,
|
||||
Party = 4,
|
||||
Caster = 5,
|
||||
Max = 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum AuctionError
|
||||
{
|
||||
Ok = 0,
|
||||
Inventory = 1,
|
||||
DatabaseError = 2,
|
||||
NotEnoughtMoney = 3,
|
||||
ItemNotFound = 4,
|
||||
HigherBid = 5,
|
||||
BidIncrement = 7,
|
||||
BidOwn = 10,
|
||||
RestrictedAccount = 13
|
||||
}
|
||||
|
||||
public enum AuctionAction
|
||||
{
|
||||
SellItem = 0,
|
||||
Cancel = 1,
|
||||
PlaceBid = 2
|
||||
}
|
||||
|
||||
public enum MailAuctionAnswers
|
||||
{
|
||||
Outbidded = 0,
|
||||
Won = 1,
|
||||
Successful = 2,
|
||||
Expired = 3,
|
||||
CancelledToBidder = 4,
|
||||
Canceled = 5,
|
||||
SalePending = 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum ResponseCodes
|
||||
{
|
||||
Success = 0,
|
||||
Failure = 1,
|
||||
Cancelled = 2,
|
||||
Disconnected = 3,
|
||||
FailedToConnect = 4,
|
||||
Connected = 5,
|
||||
VersionMismatch = 6,
|
||||
|
||||
CstatusConnecting = 7,
|
||||
CstatusNegotiatingSecurity = 8,
|
||||
CstatusNegotiationComplete = 9,
|
||||
CstatusNegotiationFailed = 10,
|
||||
CstatusAuthenticating = 11,
|
||||
|
||||
RealmListInProgress = 12,
|
||||
RealmListSuccess = 13,
|
||||
RealmListFailed = 14,
|
||||
RealmListInvalid = 15,
|
||||
RealmListRealmNotFound = 16,
|
||||
|
||||
AccountCreateInProgress = 17,
|
||||
AccountCreateSuccess = 18,
|
||||
AccountCreateFailed = 19,
|
||||
|
||||
CharListRetrieving = 20,
|
||||
CharListRetrieved = 21,
|
||||
CharListFailed = 22,
|
||||
|
||||
CharCreateInProgress = 23,
|
||||
CharCreateSuccess = 24,
|
||||
CharCreateError = 25,
|
||||
CharCreateFailed = 26,
|
||||
CharCreateNameInUse = 27,
|
||||
CharCreateDisabled = 28,
|
||||
CharCreatePvpTeamsViolation = 29,
|
||||
CharCreateServerLimit = 30,
|
||||
CharCreateAccountLimit = 31,
|
||||
CharCreateServerQueue = 32,
|
||||
CharCreateOnlyExisting = 33,
|
||||
CharCreateExpansion = 34,
|
||||
CharCreateExpansionClass = 35,
|
||||
CharCreateLevelRequirement = 36,
|
||||
CharCreateUniqueClassLimit = 37,
|
||||
CharCreateCharacterInGuild = 38,
|
||||
CharCreateRestrictedRaceclass = 39,
|
||||
CharCreateCharacterChooseRace = 40,
|
||||
CharCreateCharacterArenaLeader = 41,
|
||||
CharCreateCharacterDeleteMail = 42,
|
||||
CharCreateCharacterSwapFaction = 43,
|
||||
CharCreateCharacterRaceOnly = 44,
|
||||
CharCreateCharacterGoldLimit = 45,
|
||||
CharCreateForceLogin = 46,
|
||||
CharCreateTrial = 47,
|
||||
CharCreateTimeout = 48,
|
||||
CharCreateThrottle = 49,
|
||||
|
||||
CharDeleteInProgress = 50,
|
||||
CharDeleteSuccess = 51,
|
||||
CharDeleteFailed = 52,
|
||||
CharDeleteFailedLockedForTransfer = 53,
|
||||
CharDeleteFailedGuildLeader = 54,
|
||||
CharDeleteFailedArenaCaptain = 55,
|
||||
CharDeleteFailedHasHeirloomOrMail = 56,
|
||||
CharDeleteFailedUpgradeInProgress = 57,
|
||||
CharDeleteFailedHasWowToken = 58,
|
||||
CharDeleteFailedVasTransactionInProgress = 59,
|
||||
|
||||
CharLoginInProgress = 60,
|
||||
CharLoginSuccess = 61,
|
||||
CharLoginNoWorld = 62,
|
||||
CharLoginDuplicateCharacter = 63,
|
||||
CharLoginNoInstances = 64,
|
||||
CharLoginFailed = 65,
|
||||
CharLoginDisabled = 66,
|
||||
CharLoginNoCharacter = 67,
|
||||
CharLoginLockedForTransfer = 68,
|
||||
CharLoginLockedByBilling = 69,
|
||||
CharLoginLockedByMobileAh = 70,
|
||||
CharLoginTemporaryGmLock = 71,
|
||||
CharLoginLockedByCharacterUpgrade = 72,
|
||||
CharLoginLockedByRevokedCharacterUpgrade = 73,
|
||||
CharLoginLockedByRevokedVasTransaction = 74,
|
||||
|
||||
CharNameSuccess = 75,
|
||||
CharNameFailure = 76,
|
||||
CharNameNoName = 77,
|
||||
CharNameTooShort = 78,
|
||||
CharNameTooLong = 79,
|
||||
CharNameInvalidCharacter = 80,
|
||||
CharNameMixedLanguages = 81,
|
||||
CharNameProfane = 82,
|
||||
CharNameReserved = 83,
|
||||
CharNameInvalidApostrophe = 84,
|
||||
CharNameMultipleApostrophes = 85,
|
||||
CharNameThreeConsecutive = 86,
|
||||
CharNameInvalidSpace = 87,
|
||||
CharNameConsecutiveSpaces = 88,
|
||||
CharNameRussianConsecutiveSilentCharacters = 89,
|
||||
CharNameRussianSilentCharacterAtBeginningOrEnd = 90,
|
||||
CharNameDeclensionDoesntMatchBaseName = 91
|
||||
}
|
||||
|
||||
public enum CharacterUndeleteResult
|
||||
{
|
||||
Ok = 0,
|
||||
Cooldown = 1,
|
||||
CharCreate = 2,
|
||||
Disabled = 3,
|
||||
NameTakenByThisAccount = 4,
|
||||
Unknown = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum BattlenetRpcErrorCode : uint
|
||||
{
|
||||
Ok = 0x00000000,
|
||||
Internal = 0x00000001,
|
||||
TimedOut = 0x00000002,
|
||||
Denied = 0x00000003,
|
||||
NotExists = 0x00000004,
|
||||
NotStarted = 0x00000005,
|
||||
InProgress = 0x00000006,
|
||||
InvalidArgs = 0x00000007,
|
||||
InvalidSubscriber = 0x00000008,
|
||||
WaitingForDependency = 0x00000009,
|
||||
NoAuth = 0x0000000a,
|
||||
ParentalControlRestriction = 0x0000000b,
|
||||
NoGameAccount = 0x0000000c,
|
||||
NotImplemented = 0x0000000d,
|
||||
ObjectRemoved = 0x0000000e,
|
||||
InvalidEntityId = 0x0000000f,
|
||||
InvalidEntityAccountId = 0x00000010,
|
||||
InvalidEntityGameAccountId = 0x00000011,
|
||||
InvalidAgentId = 0x00000013,
|
||||
InvalidTargetId = 0x00000014,
|
||||
ModuleNotLoaded = 0x00000015,
|
||||
ModuleNoEntryPoint = 0x00000016,
|
||||
ModuleSignatureIncorrect = 0x00000017,
|
||||
ModuleCreateFailed = 0x00000018,
|
||||
NoProgram = 0x00000019,
|
||||
ApiNotReady = 0x0000001b,
|
||||
BadVersion = 0x0000001c,
|
||||
AttributeTooManyAttributesSet = 0x0000001d,
|
||||
AttributeMaxSizeExceeded = 0x0000001e,
|
||||
AttributeQuotaExceeded = 0x0000001f,
|
||||
ServerPoolServerDisappeared = 0x00000020,
|
||||
ServerIsPrivate = 0x00000021,
|
||||
Disabled = 0x00000022,
|
||||
ModuleNotFound = 0x00000024,
|
||||
ServerBusy = 0x00000025,
|
||||
NoBattletag = 0x00000026,
|
||||
IncompleteProfanityFilters = 0x00000027,
|
||||
InvalidRegion = 0x00000028,
|
||||
ExistsAlready = 0x00000029,
|
||||
InvalidServerThumbprint = 0x0000002a,
|
||||
PhoneLock = 0x0000002b,
|
||||
Squelched = 0x0000002c,
|
||||
TargetOffline = 0x0000002d,
|
||||
BadServer = 0x0000002e,
|
||||
NoCookie = 0x0000002f,
|
||||
ExpiredCookie = 0x00000030,
|
||||
TokenNotFound = 0x00000031,
|
||||
GameAccountNoTime = 0x00000032,
|
||||
GameAccountNoPlan = 0x00000033,
|
||||
GameAccountBanned = 0x00000034,
|
||||
GameAccountSuspended = 0x00000035,
|
||||
GameAccountAlreadySelected = 0x00000036,
|
||||
GameAccountCancelled = 0x00000037,
|
||||
GameAccountCreationDisabled = 0x00000038,
|
||||
GameAccountLocked = 0x00000039,
|
||||
|
||||
SessionDuplicate = 0x0000003c,
|
||||
SessionDisconnected = 0x0000003d,
|
||||
SessionDataChanged = 0x0000003e,
|
||||
SessionUpdateFailed = 0x0000003f,
|
||||
SessionNotFound = 0x00000040,
|
||||
|
||||
AdminKick = 0x00000046,
|
||||
UnplannedMaintenance = 0x00000047,
|
||||
PlannedMaintenance = 0x00000048,
|
||||
ServiceFailureAccount = 0x00000049,
|
||||
ServiceFailureSession = 0x0000004a,
|
||||
ServiceFailureAuth = 0x0000004b,
|
||||
ServiceFailureRisk = 0x0000004c,
|
||||
BadProgram = 0x0000004d,
|
||||
BadLocale = 0x0000004e,
|
||||
BadPlatform = 0x0000004f,
|
||||
LocaleRestrictedLa = 0x00000051,
|
||||
LocaleRestrictedRu = 0x00000052,
|
||||
LocaleRestrictedKo = 0x00000053,
|
||||
LocaleRestrictedTw = 0x00000054,
|
||||
LocaleRestricted = 0x00000055,
|
||||
AccountNeedsMaintenance = 0x00000056,
|
||||
ModuleApiError = 0x00000057,
|
||||
ModuleBadCacheHandle = 0x00000058,
|
||||
ModuleAlreadyLoaded = 0x00000059,
|
||||
NetworkBlacklisted = 0x0000005a,
|
||||
EventProcessorSlow = 0x0000005b,
|
||||
ServerShuttingDown = 0x0000005c,
|
||||
NetworkNotPrivileged = 0x0000005d,
|
||||
TooManyOutstandingRequests = 0x0000005e,
|
||||
NoAccountRegistered = 0x0000005f,
|
||||
BattlenetAccountBanned = 0x00000060,
|
||||
|
||||
OkDeprecated = 0x00000064,
|
||||
ServerInModeZombie = 0x00000065,
|
||||
|
||||
LogonModuleRequired = 0x000001f4,
|
||||
LogonModuleNotConfigured = 0x000001f5,
|
||||
LogonModuleTimeout = 0x000001f6,
|
||||
LogonAgreementRequired = 0x000001fe,
|
||||
LogonAgreementNotConfigured = 0x000001ff,
|
||||
|
||||
LogonInvalidServerProof = 0x00000208,
|
||||
LogonWebVerifyTimeout = 0x00000209,
|
||||
LogonInvalidAuthToken = 0x0000020a,
|
||||
|
||||
ChallengeSmsTooSoon = 0x00000258,
|
||||
ChallengeSmsThrottled = 0x00000259,
|
||||
ChallengeSmsTempOutage = 0x0000025a,
|
||||
ChallengeNoChallenge = 0x0000025b,
|
||||
ChallengeNotPicked = 0x0000025c,
|
||||
ChallengeAlreadyPicked = 0x0000025d,
|
||||
ChallengeInProgress = 0x0000025e,
|
||||
|
||||
ConfigFormatInvalid = 0x000002bc,
|
||||
ConfigNotFound = 0x000002bd,
|
||||
ConfigRetrieveFailed = 0x000002be,
|
||||
|
||||
NetworkModuleBusy = 0x000003e8,
|
||||
NetworkModuleCantResolveAddress = 0x000003e9,
|
||||
NetworkModuleConnectionRefused = 0x000003ea,
|
||||
NetworkModuleInterrupted = 0x000003eb,
|
||||
NetworkModuleConnectionAborted = 0x000003ec,
|
||||
NetworkModuleConnectionReset = 0x000003ed,
|
||||
NetworkModuleBadAddress = 0x000003ee,
|
||||
NetworkModuleNotReady = 0x000003ef,
|
||||
NetworkModuleAlreadyConnected = 0x000003f0,
|
||||
NetworkModuleCantCreateSocket = 0x000003f1,
|
||||
NetworkModuleNetworkUnreachable = 0x000003f2,
|
||||
NetworkModuleSocketPermissionDenied = 0x000003f3,
|
||||
NetworkModuleNotInitialized = 0x000003f4,
|
||||
NetworkModuleNoSslCertificateForPeer = 0x000003f5,
|
||||
NetworkModuleNoSslCommonNameForCertificate = 0x000003f6,
|
||||
NetworkModuleSslCommonNameDoesNotMatchRemoteEndpoint = 0x000003f7,
|
||||
NetworkModuleSocketClosed = 0x000003f8,
|
||||
NetworkModuleSslPeerIsNotRegisteredInCertbundle = 0x000003f9,
|
||||
NetworkModuleSslInitializeLowFirst = 0x000003fa,
|
||||
NetworkModuleSslCertBundleReadError = 0x000003fb,
|
||||
NetworkModuleNoCertBundle = 0x000003fc,
|
||||
NetworkModuleFailedToDownloadCertBundle = 0x000003fd,
|
||||
NetworkModuleNotReadyToRead = 0x000003fe,
|
||||
|
||||
NetworkModuleOpensslX509Ok = 0x000004b0,
|
||||
NetworkModuleOpensslX509UnableToGetIssuerCert = 0x000004b1,
|
||||
NetworkModuleOpensslX509UnableToGetCrl = 0x000004b2,
|
||||
NetworkModuleOpensslX509UnableToDecryptCertSignature = 0x000004b3,
|
||||
NetworkModuleOpensslX509UnableToDecryptCrlSignature = 0x000004b4,
|
||||
NetworkModuleOpensslX509UnableToDecodeIssuerPublicKey = 0x000004b5,
|
||||
NetworkModuleOpensslX509CertSignatureFailure = 0x000004b6,
|
||||
NetworkModuleOpensslX509CrlSignatureFailure = 0x000004b7,
|
||||
NetworkModuleOpensslX509CertNotYetValid = 0x000004b8,
|
||||
NetworkModuleOpensslX509CertHasExpired = 0x000004b9,
|
||||
NetworkModuleOpensslX509CrlNotYetValid = 0x000004ba,
|
||||
NetworkModuleOpensslX509CrlHasExpired = 0x000004bb,
|
||||
NetworkModuleOpensslX509InCertNotBeforeField = 0x000004bc,
|
||||
NetworkModuleOpensslX509InCertNotAfterField = 0x000004bd,
|
||||
NetworkModuleOpensslX509InCrlLastUpdateField = 0x000004be,
|
||||
NetworkModuleOpensslX509InCrlNextUpdateField = 0x000004bf,
|
||||
NetworkModuleOpensslX509OutOfMem = 0x000004c0,
|
||||
NetworkModuleOpensslX509DepthZeroSelfSignedCert = 0x000004c1,
|
||||
NetworkModuleOpensslX509SelfSignedCertInChain = 0x000004c2,
|
||||
NetworkModuleOpensslX509UnableToGetIssuerCertLocally = 0x000004c3,
|
||||
NetworkModuleOpensslX509UnableToVerifyLeafSignature = 0x000004c4,
|
||||
NetworkModuleOpensslX509CertChainTooLong = 0x000004c5,
|
||||
NetworkModuleOpensslX509CertRevoked = 0x000004c6,
|
||||
NetworkModuleOpensslX509InvalidCa = 0x000004c7,
|
||||
NetworkModuleOpensslX509PathLengthExceeded = 0x000004c8,
|
||||
NetworkModuleOpensslX509InvalidPurpose = 0x000004c9,
|
||||
NetworkModuleOpensslX509CertUntrusted = 0x000004ca,
|
||||
NetworkModuleOpensslX509CertRejected = 0x000004cb,
|
||||
NetworkModuleOpensslX509SubjectIssuerMismatch = 0x000004cc,
|
||||
NetworkModuleOpensslX509AkidSkidMismatch = 0x000004cd,
|
||||
NetworkModuleOpensslX509AkidIssuerSerialMismatch = 0x000004ce,
|
||||
NetworkModuleOpensslX509KeyusageNoCertsign = 0x000004cf,
|
||||
NetworkModuleOpensslX509ApplicationVerification = 0x000004d0,
|
||||
|
||||
NetworkModuleSchannelCannotFindOsVersion = 0x00000514,
|
||||
NetworkModuleSchannelOsNotSupported = 0x00000515,
|
||||
NetworkModuleSchannelLoadlibraryFail = 0x00000516,
|
||||
NetworkModuleSchannelCannotFindInterface = 0x00000517,
|
||||
NetworkModuleSchannelInitFail = 0x00000518,
|
||||
NetworkModuleSchannelFunctionCallFail = 0x00000519,
|
||||
NetworkModuleSchannelX509UnableToGetIssuerCert = 0x00000546,
|
||||
NetworkModuleSchannelX509TimeInvalid = 0x00000547,
|
||||
NetworkModuleSchannelX509SignatureInvalid = 0x00000548,
|
||||
NetworkModuleSchannelX509UnableToVerifyLeafSignature = 0x00000549,
|
||||
NetworkModuleSchannelX509SelfSignedLeafCertificate = 0x0000054a,
|
||||
NetworkModuleSchannelX509UnhandledError = 0x0000054b,
|
||||
NetworkModuleSchannelX509SelfSignedCertInChain = 0x0000054c,
|
||||
|
||||
WebsocketHandshake = 0x00000578,
|
||||
|
||||
NetworkModuleDurangoUnknown = 0x000005dc,
|
||||
NetworkModuleDurangoMalformedHostName = 0x000005dd,
|
||||
NetworkModuleDurangoInvalidConnectionResponse = 0x000005de,
|
||||
NetworkModuleDurangoInvalidCaCert = 0x000005df,
|
||||
|
||||
RpcWriteFailed = 0x00000bb8,
|
||||
RpcServiceNotBound = 0x00000bb9,
|
||||
RpcTooManyRequests = 0x00000bba,
|
||||
RpcPeerUnknown = 0x00000bbb,
|
||||
RpcPeerUnavailable = 0x00000bbc,
|
||||
RpcPeerDisconnected = 0x00000bbd,
|
||||
RpcRequestTimedOut = 0x00000bbe,
|
||||
RpcConnectionTimedOut = 0x00000bbf,
|
||||
RpcMalformedResponse = 0x00000bc0,
|
||||
RpcAccessDenied = 0x00000bc1,
|
||||
RpcInvalidService = 0x00000bc2,
|
||||
RpcInvalidMethod = 0x00000bc3,
|
||||
RpcInvalidObject = 0x00000bc4,
|
||||
RpcMalformedRequest = 0x00000bc5,
|
||||
RpcQuotaExceeded = 0x00000bc6,
|
||||
RpcNotImplemented = 0x00000bc7,
|
||||
RpcServerError = 0x00000bc8,
|
||||
RpcShutdown = 0x00000bc9,
|
||||
RpcDisconnect = 0x00000bca,
|
||||
RpcDisconnectIdle = 0x00000bcb,
|
||||
RpcProtocolError = 0x00000bcc,
|
||||
RpcNotReady = 0x00000bcd,
|
||||
RpcForwardFailed = 0x00000bce,
|
||||
RpcEncryptionFailed = 0x00000bcf,
|
||||
RpcInvalidAddress = 0x00000bd0,
|
||||
RpcMethodDisabled = 0x00000bd1,
|
||||
RpcShardNotFound = 0x00000bd2,
|
||||
RpcInvalidConnectionId = 0x00000bd3,
|
||||
RpcNotConnected = 0x00000bd4,
|
||||
RpcInvalidConnectionState = 0x00000bd5,
|
||||
RpcServiceAlreadyRegistered = 0x00000bd6,
|
||||
|
||||
PresenceInvalidFieldId = 0x00000fa0,
|
||||
PresenceNoValidSubscribers = 0x00000fa1,
|
||||
PresenceAlreadySubscribed = 0x00000fa2,
|
||||
PresenceConsumerNotFound = 0x00000fa3,
|
||||
PresenceConsumerIsNull = 0x00000fa4,
|
||||
PresenceTemporaryOutage = 0x00000fa5,
|
||||
PresenceTooManySubscriptions = 0x00000fa6,
|
||||
PresenceSubscriptionCancelled = 0x00000fa7,
|
||||
PresenceRichPresenceParseError = 0x00000fa8,
|
||||
PresenceRichPresenceXmlError = 0x00000fa9,
|
||||
PresenceRichPresenceLoadError = 0x00000faa,
|
||||
|
||||
FriendsTooManySentInvitations = 0x00001389,
|
||||
FriendsTooManyReceivedInvitations = 0x0000138a,
|
||||
FriendsFriendshipAlreadyExists = 0x0000138b,
|
||||
FriendsFriendshipDoesNotExist = 0x0000138c,
|
||||
FriendsInvitationAlreadyExists = 0x0000138d,
|
||||
FriendsInvalidInvitation = 0x0000138e,
|
||||
FriendsAlreadySubscribed = 0x0000138f,
|
||||
FriendsAccountBlocked = 0x00001391,
|
||||
FriendsNotSubscribed = 0x00001392,
|
||||
FriendsInvalidRoleId = 0x00001393,
|
||||
FriendsDisabledRoleId = 0x00001394,
|
||||
FriendsNoteMaxSizeExceeded = 0x00001395,
|
||||
FriendsUpdateFriendStateFailed = 0x00001396,
|
||||
FriendsInviteeAtMaxFriends = 0x00001397,
|
||||
FriendsInviterAtMaxFriends = 0x00001398,
|
||||
|
||||
PlatformStorageFileWriteDenied = 0x00001770,
|
||||
|
||||
WhisperUndeliverable = 0x00001b58,
|
||||
WhisperMaxSizeExceeded = 0x00001b59,
|
||||
|
||||
UserManagerAlreadyBlocked = 0x00001f40,
|
||||
UserManagerNotBlocked = 0x00001f41,
|
||||
UserManagerCannotBlockSelf = 0x00001f42,
|
||||
UserManagerAlreadyRegistered = 0x00001f43,
|
||||
UserManagerNotRegistered = 0x00001f44,
|
||||
UserManagerTooManyBlockedEntities = 0x00001f45,
|
||||
UserManagerTooManyIds = 0x00001f47,
|
||||
UserManagerBlockRecordUnavailable = 0x00001f4f,
|
||||
UserManagerBlockEntityFailed = 0x00001f50,
|
||||
UserManagerUnblockEntityFailed = 0x00001f51,
|
||||
UserManagerCannotBlockFriend = 0x00001f53,
|
||||
|
||||
SocialNetworkDbException = 0x00002328,
|
||||
SocialNetworkDenialFromProvider = 0x00002329,
|
||||
SocialNetworkInvalidSnsId = 0x0000232a,
|
||||
SocialNetworkCantSendToProvider = 0x0000232b,
|
||||
SocialNetworkExCommFailed = 0x0000232c,
|
||||
SocialNetworkDisabled = 0x0000232d,
|
||||
SocialNetworkMissingRequestParam = 0x0000232e,
|
||||
SocialNetworkUnsupportedOauthVersion = 0x0000232f,
|
||||
|
||||
ChannelFull = 0x00002710,
|
||||
ChannelNoChannel = 0x00002711,
|
||||
ChannelNotMember = 0x00002712,
|
||||
ChannelAlreadyMember = 0x00002713,
|
||||
ChannelNoSuchMember = 0x00002714,
|
||||
ChannelInvalidChannelId = 0x00002716,
|
||||
ChannelNoSuchInvitation = 0x00002718,
|
||||
ChannelTooManyInvitations = 0x00002719,
|
||||
ChannelInvitationAlreadyExists = 0x0000271a,
|
||||
ChannelInvalidChannelSize = 0x0000271b,
|
||||
ChannelInvalidRoleId = 0x0000271c,
|
||||
ChannelRoleNotAssignable = 0x0000271d,
|
||||
ChannelInsufficientPrivileges = 0x0000271e,
|
||||
ChannelInsufficientPrivacyLevel = 0x0000271f,
|
||||
ChannelInvalidPrivacyLevel = 0x00002720,
|
||||
ChannelTooManyChannelsJoined = 0x00002721,
|
||||
ChannelInvitationAlreadySubscribed = 0x00002722,
|
||||
ChannelInvalidChannelDelegate = 0x00002723,
|
||||
ChannelSlotAlreadyReserved = 0x00002724,
|
||||
ChannelSlotNotReserved = 0x00002725,
|
||||
ChannelNoReservedSlotsAvailable = 0x00002726,
|
||||
ChannelInvalidRoleSet = 0x00002727,
|
||||
ChannelRequireFriendValidation = 0x00002728,
|
||||
ChannelMemberOffline = 0x00002729,
|
||||
ChannelReceivedTooManyInvitations = 0x0000272a,
|
||||
ChannelInvitationInvalidGameAccountSelected = 0x0000272b,
|
||||
ChannelUnreachable = 0x0000272c,
|
||||
ChannelInvitationNotSubscribed = 0x0000272d,
|
||||
ChannelInvalidMessageSize = 0x0000272e,
|
||||
ChannelMaxMessageSizeExceeded = 0x0000272f,
|
||||
ChannelConfigNotFound = 0x00002730,
|
||||
ChannelInvalidChannelType = 0x00002731,
|
||||
|
||||
LocalStorageFileOpenError = 0x00002af8,
|
||||
LocalStorageFileCreateError = 0x00002af9,
|
||||
LocalStorageFileReadError = 0x00002afa,
|
||||
LocalStorageFileWriteError = 0x00002afb,
|
||||
LocalStorageFileDeleteError = 0x00002afc,
|
||||
LocalStorageFileCopyError = 0x00002afd,
|
||||
LocalStorageFileDecompressError = 0x00002afe,
|
||||
LocalStorageFileHashMismatch = 0x00002aff,
|
||||
LocalStorageFileUsageMismatch = 0x00002b00,
|
||||
LocalStorageDatabaseInitError = 0x00002b01,
|
||||
LocalStorageDatabaseNeedsRebuild = 0x00002b02,
|
||||
LocalStorageDatabaseInsertError = 0x00002b03,
|
||||
LocalStorageDatabaseLookupError = 0x00002b04,
|
||||
LocalStorageDatabaseUpdateError = 0x00002b05,
|
||||
LocalStorageDatabaseDeleteError = 0x00002b06,
|
||||
LocalStorageDatabaseShrinkError = 0x00002b07,
|
||||
LocalStorageCacheCrawlError = 0x00002b08,
|
||||
LocalStorageDatabaseIndexTriggerError = 0x00002b09,
|
||||
LocalStorageDatabaseRebuildInProgress = 0x00002b0a,
|
||||
LocalStorageOkButNotInCache = 0x00002b0b,
|
||||
LocalStorageDatabaseRebuildInterrupted = 0x00002b0d,
|
||||
LocalStorageDatabaseNotInitialized = 0x00002b0e,
|
||||
LocalStorageDirectoryCreateError = 0x00002b0f,
|
||||
LocalStorageFilekeyNotFound = 0x00002b10,
|
||||
LocalStorageNotAvailableOnServer = 0x00002b11,
|
||||
|
||||
RegistryCreateKeyError = 0x00002ee0,
|
||||
RegistryOpenKeyError = 0x00002ee1,
|
||||
RegistryReadError = 0x00002ee2,
|
||||
RegistryWriteError = 0x00002ee3,
|
||||
RegistryTypeError = 0x00002ee4,
|
||||
RegistryDeleteError = 0x00002ee5,
|
||||
RegistryEncryptError = 0x00002ee6,
|
||||
RegistryDecryptError = 0x00002ee7,
|
||||
RegistryKeySizeError = 0x00002ee8,
|
||||
RegistryValueSizeError = 0x00002ee9,
|
||||
RegistryNotFound = 0x00002eeb,
|
||||
RegistryMalformedString = 0x00002eec,
|
||||
|
||||
InterfaceAlreadyConnected = 0x000032c8,
|
||||
InterfaceNotReady = 0x000032c9,
|
||||
InterfaceOptionKeyTooLarge = 0x000032ca,
|
||||
InterfaceOptionValueTooLarge = 0x000032cb,
|
||||
InterfaceOptionKeyInvalidUtf8String = 0x000032cc,
|
||||
InterfaceOptionValueInvalidUtf8String = 0x000032cd,
|
||||
|
||||
HttpCouldntResolve = 0x000036b0,
|
||||
HttpCouldntConnect = 0x000036b1,
|
||||
HttpTimeout = 0x000036b2,
|
||||
HttpFailed = 0x000036b3,
|
||||
HttpMalformedUrl = 0x000036b4,
|
||||
HttpDownloadAborted = 0x000036b5,
|
||||
HttpCouldntWriteFile = 0x000036b6,
|
||||
HttpTooManyRedirects = 0x000036b7,
|
||||
HttpCouldntOpenFile = 0x000036b8,
|
||||
HttpCouldntCreateFile = 0x000036b9,
|
||||
HttpCouldntReadFile = 0x000036ba,
|
||||
HttpCouldntRenameFile = 0x000036bb,
|
||||
HttpCouldntCreateDirectory = 0x000036bc,
|
||||
HttpCurlIsNotReady = 0x000036bd,
|
||||
HttpCancelled = 0x000036be,
|
||||
|
||||
HttpFileNotFound = 0x00003844,
|
||||
|
||||
AccountMissingConfig = 0x00004650,
|
||||
AccountDataNotFound = 0x00004651,
|
||||
AccountAlreadySubscribed = 0x00004652,
|
||||
AccountNotSubscribed = 0x00004653,
|
||||
AccountFailedToParseTimezoneData = 0x00004654,
|
||||
AccountLoadFailed = 0x00004655,
|
||||
AccountLoadCancelled = 0x00004656,
|
||||
AccountDatabaseInvalidateFailed = 0x00004657,
|
||||
AccountCacheInvalidateFailed = 0x00004658,
|
||||
AccountSubscriptionPending = 0x00004659,
|
||||
AccountUnknownRegion = 0x0000465a,
|
||||
AccountDataFailedToParse = 0x0000465b,
|
||||
AccountUnderage = 0x0000465c,
|
||||
AccountIdentityCheckPending = 0x0000465d,
|
||||
AccountIdentityUnverified = 0x0000465e,
|
||||
|
||||
DatabaseBindingCountMismatch = 0x00004a38,
|
||||
DatabaseBindingParseFail = 0x00004a39,
|
||||
DatabaseResultsetColumnsMismatch = 0x00004a3a,
|
||||
DatabaseDeadlock = 0x00004a3b,
|
||||
DatabaseDuplicateKey = 0x00004a3c,
|
||||
DatabaseCannotConnect = 0x00004a3d,
|
||||
DatabaseStatementFailed = 0x00004a3e,
|
||||
DatabaseTransactionNotStarted = 0x00004a3f,
|
||||
DatabaseTransactionNotEnded = 0x00004a40,
|
||||
DatabaseTransactionLeak = 0x00004a41,
|
||||
DatabaseTransactionStateBad = 0x00004a42,
|
||||
DatabaseServerGone = 0x00004a43,
|
||||
DatabaseQueryTimeout = 0x00004a44,
|
||||
DatabaseBindingNotNullable = 0x00004a9c,
|
||||
DatabaseBindingInvalidInteger = 0x00004a9d,
|
||||
DatabaseBindingInvalidFloat = 0x00004a9e,
|
||||
DatabaseBindingInvalidTemporal = 0x00004a9f,
|
||||
DatabaseBindingInvalidProtobuf = 0x00004aa0,
|
||||
|
||||
PartyInvalidPartyId = 0x00004e20,
|
||||
PartyAlreadyInParty = 0x00004e21,
|
||||
PartyNotInParty = 0x00004e22,
|
||||
PartyInvitationUndeliverable = 0x00004e23,
|
||||
PartyInvitationAlreadyExists = 0x00004e24,
|
||||
PartyTooManyPartyInvitations = 0x00004e25,
|
||||
PartyTooManyReceivedInvitations = 0x00004e26,
|
||||
PartyNoSuchType = 0x00004e27,
|
||||
|
||||
GamesNoSuchFactory = 0x000055f0,
|
||||
GamesNoSuchGame = 0x000055f1,
|
||||
GamesNoSuchRequest = 0x000055f2,
|
||||
GamesNoSuchPartyMember = 0x000055f3,
|
||||
|
||||
ResourcesOffline = 0x000059d8,
|
||||
|
||||
GameServerCreateGameRefused = 0x00005dc0,
|
||||
GameServerAddPlayersRefused = 0x00005dc1,
|
||||
GameServerRemovePlayersRefused = 0x00005dc2,
|
||||
GameServerFinishGameRefused = 0x00005dc3,
|
||||
GameServerNoSuchGame = 0x00005dc4,
|
||||
GameServerNoSuchPlayer = 0x00005dc5,
|
||||
GameServerCreateGameRefusedTransient = 0x00005df2,
|
||||
GameServerAddPlayersRefusedTransient = 0x00005df3,
|
||||
GameServerRemovePlayersRefusedTransient = 0x00005df4,
|
||||
GameServerFinishGameRefusedTransient = 0x00005df5,
|
||||
GameServerCreateGameRefusedBusy = 0x00005e24,
|
||||
GameServerAddPlayersRefusedBusy = 0x00005e25,
|
||||
GameServerRemovePlayersRefusedBusy = 0x00005e26,
|
||||
GameServerFinishGameRefusedBusy = 0x00005e27,
|
||||
|
||||
GameMasterInvalidFactory = 0x000061a8,
|
||||
GameMasterInvalidGame = 0x000061a9,
|
||||
GameMasterGameFull = 0x000061aa,
|
||||
GameMasterRegisterFailed = 0x000061ab,
|
||||
GameMasterNoGameServer = 0x000061ac,
|
||||
GameMasterNoUtilityServer = 0x000061ad,
|
||||
GameMasterNoGameVersion = 0x000061ae,
|
||||
GameMasterGameJoinFailed = 0x000061af,
|
||||
GameMasterAlreadyRegistered = 0x000061b0,
|
||||
GameMasterNoFactory = 0x000061b1,
|
||||
GameMasterMultipleGameVersions = 0x000061b2,
|
||||
GameMasterInvalidPlayer = 0x000061b3,
|
||||
GameMasterInvalidGameRequest = 0x000061b4,
|
||||
GameMasterInsufficientPrivileges = 0x000061b5,
|
||||
GameMasterAlreadyInGame = 0x000061b6,
|
||||
GameMasterInvalidGameServerResponse = 0x000061b7,
|
||||
GameMasterGameAccountLookupFailed = 0x000061b8,
|
||||
GameMasterGameEntryCancelled = 0x000061b9,
|
||||
GameMasterGameEntryAbortedClientDropped = 0x000061ba,
|
||||
GameMasterGameEntryAbortedByService = 0x000061bb,
|
||||
GameMasterNoAvailableCapacity = 0x000061bc,
|
||||
GameMasterInvalidTeamId = 0x000061bd,
|
||||
GameMasterCreationInProgress = 0x000061be,
|
||||
|
||||
NotificationInvalidClientId = 0x00006590,
|
||||
NotificationDuplicateName = 0x00006591,
|
||||
NotificationNameNotFound = 0x00006592,
|
||||
NotificationInvalidServer = 0x00006593,
|
||||
NotificationQuotaExceeded = 0x00006594,
|
||||
NotificationInvalidNotificationType = 0x00006595,
|
||||
NotificationUndeliverable = 0x00006596,
|
||||
NotificationUndeliverableTemporary = 0x00006597,
|
||||
|
||||
AchievementsNothingToUpdate = 0x00006d60,
|
||||
AchievementsInvalidParams = 0x00006d61,
|
||||
AchievementsNotRegistered = 0x00006d62,
|
||||
AchievementsNotReady = 0x00006d63,
|
||||
AchievementsFailedToParseStaticData = 0x00006d64,
|
||||
AchievementsUnknownId = 0x00006d65,
|
||||
AchievementsMissingSnapshot = 0x00006d66,
|
||||
AchievementsAlreadyRegistered = 0x00006d67,
|
||||
AchievementsTooManyRegistrations = 0x00006d68,
|
||||
AchievementsAlreadyInProgress = 0x00006d69,
|
||||
AchievementsTemporaryOutage = 0x00006d6a,
|
||||
AchievementsInvalidProgramid = 0x00006d6b,
|
||||
AchievementsMissingRecord = 0x00006d6c,
|
||||
AchievementsRegistrationPending = 0x00006d6d,
|
||||
AchievementsEntityIdNotFound = 0x00006d6e,
|
||||
AchievementsAchievementIdNotFound = 0x00006d6f,
|
||||
AchievementsCriteriaIdNotFound = 0x00006d70,
|
||||
AchievementsStaticDataMismatch = 0x00006d71,
|
||||
AchievementsWrongThread = 0x00006d72,
|
||||
AchievementsCallbackIsNull = 0x00006d73,
|
||||
AchievementsAutoRegisterPending = 0x00006d74,
|
||||
AchievementsNotInitialized = 0x00006d75,
|
||||
AchievementsAchievementIdAlreadyExists = 0x00006d76,
|
||||
AchievementsFailedToDownloadStaticData = 0x00006d77,
|
||||
AchievementsStaticDataNotFound = 0x00006d78,
|
||||
|
||||
GameUtilityServerVariableRequestRefused = 0x000084d1,
|
||||
GameUtilityServerWrongNumberOfVariablesReturned = 0x000084d2,
|
||||
GameUtilityServerClientRequestRefused = 0x000084d3,
|
||||
GameUtilityServerPresenceChannelCreatedRefused = 0x000084d4,
|
||||
GameUtilityServerVariableRequestRefusedTransient = 0x00008502,
|
||||
GameUtilityServerClientRequestRefusedTransient = 0x00008503,
|
||||
GameUtilityServerPresenceChannelCreatedRefusedTransient = 0x00008504,
|
||||
GameUtilityServerServerRequestRefusedTransient = 0x00008505,
|
||||
GameUtilityServerVariableRequestRefusedBusy = 0x00008534,
|
||||
GameUtilityServerClientRequestRefusedBusy = 0x00008535,
|
||||
GameUtilityServerPresenceChannelCreatedRefusedBusy = 0x00008536,
|
||||
GameUtilityServerServerRequestRefusedBusy = 0x00008537,
|
||||
GameUtilityServerNoServer = 0x00008598,
|
||||
|
||||
IdentityInsufficientData = 0x0000a028,
|
||||
IdentityTooManyResults = 0x0000a029,
|
||||
IdentityBadId = 0x0000a02a,
|
||||
IdentityNoAccountBlob = 0x0000a02b,
|
||||
|
||||
RiskChallengeAction = 0x0000a410,
|
||||
RiskDelayAction = 0x0000a411,
|
||||
RiskThrottleAction = 0x0000a412,
|
||||
RiskAccountLocked = 0x0000a413,
|
||||
RiskCsDenied = 0x0000a414,
|
||||
RiskDisconnectAccount = 0x0000a415,
|
||||
RiskCheckSkipped = 0x0000a416,
|
||||
|
||||
ReportUnavailable = 0x0000afc8,
|
||||
ReportTooLarge = 0x0000afc9,
|
||||
ReportUnknownType = 0x0000afca,
|
||||
ReportAttributeInvalid = 0x0000afcb,
|
||||
ReportAttributeQuotaExceeded = 0x0000afcc,
|
||||
ReportUnconfirmed = 0x0000afcd,
|
||||
ReportNotConnected = 0x0000afce,
|
||||
ReportRejected = 0x0000afcf,
|
||||
ReportTooManyRequests = 0x0000afd0,
|
||||
|
||||
AccountAlreadyRegisterd = 0x0000bb80,
|
||||
AccountNotRegistered = 0x0000bb81,
|
||||
AccountRegistrationPending = 0x0000bb82,
|
||||
|
||||
MemcachedClientNoError = 0x00010000,
|
||||
MemcachedClientKeyNotFound = 0x00010001,
|
||||
MemcachedKeyExists = 0x00010002,
|
||||
MemcachedValueToLarge = 0x00010003,
|
||||
MemcachedInvalidArgs = 0x00010004,
|
||||
MemcachedItemNotStored = 0x00010005,
|
||||
MemcachedNonNumericValue = 0x00010006,
|
||||
MemcachedWrongServer = 0x00010007,
|
||||
MemcachedAuthenticationError = 0x00010008,
|
||||
MemcachedAuthenticationContinue = 0x00010009,
|
||||
MemcachedUnknownCommand = 0x0001000a,
|
||||
MemcachedOutOfMemory = 0x0001000b,
|
||||
MemcachedNotSupported = 0x0001000c,
|
||||
MemcachedInternalError = 0x0001000d,
|
||||
MemcachedTemporaryFailure = 0x0001000e,
|
||||
|
||||
MemcachedClientAlreadyConnected = 0x000186a0,
|
||||
MemcachedClientBadConfig = 0x000186a1,
|
||||
MemcachedClientNotConnected = 0x000186a2,
|
||||
MemcachedClientTimeout = 0x000186a3,
|
||||
MemcachedClientAborted = 0x000186a4,
|
||||
|
||||
UtilServerFailedToSerialize = 0x80000064,
|
||||
UtilServerDisconnectedFromBattlenet = 0x80000065,
|
||||
UtilServerTimedOut = 0x80000066,
|
||||
UtilServerNoMeteringData = 0x80000067,
|
||||
UtilServerFailPermissionCheck = 0x80000068,
|
||||
UtilServerUnknownRealm = 0x80000069,
|
||||
UtilServerMissingSessionKey = 0x8000006a,
|
||||
UtilServerMissingVirtualRealm = 0x8000006b,
|
||||
UtilServerInvalidSessionKey = 0x8000006c,
|
||||
UtilServerMissingRealmList = 0x8000006d,
|
||||
UtilServerInvalidIdentityArgs = 0x8000006e,
|
||||
UtilServerSessionObjectMissing = 0x8000006f,
|
||||
UtilServerInvalidBnetSession = 0x80000070,
|
||||
UtilServerInvalidVirtualRealm = 0x80000071,
|
||||
UtilServerInvalidClientAddress = 0x80000072,
|
||||
UtilServerFailedToSerializeResponse = 0x80000073,
|
||||
UtilServerUnknownRequest = 0x80000074,
|
||||
UtilServerUnableToGenerateJoinTicket = 0x80000075,
|
||||
UtilServerUnableToGenerateRealmListTicket = 0x80000076,
|
||||
UtilServerAccountDenied = 0x80000077,
|
||||
UtilServerInvalidWowAccount = 0x80000078,
|
||||
UtilServerUnableToStoreSession = 0x80000079,
|
||||
UtilServerSessionAlreadyCreated = 0x8000007a,
|
||||
|
||||
UserServerFailedToSerialize = 0x800000c8,
|
||||
UserServerDisconnectedFromUtil = 0x800000c9,
|
||||
UserServerSessionDuplicate = 0x800000ca,
|
||||
UserServerFailedToDisableBilling = 0x800000cb,
|
||||
UserServerPlayerDisconnected = 0x800000cc,
|
||||
UserServerFailedToParseAccountState = 0x800000cd,
|
||||
UserServerAccountLoadCancelled = 0x800000ce,
|
||||
UserServerBadPlatform = 0x800000cf,
|
||||
UserServerBadVirtualRealm = 0x800000d0,
|
||||
UserServerLocaleRestricted = 0x800000d1,
|
||||
UserServerMissingPropass = 0x800000d2,
|
||||
UserServerBadWowAccount = 0x800000d3,
|
||||
UserServerBadBnetAccount = 0x800000d4,
|
||||
UserServerFailedToParseGameAccountState = 0x800000d5,
|
||||
UserServerFailedToParseGameTimeRemaining = 0x800000d6,
|
||||
UserServerFailedToParseGameSessionInfo = 0x800000d7,
|
||||
UserServerAccountStatePoorlyFormed = 0x800000d8,
|
||||
UserServerGameAccountStatePoorlyFormed = 0x800000d9,
|
||||
UserServerGameTimeRemainingPoorlyFormed = 0x800000da,
|
||||
UserServerGameSessionInfoPoorlyFormed = 0x800000db,
|
||||
UserServerBadSessionTrackerState = 0x800000dc,
|
||||
UserServerFailedToParseCaisInfo = 0x800000dd,
|
||||
UserServerGameSessionDisconnected = 0x800000de,
|
||||
UserServerVersionMismatch = 0x800000df,
|
||||
UserServerAccountSuspended = 0x800000e0,
|
||||
UserServerNotPermittedOnRealm = 0x800000e1,
|
||||
UserServerLoginFailedConnect = 0x800000e2,
|
||||
|
||||
WowServicesTimedOut = 0x8000012c,
|
||||
WowServicesInvalidRealmListTicket = 0x8000012d,
|
||||
WowServicesInvalidJoinTicket = 0x8000012e,
|
||||
WowServicesInvalidServerAddresses = 0x8000012f,
|
||||
WowServicesInvalidSecretBlob = 0x80000130,
|
||||
WowServicesNoRealmJoinIpFound = 0x80000131,
|
||||
WowServicesDeniedRealmListTicket = 0x80000132,
|
||||
WowServicesMissingGameAccount = 0x80000133,
|
||||
WowServicesLogonInvalidAuthToken = 0x80000134,
|
||||
WowServicesNoAvailableRealms = 0x80000135,
|
||||
WowServicesFailedToParseDispatch = 0x80000136,
|
||||
WowServicesMissingMeteringFile = 0x80000137,
|
||||
WowServicesLoginInvalidContentType = 0x80000138,
|
||||
WowServicesLoginUnableToDecode = 0x80000139,
|
||||
WowServicesLoginPostError = 0x8000013a,
|
||||
WowServicesAuthenticatorParseFailed = 0x8000013b,
|
||||
WowServicesLegalParseFailed = 0x8000013c,
|
||||
WowServicesLoginAuthenticationParseFailed = 0x8000013d,
|
||||
WowSerivcesUserMustAcceptLegal = 0x8000013e,
|
||||
WowServicesDisconnected = 0x8000013f,
|
||||
WowServicesNoHandlerForDispatch = 0x80000140,
|
||||
WowServicesPreDispatchHandlerFailed = 0x80000141,
|
||||
WowServicesCriticalStreamingError = 0x80000142,
|
||||
WowServicesWorldLoadError = 0x80000143,
|
||||
WowServicesLoginFailed = 0x80000144,
|
||||
WowServicesLoginFailedOnChallenge = 0x80000145,
|
||||
WowServicesNoPrepaidTime = 0x80000146,
|
||||
WowServicesSubscriptionExpired = 0x80000147,
|
||||
WowServicesCantConnect = 0x80000148,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
[Flags]
|
||||
public enum RealmFlags
|
||||
{
|
||||
None = 0x00,
|
||||
VersionMismatch = 0x01,
|
||||
Offline = 0x02,
|
||||
SpecifyBuild = 0x04,
|
||||
Unk1 = 0x08,
|
||||
Unk2 = 0x10,
|
||||
Recommended = 0x20,
|
||||
New = 0x40,
|
||||
Full = 0x80
|
||||
}
|
||||
|
||||
public enum RealmType
|
||||
{
|
||||
Normal = 0,
|
||||
PVP = 1,
|
||||
Normal2 = 4,
|
||||
RP = 6,
|
||||
RPPVP = 8,
|
||||
|
||||
MaxType = 14,
|
||||
|
||||
FFAPVP = 16 // custom, free for all pvp mode like arena PvP in all zones except rest activated places and sanctuaries
|
||||
// replaced by REALM_PVP in realm list
|
||||
}
|
||||
|
||||
public enum RealmZones
|
||||
{
|
||||
Unknown = 0, // Any Language
|
||||
Development = 1, // Any Language
|
||||
UnitedStates = 2, // Extended-Latin
|
||||
Oceanic = 3, // Extended-Latin
|
||||
LatinAmerica = 4, // Extended-Latin
|
||||
Tournament5 = 5, // Basic-Latin At Create, Any At Login
|
||||
Korea = 6, // East-Asian
|
||||
Tournament7 = 7, // Basic-Latin At Create, Any At Login
|
||||
English = 8, // Extended-Latin
|
||||
German = 9, // Extended-Latin
|
||||
French = 10, // Extended-Latin
|
||||
Spanish = 11, // Extended-Latin
|
||||
Russian = 12, // Cyrillic
|
||||
Tournament13 = 13, // Basic-Latin At Create, Any At Login
|
||||
Taiwan = 14, // East-Asian
|
||||
Tournament15 = 15, // Basic-Latin At Create, Any At Login
|
||||
China = 16, // East-Asian
|
||||
Cn1 = 17, // Basic-Latin At Create, Any At Login
|
||||
Cn2 = 18, // Basic-Latin At Create, Any At Login
|
||||
Cn3 = 19, // Basic-Latin At Create, Any At Login
|
||||
Cn4 = 20, // Basic-Latin At Create, Any At Login
|
||||
Cn5 = 21, // Basic-Latin At Create, Any At Login
|
||||
Cn6 = 22, // Basic-Latin At Create, Any At Login
|
||||
Cn7 = 23, // Basic-Latin At Create, Any At Login
|
||||
Cn8 = 24, // Basic-Latin At Create, Any At Login
|
||||
Tournament25 = 25, // Basic-Latin At Create, Any At Login
|
||||
TestServer = 26, // Any Language
|
||||
Tournament27 = 27, // Basic-Latin At Create, Any At Login
|
||||
QaServer = 28, // Any Language
|
||||
Cn9 = 29, // Basic-Latin At Create, Any At Login
|
||||
TestServer2 = 30, // Any Language
|
||||
Cn10 = 31, // Basic-Latin At Create, Any At Login
|
||||
Ctc = 32,
|
||||
Cnc = 33,
|
||||
Cn14 = 34, // Basic-Latin At Create, Any At Login
|
||||
Cn269 = 35, // Basic-Latin At Create, Any At Login
|
||||
Cn37 = 36, // Basic-Latin At Create, Any At Login
|
||||
Cn58 = 37 // Basic-Latin At Create, Any At Login
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public struct BattlefieldSounds
|
||||
{
|
||||
public const uint HordeWins = 8454;
|
||||
public const uint AllianceWins = 8455;
|
||||
public const uint Start = 3439;
|
||||
}
|
||||
|
||||
public enum BattleFieldObjectiveStates
|
||||
{
|
||||
Neutral = 0,
|
||||
Alliance,
|
||||
Horde,
|
||||
NeutralAllianceChallenge,
|
||||
NeutralHordeChallenge,
|
||||
AllianceHordeChallenge,
|
||||
HordeAllianceChallenge
|
||||
}
|
||||
|
||||
public enum BFLeaveReason
|
||||
{
|
||||
Close = 1,
|
||||
//BF_LEAVE_REASON_UNK1 = 2, (not used)
|
||||
//BF_LEAVE_REASON_UNK2 = 4, (not used)
|
||||
Exited = 8,
|
||||
LowLevel = 10,
|
||||
NotWhileInRaid = 15,
|
||||
Deserter = 16
|
||||
}
|
||||
|
||||
public enum BattlefieldState
|
||||
{
|
||||
Inactive = 0,
|
||||
Warnup = 1,
|
||||
InProgress = 2
|
||||
}
|
||||
|
||||
public struct BattlefieldIds
|
||||
{
|
||||
public const uint WG = 1; // Wintergrasp battle
|
||||
public const uint TB = 21; // Tol Barad
|
||||
public const uint Ashran = 24; // Ashran
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public struct BattlegroundConst
|
||||
{
|
||||
//Time Intervals
|
||||
public const uint CheckPlayerPositionInverval = 1000; // Ms
|
||||
public const uint ResurrectionInterval = 30000; // Ms
|
||||
//RemindInterval = 10000, // Ms
|
||||
public const uint InvitationRemindTime = 20000; // Ms
|
||||
public const uint InviteAcceptWaitTime = 90000; // Ms
|
||||
public const uint AutocloseBattleground = 120000; // Ms
|
||||
public const uint MaxOfflineTime = 300; // Secs
|
||||
public const uint RespawnOneDay = 86400; // Secs
|
||||
public const uint RespawnImmediately = 0; // Secs
|
||||
public const uint BuffRespawnTime = 180; // Secs
|
||||
public const uint BattlegroundCountdownMax = 120; // Secs
|
||||
public const uint ArenaCountdownMax = 60; // Secs
|
||||
public const uint PlayerPositionUpdateInterval = 5; // secs
|
||||
|
||||
//EventIds
|
||||
public const int EventIdFirst = 0;
|
||||
public const int EventIdSecond = 1;
|
||||
public const int EventIdThird = 2;
|
||||
public const int EventIdFourth = 3;
|
||||
public const int EventIdCount = 4;
|
||||
|
||||
//Quests
|
||||
public const uint WsQuestReward = 43483;
|
||||
public const uint AbQuestReward = 43484;
|
||||
public const uint AvQuestReward = 43475;
|
||||
public const uint AvQuestKilledBoss = 23658;
|
||||
public const uint EyQuestReward = 43477;
|
||||
public const uint SaQuestReward = 61213;
|
||||
public const uint AbQuestReward4Bases = 24061;
|
||||
public const uint AbQuestReward5Bases = 24064;
|
||||
|
||||
//BuffObjects
|
||||
public const uint SpeedBuff = 179871;
|
||||
public const uint RegenBuff = 179904;
|
||||
public const uint BerserkerBuff = 179905;
|
||||
|
||||
//QueueGroupTypes
|
||||
public const uint BgQueuePremadeAlliance = 0;
|
||||
public const uint BgQueuePremadeHorde = 1;
|
||||
public const uint BgQueueNormalAlliance = 2;
|
||||
public const uint BgQueueNormalHorde = 3;
|
||||
public const int BgQueueTypesCount = 4;
|
||||
|
||||
//PlayerPosition
|
||||
public const sbyte PlayerPositionIconNone = 0;
|
||||
public const sbyte PlayerPositionIconHordeFlag = 1;
|
||||
public const sbyte PlayerPositionIconAllianceFlag = 2;
|
||||
|
||||
public const sbyte PlayerPositionArenaSlotNone = 1;
|
||||
public const sbyte PlayerPositionArenaSlot1 = 2;
|
||||
public const sbyte PlayerPositionArenaSlot2 = 3;
|
||||
public const sbyte PlayerPositionArenaSlot3 = 4;
|
||||
public const sbyte PlayerPositionArenaSlot4 = 5;
|
||||
public const sbyte PlayerPositionArenaSlot5 = 6;
|
||||
|
||||
//Spells
|
||||
public const uint SpellWaitingForResurrect = 2584; // Waiting To Resurrect
|
||||
public const uint SpellSpiritHealChannel = 22011; // Spirit Heal Channel
|
||||
public const uint SpellSpiritHeal = 22012; // Spirit Heal
|
||||
public const uint SpellResurrectionVisual = 24171; // Resurrection Impact Visual
|
||||
public const uint SpellArenaPreparation = 32727; // Use This One, 32728 Not Correct
|
||||
public const uint SpellPreparation = 44521; // Preparation
|
||||
public const uint SpellSpiritHealMana = 44535; // Spirit Heal
|
||||
public const uint SpellRecentlyDroppedFlag = 42792; // Recently Dropped Flag
|
||||
public const uint SpellAuraPlayerInactive = 43681; // Inactive
|
||||
public const uint SpellHonorableDefender25y = 68652; // +50% Honor When Standing At A Capture Point That You Control, 25yards Radius (Added In 3.2)
|
||||
public const uint SpellHonorableDefender60y = 66157; // +50% Honor When Standing At A Capture Point That You Control, 60yards Radius (Added In 3.2), Probably For 40+ Player Battlegrounds
|
||||
}
|
||||
|
||||
public enum BattlegroundEventFlags
|
||||
{
|
||||
None = 0x00,
|
||||
Event1 = 0x01,
|
||||
Event2 = 0x02,
|
||||
Event3 = 0x04,
|
||||
Event4 = 0x08
|
||||
}
|
||||
|
||||
// indexes of BattlemasterList.dbc
|
||||
public enum BattlegroundTypeId
|
||||
{
|
||||
None = 0, // None
|
||||
AV = 1, // Alterac Valley
|
||||
WS = 2, // Warsong Gulch
|
||||
AB = 3, // Arathi Basin
|
||||
NA = 4, // Nagrand Arena
|
||||
BE = 5, // Blade'S Edge Arena
|
||||
AA = 6, // All Arenas
|
||||
EY = 7, // Eye Of The Storm
|
||||
RL = 8, // Ruins Of Lordaernon
|
||||
SA = 9, // Strand Of The Ancients
|
||||
DS = 10, // Dalaran Sewers
|
||||
RV = 11, // The Ring Of Valor
|
||||
IC = 30, // Isle Of Conquest
|
||||
RB = 32, // Random Battleground
|
||||
Rated10Vs10 = 100, // Rated Battleground 10 Vs 10
|
||||
Rated15Vs15 = 101, // Rated Battleground 15 Vs 15
|
||||
Rated25Vs25 = 102, // Rated Battleground 25 Vs 25
|
||||
TP = 108, // Twin Peaks
|
||||
BFG = 120, // Battle For Gilneas
|
||||
// 656 = "Rated Eye Of The Storm"
|
||||
Tk = 699, // Temple Of Kotmogu
|
||||
// 706 = "Ctf3"
|
||||
SM = 708, // Silvershard Mines
|
||||
TVA = 719, // Tol'Viron Arena
|
||||
DG = 754, // Deepwind Gorge
|
||||
TTP = 757, // The Tiger'S Peak
|
||||
SSvsTM = 789, // Southshore Vs. Tarren Mill
|
||||
SmallD = 803, // Small Battleground D
|
||||
BRH = 808, // Black Rook Hold Arena
|
||||
// 809 = "New Nagrand Arena (Legion)"
|
||||
AF = 816, // Ashamane'S Fall
|
||||
// 844 = "New Blade'S Edge Arena (Legion)"
|
||||
Max = 845
|
||||
}
|
||||
|
||||
public enum BattlegroundQueueTypeId
|
||||
{
|
||||
None = 0,
|
||||
AV = 1,
|
||||
WS = 2,
|
||||
AB = 3,
|
||||
EY = 4,
|
||||
SA = 5,
|
||||
IC = 6,
|
||||
TP = 7,
|
||||
BFG = 8,
|
||||
RB = 9,
|
||||
Arena2v2 = 10,
|
||||
Arena3v3 = 11,
|
||||
Arena5v5 = 12,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum BattlegroundQueueInvitationType
|
||||
{
|
||||
NoBalance = 0, // no balance: N+M vs N players
|
||||
Balanced = 1, // teams balanced: N+1 vs N players
|
||||
Even = 2 // teams even: N vs N players
|
||||
}
|
||||
|
||||
public enum BattlegroundCriteriaId
|
||||
{
|
||||
ResilientVictory,
|
||||
SaveTheDay,
|
||||
EverythingCounts,
|
||||
AvPerfection,
|
||||
DefenseOfTheAncients,
|
||||
NotEvenAScratch,
|
||||
}
|
||||
|
||||
public enum BattlegroundSounds
|
||||
{
|
||||
HordeWins = 8454,
|
||||
AllianceWins = 8455,
|
||||
BgStart = 3439,
|
||||
BgStartL70etc = 11803
|
||||
}
|
||||
|
||||
public enum BattlegroundTeamId
|
||||
{
|
||||
Horde = 0, // Battleground: Horde, Arena: Green
|
||||
Alliance = 1, // Battleground: Alliance, Arena: Gold
|
||||
Neutral = 2 // Battleground: Neutral, Arena: None
|
||||
}
|
||||
|
||||
public enum BattlegroundMarks
|
||||
{
|
||||
SpellWsMarkLoser = 24950,
|
||||
SpellWsMarkWinner = 24951,
|
||||
SpellAbMarkLoser = 24952,
|
||||
SpellAbMarkWinner = 24953,
|
||||
SpellAvMarkLoser = 24954,
|
||||
SpellAvMarkWinner = 24955,
|
||||
SpellSaMarkWinner = 61160,
|
||||
SpellSaMarkLoser = 61159,
|
||||
ItemAvMarkOfHonor = 20560,
|
||||
ItemWsMarkOfHonor = 20558,
|
||||
ItemAbMarkOfHonor = 20559,
|
||||
ItemEyMarkOfHonor = 29024,
|
||||
ItemSaMarkOfHonor = 42425
|
||||
}
|
||||
|
||||
public enum BattlegroundMarksCount
|
||||
{
|
||||
WinnterCount = 3,
|
||||
LoserCount = 1
|
||||
}
|
||||
|
||||
public enum BattlegroundCreatures
|
||||
{
|
||||
A_SpiritGuide = 13116, // alliance
|
||||
H_SpiritGuide = 13117 // horde
|
||||
}
|
||||
|
||||
public enum BattlegroundStartTimeIntervals
|
||||
{
|
||||
Delay2m = 120000, // Ms (2 Minutes)
|
||||
Delay1m = 60000, // Ms (1 Minute)
|
||||
Delay30s = 30000, // Ms (30 Seconds)
|
||||
Delay15s = 15000, // Ms (15 Seconds) Used Only In Arena
|
||||
None = 0 // Ms
|
||||
}
|
||||
|
||||
public enum BattlegroundStatus
|
||||
{
|
||||
None = 0, // first status, should mean bg is not instance
|
||||
WaitQueue = 1, // means bg is empty and waiting for queue
|
||||
WaitJoin = 2, // this means, that BG has already started and it is waiting for more players
|
||||
InProgress = 3, // means bg is running
|
||||
WaitLeave = 4 // means some faction has won BG and it is ending
|
||||
}
|
||||
|
||||
public enum BGHonorMode
|
||||
{
|
||||
Normal = 0,
|
||||
Holiday,
|
||||
HonorModeNum
|
||||
}
|
||||
|
||||
public enum GroupJoinBattlegroundResult
|
||||
{
|
||||
None = 0,
|
||||
Deserters = 2, // You Cannot Join The BattlegroundYet Because You Or One Of Your Party Members Is Flagged As A Deserter.
|
||||
ArenaTeamPartySize = 3, // Incorrect Party Size For This Arena.
|
||||
TooManyQueues = 4, // You Can Only Be Queued For 2 Battles At Once
|
||||
CannotQueueForRated = 5, // You Cannot Queue For A Rated Match While Queued For Other Battles
|
||||
BattledgroundQueuedForRated = 6, // You Cannot Queue For Another Battle While Queued For A Rated Arena Match
|
||||
TeamLeftQueue = 7, // Your Team Has Left The Arena Queue
|
||||
NotInBattleground= 8, // You Can'T Do That In A Battleground.
|
||||
JoinXpGain = 9, // Wtf, Doesn'T Exist In Client...
|
||||
JoinRangeIndex = 10, // Cannot Join The Queue Unless All Members Of Your Party Are In The Same BattlegroundLevel Range.
|
||||
JoinTimedOut = 11, // %S Was Unavailable To Join The Queue. (Uint64 Guid Exist In Client Cache)
|
||||
//JoinTimedOut = 12, // Same As 11
|
||||
//TeamLeftQueue = 13, // Same As 7
|
||||
LfgCantUseBattleground= 14, // You Cannot Queue For A BattlegroundOr Arena While Using The Dungeon System.
|
||||
InRandomBg = 15, // Can'T Do That While In A Random BattlegroundQueue.
|
||||
InNonRandomBg = 16, // Can'T Queue For Random BattlegroundWhile In Another BattlegroundQueue.
|
||||
BgDeveloperOnly = 17,
|
||||
InvitationDeclined = 18,
|
||||
MeetingStoneNotFound = 19,
|
||||
WargameRequestFailure = 20,
|
||||
BattlefieldTeamPartySize = 22,
|
||||
NotOnTournamentRealm = 23,
|
||||
PlayersFromDifferentRealms = 24,
|
||||
RemoveFromPvpQueueGrantLevel = 33,
|
||||
RemoveFromPvpQueueFactionChange = 34,
|
||||
JoinFailed = 35,
|
||||
DupeQueue = 43,
|
||||
JoinNoValidSpecForRole = 44,
|
||||
JoinRespec = 45,
|
||||
AlreadyUsingLFGList = 46,
|
||||
JoinMustCompleteQuest = 47
|
||||
}
|
||||
|
||||
public enum ScoreType
|
||||
{
|
||||
KillingBlows = 1,
|
||||
Deaths = 2,
|
||||
HonorableKills = 3,
|
||||
BonusHonor = 4,
|
||||
DamageDone = 5,
|
||||
HealingDone = 6,
|
||||
|
||||
// Ws And Ey
|
||||
FlagCaptures = 7,
|
||||
FlagReturns = 8,
|
||||
|
||||
// Ab And Ic
|
||||
BasesAssaulted = 9,
|
||||
BasesDefended = 10,
|
||||
|
||||
// Av
|
||||
GraveyardsAssaulted = 11,
|
||||
GraveyardsDefended = 12,
|
||||
TowersAssaulted = 13,
|
||||
TowersDefended = 14,
|
||||
MinesCaptured = 15,
|
||||
|
||||
// Sota
|
||||
DestroyedDemolisher = 16,
|
||||
DestroyedWall = 17
|
||||
}
|
||||
|
||||
//Arenas
|
||||
public struct ArenaSpellIds
|
||||
{
|
||||
public const uint AllianceGoldFlag = 32724;
|
||||
public const uint AllianceGreenFlag = 32725;
|
||||
public const uint HordeGoldFlag = 35774;
|
||||
public const uint HordeGreenFlag = 35775;
|
||||
public const uint LastManStanding = 26549; // Arena Achievement Related
|
||||
}
|
||||
|
||||
public enum ArenaTeamCommandTypes
|
||||
{
|
||||
Create_S = 0x00,
|
||||
Invite_SS = 0x01,
|
||||
Quit_S = 0x03,
|
||||
Founder_S = 0x0e
|
||||
}
|
||||
|
||||
public enum ArenaTeamCommandErrors
|
||||
{
|
||||
ArenaTeamCreated = 0x00,
|
||||
ArenaTeamInternal = 0x01,
|
||||
AlreadyInArenaTeam = 0x02,
|
||||
AlreadyInArenaTeamS = 0x03,
|
||||
InvitedToArenaTeam = 0x04,
|
||||
AlreadyInvitedToArenaTeamS = 0x05,
|
||||
ArenaTeamNameInvalid = 0x06,
|
||||
ArenaTeamNameExistsS = 0x07,
|
||||
ArenaTeamLeaderLeaveS = 0x08,
|
||||
ArenaTeamPermissions = 0x08,
|
||||
ArenaTeamPlayerNotInTeam = 0x09,
|
||||
ArenaTeamPlayerNotInTeamSs = 0x0a,
|
||||
ArenaTeamPlayerNotFoundS = 0x0b,
|
||||
ArenaTeamNotAllied = 0x0c,
|
||||
ArenaTeamIgnoringYouS = 0x13,
|
||||
ArenaTeamTargetTooLowS = 0x15,
|
||||
ArenaTeamTargetTooHighS = 0x16,
|
||||
ArenaTeamTooManyMembersS = 0x17,
|
||||
ArenaTeamNotFound = 0x1b,
|
||||
ArenaTeamsLocked = 0x1e,
|
||||
ArenaTeamTooManyCreate = 0x21,
|
||||
}
|
||||
|
||||
public enum ArenaTeamEvents
|
||||
{
|
||||
JoinSs = 3, // Player Name + Arena Team Name
|
||||
LeaveSs = 4, // Player Name + Arena Team Name
|
||||
RemoveSss = 5, // Player Name + Arena Team Name + Captain Name
|
||||
LeaderIsSs = 6, // Player Name + Arena Team Name
|
||||
LeaderChangedSss = 7, // Old Captain + New Captain + Arena Team Name
|
||||
DisbandedS = 8 // Captain Name + Arena Team Name
|
||||
}
|
||||
|
||||
public enum ArenaTypes
|
||||
{
|
||||
BG = 0,
|
||||
Team2v2 = 2,
|
||||
Team3v3 = 3,
|
||||
Team5v5 = 5
|
||||
}
|
||||
|
||||
public enum ArenaErrorType
|
||||
{
|
||||
NoTeam = 0,
|
||||
ExpiredCAIS = 1,
|
||||
CantUseBattleground = 2
|
||||
}
|
||||
|
||||
public enum ArenaTeamInfoType
|
||||
{
|
||||
Id = 0,
|
||||
Type = 1, // new in 3.2 - team type?
|
||||
Member = 2, // 0 - captain, 1 - member
|
||||
GamesWeek = 3,
|
||||
GamesSeason = 4,
|
||||
WinsSeason = 5,
|
||||
PersonalRating = 6,
|
||||
End = 7
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum FlagsControlType
|
||||
{
|
||||
Apply = 1,
|
||||
Remove = 2
|
||||
}
|
||||
|
||||
public enum BattlePetError
|
||||
{
|
||||
CantHaveMorePetsOfThatType = 3,
|
||||
CantHaveMorePets = 4,
|
||||
TooHighLevelToUncage = 7,
|
||||
|
||||
// TODO: find correct values if possible and needed (also wrong order)
|
||||
DuplicateConvertedPet,
|
||||
NeedToUnlock,
|
||||
BadParam,
|
||||
LockedPetAlreadyExists,
|
||||
Ok,
|
||||
Uncapturable,
|
||||
CantInvalidCharacterGuid
|
||||
}
|
||||
|
||||
// taken from BattlePetState.db2 - it seems to store some initial values for battle pets
|
||||
// there are only values used in BattlePetSpeciesState.db2 and BattlePetBreedState.db2
|
||||
// TODO: expand this enum if needed
|
||||
public enum BattlePetState
|
||||
{
|
||||
MaxHealthBonus = 2,
|
||||
InternalInitialLevel = 17,
|
||||
StatPower = 18,
|
||||
StatStamina = 19,
|
||||
StatSpeed = 20,
|
||||
ModDamageDealtPercent = 23,
|
||||
Gender = 78, // 1 - Male, 2 - Female
|
||||
CosmeticWaterBubbled = 85,
|
||||
SpecialIsCockroach = 93,
|
||||
CosmeticFlyTier = 128,
|
||||
CosmeticBigglesworth = 144,
|
||||
PassiveElite = 153,
|
||||
PassiveBoss = 162,
|
||||
CosmeticTreasureGoblin = 176,
|
||||
// These Are Not In Battlepetstate.Db2 But Are Used In Battlepetspeciesstate.Db2
|
||||
StartWithBuff = 183,
|
||||
StartWithBuff2 = 184,
|
||||
//
|
||||
CosmeticSpectralBlue = 196
|
||||
}
|
||||
|
||||
public enum BattlePetSaveInfo
|
||||
{
|
||||
Unchanged = 0,
|
||||
Changed = 1,
|
||||
New = 2,
|
||||
Removed = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public struct BlackMarketConst
|
||||
{
|
||||
public const ulong MaxBid = 1000000UL* MoneyConstants.Gold;
|
||||
}
|
||||
public enum BlackMarketError
|
||||
{
|
||||
Ok = 0,
|
||||
ItemNotFound = 1,
|
||||
AlreadyBid = 2,
|
||||
HigherBid = 4,
|
||||
DatabaseError = 6,
|
||||
NotEnoughMoney = 7,
|
||||
RestrictedAccountTrial = 9
|
||||
}
|
||||
|
||||
public enum BMAHMailAuctionAnswers
|
||||
{
|
||||
Outbid = 0,
|
||||
Won = 1,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum CalendarMailAnswers
|
||||
{
|
||||
EventRemovedMailSubject = 0,
|
||||
InviteRemovedMailSubject = 0x100
|
||||
}
|
||||
|
||||
public enum CalendarFlags
|
||||
{
|
||||
AllAllowed = 0x001,
|
||||
InvitesLocked = 0x010,
|
||||
WithoutInvites = 0x040,
|
||||
GuildEvent = 0x400
|
||||
}
|
||||
|
||||
public enum CalendarModerationRank
|
||||
{
|
||||
Player = 0,
|
||||
Moderator = 1,
|
||||
Owner = 2
|
||||
}
|
||||
|
||||
public enum CalendarSendEventType
|
||||
{
|
||||
Get = 0,
|
||||
Add = 1,
|
||||
Copy = 2
|
||||
}
|
||||
|
||||
public enum CalendarEventType
|
||||
{
|
||||
Raid = 0,
|
||||
Dungeon = 1,
|
||||
Pvp = 2,
|
||||
Meeting = 3,
|
||||
Other = 4,
|
||||
Heroic = 5
|
||||
}
|
||||
|
||||
public enum CalendarRepeatType
|
||||
{
|
||||
Never = 0,
|
||||
Weekly = 1,
|
||||
Biweekly = 2,
|
||||
Monthly = 3
|
||||
}
|
||||
|
||||
public enum CalendarInviteStatus
|
||||
{
|
||||
Invited = 0,
|
||||
Accepted = 1,
|
||||
Declined = 2,
|
||||
Confirmed = 3,
|
||||
Out = 4,
|
||||
Standby = 5,
|
||||
SignedUp = 6,
|
||||
NotSignedUp = 7,
|
||||
Tentative = 8,
|
||||
Removed = 9 // Correct Name?
|
||||
}
|
||||
|
||||
public enum CalendarError
|
||||
{
|
||||
Ok = 0,
|
||||
GuildEventsExceeded = 1,
|
||||
EventsExceeded = 2,
|
||||
SelfInvitesExceeded = 3,
|
||||
OtherInvitesExceeded = 4,
|
||||
Permissions = 5,
|
||||
EventInvalid = 6,
|
||||
NotInvited = 7,
|
||||
Internal = 8,
|
||||
GuildPlayerNotInGuild = 9,
|
||||
AlreadyInvitedToEventS = 10,
|
||||
PlayerNotFound = 11,
|
||||
NotAllied = 12,
|
||||
IgnoringYouS = 13,
|
||||
InvitesExceeded = 14,
|
||||
InvalidDate = 16,
|
||||
InvalidTime = 17,
|
||||
|
||||
NeedsTitle = 19,
|
||||
EventPassed = 20,
|
||||
EventLocked = 21,
|
||||
DeleteCreatorFailed = 22,
|
||||
SystemDisabled = 24,
|
||||
RestrictedAccount = 25,
|
||||
ArenaEventsExceeded = 26,
|
||||
RestrictedLevel = 27,
|
||||
UserSquelched = 28,
|
||||
NoInvite = 29,
|
||||
|
||||
EventWrongServer = 36,
|
||||
InviteWrongServer = 37,
|
||||
NoGuildInvites = 38,
|
||||
InvalidSignup = 39,
|
||||
NoModerator = 40
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum ChatNotify
|
||||
{
|
||||
JoinedNotice = 0x00, //+ "%S Joined Channel.";
|
||||
LeftNotice = 0x01, //+ "%S Left Channel.";
|
||||
//SuspendedNotice = 0x01, // "%S Left Channel.";
|
||||
YouJoinedNotice = 0x02, //+ "Joined Channel: [%S]"; -- You Joined
|
||||
//YouChangedNotice = 0x02, // "Changed Channel: [%S]";
|
||||
YouLeftNotice = 0x03, //+ "Left Channel: [%S]"; -- You Left
|
||||
WrongPasswordNotice = 0x04, //+ "Wrong Password For %S.";
|
||||
NotMemberNotice = 0x05, //+ "Not On Channel %S.";
|
||||
NotModeratorNotice = 0x06, //+ "Not A Moderator Of %S.";
|
||||
PasswordChangedNotice = 0x07, //+ "[%S] Password Changed By %S.";
|
||||
OwnerChangedNotice = 0x08, //+ "[%S] Owner Changed To %S.";
|
||||
PlayerNotFoundNotice = 0x09, //+ "[%S] Player %S Was Not Found.";
|
||||
NotOwnerNotice = 0x0a, //+ "[%S] You Are Not The Channel Owner.";
|
||||
ChannelOwnerNotice = 0x0b, //+ "[%S] Channel Owner Is %S.";
|
||||
ModeChangeNotice = 0x0c, //?
|
||||
AnnouncementsOnNotice = 0x0d, //+ "[%S] Channel Announcements Enabled By %S.";
|
||||
AnnouncementsOffNotice = 0x0e, //+ "[%S] Channel Announcements Disabled By %S.";
|
||||
ModerationOnNotice = 0x0f, //+ "[%S] Channel Moderation Enabled By %S.";
|
||||
ModerationOffNotice = 0x10, //+ "[%S] Channel Moderation Disabled By %S.";
|
||||
MutedNotice = 0x11, //+ "[%S] You Do Not Have Permission To Speak.";
|
||||
PlayerKickedNotice = 0x12, //? "[%S] Player %S Kicked By %S.";
|
||||
BannedNotice = 0x13, //+ "[%S] You Are Bannedstore From That Channel.";
|
||||
PlayerBannedNotice = 0x14, //? "[%S] Player %S Bannedstore By %S.";
|
||||
PlayerUnbannedNotice = 0x15, //? "[%S] Player %S Unbanned By %S.";
|
||||
PlayerNotBannedNotice = 0x16, //+ "[%S] Player %S Is Not Bannedstore.";
|
||||
PlayerAlreadyMemberNotice = 0x17, //+ "[%S] Player %S Is Already On The Channel.";
|
||||
InviteNotice = 0x18, //+ "%2$S Has Invited You To Join The Channel '%1$S'.";
|
||||
InviteWrongFactionNotice = 0x19, //+ "Target Is In The Wrong Alliance For %S.";
|
||||
WrongFactionNotice = 0x1a, //+ "Wrong Alliance For %S.";
|
||||
InvalidNameNotice = 0x1b, //+ "Invalid Channel Name";
|
||||
NotModeratedNotice = 0x1c, //+ "%S Is Not Moderated";
|
||||
PlayerInvitedNotice = 0x1d, //+ "[%S] You Invited %S To Join The Channel";
|
||||
PlayerInviteBannedNotice = 0x1e, //+ "[%S] %S Has Been Bannedstore.";
|
||||
ThrottledNotice = 0x1f, //+ "[%S] The Number Of Messages That Can Be Sent To This Channel Is Limited, Please Wait To Send Another Message.";
|
||||
NotInAreaNotice = 0x20, //+ "[%S] You Are Not In The Correct Area For This Channel."; -- The User Is Trying To Send A Chat To A Zone Specific Channel, And They'Re Not Physically In That Zone.
|
||||
NotInLfgNotice = 0x21, //+ "[%S] You Must Be Queued In Looking For Group Before Joining This Channel."; -- The User Must Be In The Looking For Group System To Join Lfg Chat Channels.
|
||||
VoiceOnNotice = 0x22, //+ "[%S] Channel Voice Enabled By %S.";
|
||||
VoiceOffNotice = 0x23, //+ "[%S] Channel Voice Disabled By %S.";
|
||||
TrialRestricted = 0x24,
|
||||
NotAllowedInChannel = 0x25
|
||||
}
|
||||
|
||||
public enum ChannelFlags
|
||||
{
|
||||
None = 0x00,
|
||||
Custom = 0x01,
|
||||
// 0x02
|
||||
Trade = 0x04,
|
||||
NotLfg = 0x08,
|
||||
General = 0x10,
|
||||
City = 0x20,
|
||||
Lfg = 0x40,
|
||||
Voice = 0x80
|
||||
// General 0x18 = 0x10 | 0x08
|
||||
// Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04
|
||||
// LocalDefence 0x18 = 0x10 | 0x08
|
||||
// GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08
|
||||
// LookingForGroup 0x50 = 0x40 | 0x10
|
||||
}
|
||||
|
||||
public enum ChannelDBCFlags
|
||||
{
|
||||
None = 0x00000,
|
||||
Initial = 0x00001, // General, Trade, Localdefense, Lfg
|
||||
ZoneDep = 0x00002, // General, Trade, Localdefense, Guildrecruitment
|
||||
Global = 0x00004, // Worlddefense
|
||||
Trade = 0x00008, // Trade, Lfg
|
||||
CityOnly = 0x00010, // Trade, Guildrecruitment, Lfg
|
||||
CityOnly2 = 0x00020, // Trade, Guildrecruitment, Lfg
|
||||
Defense = 0x10000, // Localdefense, Worlddefense
|
||||
GuildReq = 0x20000, // Guildrecruitment
|
||||
Lfg = 0x40000, // Lfg
|
||||
Unk1 = 0x80000 // General
|
||||
}
|
||||
|
||||
public enum ChannelMemberFlags
|
||||
{
|
||||
None = 0x00,
|
||||
Owner = 0x01,
|
||||
Moderator = 0x02,
|
||||
Voiced = 0x04,
|
||||
Muted = 0x08,
|
||||
Custom = 0x10,
|
||||
MicMuted = 0x20
|
||||
// 0x40
|
||||
// 0x80
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum ConditionTypes
|
||||
{ // value1 value2 value3
|
||||
None = 0, // 0 0 0 Always True
|
||||
Aura = 1, // Spell_Id Effindex Use Target? True If Player (Or Target, If Value3) Has Aura Of Spell_Id With Effect Effindex
|
||||
Item = 2, // Item_Id Count Bank True If Has #Count Of Item_Ids (If 'Bank' Is Set It Searches In Bank Slots Too)
|
||||
ItemEquipped = 3, // Item_Id 0 0 True If Has Item_Id Equipped
|
||||
Zoneid = 4, // Zone_Id 0 0 True If In Zone_Id
|
||||
ReputationRank = 5, // Faction_Id Rankmask 0 True If Has Min_Rank For Faction_Id
|
||||
Team = 6, // Player_Team 0, 0 469 - Alliance, 67 - Horde)
|
||||
Skill = 7, // Skill_Id Skill_Value 0 True If Has Skill_Value For Skill_Id
|
||||
QuestRewarded = 8, // Quest_Id 0 0 True If Quest_Id Was Rewarded Before
|
||||
QuestTaken = 9, // Quest_Id 0, 0 True While Quest Active
|
||||
DrunkenState = 10, // Drunkenstate 0, 0 True If Player Is Drunk Enough
|
||||
WorldState = 11, // Index Value 0 True If World Has The Value For The Index
|
||||
ActiveEvent = 12, // Event_Id 0 0 True If Event Is Active
|
||||
InstanceInfo = 13, // Entry Data Type True If The Instance Info Defined By Type (Enum Instanceinfo) Equals Data.
|
||||
QuestNone = 14, // Quest_Id 0 0 True If Doesn'T Have Quest Saved
|
||||
Class = 15, // Class 0 0 True If Player'S Class Is Equal To Class
|
||||
Race = 16, // Race 0 0 True If Player'S Race Is Equal To Race
|
||||
Achievement = 17, // Achievement_Id 0 0 True If Achievement Is Complete
|
||||
Title = 18, // Title Id 0 0 True If Player Has Title
|
||||
Spawnmask = 19, // Spawnmask 0 0 True If In Spawnmask
|
||||
Gender = 20, // Gender 0 0 True If Player'S Gender Is Equal To Gender
|
||||
UnitState = 21, // Unitstate 0 0 True If Unit Has Unitstate
|
||||
Mapid = 22, // Map_Id 0 0 True If In Map_Id
|
||||
Areaid = 23, // Area_Id 0 0 True If In Area_Id
|
||||
CreatureType = 24, // cinfo.type 0 0 true if creature_template.type = value1
|
||||
Spell = 25, // Spell_Id 0 0 True If Player Has Learned Spell
|
||||
PhaseId = 26, // Phasemask 0 0 True If Object Is In PhaseId
|
||||
Level = 27, // Level Comparisontype 0 True If Unit'S Level Is Equal To Param1 (Param2 Can Modify The Statement)
|
||||
QuestComplete = 28, // Quest_Id 0 0 True If Player Has Quest_Id With All Objectives Complete, But Not Yet Rewarded
|
||||
NearCreature = 29, // Creature Entry Distance 0 True If There Is A Creature Of Entry In Range
|
||||
NearGameobject = 30, // Gameobject Entry Distance 0 True If There Is A Gameobject Of Entry In Range
|
||||
ObjectEntryGuid = 31, // Typeid Entry 0 True If Object Is Type Typeid And The Entry Is 0 Or Matches Entry Of The Object
|
||||
TypeMask = 32, // Typemask 0 0 True If Object Is Type Object'S Typemask Matches Provided Typemask
|
||||
RelationTo = 33, // Conditiontarget Relationtype 0 True If Object Is In Given Relation With Object Specified By Conditiontarget
|
||||
ReactionTo = 34, // Conditiontarget Rankmask 0 True If Object'S Reaction Matches Rankmask Object Specified By Conditiontarget
|
||||
DistanceTo = 35, // Conditiontarget Distance Comparisontype True If Object And Conditiontarget Are Within Distance Given By Parameters
|
||||
Alive = 36, // 0 0 0 True If Unit Is Alive
|
||||
HpVal = 37, // Hpval Comparisontype 0 True If Unit'S Hp Matches Given Value
|
||||
HpPct = 38, // Hppct Comparisontype 0 True If Unit'S Hp Matches Given Pct
|
||||
RealmAchievement = 39, // achievement_id 0 0 true if realm achievement is complete
|
||||
InWater = 40, // 0 0 0 true if unit in water
|
||||
TerrainSwap = 41, // terrainSwap 0 0 true if object is in terrainswap
|
||||
StandState = 42, // stateType state 0 true if unit matches specified sitstate (0,x: has exactly state x; 1,0: any standing state; 1,1: any sitting state;)
|
||||
DailyQuestDone = 43, // quest id 0 0 true if daily quest has been completed for the day
|
||||
Charmed = 44, // 0 0 0 true if unit is currently charmed
|
||||
PetType = 45, // mask 0 0 true if player has a pet of given type(s)
|
||||
Taxi = 46, // 0 0 0 true if player is on taxi
|
||||
Queststate = 47, // quest_id state_mask 0 true if player is in any of the provided quest states for the quest (1 = not taken, 2 = completed, 8 = in progress, 32 = failed, 64 = rewarded)
|
||||
ObjectiveComplete = 48, // ID 0 0 true if player has ID objective complete, but quest not yet rewarded
|
||||
Max = 49 // Max
|
||||
}
|
||||
|
||||
public enum ConditionSourceType
|
||||
{
|
||||
None = 0,
|
||||
CreatureLootTemplate = 1,
|
||||
DisenchantLootTemplate = 2,
|
||||
FishingLootTemplate = 3,
|
||||
GameobjectLootTemplate = 4,
|
||||
ItemLootTemplate = 5,
|
||||
MailLootTemplate = 6,
|
||||
MillingLootTemplate = 7,
|
||||
PickpocketingLootTemplate = 8,
|
||||
ProspectingLootTemplate = 9,
|
||||
ReferenceLootTemplate = 10,
|
||||
SkinningLootTemplate = 11,
|
||||
SpellLootTemplate = 12,
|
||||
SpellImplicitTarget = 13,
|
||||
GossipMenu = 14,
|
||||
GossipMenuOption = 15,
|
||||
CreatureTemplateVehicle = 16,
|
||||
Spell = 17,
|
||||
SpellClickEvent = 18,
|
||||
QuestAvailable = 19,
|
||||
// Condition source type 20 unused
|
||||
VehicleSpell = 21,
|
||||
SmartEvent = 22,
|
||||
NpcVendor = 23,
|
||||
SpellProc = 24,
|
||||
TerrainSwap = 25,
|
||||
Phase = 26,
|
||||
Max = 27
|
||||
}
|
||||
|
||||
public enum RelationType
|
||||
{
|
||||
Self = 0,
|
||||
InParty,
|
||||
InRaidOrParty,
|
||||
OwnedBy,
|
||||
PassengerOf,
|
||||
CreatedBy,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum InstanceInfo
|
||||
{
|
||||
Data = 0,
|
||||
Data64,
|
||||
BossState
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum ConnectionType
|
||||
{
|
||||
Realm = 0,
|
||||
Instance = 1,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum ConnectToSerial
|
||||
{
|
||||
None = 0,
|
||||
Realm = 14,
|
||||
WorldAttempt1 = 17,
|
||||
WorldAttempt2 = 35,
|
||||
WorldAttempt3 = 53,
|
||||
WorldAttempt4 = 71,
|
||||
WorldAttempt5 = 89
|
||||
}
|
||||
|
||||
public enum LoginFailureReason
|
||||
{
|
||||
Failed = 0,
|
||||
NoWorld = 1,
|
||||
DuplicateCharacter = 2,
|
||||
NoInstances = 3,
|
||||
Disabled = 4,
|
||||
NoCharacter = 5,
|
||||
LockedForTransfer = 6,
|
||||
LockedByBilling = 7,
|
||||
LockedByMobileAH = 8,
|
||||
TemporaryGMLock = 9,
|
||||
LockedByCharacterUpgrade = 10,
|
||||
LockedByRevokedCharacterUpgrade = 11
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum CreatureLinkedRespawnType
|
||||
{
|
||||
CreatureToCreature,
|
||||
CreatureToGO, // Creature is dependant on GO
|
||||
GOToGO,
|
||||
GOToCreature // GO is dependant on creature
|
||||
}
|
||||
|
||||
public enum AiReaction
|
||||
{
|
||||
Alert = 0, // pre-aggro (used in client packet handler)
|
||||
Friendly = 1, // (NOT used in client packet handler)
|
||||
Hostile = 2, // sent on every attack, triggers aggro sound (used in client packet handler)
|
||||
Afraid = 3, // seen for polymorph (when AI not in control of self?) (NOT used in client packet handler)
|
||||
Destory = 4 // used on object destroy (NOT used in client packet handler)
|
||||
}
|
||||
|
||||
public enum CreatureEliteType
|
||||
{
|
||||
Normal = 0,
|
||||
Elite = 1,
|
||||
RareElite = 2,
|
||||
WorldBoss = 3,
|
||||
Rare = 4,
|
||||
Unknown = 5 // found in 2.2.3 for 2 mobs
|
||||
}
|
||||
|
||||
[System.Flags]
|
||||
public enum UnitFlags : uint
|
||||
{
|
||||
ServerControlled = 0x01,
|
||||
NonAttackable = 0x02,
|
||||
RemoveClientControl = 0x04, // This is a legacy flag used to disable movement player's movement while controlling other units, SMSG_CLIENT_CONTROL replaces this functionality clientside now. CONFUSED and FLEEING flags have the same effect on client movement asDISABLE_MOVE_CONTROL in addition to preventing spell casts/autoattack (they all allow climbing steeper hills and emotes while moving)
|
||||
PvpAttackable = 0x08,
|
||||
Rename = 0x10,
|
||||
Preparation = 0x20,
|
||||
Unk6 = 0x40,
|
||||
NotAttackable1 = 0x80,
|
||||
ImmuneToPc = 0x100,
|
||||
ImmuneToNpc = 0x200,
|
||||
Looting = 0x400,
|
||||
PetInCombat = 0x800,
|
||||
Pvp = 0x1000,
|
||||
Silenced = 0x2000,
|
||||
CannotSwim = 0x4000,
|
||||
Unk15 = 0x8000,
|
||||
Unk16 = 0x10000,
|
||||
Pacified = 0x20000,
|
||||
Stunned = 0x40000,
|
||||
InCombat = 0x80000,
|
||||
TaxiFlight = 0x100000,
|
||||
Disarmed = 0x200000,
|
||||
Confused = 0x400000,
|
||||
Fleeing = 0x800000,
|
||||
PlayerControlled = 0x1000000,
|
||||
NotSelectable = 0x2000000,
|
||||
Skinnable = 0x4000000,
|
||||
Mount = 0x8000000,
|
||||
Unk28 = 0x10000000,
|
||||
Unk29 = 0x20000000,
|
||||
Sheathe = 0x40000000,
|
||||
Unk31 = 0x80000000
|
||||
}
|
||||
|
||||
public enum UnitFlags2 : uint
|
||||
{
|
||||
FeignDeath = 0x01,
|
||||
Unk1 = 0x02,
|
||||
IgnoreReputation = 0x04,
|
||||
ComprehendLang = 0x08,
|
||||
MirrorImage = 0x10,
|
||||
InstantlyAppearModel = 0x20,
|
||||
ForceMove = 0x40,
|
||||
DisarmOffhand = 0x80,
|
||||
DisablePredStats = 0x100,
|
||||
DisarmRanged = 0x400,
|
||||
RegeneratePower = 0x800,
|
||||
RestrictPartyInteraction = 0x1000,
|
||||
PreventSpellClick = 0x2000,
|
||||
AllowEnemyInteract = 0x4000,
|
||||
DisableTurn = 0x8000,
|
||||
Unk2 = 0x10000,
|
||||
PlayDeathAnim = 0x20000,
|
||||
AllowCheatSpells = 0x40000,
|
||||
NoActions = 0x800000
|
||||
}
|
||||
|
||||
public enum UnitFlags3 : uint
|
||||
{
|
||||
Unk1 = 0x01,
|
||||
}
|
||||
|
||||
public enum NPCFlags : ulong
|
||||
{
|
||||
None = 0x00,
|
||||
Gossip = 0x01,
|
||||
QuestGiver = 0x02,
|
||||
Unk1 = 0x04,
|
||||
Unk2 = 0x08,
|
||||
Trainer = 0x10,
|
||||
TrainerClass = 0x20,
|
||||
TrainerProfession = 0x40,
|
||||
Vendor = 0x80,
|
||||
VendorGeneral = 0x100,
|
||||
VendorFood = 0x200,
|
||||
VendorPoison = 0x400,
|
||||
VendorReagent = 0x800,
|
||||
Repair = 0x1000,
|
||||
FlightMaster = 0x2000,
|
||||
SpiritHealer = 0x4000,
|
||||
SpiritGuide = 0x8000,
|
||||
Innkeeper = 0x10000,
|
||||
Banker = 0x20000,
|
||||
Petitioner = 0x40000,
|
||||
TabardDesigner = 0x80000,
|
||||
BattleMaster = 0x100000,
|
||||
Auctioneer = 0x200000,
|
||||
StableMaster = 0x400000,
|
||||
GuildBanker = 0x800000,
|
||||
SpellClick = 0x1000000,
|
||||
PlayerVehicle = 0x2000000,
|
||||
Mailbox = 0x4000000,
|
||||
ArtifactPowerRespec = 0x8000000,
|
||||
Transmogrifier = 0x10000000,
|
||||
VaultKeeper = 0x20000000,
|
||||
BlackMarket = 0x80000000,
|
||||
ItemUpgradeMaster = 0x100000000,
|
||||
GarrisonArchitect = 0x200000000,
|
||||
Steering = 0x400000000,
|
||||
ShipmentCrafter = 0x1000000000,
|
||||
GarrisonMissionNpc = 0x2000000000,
|
||||
TradeskillNpc = 0x4000000000,
|
||||
BlackMarketView = 0x8000000000
|
||||
}
|
||||
|
||||
public enum CreatureTypeFlags : uint
|
||||
{
|
||||
TameablePet = 0x01, // Makes the mob tameable (must also be a beast and have family set)
|
||||
GhostVisible = 0x02, // Creature are also visible for not alive player. Allow gossip interaction if npcflag allow?
|
||||
BossMob = 0x04, // Changes creature's visible level to "??" in the creature's portrait - Immune Knockback.
|
||||
DoNotPlayWoundParryAnimation = 0x08,
|
||||
HideFactionTooltip = 0x10,
|
||||
Unk5 = 0x20, // Sound related
|
||||
SpellAttackable = 0x40,
|
||||
CanInteractWhileDead = 0x80, // Player can interact with the creature if its dead (not player dead)
|
||||
HerbSkinningSkill = 0x100, // Can be looted by herbalist
|
||||
MiningSkinningSkill = 0x200, // Can be looted by miner
|
||||
DoNotLogDeath = 0x400, // Death event will not show up in combat log
|
||||
MountedCombatAllowed = 0x800, // Creature can remain mounted when entering combat
|
||||
CanAssist = 0x1000, // ? Can aid any player in combat if in range?
|
||||
IsPetBarUsed = 0x2000,
|
||||
MaskUID = 0x4000,
|
||||
EngineeringSkinningSkill = 0x8000, // Can be looted by engineer
|
||||
ExoticPet = 0x10000, // Can be tamed by hunter as exotic pet
|
||||
UseDefaultCollisionBox = 0x20000, // Collision related. (always using default collision box?)
|
||||
IsSiegeWeapon = 0x40000,
|
||||
CanCollideWithMissiles = 0x80000, // Projectiles can collide with this creature - interacts with TARGET_DEST_TRAJ
|
||||
HideNamePlate = 0x100000,
|
||||
DoNotPlayMountedAnimations = 0x200000,
|
||||
IsLinkAll = 0x400000,
|
||||
InteractOnlyWithCreator = 0x800000,
|
||||
DoNotPlayUnitEventSounds = 0x1000000,
|
||||
HasNoShadowBlob = 0x2000000,
|
||||
TreatAsRaidUnit = 0x4000000, //! Creature can be targeted by spells that require target to be in caster's party/raid
|
||||
ForceGossip = 0x8000000, // Allows the creature to display a single gossip option.
|
||||
DoNotSheathe = 0x10000000,
|
||||
DoNotTargetOnInteration = 0x20000000,
|
||||
DoNotRenderObjectName = 0x40000000,
|
||||
UnitIsQuestBoss = 0x80000000 // Not verified
|
||||
}
|
||||
|
||||
public enum CreatureFlagsExtra : uint
|
||||
{
|
||||
InstanceBind = 0x01, // Creature Kill Bind Instance With Killer And Killer'S Group
|
||||
Civilian = 0x02, // Not Aggro (Ignore Faction/Reputation Hostility)
|
||||
NoParry = 0x04, // Creature Can'T Parry
|
||||
NoParryHasten = 0x08, // Creature Can'T Counter-Attack At Parry
|
||||
NoBlock = 0x10, // Creature Can'T Block
|
||||
NoCrush = 0x20, // Creature Can'T Do Crush Attacks
|
||||
NoXpAtKill = 0x40, // Creature Kill Not Provide Xp
|
||||
Trigger = 0x80, // Trigger Creature
|
||||
NoTaunt = 0x100, // Creature Is Immune To Taunt Auras And Effect Attack Me
|
||||
Worldevent = 0x4000, // Custom Flag For World Event Creatures (Left Room For Merging)
|
||||
Guard = 0x8000, // Creature Is Guard
|
||||
NoCrit = 0x20000, // Creature Can'T Do Critical Strikes
|
||||
NoSkillgain = 0x40000, // Creature Won'T Increase Weapon Skills
|
||||
TauntDiminish = 0x80000, // Taunt Is A Subject To Diminishing Returns On This Creautre
|
||||
AllDiminish = 0x100000, // Creature Is Subject To All Diminishing Returns As Player Are
|
||||
NoPlayerDamageReq = 0x200000, // creature does not need to take player damage for kill credit
|
||||
DungeonBoss = 0x10000000, // Creature Is A Dungeon Boss (Set Dynamically, Do Not Add In Db)
|
||||
IgnorePathfinding = 0x20000000, // creature ignore pathfinding
|
||||
ImmunityKnockback = 0x40000000, // creature is immune to knockback effects
|
||||
|
||||
DBAllowed = (InstanceBind | Civilian | NoParry | NoParryHasten | NoBlock | NoCrush | NoXpAtKill |
|
||||
Trigger | NoTaunt | Worldevent | NoCrit | NoSkillgain | TauntDiminish | AllDiminish | Guard |
|
||||
IgnorePathfinding | NoPlayerDamageReq | ImmunityKnockback)
|
||||
}
|
||||
|
||||
public enum CreatureType
|
||||
{
|
||||
Beast = 1,
|
||||
Dragonkin = 2,
|
||||
Demon = 3,
|
||||
Elemental = 4,
|
||||
Giant = 5,
|
||||
Undead = 6,
|
||||
Humanoid = 7,
|
||||
Critter = 8,
|
||||
Mechanical = 9,
|
||||
NotSpecified = 10,
|
||||
Totem = 11,
|
||||
NonCombatPet = 12,
|
||||
GasCloud = 13,
|
||||
WildPet = 14,
|
||||
Aberration = 15,
|
||||
|
||||
MaskDemonOrUnDead = (1 << (Demon - 1)) | (1 << (Undead - 1)),
|
||||
MaskHumanoidOrUndead = (1 << (Humanoid - 1)) | (1 << (Undead - 1)),
|
||||
MaskMechanicalOrElemental = (1 << (Mechanical - 1)) | (1 << (Elemental - 1))
|
||||
}
|
||||
|
||||
public enum CreatureFamily
|
||||
{
|
||||
None = 0,
|
||||
Wolf = 1,
|
||||
Cat = 2,
|
||||
Spider = 3,
|
||||
Bear = 4,
|
||||
Boar = 5,
|
||||
Crocolisk = 6,
|
||||
CarrionBird = 7,
|
||||
Crab = 8,
|
||||
Gorilla = 9,
|
||||
HorseCustom = 10, // Does Not Exist In Dbc But Used For Horse Like Beasts In Db
|
||||
Raptor = 11,
|
||||
Tallstrider = 12,
|
||||
Felhunter = 15,
|
||||
Voidwalker = 16,
|
||||
Succubus = 17,
|
||||
Doomguard = 19,
|
||||
Scorpid = 20,
|
||||
Turtle = 21,
|
||||
Imp = 23,
|
||||
Bat = 24,
|
||||
Hyena = 25,
|
||||
BirdOfPrey = 26,
|
||||
WindSerpent = 27,
|
||||
RemoteControl = 28,
|
||||
Felguard = 29,
|
||||
Dragonhawk = 30,
|
||||
Ravager = 31,
|
||||
WarpStalker = 32,
|
||||
Sporebat = 33,
|
||||
NetherRay = 34,
|
||||
Serpent = 35,
|
||||
Moth = 37,
|
||||
Chimaera = 38,
|
||||
Devilsaur = 39,
|
||||
Ghoul = 40,
|
||||
Silithid = 41,
|
||||
Worm = 42,
|
||||
Rhino = 43,
|
||||
Wasp = 44,
|
||||
CoreHound = 45,
|
||||
SpiritBeast = 46,
|
||||
WaterElemental = 49,
|
||||
Fox = 50,
|
||||
Monkey = 51,
|
||||
Dog = 52,
|
||||
Beetle = 53,
|
||||
ShaleSpider = 55,
|
||||
Zombie = 56,
|
||||
BeetleOld = 57,
|
||||
Silithid2 = 59,
|
||||
Wasp2 = 66,
|
||||
Hydra = 68,
|
||||
Felimp = 100,
|
||||
Voidlord = 101,
|
||||
Shivara = 102,
|
||||
Observer = 103,
|
||||
Wrathguard = 104,
|
||||
Infernal = 108,
|
||||
Fireelemental = 116,
|
||||
Earthelemental = 117,
|
||||
Crane = 125,
|
||||
Waterstrider = 126,
|
||||
Porcupine = 127,
|
||||
Quilen = 128,
|
||||
Goat = 129,
|
||||
Basilisk = 130,
|
||||
Direhorn = 138,
|
||||
Stormelemental = 145,
|
||||
Mtwaterelemental = 146,
|
||||
Torrorguard = 147,
|
||||
Abyssal = 148,
|
||||
Rylak = 149,
|
||||
Riverbeast = 150,
|
||||
Stag = 151
|
||||
}
|
||||
|
||||
public enum InhabitType
|
||||
{
|
||||
Ground = 1,
|
||||
Water = 2,
|
||||
Air = 4,
|
||||
Root = 8,
|
||||
Anywhere = Ground | Water | Air | Root
|
||||
}
|
||||
|
||||
public enum EvadeReason
|
||||
{
|
||||
NoHostiles, // the creature's threat list is empty
|
||||
Boundary, // the creature has moved outside its evade boundary
|
||||
NoPath, // the creature was unable to reach its target for over 5 seconds
|
||||
SequenceBreak, // this is a boss and the pre-requisite encounters for engaging it are not defeated yet
|
||||
Other
|
||||
}
|
||||
|
||||
public enum GroupAIFlags
|
||||
{
|
||||
None = 0, // No creature group behavior
|
||||
MembersAssistLeader = 0x01, // The member aggroes if the leader aggroes
|
||||
LeaderAssistsMember = 0x02, // The leader aggroes if the member aggroes
|
||||
MembersAssistMember = (MembersAssistLeader | LeaderAssistsMember), // every member will assist if any member is attacked
|
||||
IdleInFormation = 0x200, // The member will follow the leader when pathing idly
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum GameObjectTypes : byte
|
||||
{
|
||||
Door = 0,
|
||||
Button = 1,
|
||||
QuestGiver = 2,
|
||||
Chest = 3,
|
||||
Binder = 4,
|
||||
Generic = 5,
|
||||
Trap = 6,
|
||||
Chair = 7,
|
||||
SpellFocus = 8,
|
||||
Text = 9,
|
||||
Goober = 10,
|
||||
Transport = 11,
|
||||
AreaDamage = 12,
|
||||
Camera = 13,
|
||||
MapObject = 14,
|
||||
MapObjTransport = 15,
|
||||
DuelArbiter = 16,
|
||||
FishingNode = 17,
|
||||
Ritual = 18,
|
||||
Mailbox = 19,
|
||||
DoNotUse = 20,
|
||||
GuardPost = 21,
|
||||
SpellCaster = 22,
|
||||
MeetingStone = 23,
|
||||
FlagStand = 24,
|
||||
FishingHole = 25,
|
||||
FlagDrop = 26,
|
||||
MiniGame = 27,
|
||||
DoNotUse2 = 28,
|
||||
ControlZone = 29,
|
||||
AuraGenerator = 30,
|
||||
DungeonDifficulty = 31,
|
||||
BarberChair = 32,
|
||||
DestructibleBuilding = 33,
|
||||
GuildBank = 34,
|
||||
TrapDoor = 35,
|
||||
NewFlag = 36,
|
||||
NewFlagDrop = 37,
|
||||
GarrisonBuilding = 38,
|
||||
GarrisonPlot = 39,
|
||||
ClientCreature = 40,
|
||||
ClientItem = 41,
|
||||
CapturePoint = 42,
|
||||
PhaseableMo = 43,
|
||||
GarrisonMonument = 44,
|
||||
GarrisonShipment = 45,
|
||||
GarrisonMonumentPlaque = 46,
|
||||
ArtifactForge = 47,
|
||||
UILink = 48,
|
||||
KeystoneReceptacle = 49,
|
||||
GatheringNode = 50,
|
||||
ChallengeModeReward = 51,
|
||||
Max = 52
|
||||
}
|
||||
|
||||
public enum GameObjectState
|
||||
{
|
||||
Active = 0,
|
||||
Ready = 1,
|
||||
ActiveAlternative = 2,
|
||||
TransportActive = 24,
|
||||
TransportStopped = 25,
|
||||
Max = 3
|
||||
}
|
||||
|
||||
public enum GameObjectDynamicLowFlags
|
||||
{
|
||||
HideModel = 0x02,
|
||||
Activate = 0x04,
|
||||
Animate = 0x08,
|
||||
NoInteract = 0x10,
|
||||
Sparkle = 0x20,
|
||||
Stopped = 0x40
|
||||
}
|
||||
|
||||
public enum GameObjectFlags
|
||||
{
|
||||
InUse = 0x01, // Disables Interaction While Animated
|
||||
Locked = 0x02, // Require Key, Spell, Event, Etc To Be Opened. Makes "Locked" Appear In Tooltip
|
||||
InteractCond = 0x04, // cannot interact (condition to interact - requires GO_DYNFLAG_LO_ACTIVATE to enable interaction clientside)
|
||||
Transport = 0x08, // Any Kind Of Transport? Object Can Transport (Elevator, Boat, Car)
|
||||
NotSelectable = 0x10, // Not Selectable Even In Gm Mode
|
||||
NoDespawn = 0x20, // Never Despawn, Typically For Doors, They Just Change State
|
||||
AiObstacle = 0x40, // makes the client register the object in something called AIObstacleMgr, unknown what it does
|
||||
FreezeAnimation = 0x80,
|
||||
Damaged = 0x200,
|
||||
Destroyed = 0x400,
|
||||
InteractDistanceUsesTemplateModel = 0x80000, // client checks interaction distance from model sent in SMSG_QUERY_GAMEOBJECT_RESPONSE instead of GAMEOBJECT_DISPLAYID
|
||||
MapObject = 0x00100000 // pre-7.0 model loading used to be controlled by file extension (wmo vs m2)
|
||||
}
|
||||
|
||||
public enum LootState
|
||||
{
|
||||
NotReady = 0,
|
||||
Ready, // can be ready but despawned, and then not possible activate until spawn
|
||||
Activated,
|
||||
JustDeactivated
|
||||
}
|
||||
|
||||
public enum GameObjectDestructibleState
|
||||
{
|
||||
Intact = 0,
|
||||
Damaged = 1,
|
||||
Destroyed = 2,
|
||||
Rebuilding = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public struct GarrisonFactionIndex
|
||||
{
|
||||
public const uint Horde = 0;
|
||||
public const uint Alliance = 1;
|
||||
}
|
||||
|
||||
public enum GarrisonBuildingFlags : byte
|
||||
{
|
||||
NeedsPlan = 0x1
|
||||
}
|
||||
|
||||
enum GarrisonFollowerFlags
|
||||
{
|
||||
Unique = 0x1
|
||||
}
|
||||
|
||||
public enum GarrisonFollowerType
|
||||
{
|
||||
Garrison = 1,
|
||||
Shipyard = 2
|
||||
}
|
||||
|
||||
public enum GarrisonAbilityFlags : ushort
|
||||
{
|
||||
Trait = 0x01,
|
||||
CannotRoll = 0x02,
|
||||
HordeOnly = 0x04,
|
||||
AllianceOnly = 0x08,
|
||||
CannotRemove = 0x10,
|
||||
Exclusive = 0x20,
|
||||
SingleMissionDuration = 0x40,
|
||||
ActiveOnlyOnZoneSupport = 0x80,
|
||||
ApplyToFirstMission = 0x100,
|
||||
IsSpecialization = 0x200,
|
||||
IsEmptySlot = 0x400
|
||||
}
|
||||
|
||||
public enum GarrisonError
|
||||
{
|
||||
Success = 0,
|
||||
NoGarrison = 1,
|
||||
GarrisonExists = 2,
|
||||
GarrisonSameTypeExists = 3,
|
||||
InvalidGarrison = 4,
|
||||
InvalidGarrisonLevel = 5,
|
||||
GarrisonLevelUnchanged = 6,
|
||||
NotInGarrison = 7,
|
||||
NoBuilding = 8,
|
||||
BuildingExists = 9,
|
||||
InvalidPlotInstanceId = 10,
|
||||
InvalidBuildingId = 11,
|
||||
InvalidUpgradeLevel = 12,
|
||||
UpgradeLevelExceedsGarrisonLevel = 13,
|
||||
PlotsNotFull = 14,
|
||||
InvalidSiteId = 15,
|
||||
InvalidPlotBuilding = 16,
|
||||
InvalidFaction = 17,
|
||||
InvalidSpecialization = 18,
|
||||
SpecializationExists = 19,
|
||||
SpecializationOnCooldown = 20,
|
||||
BlueprintExists = 21,
|
||||
RequiresBlueprint = 22,
|
||||
InvalidDoodadSetId = 23,
|
||||
BuildingTypeExists = 24,
|
||||
BuildingNotActive = 25,
|
||||
ConstructionComplete = 26,
|
||||
FollowerExists = 27,
|
||||
InvalidFollower = 28,
|
||||
FollowerAlreadyOnMission = 29,
|
||||
FollowerInBuilding = 30,
|
||||
FollowerInvalidForBuilding = 31,
|
||||
InvalidFollowerLevel = 32,
|
||||
MissionExists = 33,
|
||||
InvalidMission = 34,
|
||||
InvalidMissionTime = 35,
|
||||
InvalidMissionRewardIndex = 36,
|
||||
MissionNotOffered = 37,
|
||||
AlreadyOnMission = 38,
|
||||
MissionSizeInvalid = 39,
|
||||
FollowerSoftCapExceeded = 40,
|
||||
NotOnMission = 41,
|
||||
AlreadyCompletedMission = 42,
|
||||
MissionNotComplete = 43,
|
||||
MissionRewardsPending = 44,
|
||||
MissionExpired = 45,
|
||||
NotEnoughCurrency = 46,
|
||||
NotEnoughGold = 47,
|
||||
BuildingMissing = 48,
|
||||
NoArchitect = 49,
|
||||
ArchitectNotAvailable = 50,
|
||||
NoMissionNpc = 51,
|
||||
MissionNpcNotAvailable = 52,
|
||||
InternalError = 53,
|
||||
InvalidStaticTableValue = 54,
|
||||
InvalidItemLevel = 55,
|
||||
InvalidAvailableRecruit = 56,
|
||||
FollowerAlreadyRecruited = 57,
|
||||
RecruitmentGenerationInProgress = 58,
|
||||
RecruitmentOnCooldown = 59,
|
||||
RecruitBlockedByGeneration = 60,
|
||||
RecruitmentNpcNotAvailable = 61,
|
||||
InvalidFollowerQuality = 62,
|
||||
ProxyNotOk = 63,
|
||||
RecallPortalUsedLessThan24HoursAgo = 64,
|
||||
OnRemoveBuildingSpellFailed = 65,
|
||||
OperationNotSupported = 66,
|
||||
FollowerFatigued = 67,
|
||||
UpgradeConditionFailed = 68,
|
||||
FollowerInactive = 69,
|
||||
FollowerActive = 70,
|
||||
FollowerActivationUnavailable = 71,
|
||||
FollowerTypeMismatch = 72,
|
||||
InvalidGarrisonType = 73,
|
||||
MissionStartConditionFailed = 74,
|
||||
InvalidFollowerAbility = 75,
|
||||
InvalidMissionBonusAbility = 76,
|
||||
HigherBuildingTypeExists = 77,
|
||||
AtFollowerHardCap = 78,
|
||||
FollowerCannotGainXp = 79,
|
||||
NoOp = 80,
|
||||
AtClassSpecCap = 81,
|
||||
MissionRequires100ToStart = 82,
|
||||
MissionMissingRequiredFollower = 83,
|
||||
InvalidTalent = 84,
|
||||
AlreadyResearchingTalent = 85,
|
||||
FailedCondition = 86,
|
||||
InvalidTier = 87,
|
||||
InvalidClass = 88
|
||||
}
|
||||
|
||||
public enum GarrisonFollowerStatus
|
||||
{
|
||||
Favorite = 0x01,
|
||||
Exhausted = 0x02,
|
||||
Inactive = 0x04,
|
||||
Troop = 0x08,
|
||||
NoXpGain = 0x10
|
||||
}
|
||||
|
||||
public enum GarrisonType
|
||||
{
|
||||
Garrison = 2,
|
||||
ClassOrder = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum GossipOption
|
||||
{
|
||||
None = 0, //Unit_Npc_Flag_None (0)
|
||||
Gossip = 1, //Unit_Npc_Flag_Gossip (1)
|
||||
Questgiver = 2, //Unit_Npc_Flag_Questgiver (2)
|
||||
Vendor = 3, //Unit_Npc_Flag_Vendor (128)
|
||||
Taxivendor = 4, //Unit_Npc_Flag_Taxivendor (8192)
|
||||
Trainer = 5, //Unit_Npc_Flag_Trainer (16)
|
||||
Spirithealer = 6, //Unit_Npc_Flag_Spirithealer (16384)
|
||||
Spiritguide = 7, //Unit_Npc_Flag_Spiritguide (32768)
|
||||
Innkeeper = 8, //Unit_Npc_Flag_Innkeeper (65536)
|
||||
Banker = 9, //Unit_Npc_Flag_Banker (131072)
|
||||
Petitioner = 10, //Unit_Npc_Flag_Petitioner (262144)
|
||||
Tabarddesigner = 11, //Unit_Npc_Flag_Tabarddesigner (524288)
|
||||
Battlefield = 12, //Unit_Npc_Flag_Battlefieldperson (1048576)
|
||||
Auctioneer = 13, //Unit_Npc_Flag_Auctioneer (2097152)
|
||||
Stablepet = 14, //Unit_Npc_Flag_Stable (4194304)
|
||||
Armorer = 15, //Unit_Npc_Flag_Armorer (4096)
|
||||
Unlearntalents = 16, //Unit_Npc_Flag_Trainer (16) (Bonus Option For Trainer)
|
||||
Unlearnpettalents_Old = 17, // deprecated
|
||||
Learndualspec = 18, //Unit_Npc_Flag_Trainer (16) (Bonus Option For Trainer)
|
||||
Outdoorpvp = 19, //Added By Code (Option For Outdoor Pvp Creatures)
|
||||
Max
|
||||
}
|
||||
|
||||
public enum GossipOptionIcon
|
||||
{
|
||||
Chat = 0, // White Chat Bubble
|
||||
Vendor = 1, // Brown Bag
|
||||
Taxi = 2, // Flightmarker (Paperplane)
|
||||
Trainer = 3, // Brown Book (Trainer)
|
||||
Interact1 = 4, // Golden Interaction Wheel
|
||||
Interact2 = 5, // Golden Interaction Wheel
|
||||
MoneyBag = 6, // Brown Bag (With Gold Coin In Lower Corner)
|
||||
Talk = 7, // White Chat Bubble (With "..." Inside)
|
||||
Tabard = 8, // White Tabard
|
||||
Battle = 9, // Two Crossed Swords
|
||||
Dot = 10, // Yellow Dot/Point
|
||||
Chat11 = 11, // White Chat Bubble
|
||||
Chat12 = 12, // White Chat Bubble
|
||||
Chat13 = 13, // White Chat Bubble
|
||||
Unk14 = 14, // Invalid - Do Not Use
|
||||
Unk15 = 15, // Invalid - Do Not Use
|
||||
Chat16 = 16, // White Chat Bubble
|
||||
Chat17 = 17, // White Chat Bubble
|
||||
Chat18 = 18, // White Chat Bubble
|
||||
Chat19 = 19, // White Chat Bubble
|
||||
Chat20 = 20, // White Chat Bubble
|
||||
Chat21 = 21, // transmogrifier?
|
||||
Max
|
||||
}
|
||||
|
||||
public struct eTradeskill
|
||||
{
|
||||
// Skill Defines
|
||||
public const uint TradeskillAlchemy = 1;
|
||||
public const uint TradeskillBlacksmithing = 2;
|
||||
public const uint TradeskillCooking = 3;
|
||||
public const uint TradeskillEnchanting = 4;
|
||||
public const uint TradeskillEngineering = 5;
|
||||
public const uint TradeskillFirstaid = 6;
|
||||
public const uint TradeskillHerbalism = 7;
|
||||
public const uint TradeskillLeatherworking = 8;
|
||||
public const uint TradeskillPoisons = 9;
|
||||
public const uint TradeskillTailoring = 10;
|
||||
public const uint TradeskillMining = 11;
|
||||
public const uint TradeskillFishing = 12;
|
||||
public const uint TradeskillSkinning = 13;
|
||||
public const uint TradeskillJewlcrafting = 14;
|
||||
public const uint TradeskillInscription = 15;
|
||||
|
||||
public const uint TradeskillLevelNone = 0;
|
||||
public const uint TradeskillLevelApprentice = 1;
|
||||
public const uint TradeskillLevelJourneyman = 2;
|
||||
public const uint TradeskillLevelExpert = 3;
|
||||
public const uint TradeskillLevelArtisan = 4;
|
||||
public const uint TradeskillLevelMaster = 5;
|
||||
public const uint TradeskillLevelGrandMaster = 6;
|
||||
|
||||
// Gossip Defines
|
||||
public const uint GossipActionTrade = 1;
|
||||
public const uint GossipActionTrain = 2;
|
||||
public const uint GossipActionTaxi = 3;
|
||||
public const uint GossipActionGuild = 4;
|
||||
public const uint GossipActionBattle = 5;
|
||||
public const uint GossipActionBank = 6;
|
||||
public const uint GossipActionInn = 7;
|
||||
public const uint GossipActionHeal = 8;
|
||||
public const uint GossipActionTabard = 9;
|
||||
public const uint GossipActionAuction = 10;
|
||||
public const uint GossipActionInnInfo = 11;
|
||||
public const uint GossipActionUnlearn = 12;
|
||||
public const uint GossipActionInfoDef = 1000;
|
||||
|
||||
public const uint GossipSenderMain = 1;
|
||||
public const uint GossipSenderInnInfo = 2;
|
||||
public const uint GossipSenderInfo = 3;
|
||||
public const uint GossipSenderSecProftrain = 4;
|
||||
public const uint GossipSenderSecClasstrain = 5;
|
||||
public const uint GossipSenderSecBattleinfo = 6;
|
||||
public const uint GossipSenderSecBank = 7;
|
||||
public const uint GossipSenderSecInn = 8;
|
||||
public const uint GossipSenderSecMailbox = 9;
|
||||
public const uint GossipSenderSecStablemaster = 10;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum RemoveMethod
|
||||
{
|
||||
Default = 0,
|
||||
Kick = 1,
|
||||
Leave = 2,
|
||||
KickLFG = 3
|
||||
}
|
||||
|
||||
public enum GroupMemberOnlineStatus
|
||||
{
|
||||
Offline = 0x00,
|
||||
Online = 0x01, // Lua_UnitIsConnected
|
||||
PVP = 0x02, // Lua_UnitIsPVP
|
||||
Dead = 0x04, // Lua_UnitIsDead
|
||||
Ghost = 0x08, // Lua_UnitIsGhost
|
||||
PVPFFA = 0x10, // Lua_UnitIsPVPFreeForAll
|
||||
Unk3 = 0x20, // used in calls from Lua_GetPlayerMapPosition/Lua_GetBattlefieldFlagPosition
|
||||
AFK = 0x40, // Lua_UnitIsAFK
|
||||
DND = 0x80, // Lua_UnitIsDND
|
||||
RAF = 0x100,
|
||||
Vehicle = 0x200, // Lua_UnitInVehicle
|
||||
}
|
||||
|
||||
public enum GroupMemberFlags
|
||||
{
|
||||
Assistant = 0x01,
|
||||
MainTank = 0x02,
|
||||
MainAssist = 0x04
|
||||
}
|
||||
|
||||
public enum GroupMemberAssignment
|
||||
{
|
||||
MainTank = 0,
|
||||
MainAssist = 1
|
||||
}
|
||||
|
||||
public enum GroupType
|
||||
{
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
WorldPvp = 4,
|
||||
}
|
||||
|
||||
public enum GroupFlags
|
||||
{
|
||||
None = 0x00,
|
||||
FakeRaid = 0x01,
|
||||
Raid = 0x02,
|
||||
LfgRestricted = 0x04, // Script_HasLFGRestrictions()
|
||||
Lfg = 0x08,
|
||||
Destroyed = 0x10,
|
||||
OnePersonParty = 0x020, // Script_IsOnePersonParty()
|
||||
EveryoneAssistant = 0x040, // Script_IsEveryoneAssistant()
|
||||
GuildGroup = 0x100,
|
||||
|
||||
MaskBgRaid = FakeRaid | Raid
|
||||
}
|
||||
|
||||
public enum GroupUpdateFlags
|
||||
{
|
||||
None = 0x00, // nothing
|
||||
Unk704 = 0x01, // Uint8[2] (Unk)
|
||||
Status = 0x02, // public ushort (Groupmemberstatusflag)
|
||||
PowerType = 0x04, // Uint8 (Powertype)
|
||||
Unk322 = 0x08, // public ushort (Unk)
|
||||
CurHp = 0x10, // Uint32 (Hp)
|
||||
MaxHp = 0x20, // Uint32 (Max Hp)
|
||||
CurPower = 0x40, // Int16 (Power Value)
|
||||
MaxPower = 0x80, // Int16 (Max Power Value)
|
||||
Level = 0x100, // public ushort (Level Value)
|
||||
Unk200000 = 0x200, // Int16 (Unk)
|
||||
Zone = 0x400, // public ushort (Zone Id)
|
||||
Unk2000000 = 0x800, // Int16 (Unk)
|
||||
Unk4000000 = 0x1000, // Int32 (Unk)
|
||||
Position = 0x2000, // public ushort (X), public ushort (Y), public ushort (Z)
|
||||
VehicleSeat = 0x4000, // Int32 (Vehicle Seat Id)
|
||||
Auras = 0x8000, // Uint8 (Unk), Uint64 (Mask), Uint32 (Count), For Each Bit Set: Uint32 (Spell Id) + public ushort (Auraflags) (If Has Flags Scalable -> 3x Int32 (Bps))
|
||||
Pet = 0x10000, // Complex (Pet)
|
||||
Phase = 0x20000, // Int32 (Unk), Uint32 (Phase Count), For (Count) Uint16(Phaseid)
|
||||
|
||||
Full = Unk704 | Status | PowerType | Unk322 | CurHp | MaxHp |
|
||||
CurPower | MaxPower | Level | Unk200000 | Zone | Unk2000000 |
|
||||
Unk4000000 | Position | VehicleSeat | Auras | Pet | Phase // All Known Flags
|
||||
}
|
||||
|
||||
public enum GroupUpdatePetFlags
|
||||
{
|
||||
None = 0x00000000, // nothing
|
||||
GUID = 0x00000001, // ObjectGuid (pet guid)
|
||||
Name = 0x00000002, // cstring (name, NULL terminated string)
|
||||
ModelId = 0x00000004, // public ushort (model id)
|
||||
CurHp = 0x00000008, // uint32 (HP)
|
||||
MaxHp = 0x00000010, // uint32 (max HP)
|
||||
Auras = 0x00000020, // [see GROUP_UPDATE_FLAG_AURAS]
|
||||
|
||||
Full = GUID | Name | ModelId | CurHp | MaxHp | Auras // all pet flags
|
||||
}
|
||||
|
||||
public enum PartyResult
|
||||
{
|
||||
Ok = 0,
|
||||
BadPlayerNameS = 1,
|
||||
TargetNotInGroupS = 2,
|
||||
TargetNotInInstanceS = 3,
|
||||
GroupFull = 4,
|
||||
AlreadyInGroupS = 5,
|
||||
NotInGroup = 6,
|
||||
NotLeader = 7,
|
||||
PlayerWrongFaction = 8,
|
||||
IgnoringYouS = 9,
|
||||
LfgPending = 12,
|
||||
InviteRestricted = 13,
|
||||
GroupSwapFailed = 14, // If (Partyoperation == PartyOpSwap) GroupSwapFailed Else InviteInCombat
|
||||
InviteUnknownRealm = 15,
|
||||
InviteNoPartyServer = 16,
|
||||
InvitePartyBusy = 17,
|
||||
PartyTargetAmbiguous = 18,
|
||||
PartyLfgInviteRaidLocked = 19,
|
||||
PartyLfgBootLimit = 20,
|
||||
PartyLfgBootCooldownS = 21,
|
||||
PartyLfgBootInProgress = 22,
|
||||
PartyLfgBootTooFewPlayers = 23,
|
||||
PartyLfgBootNotEligibleS = 24,
|
||||
RaidDisallowedByLevel = 25,
|
||||
PartyLfgBootInCombat = 26,
|
||||
VoteKickReasonNeeded = 27,
|
||||
PartyLfgBootDungeonComplete = 28,
|
||||
PartyLfgBootLootRolls = 29,
|
||||
PartyLfgTeleportInCombat = 30
|
||||
}
|
||||
|
||||
public enum PartyOperation
|
||||
{
|
||||
Invite = 0,
|
||||
UnInvite = 1,
|
||||
Leave = 2,
|
||||
Swap = 4
|
||||
}
|
||||
|
||||
public enum GroupCategory
|
||||
{
|
||||
Home = 0,
|
||||
Instance = 1,
|
||||
|
||||
Max
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public class GuildConst
|
||||
{
|
||||
public const int MaxBankTabs = 8;
|
||||
public const int MaxBankSlots = 98;
|
||||
public const int BankMoneyLogsTab = 100;
|
||||
|
||||
public const uint WithdrawMoneyUnlimited = 0xFFFFFFFF;
|
||||
public const int WithdrawSlotUnlimited = -1;
|
||||
public const uint EventLogGuidUndefined = 0xFFFFFFFF;
|
||||
|
||||
public const uint ChallengesTypes = 6;
|
||||
public const uint CharterItemId = 5863;
|
||||
|
||||
public const int RankNone = 0xFF;
|
||||
public const int MinRanks = 5;
|
||||
public const int MaxRanks = 10;
|
||||
|
||||
public const int BankLogMaxRecords = 25;
|
||||
public const int EventLogMaxRecords = 100;
|
||||
public const int NewsLogMaxRecords = 250;
|
||||
|
||||
public static int[] ChallengeGoldReward = { 0, 250, 1000, 500, 250, 500 };
|
||||
public static int[] ChallengeMaxLevelGoldReward = { 0, 125, 500, 250, 125, 250 };
|
||||
public static int[] ChallengesMaxCount = { 0, 7, 1, 3, 0, 3 };
|
||||
|
||||
public static uint MinNewsItemLevel = 353;
|
||||
|
||||
public static byte OldMaxLevel = 25;
|
||||
}
|
||||
|
||||
public enum GuildRankRights
|
||||
{
|
||||
None = 0x00000000,
|
||||
GChatListen = 0x00000001,
|
||||
GChatSpeak = 0x00000002,
|
||||
OffChatListen = 0x00000004,
|
||||
OffChatSpeak = 0x00000008,
|
||||
Invite = 0x00000010,
|
||||
Remove = 0x00000020,
|
||||
Roster = 0x00000040,
|
||||
Promote = 0x00000080,
|
||||
Demote = 0x00000100,
|
||||
Unk200 = 0x00000200,
|
||||
Unk400 = 0x00000400,
|
||||
Unk800 = 0x00000800,
|
||||
SetMotd = 0x00001000,
|
||||
EditPublicNote = 0x00002000,
|
||||
ViewOffNote = 0x00004000,
|
||||
EOffNote = 0x00008000,
|
||||
ModifyGuildInfo = 0x00010000,
|
||||
WithdrawGoldLock = 0x00020000, // remove money withdraw capacity
|
||||
WithdrawRepair = 0x00040000, // withdraw for repair
|
||||
WithdrawGold = 0x00080000, // withdraw gold
|
||||
CreateGuildEvent = 0x00100000, // wotlk
|
||||
All = 0x00DDFFBF
|
||||
}
|
||||
|
||||
public struct GuildDefaultRanks
|
||||
{
|
||||
public const int Master = 0;
|
||||
public const int Officer = 1;
|
||||
public const int Veteran = 2;
|
||||
public const int Member = 3;
|
||||
public const int Initiate = 4;
|
||||
}
|
||||
|
||||
public enum GuildMemberFlags
|
||||
{
|
||||
None = 0,
|
||||
Online = 1,
|
||||
AFK = 2,
|
||||
DND = 3,
|
||||
Mobile = 4
|
||||
}
|
||||
|
||||
public enum GuildMemberData
|
||||
{
|
||||
ZoneId,
|
||||
AchievementPoints,
|
||||
Level,
|
||||
}
|
||||
|
||||
public enum GuildCommandType
|
||||
{
|
||||
CreateGuild = 0,
|
||||
InvitePlayer = 1,
|
||||
LeaveGuild = 3,
|
||||
GetRoster = 5,
|
||||
PromotePlayer = 6,
|
||||
DemotePlayer = 7,
|
||||
RemovePlayer = 8,
|
||||
ChangeLeader = 10,
|
||||
EditMOTD = 11,
|
||||
GuildChat = 13,
|
||||
Founder = 14,
|
||||
ChangeRank = 16,
|
||||
EditPublicNote = 19,
|
||||
ViewTab = 21,
|
||||
MoveItem = 22,
|
||||
Repair = 25
|
||||
}
|
||||
|
||||
public enum GuildCommandError
|
||||
{
|
||||
Success = 0,
|
||||
GuildInternal = 1,
|
||||
AlreadyInGuild = 2,
|
||||
AlreadyInGuild_S = 3,
|
||||
InvitedToGuild = 4,
|
||||
AlreadyInvitedToGuild_S = 5,
|
||||
NameInvalid = 6,
|
||||
NameExists_S = 7,
|
||||
LeaderLeave = 8,
|
||||
Permissions = 8,
|
||||
PlayerNotInGuild = 9,
|
||||
PlayerNotInGuild_S = 10,
|
||||
PlayerNotFound_S = 11,
|
||||
NotAllied = 12,
|
||||
RankTooHigh_S = 13,
|
||||
RankTooLow_S = 14,
|
||||
RanksLocked = 17,
|
||||
RankInUse = 18,
|
||||
IgnoringYou_S = 19,
|
||||
Unk1 = 20,
|
||||
WithdrawLimit = 25,
|
||||
NotEnoughMoney = 26,
|
||||
BankFull = 28,
|
||||
ItemNotFound = 29,
|
||||
TooMuchMoney = 31,
|
||||
WrongTab = 32,
|
||||
RequiresAuthenticator = 34,
|
||||
BankVoucherFailed = 35,
|
||||
TrialAccount = 36,
|
||||
UndeletableDueToLevel = 37,
|
||||
MoveStarting = 38,
|
||||
RepTooLow = 39
|
||||
}
|
||||
|
||||
public enum GuildEventLogTypes
|
||||
{
|
||||
InvitePlayer = 1,
|
||||
JoinGuild = 2,
|
||||
PromotePlayer = 3,
|
||||
DemotePlayer = 4,
|
||||
UninvitePlayer = 5,
|
||||
LeaveGuild = 6,
|
||||
}
|
||||
|
||||
public enum GuildBankEventLogTypes
|
||||
{
|
||||
DepositItem = 1,
|
||||
WithdrawItem = 2,
|
||||
MoveItem = 3,
|
||||
DepositMoney = 4,
|
||||
WithdrawMoney = 5,
|
||||
RepairMoney = 6,
|
||||
MoveItem2 = 7,
|
||||
Unk1 = 8,
|
||||
BuySlot = 9,
|
||||
CashFlowDeposit = 10
|
||||
}
|
||||
|
||||
public enum GuildEmblemError
|
||||
{
|
||||
Success = 0,
|
||||
InvalidTabardColors = 1,
|
||||
NoGuild = 2,
|
||||
NotGuildMaster = 3,
|
||||
NotEnoughMoney = 4,
|
||||
InvalidVendor = 5
|
||||
}
|
||||
|
||||
public enum GuildBankRights : int
|
||||
{
|
||||
ViewTab = 0x01,
|
||||
PutItem = 0x02,
|
||||
UpdateText = 0x04,
|
||||
|
||||
DepositItem = ViewTab | PutItem,
|
||||
Full = -1
|
||||
}
|
||||
|
||||
public enum GuildNews
|
||||
{
|
||||
Achievement = 0,
|
||||
PlayerAchievement = 1,
|
||||
DungeonEncounter = 2,
|
||||
ItemLooted = 3,
|
||||
ItemCrafted = 4,
|
||||
ItemPurchased = 5,
|
||||
LevelUp = 6,
|
||||
Create = 7,
|
||||
Event = 8
|
||||
}
|
||||
|
||||
public enum PetitionTurns
|
||||
{
|
||||
Ok = 0,
|
||||
AlreadyInGuild = 2,
|
||||
NeedMoreSignatures = 4,
|
||||
GuildPermissions = 11,
|
||||
GuildNameInvalid = 12
|
||||
}
|
||||
|
||||
public enum PetitionSigns
|
||||
{
|
||||
Ok = 0,
|
||||
AlreadySigned = 1,
|
||||
AlreadyInGuild = 2,
|
||||
CantSignOwn = 3,
|
||||
NotServer = 4,
|
||||
Full = 5,
|
||||
AlreadySignedOther = 6,
|
||||
RestrictedAccount = 7
|
||||
}
|
||||
|
||||
public enum CharterTypes
|
||||
{
|
||||
Guild = 4,
|
||||
Arena2v2 = 2,
|
||||
Arena3v3 = 3,
|
||||
Arena5v5 = 5,
|
||||
}
|
||||
|
||||
public struct CharterCosts
|
||||
{
|
||||
public const uint Guild = 1000;
|
||||
public const uint Arena2v2 = 800000;
|
||||
public const uint Arena3v3 = 1200000;
|
||||
public const uint Arena5v5 = 2000000;
|
||||
}
|
||||
|
||||
public enum GuildFinderOptionsInterest
|
||||
{
|
||||
Questing = 0x01,
|
||||
Dungeons = 0x02,
|
||||
Raids = 0x04,
|
||||
PVP = 0x08,
|
||||
RolePlaying = 0x10,
|
||||
All = Questing | Dungeons | Raids | PVP | RolePlaying
|
||||
}
|
||||
|
||||
public enum GuildFinderOptionsAvailability
|
||||
{
|
||||
Weekdays = 0x1,
|
||||
Weekends = 0x2,
|
||||
Always = Weekdays | Weekends
|
||||
}
|
||||
|
||||
public enum GuildFinderOptionsRoles
|
||||
{
|
||||
Tank = 0x1,
|
||||
Healer = 0x2,
|
||||
DPS = 0x4,
|
||||
All = Tank | Healer | DPS
|
||||
}
|
||||
|
||||
public enum GuildFinderOptionsLevel
|
||||
{
|
||||
Any = 0x1,
|
||||
Max = 0x2,
|
||||
All = Any | Max
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
[Flags]
|
||||
public enum LfgRoles
|
||||
{
|
||||
None = 0x00,
|
||||
Leader = 0x01,
|
||||
Tank = 0x02,
|
||||
Healer = 0x04,
|
||||
Damage = 0x08
|
||||
}
|
||||
|
||||
public enum LfgUpdateType
|
||||
{
|
||||
Default = 0, // Internal Use
|
||||
LeaderUnk1 = 1, // Fixme: At Group Leave
|
||||
RolecheckAborted = 4,
|
||||
JoinQueue = 6,
|
||||
RolecheckFailed = 7,
|
||||
RemovedFromQueue = 8,
|
||||
ProposalFailed = 9,
|
||||
ProposalDeclined = 10,
|
||||
GroupFound = 11,
|
||||
AddedToQueue = 13,
|
||||
SuspendedQueue = 14,
|
||||
ProposalBegin = 15,
|
||||
UpdateStatus = 16,
|
||||
GroupMemberOffline = 17,
|
||||
GroupDisbandUnk16 = 18, // FIXME: Sometimes at group disband
|
||||
JoinQueueInitial = 25,
|
||||
DungeonFinished = 26,
|
||||
PartyRoleNotAvailable = 46,
|
||||
JoinLfgObjectFailed = 48,
|
||||
RemovedLevelup = 49,
|
||||
RemovedXpToggle = 50,
|
||||
RemovedFactionChange = 51
|
||||
}
|
||||
|
||||
public enum LfgState
|
||||
{
|
||||
None,
|
||||
Rolecheck,
|
||||
Queued,
|
||||
Proposal,
|
||||
//Boot,
|
||||
Dungeon = 5,
|
||||
FinishedDungeon,
|
||||
Raidbrowser
|
||||
}
|
||||
|
||||
public enum LfgQueueType
|
||||
{
|
||||
Dungeon = 1,
|
||||
LRF = 2,
|
||||
Scenario = 3,
|
||||
Flex = 4,
|
||||
WorldPvP = 5
|
||||
}
|
||||
|
||||
public enum LfgLockStatusType
|
||||
{
|
||||
InsufficientExpansion = 1,
|
||||
TooLowLevel = 2,
|
||||
TooHighLevel = 3,
|
||||
TooLowGearScore = 4,
|
||||
TooHighGearScore = 5,
|
||||
RaidLocked = 6,
|
||||
AttunementTooLowLevel = 1001,
|
||||
AttunementTooHighLevel = 1002,
|
||||
QuestNotCompleted = 1022,
|
||||
MissingItem = 1025,
|
||||
NotInSeason = 1031,
|
||||
MissingAchievement = 1034
|
||||
}
|
||||
|
||||
public enum LfgOptions
|
||||
{
|
||||
EnableDungeonFinder = 0x01,
|
||||
EnableRaidBrowser = 0x02,
|
||||
}
|
||||
|
||||
public enum LfgFlags
|
||||
{
|
||||
Unk1 = 0x1,
|
||||
Unk2 = 0x2,
|
||||
Seasonal = 0x4,
|
||||
Unk3 = 0x8
|
||||
}
|
||||
|
||||
public enum LfgType : byte
|
||||
{
|
||||
None = 0,
|
||||
Dungeon = 1,
|
||||
Raid = 2,
|
||||
Zone = 4,
|
||||
Quest = 5,
|
||||
RandomDungeon = 6
|
||||
}
|
||||
|
||||
public enum LfgProposalState
|
||||
{
|
||||
Initiating = 0,
|
||||
Failed = 1,
|
||||
Success = 2
|
||||
}
|
||||
|
||||
public enum LfgTeleportResult
|
||||
{
|
||||
// 7 = "You Can'T Do That Right Now" | 5 = No Client Reaction
|
||||
None = 0, // Internal Use
|
||||
Dead = 1,
|
||||
Falling = 2,
|
||||
OnTransport = 3,
|
||||
Exhaustion = 4,
|
||||
NoReturnLocation = 6,
|
||||
ImmuneToSummons = 8 // Fixme - It Can Be 7 Or 8 (Need Proper Data)
|
||||
|
||||
// unknown values
|
||||
//LFG_TELEPORT_RESULT_NOT_IN_DUNGEON,
|
||||
//LFG_TELEPORT_RESULT_NOT_ALLOWED,
|
||||
//LFG_TELEPORT_RESULT_ALREADY_IN_DUNGEON
|
||||
}
|
||||
|
||||
public enum LfgJoinResult
|
||||
{
|
||||
// 3 = No client reaction | 18 = "Rolecheck failed"
|
||||
Ok = 0x00, // Joined (No Client Msg)
|
||||
GroupFull = 0x1f, // Your Group Is Already Full.
|
||||
NoLfgObject = 0x21, // Internal Lfg Error.
|
||||
NoSlotsPlayer = 0x22, // You Do Not Meet The Requirements For The Chosen Dungeons.
|
||||
MismatchedSlots = 0x23, // You Cannot Mix Dungeons, Raids, And Random When Picking Dungeons.
|
||||
PartyPlayersFromDifferentRealms = 0x24, // The Dungeon You Chose Does Not Support Players From Multiple Realms.
|
||||
MembersNotPresent = 0x25, // One Or More Group Members Are Pending Invites Or Disconnected.
|
||||
GetInfoTimeout = 0x26, // Could Not Retrieve Information About Some Party Members.
|
||||
InvalidSlot = 0x27, // One Or More Dungeons Was Not Valid.
|
||||
DeserterPlayer = 0x28, // You Can Not Queue For Dungeons Until Your Deserter Debuff Wears Off.
|
||||
DeserterParty = 0x29, // One Or More Party Members Has A Deserter Debuff.
|
||||
RandomCooldownPlayer = 0x2a, // You Can Not Queue For Random Dungeons While On Random Dungeon Cooldown.
|
||||
RandomCooldownParty = 0x2b, // One Or More Party Members Are On Random Dungeon Cooldown.
|
||||
TooManyMembers = 0x2c, // You Have Too Many Group Members To Queue For That.
|
||||
CantUseDungeons = 0x2d, // You Cannot Queue For A Dungeon Or Raid While Using Battlegrounds Or Arenas.
|
||||
RoleCheckFailed = 0x2e, // The Role Check Has Failed.
|
||||
TooFewMembers = 0x34, // You Do Not Have Enough Group Members To Queue For That.
|
||||
ReasonTooManyLfg = 0x35, // You Are Queued For Too Many Instances.
|
||||
MismatchedSlotsLocalXrealm = 0x37, // You Cannot Mix Realm-Only And X-Realm Entries When Listing Your Name In Other Raids.
|
||||
AlreadyUsingLfgList = 0x3f, // You Can'T Do That While Using Premade Groups.
|
||||
NotLeader = 0x45, // You Are Not The Party Leader.
|
||||
Dead = 0x49,
|
||||
|
||||
PartyNotMeetReqs = 6, // One Or More Party Members Do Not Meet The Requirements For The Chosen Dungeons (Fixme)
|
||||
}
|
||||
|
||||
public enum LfgRoleCheckState
|
||||
{
|
||||
Default = 0, // Internal Use = Not Initialized.
|
||||
Finished = 1, // Role Check Finished
|
||||
Initialiting = 2, // Role Check Begins
|
||||
MissingRole = 3, // Someone Didn'T Selected A Role After 2 Mins
|
||||
WrongRoles = 4, // Can'T Form A Group With That Role Selection
|
||||
Aborted = 5, // Someone Leave The Group
|
||||
NoRole = 6 // Someone Selected No Role
|
||||
}
|
||||
|
||||
public enum LfgAnswer
|
||||
{
|
||||
Pending = -1,
|
||||
Deny = 0,
|
||||
Agree = 1
|
||||
}
|
||||
|
||||
public enum LfgCompatibility
|
||||
{
|
||||
Pending,
|
||||
WrongGroupSize,
|
||||
TooMuchPlayers,
|
||||
MultipleLfgGroups,
|
||||
HasIgnores,
|
||||
NoRoles,
|
||||
NoDungeons,
|
||||
WithLessPlayers, // Values Under This = Not Compatible (Do Not Modify Order)
|
||||
BadStates,
|
||||
Match // Must Be The Last One
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum RollType
|
||||
{
|
||||
Pass = 0,
|
||||
Need = 1,
|
||||
Greed = 2,
|
||||
Disenchant = 3,
|
||||
NotEmitedYet = 4,
|
||||
NotValid = 5,
|
||||
|
||||
MaxTypes = 4,
|
||||
}
|
||||
|
||||
public enum RollMask
|
||||
{
|
||||
Pass = 0x01,
|
||||
Need = 0x02,
|
||||
Greed = 0x04,
|
||||
Disenchant = 0x08,
|
||||
|
||||
AllNoDisenchant = 0x07,
|
||||
AllMask = 0x0f
|
||||
}
|
||||
|
||||
public enum LootMethod
|
||||
{
|
||||
FreeForAll = 0,
|
||||
MasterLoot = 2,
|
||||
GroupLoot = 3,
|
||||
PersonalLoot = 5
|
||||
}
|
||||
|
||||
public enum LootModes
|
||||
{
|
||||
Default = 0x1,
|
||||
HardMode1 = 0x2,
|
||||
HardMode2 = 0x4,
|
||||
HardMode3 = 0x8,
|
||||
HardMode4 = 0x10,
|
||||
JunkFish = 0x8000
|
||||
}
|
||||
|
||||
public enum PermissionTypes
|
||||
{
|
||||
All = 0,
|
||||
Group = 1,
|
||||
Master = 2,
|
||||
Restricted = 3,
|
||||
Owner = 5,
|
||||
None = 6
|
||||
}
|
||||
|
||||
public enum LootType
|
||||
{
|
||||
None = 0,
|
||||
Corpse = 1,
|
||||
Pickpocketing = 2,
|
||||
Fishing = 3,
|
||||
Disenchanting = 4,
|
||||
// Ignored Always By Client
|
||||
Skinning = 6,
|
||||
Prospecting = 7,
|
||||
Milling = 8,
|
||||
|
||||
Fishinghole = 20, // Unsupported By Client, Sending Fishing Instead
|
||||
Insignia = 21, // Unsupported By Client, Sending Corpse Instead
|
||||
FishingJunk = 22 // unsupported by client, sending LOOT_FISHING instead
|
||||
}
|
||||
|
||||
public enum LootError
|
||||
{
|
||||
DidntKill = 0, // You don't have permission to loot that corpse.
|
||||
TooFar = 4, // You are too far away to loot that corpse.
|
||||
BadFacing = 5, // You must be facing the corpse to loot it.
|
||||
Locked = 6, // Someone is already looting that corpse.
|
||||
NotStanding = 8, // You need to be standing up to loot something!
|
||||
Stunned = 9, // You can't loot anything while stunned!
|
||||
PlayerNotFound = 10, // Player not found
|
||||
PlayTimeExceeded = 11, // Maximum play time exceeded
|
||||
MasterInvFull = 12, // That player's inventory is full
|
||||
MasterUniqueItem = 13, // Player has too many of that item already
|
||||
MasterOther = 14, // Can't assign item to that player
|
||||
AlreadPickPocketed = 15, // Your target has already had its pockets picked
|
||||
NotWhileShapeShifted = 16, // You can't do that while shapeshifted.
|
||||
NoLoot = 17 // There is no loot.
|
||||
}
|
||||
|
||||
// type of Loot Item in Loot View
|
||||
public enum LootSlotType
|
||||
{
|
||||
AllowLoot = 0, // Player Can Loot The Item.
|
||||
RollOngoing = 1, // Roll Is Ongoing. Player Cannot Loot.
|
||||
Locked = 2, // Item Is Shown In Red. Player Cannot Loot.
|
||||
Master = 3, // Item Can Only Be Distributed By Group Loot Master.
|
||||
Owner = 4 // Ignore Binding Confirmation And Etc, For Single Player Looting
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum MailMessageType
|
||||
{
|
||||
Normal = 0,
|
||||
Auction = 2,
|
||||
Creature = 3,
|
||||
Gameobject = 4,
|
||||
Calendar = 5,
|
||||
Blackmarket = 6
|
||||
}
|
||||
|
||||
public enum MailCheckMask
|
||||
{
|
||||
None = 0x00,
|
||||
Read = 0x01,
|
||||
Returned = 0x02, /// This Mail Was Returned. Do Not Allow Returning Mail Back Again.
|
||||
Copied = 0x04, /// This Mail Was Copied. Do Not Allow Making A Copy Of Items In Mail.
|
||||
CodPayment = 0x08,
|
||||
HasBody = 0x10 /// This Mail Has Body Text.
|
||||
}
|
||||
|
||||
public enum MailStationery
|
||||
{
|
||||
Test = 1,
|
||||
Default = 41,
|
||||
Gm = 61,
|
||||
Auction = 62,
|
||||
Val = 64, // Valentine
|
||||
Chr = 65, // Christmas
|
||||
Orp = 67 // Orphan
|
||||
}
|
||||
|
||||
public enum MailState
|
||||
{
|
||||
Unchanged = 1,
|
||||
Changed = 2,
|
||||
Deleted = 3
|
||||
}
|
||||
|
||||
public enum MailShowFlags
|
||||
{
|
||||
Unk0 = 0x0001,
|
||||
Delete = 0x0002, // Forced Show Delete Button Instead Return Button
|
||||
Auction = 0x0004, // From Old Comment
|
||||
Unk2 = 0x0008, // Unknown, Cod Will Be Shown Even Without That Flag
|
||||
Return = 0x0010
|
||||
}
|
||||
|
||||
public enum MailResponseType
|
||||
{
|
||||
Send = 0,
|
||||
MoneyTaken = 1,
|
||||
ItemTaken = 2,
|
||||
ReturnedToSender = 3,
|
||||
Deleted = 4,
|
||||
MadePermanent = 5
|
||||
}
|
||||
|
||||
public enum MailResponseResult
|
||||
{
|
||||
Ok = 0,
|
||||
EquipError = 1,
|
||||
CannotSendToSelf = 2,
|
||||
NotEnoughMoney = 3,
|
||||
RecipientNotFound = 4,
|
||||
NotYourTeam = 5,
|
||||
InternalError = 6,
|
||||
DisabledForTrialAcc = 14,
|
||||
RecipientCapReached = 15,
|
||||
CantSendWrappedCod = 16,
|
||||
MailAndChatSuspended = 17,
|
||||
TooManyAttachments = 18,
|
||||
MailAttachmentInvalid = 19,
|
||||
ItemHasExpired = 21
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public class MapConst
|
||||
{
|
||||
//Grids
|
||||
public const int MaxGrids = 64;
|
||||
public const float SizeofGrids = 533.33333f;
|
||||
public const float CenterGridCellId = (MaxCells * MaxGrids / 2);
|
||||
public const float CenterGridId = (MaxGrids / 2);
|
||||
public const float CenterGridOffset = (SizeofGrids / 2);
|
||||
public const float CenterGridCellOffset = (SizeofCells / 2);
|
||||
|
||||
//Cells
|
||||
public const int MaxCells = 8;
|
||||
public const float SizeofCells = (SizeofGrids / MaxCells);
|
||||
public const int TotalCellsPerMap = (MaxGrids * MaxCells);
|
||||
public const float MapSize = (SizeofGrids * MaxGrids);
|
||||
public const float MapHalfSize = (MapSize / 2);
|
||||
|
||||
public const uint MaxGroupSize = 5;
|
||||
public const uint MaxRaidSize = 40;
|
||||
public const uint MaxRaidSubGroups = MaxRaidSize / MaxGroupSize;
|
||||
public const uint TargetIconsCount = 8;
|
||||
public const uint RaidMarkersCount = 8;
|
||||
public const uint ReadycheckDuration = 35000;
|
||||
|
||||
//Liquid
|
||||
public const int MapLiquidTypeNoWater = 0x00;
|
||||
public const int MapLiquidTypeWater = 0x01;
|
||||
public const int MapLiquidTypeOcean = 0x02;
|
||||
public const int MapLiquidTypeMagma = 0x04;
|
||||
public const int MapLiquidTypeSlime = 0x08;
|
||||
public const int MapLiquidTypeDarkWater = 0x10;
|
||||
public const int MapLiquidTypeWMOWater = 0x20;
|
||||
public const int MapAllLiquidTypes = (MapLiquidTypeWater | MapLiquidTypeOcean | MapLiquidTypeMagma | MapLiquidTypeSlime);
|
||||
public const float LiquidTileSize = (533.333f / 128.0f);
|
||||
|
||||
public const int MinMapUpdateDelay = 50;
|
||||
public const int MinGridDelay = (Time.Minute * Time.InMilliseconds);
|
||||
|
||||
public const int MapResolution = 128;
|
||||
public const float DefaultHeightSearch = 50.0f;
|
||||
public const float InvalidHeight = -100000.0f;
|
||||
public const float MaxHeight = 100000.0f;
|
||||
public const float MaxFallDistance = 250000.0f;
|
||||
|
||||
public const string MapMagic = "MAPS";
|
||||
public const string MapVersionMagic = "v1.8";
|
||||
public const string MapAreaMagic = "AREA";
|
||||
public const string MapHeightMagic = "MHGT";
|
||||
public const string MapLiquidMagic = "MLIQ";
|
||||
|
||||
public const string mmapMagic = "MMAP";
|
||||
public const int mmapVersion = 8;
|
||||
|
||||
public const string VMapMagic = "VMAP_4.5";
|
||||
public const float VMAPInvalidHeightValue = -200000.0f;
|
||||
}
|
||||
|
||||
public enum NewWorldReason
|
||||
{
|
||||
Normal = 16, // Normal map change
|
||||
Seamless = 21, // Teleport to another map without a loading screen, used for outdoor scenarios
|
||||
}
|
||||
|
||||
public enum InstanceResetWarningType
|
||||
{
|
||||
WarningHours = 1, // WARNING! %s is scheduled to reset in %d hour(s).
|
||||
WarningMin = 2, // WARNING! %s is scheduled to reset in %d minute(s)!
|
||||
WarningMinSoon = 3, // WARNING! %s is scheduled to reset in %d minute(s). Please exit the zone or you will be returned to your bind location!
|
||||
Welcome = 4, // Welcome to %s. This raid instance is scheduled to reset in %s.
|
||||
Expired = 5
|
||||
}
|
||||
|
||||
public enum InstanceResetMethod
|
||||
{
|
||||
All,
|
||||
ChangeDifficulty,
|
||||
Global,
|
||||
GroupDisband,
|
||||
GroupJoin,
|
||||
RespawnDelay
|
||||
}
|
||||
|
||||
public enum GridMapTypeMask
|
||||
{
|
||||
None = 0x00,
|
||||
Corpse = 0x01,
|
||||
Creature = 0x02,
|
||||
DynamicObject = 0x04,
|
||||
GameObject = 0x08,
|
||||
Player = 0x10,
|
||||
AreaTrigger = 0x20,
|
||||
Conversation = 0x40,
|
||||
All = 0x7F,
|
||||
|
||||
//GameObjects, Creatures(except pets), DynamicObject, Corpse(Bones), AreaTrigger
|
||||
AllGrid = GameObject | Creature | DynamicObject | Corpse | AreaTrigger | Conversation,
|
||||
|
||||
//Player, Pets, Corpse(resurrectable), DynamicObject(farsight)
|
||||
AllWorld = Player | Creature | Corpse | DynamicObject
|
||||
}
|
||||
|
||||
public enum ZLiquidStatus
|
||||
{
|
||||
NoWater = 0x00,
|
||||
AboveWater = 0x01,
|
||||
WaterWalk = 0x02,
|
||||
InWater = 0x04,
|
||||
UnderWater = 0x08
|
||||
}
|
||||
|
||||
public enum EncounterFrameType
|
||||
{
|
||||
SetCombatResLimit = 0,
|
||||
ResetCombatResLimit = 1,
|
||||
Engage = 2,
|
||||
Disengage = 3,
|
||||
UpdatePriority = 4,
|
||||
AddTimer = 5,
|
||||
EnableObjective = 6,
|
||||
UpdateObjective = 7,
|
||||
DisableObjective = 8,
|
||||
Unk7 = 9, // Seems To Have Something To Do With Sorting The Encounter Units
|
||||
AddCombatResLimit = 10
|
||||
}
|
||||
|
||||
public enum EncounterState
|
||||
{
|
||||
NotStarted = 0,
|
||||
InProgress = 1,
|
||||
Fail = 2,
|
||||
Done = 3,
|
||||
Special = 4,
|
||||
ToBeDecided = 5
|
||||
}
|
||||
|
||||
public enum EncounterCreditType
|
||||
{
|
||||
KillCreature = 0,
|
||||
CastSpell = 1
|
||||
}
|
||||
|
||||
public enum DoorType
|
||||
{
|
||||
Room = 0, // Door can open if encounter is not in progress
|
||||
Passage = 1, // Door can open if encounter is done
|
||||
SpawnHole = 2, // Door can open if encounter is in progress, typically used for spawning places
|
||||
Max
|
||||
}
|
||||
|
||||
public enum EnterState
|
||||
{
|
||||
CanEnter = 0,
|
||||
CannotEnterAlreadyInMap = 1, // Player Is Already In The Map
|
||||
CannotEnterNoEntry, // No Map Entry Was Found For The Target Map Id
|
||||
CannotEnterUninstancedDungeon, // No Instance Template Was Found For Dungeon Map
|
||||
CannotEnterDifficultyUnavailable, // Requested Instance Difficulty Is Not Available For Target Map
|
||||
CannotEnterNotInRaid, // Target Instance Is A Raid Instance And The Player Is Not In A Raid Group
|
||||
CannotEnterCorpseInDifferentInstance, // Player Is Dead And Their Corpse Is Not In Target Instance
|
||||
CannotEnterInstanceBindMismatch, // Player'S Permanent Instance Save Is Not Compatible With Their Group'S Current Instance Bind
|
||||
CannotEnterTooManyInstances, // Player Has Entered Too Many Instances Recently
|
||||
CannotEnterMaxPlayers, // Target Map Already Has The Maximum Number Of Players Allowed
|
||||
CannotEnterZoneInCombat, // A Boss Encounter Is Currently In Progress On The Target Map
|
||||
CannotEnterUnspecifiedReason
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum MovementSlot
|
||||
{
|
||||
Idle,
|
||||
Active,
|
||||
Controlled,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum MovementGeneratorType
|
||||
{
|
||||
Idle = 0, // IdleMovement
|
||||
Random = 1, // RandomMovement
|
||||
Waypoint = 2, // WaypointMovement
|
||||
|
||||
MaxDB = 3, // *** this and below motion types can't be set in DB.
|
||||
AnimalRandom = MaxDB, // AnimalRandomMovementGenerator.h
|
||||
Confused = 4, // ConfusedMovementGenerator.h
|
||||
Chase = 5, // TargetedMovementGenerator.h
|
||||
Home = 6, // HomeMovementGenerator.h
|
||||
Flight = 7, // WaypointMovementGenerator.h
|
||||
Point = 8, // PointMovementGenerator.h
|
||||
Fleeing = 9, // FleeingMovementGenerator.h
|
||||
Distract = 10, // IdleMovementGenerator.h
|
||||
Assistance = 11, // PointMovementGenerator.h (first part of flee for assistance)
|
||||
AssistanceDistract = 12, // IdleMovementGenerator.h (second part of flee for assistance)
|
||||
TimedFleeing = 13, // FleeingMovementGenerator.h (alt.second part of flee for assistance)
|
||||
Follow = 14,
|
||||
Rotate = 15,
|
||||
Effect = 16,
|
||||
Null = 17,
|
||||
SplineChain = 18,
|
||||
Max
|
||||
}
|
||||
|
||||
public struct EventId
|
||||
{
|
||||
public const uint Charge = 1003;
|
||||
public const uint Jump = 1004;
|
||||
|
||||
/// Special charge event which is used for charge spells that have explicit targets
|
||||
/// and had a path already generated - using it in PointMovementGenerator will not
|
||||
/// create a new spline and launch it
|
||||
public const uint ChargePrepath = 1005;
|
||||
public const uint SmartRandomPoint = 0xFFFFFE;
|
||||
public const uint SmartEscortLastOCCPoint = 0xFFFFFF;
|
||||
}
|
||||
|
||||
public enum AnimType
|
||||
{
|
||||
ToGround = 0, // 460 = ToGround, index of AnimationData.dbc
|
||||
FlyToFly = 1, // 461 = FlyToFly?
|
||||
ToFly = 2, // 458 = ToFly
|
||||
FlyToGround = 3 // 463 = FlyToGround
|
||||
}
|
||||
|
||||
public enum RotateDirection
|
||||
{
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
|
||||
public enum UpdateCollisionHeightReason
|
||||
{
|
||||
Scale = 0,
|
||||
Mount = 1,
|
||||
Force = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
[Flags]
|
||||
public enum MovementFlag
|
||||
{
|
||||
None = 0x0,
|
||||
Forward = 0x1,
|
||||
Backward = 0x2,
|
||||
StrafeLeft = 0x4,
|
||||
StrafeRight = 0x8,
|
||||
Left = 0x10,
|
||||
Right = 0x20,
|
||||
PitchUp = 0x40,
|
||||
PitchDown = 0x80,
|
||||
Walking = 0x100,
|
||||
DisableGravity = 0x200,
|
||||
Root = 0x400,
|
||||
Falling = 0x800,
|
||||
FallingFar = 0x1000,
|
||||
PendingStop = 0x2000,
|
||||
PendingStrafeStop = 0x4000,
|
||||
PendingForward = 0x8000,
|
||||
PendingBackward = 0x10000,
|
||||
PendingStrafeLeft = 0x20000,
|
||||
PendingStrafeRight = 0x40000,
|
||||
PendingRoot = 0x80000,
|
||||
Swimming = 0x100000,
|
||||
Ascending = 0x200000,
|
||||
Descending = 0x400000,
|
||||
CanFly = 0x800000,
|
||||
Flying = 0x1000000,
|
||||
SplineElevation = 0x2000000,
|
||||
WaterWalk = 0x4000000,
|
||||
FallingSlow = 0x8000000,
|
||||
Hover = 0x10000000,
|
||||
DisableCollision = 0x20000000,
|
||||
|
||||
MaskMoving = Forward | Backward | StrafeLeft | StrafeRight | Falling | Ascending | Descending,
|
||||
|
||||
MaskTurning = Left | Right | PitchUp | PitchDown,
|
||||
|
||||
MaskMovingFly = Flying | Ascending | Descending,
|
||||
|
||||
MaskCreatureAllowed = Forward | DisableGravity | Root | Swimming |
|
||||
CanFly | WaterWalk | FallingSlow | Hover | DisableCollision,
|
||||
|
||||
MaskPlayerOnly = Flying,
|
||||
|
||||
MaskHasPlayerStatusOpcode = DisableGravity | Root | CanFly | WaterWalk |
|
||||
FallingSlow | Hover | DisableCollision
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum MovementFlag2
|
||||
{
|
||||
None = 0x0,
|
||||
NoStrafe = 0x1,
|
||||
NoJumping = 0x2,
|
||||
FullSpeedTurning = 0x4,
|
||||
FullSpeedPitching = 0x8,
|
||||
AlwaysAllowPitching = 0x10,
|
||||
IsVehicleExitVoluntary = 0x20,
|
||||
JumpSplineInAir = 0x40,
|
||||
AnimTierInTrans = 0x80,
|
||||
WaterwalkingFullPitch = 0x100, // will always waterwalk, even if facing the camera directly down
|
||||
VehiclePassengerIsTransitionAllowed = 0x200,
|
||||
CanSwimToFlyTrans = 0x400,
|
||||
Unk11 = 0x800, // terrain normal calculation is disabled if this flag is not present, client automatically handles setting this flag
|
||||
CanTurnWhileFalling = 0x1000,
|
||||
Unk13 = 0x2000, // will always waterwalk, even if facing the camera directly down
|
||||
IgnoreMovementForces = 0x4000,
|
||||
Unk15 = 0x8000,
|
||||
CanDoubleJump = 0x10000,
|
||||
DoubleJump = 0x20000,
|
||||
// these flags cannot be sent (18 bits in packet)
|
||||
Unk18 = 0x40000,
|
||||
Unk19 = 0x80000,
|
||||
InterpolatedMovement = 0x100000,
|
||||
InterpolatedTurning = 0x200000,
|
||||
InterpolatedPitching = 0x400000
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
public enum MonsterMoveType
|
||||
{
|
||||
Normal = 0,
|
||||
FacingSpot = 1,
|
||||
FacingTarget = 2,
|
||||
FacingAngle = 3
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SplineFlag : uint
|
||||
{
|
||||
None = 0x00,
|
||||
// x00-x07 used as animation Ids storage in pair with Animation flag
|
||||
Unknown0 = 0x00000008, // NOT VERIFIED - does someting related to falling/fixed orientation
|
||||
FallingSlow = 0x00000010,
|
||||
Done = 0x00000020,
|
||||
Falling = 0x00000040, // Affects elevation computation, can't be combined with Parabolic flag
|
||||
NoSpline = 0x00000080,
|
||||
Unknown1 = 0x00000100, // NOT VERIFIED
|
||||
Flying = 0x00000200, // Smooth movement(Catmullrom interpolation mode), flying animation
|
||||
OrientationFixed = 0x00000400, // Model orientation fixed
|
||||
Catmullrom = 0x00000800, // Used Catmullrom interpolation mode
|
||||
Cyclic = 0x00001000, // Movement by cycled spline
|
||||
EnterCycle = 0x00002000, // Everytimes appears with cyclic flag in monster move packet, erases first spline vertex after first cycle done
|
||||
Frozen = 0x00004000, // Will never arrive
|
||||
TransportEnter = 0x00008000,
|
||||
TransportExit = 0x00010000,
|
||||
Unknown2 = 0x00020000, // NOT VERIFIED
|
||||
Unknown3 = 0x00040000, // NOT VERIFIED
|
||||
Backward = 0x00080000,
|
||||
SmoothGroundPath = 0x00100000,
|
||||
CanSwim = 0x00200000,
|
||||
UncompressedPath = 0x00400000,
|
||||
Unknown4 = 0x00800000, // NOT VERIFIED
|
||||
Unknown5 = 0x01000000, // NOT VERIFIED
|
||||
Animation = 0x02000000, // Plays animation after some time passed
|
||||
Parabolic = 0x04000000, // Affects elevation computation, can't be combined with Falling flag
|
||||
FadeObject = 0x08000000,
|
||||
Steering = 0x10000000,
|
||||
Unknown8 = 0x20000000, // NOT VERIFIED
|
||||
Unknown9 = 0x40000000, // NOT VERIFIED
|
||||
Unknown10 = 0x80000000, // NOT VERIFIED
|
||||
|
||||
// animation ids stored here, see AnimType enum, used with Animation flag
|
||||
MaskAnimations = 0x7,
|
||||
// flags that shouldn't be appended into SMSG_MONSTER_MOVE\SMSG_MONSTER_MOVE_TRANSPORT packet, should be more probably
|
||||
MaskNoMonsterMove = MaskAnimations | Done,
|
||||
// Unused, not suported flags
|
||||
MaskUnused = NoSpline | EnterCycle | Frozen | Unknown0 | Unknown1 | Unknown2 | Unknown3 | Unknown4 | FadeObject | Steering | Unknown8 | Unknown9 | Unknown10
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
// Player state
|
||||
public enum SessionStatus
|
||||
{
|
||||
Authed = 0, // Player authenticated (_player == NULL, m_playerRecentlyLogout = false or will be reset before handler call, m_GUID have garbage)
|
||||
Loggedin, // Player in game (_player != NULL, m_GUID == _player->GetGUID(), inWorld())
|
||||
Transfer, // Player transferring to another map (_player != NULL, m_GUID == _player->GetGUID(), !inWorld())
|
||||
LoggedinOrRecentlyLogout, // _player != NULL or _player == NULL && m_playerRecentlyLogout && m_playerLogout, m_GUID store last _player guid)
|
||||
}
|
||||
|
||||
public enum PacketProcessing
|
||||
{
|
||||
Inplace = 0, //process packet whenever we receive it - mostly for non-handled or non-implemented packets
|
||||
ThreadUnsafe, //packet is not thread-safe - process it in World.UpdateSessions()
|
||||
ThreadSafe //packet is thread-safe - process it in Map.Update()
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum TypeId
|
||||
{
|
||||
Object = 0,
|
||||
Item = 1,
|
||||
Container = 2,
|
||||
Unit = 3,
|
||||
Player = 4,
|
||||
GameObject = 5,
|
||||
DynamicObject = 6,
|
||||
Corpse = 7,
|
||||
AreaTrigger = 8,
|
||||
SceneObject = 9,
|
||||
Conversation = 10
|
||||
}
|
||||
|
||||
public enum TypeMask
|
||||
{
|
||||
Object = 0x01,
|
||||
Item = 0x02,
|
||||
Container = Item | 0x04,
|
||||
Unit = 0x08,
|
||||
Player = 0x10,
|
||||
GameObject = 0x20,
|
||||
DynamicObject = 0x40,
|
||||
Corpse = 0x80,
|
||||
AreaTrigger = 0x100,
|
||||
Sceneobject = 0x200,
|
||||
Conversation = 0x400,
|
||||
Seer = Player | Unit | DynamicObject
|
||||
}
|
||||
|
||||
public enum HighGuid
|
||||
{
|
||||
Null = 0,
|
||||
Uniq = 1,
|
||||
Player = 2,
|
||||
Item = 3,
|
||||
WorldTransaction = 4,
|
||||
StaticDoor = 5, //NYI
|
||||
Transport = 6,
|
||||
Conversation = 7,
|
||||
Creature = 8,
|
||||
Vehicle = 9,
|
||||
Pet = 10,
|
||||
GameObject = 11,
|
||||
DynamicObject = 12,
|
||||
AreaTrigger = 13,
|
||||
Corpse = 14,
|
||||
LootObject = 15,
|
||||
SceneObject = 16,
|
||||
Scenario = 17,
|
||||
AIGroup = 18,
|
||||
DynamicDoor = 19,
|
||||
ClientActor = 20, //NYI
|
||||
Vignette = 21,
|
||||
CallForHelp = 22,
|
||||
AIResource = 23,
|
||||
AILock = 24,
|
||||
AILockTicket = 25,
|
||||
ChatChannel = 26,
|
||||
Party = 27,
|
||||
Guild = 28,
|
||||
WowAccount = 29,
|
||||
BNetAccount = 30,
|
||||
GMTask = 31,
|
||||
MobileSession = 32, //NYI
|
||||
RaidGroup = 33,
|
||||
Spell = 34,
|
||||
Mail = 35,
|
||||
WebObj = 36, //NYI
|
||||
LFGObject = 37, //NYI
|
||||
LFGList = 38, //NYI
|
||||
UserRouter = 39,
|
||||
PVPQueueGroup = 40,
|
||||
UserClient = 41,
|
||||
PetBattle = 42, //NYI
|
||||
UniqUserClient = 43,
|
||||
BattlePet = 44,
|
||||
CommerceObj = 45,
|
||||
ClientSession = 46,
|
||||
Cast = 47
|
||||
}
|
||||
|
||||
public enum NotifyFlags
|
||||
{
|
||||
None = 0x00,
|
||||
AIRelocation = 0x01,
|
||||
VisibilityChanged = 0x02,
|
||||
All = 0xFF
|
||||
}
|
||||
|
||||
public enum TempSummonType
|
||||
{
|
||||
TimedOrDeadDespawn = 1, // despawns after a specified time OR when the creature disappears
|
||||
TimedOrCorpseDespawn = 2, // despawns after a specified time OR when the creature dies
|
||||
TimedDespawn = 3, // despawns after a specified time
|
||||
TimedDespawnOOC = 4, // despawns after a specified time after the creature is out of combat
|
||||
CorpseDespawn = 5, // despawns instantly after death
|
||||
CorpseTimedDespawn = 6, // despawns after a specified time after death
|
||||
DeadDespawn = 7, // despawns when the creature disappears
|
||||
ManualDespawn = 8 // despawns when UnSummon() is called
|
||||
}
|
||||
|
||||
public enum SummonCategory
|
||||
{
|
||||
Wild = 0,
|
||||
Ally = 1,
|
||||
Pet = 2,
|
||||
Puppet = 3,
|
||||
Vehicle = 4,
|
||||
Unk = 5 // as of patch 3.3.5a only Bone Spike in Icecrown Citadel
|
||||
// uses this category
|
||||
}
|
||||
|
||||
public enum SummonType
|
||||
{
|
||||
None = 0,
|
||||
Pet = 1,
|
||||
Guardian = 2,
|
||||
Minion = 3,
|
||||
Totem = 4,
|
||||
Minipet = 5,
|
||||
Guardian2 = 6,
|
||||
Wild2 = 7,
|
||||
Wild3 = 8, // Related to phases and DK prequest line (3.3.5a)
|
||||
Vehicle = 9,
|
||||
Vehicle2 = 10, // Oculus and Argent Tournament vehicles (3.3.5a)
|
||||
LightWell = 11,
|
||||
Jeeves = 12,
|
||||
Unk13 = 13
|
||||
}
|
||||
|
||||
public enum SummonerType
|
||||
{
|
||||
Creature = 0,
|
||||
GameObject = 1,
|
||||
Map = 2
|
||||
}
|
||||
|
||||
public enum GhostVisibilityType
|
||||
{
|
||||
Alive = 0x1,
|
||||
Ghost = 0x2
|
||||
}
|
||||
|
||||
public enum StealthType
|
||||
{
|
||||
General = 0,
|
||||
Trap = 1,
|
||||
|
||||
Max = 2
|
||||
}
|
||||
|
||||
public enum InvisibilityType
|
||||
{
|
||||
General = 0,
|
||||
Unk1 = 1,
|
||||
Unk2 = 2,
|
||||
Trap = 3,
|
||||
Unk4 = 4,
|
||||
Unk5 = 5,
|
||||
Drunk = 6,
|
||||
Unk7 = 7,
|
||||
Unk8 = 8,
|
||||
Unk9 = 9,
|
||||
Unk10 = 10,
|
||||
Unk11 = 11,
|
||||
Unk12 = 12,
|
||||
Unk13 = 13,
|
||||
Unk14 = 14,
|
||||
Unk15 = 15,
|
||||
Unk16 = 16,
|
||||
Unk17 = 17,
|
||||
Unk18 = 18,
|
||||
Unk19 = 19,
|
||||
Unk20 = 20,
|
||||
Unk21 = 21,
|
||||
Unk22 = 22,
|
||||
Unk23 = 23,
|
||||
Unk24 = 24,
|
||||
Unk25 = 25,
|
||||
Unk26 = 26,
|
||||
Unk27 = 27,
|
||||
Unk28 = 28,
|
||||
Unk29 = 29,
|
||||
Unk30 = 30,
|
||||
Unk31 = 31,
|
||||
Unk32 = 32,
|
||||
Unk33 = 33,
|
||||
Unk34 = 34,
|
||||
Unk35 = 35,
|
||||
Unk36 = 36,
|
||||
Unk37 = 37,
|
||||
|
||||
Max = 38
|
||||
}
|
||||
|
||||
public enum ServerSideVisibilityType
|
||||
{
|
||||
GM = 0,
|
||||
Ghost = 1,
|
||||
}
|
||||
|
||||
public enum SessionFlags
|
||||
{
|
||||
None = 0x00,
|
||||
FromRedirect = 0x01,
|
||||
HasRedirected = 0x02
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum ObjectiveStates
|
||||
{
|
||||
Neutral = 0,
|
||||
Alliance,
|
||||
Horde,
|
||||
NeutralAllianceChallenge,
|
||||
NeutralHordeChallenge,
|
||||
AllianceHordeChallenge,
|
||||
HordeAllianceChallenge
|
||||
}
|
||||
|
||||
public enum OutdoorPvPTypes
|
||||
{
|
||||
HellfirePeninsula = 1,
|
||||
Nagrand = 2,
|
||||
TerokkarForest = 3,
|
||||
Zangarmarsh = 4,
|
||||
Silithus = 5,
|
||||
Max = 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum CharmType
|
||||
{
|
||||
Charm,
|
||||
Possess,
|
||||
Vehicle,
|
||||
Convert
|
||||
}
|
||||
|
||||
public enum PetType
|
||||
{
|
||||
Summon = 0,
|
||||
Hunter = 1,
|
||||
Max = 4
|
||||
}
|
||||
|
||||
public enum PetSaveMode
|
||||
{
|
||||
AsDeleted = -1, // not saved in fact
|
||||
AsCurrent = 0, // in current slot (with player)
|
||||
FirstStableSlot = 1,
|
||||
LastStableSlot = 4, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT
|
||||
NotInSlot = 100 // for avoid conflict with stable size grow will use 100
|
||||
}
|
||||
|
||||
public enum HappinessState
|
||||
{
|
||||
UnHappy = 1,
|
||||
Content = 2,
|
||||
Happy = 3
|
||||
}
|
||||
|
||||
public enum PetSpellState
|
||||
{
|
||||
Unchanged = 0,
|
||||
Changed = 1,
|
||||
New = 2,
|
||||
Removed = 3
|
||||
}
|
||||
|
||||
public enum PetSpellType
|
||||
{
|
||||
Normal = 0,
|
||||
Family = 1,
|
||||
Talent = 2
|
||||
}
|
||||
|
||||
public enum ActionFeedback
|
||||
{
|
||||
None = 0,
|
||||
PetDead = 1,
|
||||
NothingToAtt = 2,
|
||||
CantAttTarget = 3
|
||||
}
|
||||
|
||||
public enum PetTalk
|
||||
{
|
||||
SpecialSpell = 0,
|
||||
Attack = 1
|
||||
}
|
||||
|
||||
public enum CommandStates
|
||||
{
|
||||
Stay = 0,
|
||||
Follow = 1,
|
||||
Attack = 2,
|
||||
Abandon = 3,
|
||||
MoveTo = 4
|
||||
}
|
||||
|
||||
public enum PetNameInvalidReason
|
||||
{
|
||||
// custom, not send
|
||||
Success = 0,
|
||||
|
||||
Invalid = 1,
|
||||
NoName = 2,
|
||||
TooShort = 3,
|
||||
TooLong = 4,
|
||||
MixedLanguages = 6,
|
||||
Profane = 7,
|
||||
Reserved = 8,
|
||||
ThreeConsecutive = 11,
|
||||
InvalidSpace = 12,
|
||||
ConsecutiveSpaces = 13,
|
||||
RussianConsecutiveSilentCharacters = 14,
|
||||
RussianSilentCharacterAtBeginningOrEnd = 15,
|
||||
DeclensionDoesntMatchBaseName = 16
|
||||
}
|
||||
|
||||
public enum PetStableinfo
|
||||
{
|
||||
Active = 1,
|
||||
Inactive = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,771 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
public struct PlayerConst
|
||||
{
|
||||
public const int MaxTalentTiers = 7;
|
||||
public const int MaxTalentColumns = 3;
|
||||
public const int MaxTalentRank = 5;
|
||||
public const int MinSpecializationLevel = 10;
|
||||
public const int MaxSpecializations = 4;
|
||||
public const int MaxMasterySpells = 2;
|
||||
|
||||
public const int ReqPrimaryTreeTalents = 31;
|
||||
public const int ExploredZonesSize = 256;
|
||||
public const ulong MaxMoneyAmount = ulong.MaxValue;
|
||||
public const int MaxActionButtons = 132;
|
||||
public const int MaxActionButtonActionValue = 0x00FFFFFF + 1;
|
||||
|
||||
public const uint KnowTitlesSize = 6;
|
||||
public const uint MaxTitleIndex = KnowTitlesSize * 64;
|
||||
|
||||
public const int MaxDailyQuests = 25;
|
||||
public const int QuestsCompletedBitsSize = 1750;
|
||||
|
||||
public static TimeSpan InfinityCooldownDelay = TimeSpan.FromSeconds(Time.Month); // used for set "infinity cooldowns" for spells and check
|
||||
public const uint infinityCooldownDelayCheck = Time.Month / 2;
|
||||
public const int MaxPlayerSummonDelay = 2 * Time.Minute;
|
||||
|
||||
public const int TaxiMaskSize = 243;
|
||||
|
||||
// corpse reclaim times
|
||||
public const int DeathExpireStep = (5 * Time.Minute);
|
||||
public const int MaxDeathCount = 3;
|
||||
|
||||
public const int MaxCUFProfiles = 5;
|
||||
|
||||
public static uint[] copseReclaimDelay = { 30, 60, 120 };
|
||||
|
||||
public const int MaxRunes = 7;
|
||||
public const int MaxRechargingRunes = 3;
|
||||
|
||||
public static uint[] DefaultTalentRowLevels = { 15, 30, 45, 60, 75, 90, 100 };
|
||||
public static uint[] DKTalentRowLevels = { 57, 58, 59, 60, 75, 90, 100 };
|
||||
//public static uint[] DHTalentRowLevels = { 99, 100, 102, 104, 106, 108, 110 };
|
||||
|
||||
public const int CustomDisplaySize = 3;
|
||||
|
||||
public const int ArtifactsAllWeaponsGeneralWeaponEquippedPassive = 197886;
|
||||
|
||||
public const byte MaxHonorLevel = 50;
|
||||
public const byte LevelMinHonor = 110;
|
||||
}
|
||||
|
||||
public struct MoneyConstants
|
||||
{
|
||||
public const int Copper = 1;
|
||||
public const int Silver = Copper * 100;
|
||||
public const int Gold = Silver * 100;
|
||||
}
|
||||
|
||||
public struct PlayerFieldOffsets
|
||||
{
|
||||
public const byte BytesOffsetSkinId = 0;
|
||||
public const byte BytesOffsetFaceId = 1;
|
||||
public const byte BytesOffsetHairStyleId = 2;
|
||||
public const byte BytesOffsetHairColorId = 3;
|
||||
|
||||
public const byte Bytes2OffsetCustomDisplayOption = 0; // 3 Bytes
|
||||
public const byte Bytes2OffsetFacialStyle = 3;
|
||||
|
||||
public const byte Bytes3OffsetPartyType = 0;
|
||||
public const byte Bytes3OffsetBankBagSlots = 1;
|
||||
public const byte Bytes3OffsetGender = 2;
|
||||
public const byte Bytes3OffsetInebriation = 3;
|
||||
|
||||
public const byte Bytes4OffsetPvpTitle = 0;
|
||||
public const byte Bytes4OffsetArenaFaction = 1;
|
||||
|
||||
public const byte FieldBytesOffsetRafGrantableLevel = 0;
|
||||
public const byte FieldBytesOffsetActionBarToggles = 1;
|
||||
public const byte FieldBytesOffsetLifetimeMaxPvpRank = 2;
|
||||
public const byte FieldBytesOffsetMaxArtifactPowerRanks = 3;
|
||||
|
||||
public const byte FieldBytes2OffsetIgnorePowerRegenPredictionMask = 0;
|
||||
public const byte FieldBytes2OffsetAuraVision = 1;
|
||||
|
||||
public const byte FieldBytes3OffsetOverrideSpellsId = 2; // Uint16!
|
||||
public const byte FieldBytes3OffsetOverrideSpellsIdUint16Offset = FieldBytes3OffsetOverrideSpellsId / 2;
|
||||
|
||||
public const byte FieldKillsOffsetTodayKills = 0;
|
||||
public const byte FieldKillsOffsetYesterdayKills = 1;
|
||||
|
||||
public const byte RestStateXp = 0;
|
||||
public const byte RestRestedXp = 1;
|
||||
public const byte RestStateHonor = 2;
|
||||
public const byte RestRestedHonor = 3;
|
||||
}
|
||||
|
||||
public enum TradeSlots
|
||||
{
|
||||
Invalid = -1,
|
||||
NonTraded = 6,
|
||||
TradedCount = 6,
|
||||
Count = 7
|
||||
}
|
||||
|
||||
public enum Tutorials
|
||||
{
|
||||
Talent = 0,
|
||||
Spec = 1,
|
||||
Glyph = 2,
|
||||
SpellBook = 3,
|
||||
Professions = 4,
|
||||
CoreAbilitites = 5,
|
||||
PetJournal = 6,
|
||||
WhatHasChanged = 7,
|
||||
Max = 8
|
||||
}
|
||||
|
||||
public enum TradeStatus
|
||||
{
|
||||
PlayerBusy = 0,
|
||||
Proposed = 1,
|
||||
Initiated = 2,
|
||||
Cancelled = 3,
|
||||
Accepted = 4,
|
||||
AlreadyTrading = 5,
|
||||
NoTarget = 6,
|
||||
Unaccepted = 7,
|
||||
Complete = 8,
|
||||
StateChanged = 9,
|
||||
TooFarAway = 10,
|
||||
WrongFaction = 11,
|
||||
Failed = 12,
|
||||
Petition = 13,
|
||||
PlayerIgnored = 14,
|
||||
Stunned = 15,
|
||||
TargetStunned = 16,
|
||||
Dead = 17,
|
||||
TargetDead = 18,
|
||||
LoggingOut = 19,
|
||||
TargetLoggingOut = 20,
|
||||
RestrictedAccount = 21,
|
||||
WrongRealm = 22,
|
||||
NotOnTaplist = 23,
|
||||
CurrencyNotTradable = 24,
|
||||
NotEnoughCurrency = 25,
|
||||
}
|
||||
|
||||
public enum RestFlag
|
||||
{
|
||||
Tavern = 0x01,
|
||||
City = 0x02,
|
||||
FactionArea = 0x04
|
||||
}
|
||||
|
||||
public enum ChatFlags
|
||||
{
|
||||
None = 0x00,
|
||||
AFK = 0x01,
|
||||
DND = 0x02,
|
||||
GM = 0x04,
|
||||
Com = 0x08, // Commentator
|
||||
Dev = 0x10,
|
||||
BossSound = 0x20, // Plays "RaidBossEmoteWarning" sound on raid boss emote/whisper
|
||||
Mobile = 0x40
|
||||
}
|
||||
|
||||
public enum DrunkenState
|
||||
{
|
||||
Sober = 0,
|
||||
Tipsy = 1,
|
||||
Drunk = 2,
|
||||
Smashed = 3
|
||||
}
|
||||
|
||||
public enum TalentSpecialization // talent tabs
|
||||
{
|
||||
MageArcane = 62,
|
||||
MageFire = 63,
|
||||
MageFrost = 64,
|
||||
PaladinHoly = 65,
|
||||
PaladinProtection = 66,
|
||||
PaladinRetribution = 70,
|
||||
WarriorArms = 71,
|
||||
WarriorFury = 72,
|
||||
WarriorProtection = 73,
|
||||
DruidBalance = 102,
|
||||
DruidFeralCombat = 103,
|
||||
DruidRestoration = 104,
|
||||
DeathKnightBlood = 250,
|
||||
DeathKnightFrost = 251,
|
||||
DeathKnightUnholy = 252,
|
||||
HunterBeastMastery = 253,
|
||||
HunterMarksman = 254,
|
||||
HunterSurvival = 255,
|
||||
PriestDiscipline = 256,
|
||||
PriestHoly = 257,
|
||||
PriestShadow = 258,
|
||||
RogueAssassination = 259,
|
||||
RogueCombat = 260,
|
||||
RogueSubtlety = 261,
|
||||
ShamanElemental = 262,
|
||||
ShamanEnhancement = 263,
|
||||
ShamanRestoration = 264,
|
||||
WarlockAffliction = 265,
|
||||
WarlockDemonology = 266,
|
||||
WarlockDestruction = 267,
|
||||
MonkBrewmaster = 268,
|
||||
MonkBattledancer = 269,
|
||||
MonkMistweaver = 270,
|
||||
DemonHunterHavoc = 577,
|
||||
DemonHunterVengeance = 581
|
||||
}
|
||||
|
||||
public enum SpecResetType
|
||||
{
|
||||
Talents = 0,
|
||||
Specialization = 1,
|
||||
Glyphs = 2,
|
||||
PetTalents = 3
|
||||
}
|
||||
|
||||
public enum MirrorTimerType
|
||||
{
|
||||
Disabled = -1,
|
||||
Fatigue = 0,
|
||||
Breath = 1,
|
||||
Fire = 2, // feign death
|
||||
Max = 3
|
||||
}
|
||||
|
||||
public enum TransferAbortReason
|
||||
{
|
||||
None = 0,
|
||||
Error = 1,
|
||||
MaxPlayers = 2, // Transfer ed: Instance Is Full
|
||||
NotFound = 3, // Transfer ed: Instance Not Found
|
||||
TooManyInstances = 4, // You Have Entered Too Many Instances Recently.
|
||||
ZoneInCombat = 6, // Unable To Zone In While An Encounter Is In Progress.
|
||||
InsufExpanLvl = 7, // You Must Have <Tbc, Wotlk> Expansion Installed To Access This Area.
|
||||
Difficulty = 8, // <Normal, Heroic, Epic> Difficulty Mode Is Not Available For %S.
|
||||
UniqueMessage = 9, // Until You'Ve Escaped Tlk'S Grasp, You Cannot Leave This Place!
|
||||
TooManyRealmInstances = 10, // Additional Instances Cannot Be Launched, Please Try Again Later.
|
||||
NeedGroup = 11, // Transfer ed: You Must Be In A Raid Group To Enter This Instance
|
||||
NotFound2 = 12, // Transfer ed: Instance Not Found
|
||||
NotFound3 = 13, // Transfer ed: Instance Not Found
|
||||
NotFound4 = 14, // Transfer ed: Instance Not Found
|
||||
RealmOnly = 15, // All Players In The Party Must Be From The Same Realm To Enter %S.
|
||||
MapNotAllowed = 16, // Map Cannot Be Entered At This Time.
|
||||
LockedToDifferentInstance = 18, // You Are Already Locked To %S
|
||||
AlreadyCompletedEncounter = 19, // You Are Ineligible To Participate In At Least One Encounter In This Instance Because You Are Already Locked To An Instance In Which It Has Been Defeated.
|
||||
DifficultyNotFound = 22, // Client Writes To Console "Unable To Resolve Requested Difficultyid %U To Actual Difficulty For Map %D"
|
||||
XrealmZoneDown = 24, // Transfer ed: Cross-Realm Zone Is Down
|
||||
SoloPlayerSwitchDifficulty = 26, // This Instance Is Already In Progress. You May Only Switch Difficulties From Inside The Instance.
|
||||
}
|
||||
|
||||
public enum RaidGroupReason
|
||||
{
|
||||
None = 0,
|
||||
Lowlevel = 1, // "You are too low level to enter this instance."
|
||||
Only = 2, // "You must be in a raid group to enter this instance."
|
||||
Full = 3, // "The instance is full."
|
||||
RequirementsUnmatch = 4 // "You do not meet the requirements to enter this instance."
|
||||
}
|
||||
|
||||
public enum ResetFailedReason
|
||||
{
|
||||
Failed = 0, // "Cannot reset %s. There are players still inside the instance."
|
||||
Zoning = 1, // "Cannot reset %s. There are players in your party attempting to zone into an instance."
|
||||
Offline = 2 // "Cannot reset %s. There are players offline in your party."
|
||||
}
|
||||
|
||||
public enum ActivateTaxiReply
|
||||
{
|
||||
Ok = 0,
|
||||
UnspecifiedServerError = 1,
|
||||
NoSuchPath = 2,
|
||||
NotEnoughMoney = 3,
|
||||
TooFarAway = 4,
|
||||
NoVendorNearby = 5,
|
||||
NotVisited = 6,
|
||||
PlayerBusy = 7,
|
||||
PlayerAlreadyMounted = 8,
|
||||
PlayerShapeshifted = 9,
|
||||
PlayerMoving = 10,
|
||||
SameNode = 11,
|
||||
NotStanding = 12,
|
||||
}
|
||||
|
||||
public enum TaxiNodeStatus
|
||||
{
|
||||
None = 0,
|
||||
Learned = 1,
|
||||
Unlearned = 2,
|
||||
NotEligible = 3
|
||||
}
|
||||
|
||||
public enum PlayerDelayedOperations
|
||||
{
|
||||
SavePlayer = 0x01,
|
||||
ResurrectPlayer = 0x02,
|
||||
SpellCastDeserter = 0x04,
|
||||
BGMountRestore = 0x08, ///< Flag to restore mount state after teleport from BG
|
||||
BGTaxiRestore = 0x10, ///< Flag to restore taxi state after teleport from BG
|
||||
BGGroupRestore = 0x20, ///< Flag to restore group state after teleport from BG
|
||||
End
|
||||
}
|
||||
|
||||
public enum CorpseType
|
||||
{
|
||||
Bones = 0,
|
||||
ResurrectablePVE = 1,
|
||||
ResurrectablePVP = 2,
|
||||
Max = 3
|
||||
}
|
||||
|
||||
public enum CorpseFlags
|
||||
{
|
||||
None = 0x00,
|
||||
Bones = 0x01,
|
||||
Unk1 = 0x02,
|
||||
PvP = 0x04,
|
||||
HideHelm = 0x08,
|
||||
HideCloak = 0x10,
|
||||
Skinnable = 0x20,
|
||||
FFAPvP = 0x40
|
||||
}
|
||||
|
||||
public enum ActionButtonUpdateState
|
||||
{
|
||||
UnChanged = 0,
|
||||
Changed = 1,
|
||||
New = 2,
|
||||
Deleted = 3
|
||||
}
|
||||
|
||||
public enum ActionButtonType
|
||||
{
|
||||
Spell = 0x00,
|
||||
C = 0x01, // click?
|
||||
Eqset = 0x20,
|
||||
Dropdown = 0x30,
|
||||
Macro = 0x40,
|
||||
CMacro = C | Macro,
|
||||
Mount = 0x60,
|
||||
Item = 0x80
|
||||
}
|
||||
|
||||
public enum TeleportToOptions
|
||||
{
|
||||
GMMode = 0x01,
|
||||
NotLeaveTransport = 0x02,
|
||||
NotLeaveCombat = 0x04,
|
||||
NotUnSummonPet = 0x08,
|
||||
Spell = 0x10,
|
||||
Seamless = 0x20
|
||||
}
|
||||
|
||||
/// Type of environmental damages
|
||||
public enum EnviromentalDamage
|
||||
{
|
||||
Exhausted = 0,
|
||||
Drowning = 1,
|
||||
Fall = 2,
|
||||
Lava = 3,
|
||||
Slime = 4,
|
||||
Fire = 5,
|
||||
FallToVoid = 6 // custom case for fall without durability loss
|
||||
}
|
||||
|
||||
public enum PlayerUnderwaterState
|
||||
{
|
||||
None = 0x00,
|
||||
InWater = 0x01, // terrain type is water and player is afflicted by it
|
||||
InLava = 0x02, // terrain type is lava and player is afflicted by it
|
||||
InSlime = 0x04, // terrain type is lava and player is afflicted by it
|
||||
InDarkWater = 0x08, // terrain type is dark water and player is afflicted by it
|
||||
|
||||
ExistTimers = 0x10
|
||||
}
|
||||
|
||||
public struct RuneCooldowns
|
||||
{
|
||||
public const int Base = 10000;
|
||||
public const int Miss = 1500; // cooldown applied on runes when the spell misses
|
||||
}
|
||||
|
||||
public enum PlayerFlags : uint
|
||||
{
|
||||
GroupLeader = 0x01,
|
||||
AFK = 0x02,
|
||||
DND = 0x04,
|
||||
GM = 0x08,
|
||||
Ghost = 0x10,
|
||||
Resting = 0x20,
|
||||
Unk6 = 0x40,
|
||||
Unk7 = 0x80,
|
||||
ContestedPVP = 0x100,
|
||||
InPVP = 0x200,
|
||||
HideHelm = 0x400,
|
||||
HideCloak = 0x800,
|
||||
PlayedLongTime = 0x1000,
|
||||
PlayedTooLong = 0x2000,
|
||||
IsOutOfBounds = 0x4000,
|
||||
Developer = 0x8000,
|
||||
Unk16 = 0x10000,
|
||||
TaxiBenchmark = 0x20000,
|
||||
PVPTimer = 0x40000,
|
||||
Uber = 0x80000,
|
||||
Unk20 = 0x100000,
|
||||
Unk21 = 0x200000,
|
||||
Commentator2 = 0x400000,
|
||||
AllowOnlyAbility = 0x800000,
|
||||
PetBattlesUnlocked = 0x1000000,
|
||||
NoXPGain = 0x2000000,
|
||||
Unk26 = 0x4000000,
|
||||
AutoDeclineGuild = 0x8000000,
|
||||
GuildLevelEnabled = 0x10000000,
|
||||
VoidUnlocked = 0x20000000,
|
||||
Mentor = 0x40000000,
|
||||
Unk31 = 0x80000000
|
||||
}
|
||||
|
||||
public enum PlayerFlagsEx
|
||||
{
|
||||
ReagentBankUnlocked = 0x01,
|
||||
MercenaryMode = 0x02
|
||||
}
|
||||
|
||||
public enum CharacterFlags : uint
|
||||
{
|
||||
None = 0x00000000,
|
||||
Unk1 = 0x00000001,
|
||||
Unk2 = 0x00000002,
|
||||
CharacterLockedForTransfer = 0x00000004,
|
||||
Unk4 = 0x00000008,
|
||||
Unk5 = 0x00000010,
|
||||
Unk6 = 0x00000020,
|
||||
Unk7 = 0x00000040,
|
||||
Unk8 = 0x00000080,
|
||||
Unk9 = 0x00000100,
|
||||
Unk10 = 0x00000200,
|
||||
HideHelm = 0x00000400,
|
||||
HideCloak = 0x00000800,
|
||||
Unk13 = 0x00001000,
|
||||
Ghost = 0x00002000,
|
||||
Rename = 0x00004000,
|
||||
Unk16 = 0x00008000,
|
||||
Unk17 = 0x00010000,
|
||||
Unk18 = 0x00020000,
|
||||
Unk19 = 0x00040000,
|
||||
Unk20 = 0x00080000,
|
||||
Unk21 = 0x00100000,
|
||||
Unk22 = 0x00200000,
|
||||
Unk23 = 0x00400000,
|
||||
Unk24 = 0x00800000,
|
||||
LockedByBilling = 0x01000000,
|
||||
Declined = 0x02000000,
|
||||
Unk27 = 0x04000000,
|
||||
Unk28 = 0x08000000,
|
||||
Unk29 = 0x10000000,
|
||||
Unk30 = 0x20000000,
|
||||
Unk31 = 0x40000000,
|
||||
Unk32 = 0x80000000
|
||||
}
|
||||
|
||||
public enum PlayerLocalFlags
|
||||
{
|
||||
TrackStealthed = 0x02,
|
||||
ReleaseTimer = 0x08, // Display time till auto release spirit
|
||||
NoReleaseWindow = 0x10, // Display no "release spirit" window at all
|
||||
NoPetBar = 0x00000020, // CGPetInfo::IsPetBarUsed
|
||||
OverrideCameraMinHeight = 0x00000040,
|
||||
UsingPartGarrison = 0x00000100,
|
||||
CanUseObjectsMounted = 0x00000200,
|
||||
CanVisitPartyGarrison = 0x00000400
|
||||
}
|
||||
|
||||
public enum PlayerFieldByte2Flags
|
||||
{
|
||||
None = 0x00,
|
||||
Stealth = 0x20,
|
||||
InvisibilityGlow = 0x40
|
||||
}
|
||||
|
||||
public enum AreaTeams
|
||||
{
|
||||
None = 0,
|
||||
Ally = 2,
|
||||
Horde = 4,
|
||||
Any = 6
|
||||
}
|
||||
|
||||
public enum RestTypes : byte
|
||||
{
|
||||
XP = 0,
|
||||
Honor = 1,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum PlayerRestState
|
||||
{
|
||||
Rested = 0x01,
|
||||
NotRAFLinked = 0x02,
|
||||
RAFLinked = 0x06
|
||||
}
|
||||
|
||||
public enum CharacterCustomizeFlags
|
||||
{
|
||||
None = 0x00,
|
||||
Customize = 0x01, // Name, Gender, Etc...
|
||||
Faction = 0x10000, // Name, Gender, Faction, Etc...
|
||||
Race = 0x100000 // Name, Gender, Race, Etc...
|
||||
}
|
||||
|
||||
public enum CharacterFlags3 : uint
|
||||
{
|
||||
LockedByRevokedVasTransaction = 0x100000,
|
||||
LockedByRevokedCharacterUpgrade = 0x80000000,
|
||||
}
|
||||
|
||||
public enum CharacterFlags4
|
||||
{
|
||||
TrialBoost = 0x80,
|
||||
TrialBoostLocked = 0x40000,
|
||||
}
|
||||
|
||||
public enum TextureSection // TODO: Find a better name. Used in CharSections.dbc
|
||||
{
|
||||
BaseSkin = 0,
|
||||
Face = 1,
|
||||
FacialHair = 2,
|
||||
Hair = 3,
|
||||
Underwear = 4,
|
||||
}
|
||||
|
||||
public enum AtLoginFlags
|
||||
{
|
||||
None = 0x00,
|
||||
Rename = 0x01,
|
||||
ResetSpells = 0x02,
|
||||
ResetTalents = 0x04,
|
||||
Customize = 0x08,
|
||||
ResetPetTalents = 0x10,
|
||||
FirstLogin = 0x20,
|
||||
ChangeFaction = 0x40,
|
||||
ChangeRace = 0x80,
|
||||
Resurrect = 0x100
|
||||
}
|
||||
|
||||
public enum PlayerSlots
|
||||
{
|
||||
// first slot for item stored (in any way in player items data)
|
||||
Start = 0,
|
||||
// last+1 slot for item stored (in any way in player items data)
|
||||
End = 187,
|
||||
Count = (End - Start)
|
||||
}
|
||||
|
||||
public enum PlayerTitle : ulong
|
||||
{
|
||||
Disabled = 0x0000000000000000,
|
||||
None = 0x0000000000000001,
|
||||
Private = 0x0000000000000002, // 1
|
||||
Corporal = 0x0000000000000004, // 2
|
||||
SergeantA = 0x0000000000000008, // 3
|
||||
MasterSergeant = 0x0000000000000010, // 4
|
||||
SergeantMajor = 0x0000000000000020, // 5
|
||||
Knight = 0x0000000000000040, // 6
|
||||
KnightLieutenant = 0x0000000000000080, // 7
|
||||
KnightCaptain = 0x0000000000000100, // 8
|
||||
KnightChampion = 0x0000000000000200, // 9
|
||||
LieutenantCommander = 0x0000000000000400, // 10
|
||||
Commander = 0x0000000000000800, // 11
|
||||
Marshal = 0x0000000000001000, // 12
|
||||
FieldMarshal = 0x0000000000002000, // 13
|
||||
GrandMarshal = 0x0000000000004000, // 14
|
||||
Scout = 0x0000000000008000, // 15
|
||||
Grunt = 0x0000000000010000, // 16
|
||||
SergeantH = 0x0000000000020000, // 17
|
||||
SeniorSergeant = 0x0000000000040000, // 18
|
||||
FirstSergeant = 0x0000000000080000, // 19
|
||||
StoneGuard = 0x0000000000100000, // 20
|
||||
BloodGuard = 0x0000000000200000, // 21
|
||||
Legionnaire = 0x0000000000400000, // 22
|
||||
Centurion = 0x0000000000800000, // 23
|
||||
Champion = 0x0000000001000000, // 24
|
||||
LieutenantGeneral = 0x0000000002000000, // 25
|
||||
General = 0x0000000004000000, // 26
|
||||
Warlord = 0x0000000008000000, // 27
|
||||
HighWarlord = 0x0000000010000000, // 28
|
||||
Gladiator = 0x0000000020000000, // 29
|
||||
Duelist = 0x0000000040000000, // 30
|
||||
Rival = 0x0000000080000000, // 31
|
||||
Challenger = 0x0000000100000000, // 32
|
||||
ScarabLord = 0x0000000200000000, // 33
|
||||
Conqueror = 0x0000000400000000, // 34
|
||||
Justicar = 0x0000000800000000, // 35
|
||||
ChampionOfTheNaaru = 0x0000001000000000, // 36
|
||||
MercilessGladiator = 0x0000002000000000, // 37
|
||||
OfTheShatteredSun = 0x0000004000000000, // 38
|
||||
HandOfAdal = 0x0000008000000000, // 39
|
||||
VengefulGladiator = 0x0000010000000000, // 40
|
||||
}
|
||||
|
||||
public enum PlayerExtraFlags
|
||||
{
|
||||
// gm abilities
|
||||
GMOn = 0x01,
|
||||
AcceptWhispers = 0x04,
|
||||
TaxiCheat = 0x08,
|
||||
GMInvisible = 0x10,
|
||||
GMChat = 0x20, // Show GM badge in chat messages
|
||||
|
||||
// other states
|
||||
PVPDeath = 0x100 // store PvP death status until corpse creating.
|
||||
}
|
||||
|
||||
public enum EquipmentSetUpdateState
|
||||
{
|
||||
Unchanged = 0,
|
||||
Changed = 1,
|
||||
New = 2,
|
||||
Deleted = 3
|
||||
}
|
||||
|
||||
public enum CUFBoolOptions
|
||||
{
|
||||
KeepGroupsTogether,
|
||||
DisplayPets,
|
||||
DisplayMainTankAndAssist,
|
||||
DisplayHealPrediction,
|
||||
DisplayAggroHighlight,
|
||||
DisplayOnlyDispellableDebuffs,
|
||||
DisplayPowerBar,
|
||||
DisplayBorder,
|
||||
UseClassColors,
|
||||
DisplayHorizontalGroups,
|
||||
DisplayNonBossDebuffs,
|
||||
DynamicPosition,
|
||||
Locked,
|
||||
Shown,
|
||||
AutoActivate2Players,
|
||||
AutoActivate3Players,
|
||||
AutoActivate5Players,
|
||||
AutoActivate10Players,
|
||||
AutoActivate15Players,
|
||||
AutoActivate25Players,
|
||||
AutoActivate40Players,
|
||||
AutoActivateSpec1,
|
||||
AutoActivateSpec2,
|
||||
AutoActivateSpec3,
|
||||
AutoActivateSpec4,
|
||||
AutoActivatePvp,
|
||||
AutoActivatePve,
|
||||
|
||||
BoolOptionsCount,
|
||||
}
|
||||
|
||||
public enum DuelCompleteType
|
||||
{
|
||||
Interrupted = 0,
|
||||
Won = 1,
|
||||
Fled = 2
|
||||
}
|
||||
|
||||
public enum ReferAFriendError
|
||||
{
|
||||
None = 0,
|
||||
NotReferredBy = 1,
|
||||
TargetTooHigh = 2,
|
||||
InsufficientGrantableLevels = 3,
|
||||
TooFar = 4,
|
||||
DifferentFaction = 5,
|
||||
NotNow = 6,
|
||||
GrantLevelMaxI = 7,
|
||||
NoTarget = 8,
|
||||
NotInGroup = 9,
|
||||
SummonLevelMaxI = 10,
|
||||
SummonCooldown = 11,
|
||||
InsufExpanLvl = 12,
|
||||
SummonOfflineS = 13,
|
||||
NoXrealm = 14,
|
||||
MapIncomingTransferNotAllowed = 15
|
||||
}
|
||||
|
||||
public enum PlayerCommandStates
|
||||
{
|
||||
None = 0x00,
|
||||
God = 0x01,
|
||||
Casttime = 0x02,
|
||||
Cooldown = 0x04,
|
||||
Power = 0x08,
|
||||
Waterwalk = 0x10
|
||||
}
|
||||
|
||||
public enum AttackSwingErr
|
||||
{
|
||||
CantAttack = 0,
|
||||
BadFacing = 1,
|
||||
NotInRange = 2,
|
||||
DeadTarget = 3
|
||||
}
|
||||
|
||||
public enum PlayerLogXPReason
|
||||
{
|
||||
Kill = 0,
|
||||
NoKill = 1
|
||||
}
|
||||
|
||||
public enum HeirloomPlayerFlags
|
||||
{
|
||||
None = 0x00,
|
||||
BonusLevel90 = 0x01,
|
||||
BonusLevel100 = 0x02,
|
||||
BonusLevel110 = 0x04
|
||||
}
|
||||
|
||||
public enum HeirloomItemFlags
|
||||
{
|
||||
None = 0x00,
|
||||
ShowOnlyIfKnown = 0x01,
|
||||
Pvp = 0x02
|
||||
}
|
||||
|
||||
public enum DeclinedNameResult
|
||||
{
|
||||
Success = 0,
|
||||
Error = 1
|
||||
}
|
||||
|
||||
public enum BindExtensionState
|
||||
{
|
||||
Expired = 0,
|
||||
Normal = 1,
|
||||
Extended = 2,
|
||||
Keep = 255 // special state: keep current save type
|
||||
}
|
||||
|
||||
public enum TalentLearnResult
|
||||
{
|
||||
LearnOk = 0,
|
||||
FailedUnknown = 1,
|
||||
FailedNotEnoughTalentsInPrimaryTree = 2,
|
||||
FailedNoPrimaryTreeSelected = 3,
|
||||
FailedCantDoThatRightNow = 4,
|
||||
FailedAffectingCombat = 5,
|
||||
FailedCantRemoveTalent = 6,
|
||||
FailedCantDoThatChallengeModeActive = 7,
|
||||
FailedRestArea = 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
public enum QuestObjectiveType
|
||||
{
|
||||
Monster = 0,
|
||||
Item = 1,
|
||||
GameObject = 2,
|
||||
TalkTo = 3,
|
||||
Currency = 4,
|
||||
LearnSpell = 5,
|
||||
MinReputation = 6,
|
||||
MaxReputation = 7,
|
||||
Money = 8,
|
||||
PlayerKills = 9,
|
||||
AreaTrigger = 10,
|
||||
WinPetBattleAgainstNpc = 11,
|
||||
DefeatBattlePet = 12,
|
||||
WinPvpPetBattles = 13,
|
||||
CriteriaTree = 14,
|
||||
ProgressBar = 15,
|
||||
HaveCurrency = 16, // requires the player to have X currency when turning in but does not consume it
|
||||
ObtainCurrency = 17 // requires the player to gain X currency after starting the quest but not required to keep it until the end (does not consume)
|
||||
}
|
||||
|
||||
public enum QuestObjectiveFlags
|
||||
{
|
||||
TrackedOnMinimap = 0x01, // Client Displays Large Yellow Blob On Minimap For Creature/Gameobject
|
||||
Sequenced = 0x02, // Client Will Not See The Objective Displayed Until All Previous Objectives Are Completed
|
||||
Optional = 0x04, // Not Required To Complete The Quest
|
||||
Hidden = 0x08, // Never Displayed In Quest Log
|
||||
HideItemGains = 0x10, // Skip Showing Item Objective Progress
|
||||
ProgressCountsItemsInInventory = 0x20, // Item Objective Progress Counts Items In Inventory Instead Of Reading It From Updatefields
|
||||
PartOfProgressBar = 0x40, // Hidden Objective Used To Calculate Progress Bar Percent (Quests Are Limited To A Single Progress Bar Objective)
|
||||
}
|
||||
|
||||
public struct QuestSlotOffsets
|
||||
{
|
||||
public const int Id = 0;
|
||||
public const int State = 1;
|
||||
public const int Counts = 2;
|
||||
public const int Time = 14;
|
||||
public const int Max = 16;
|
||||
}
|
||||
|
||||
public enum QuestSlotStateMask
|
||||
{
|
||||
None = 0x0000,
|
||||
Complete = 0x0001,
|
||||
Fail = 0x0002
|
||||
}
|
||||
|
||||
public enum QuestType
|
||||
{
|
||||
AutoComplete= 0,
|
||||
Disabled = 1,
|
||||
Normal = 2,
|
||||
Task = 3,
|
||||
Max = 4
|
||||
}
|
||||
|
||||
public enum QuestInfos
|
||||
{
|
||||
Group = 1,
|
||||
Class = 21,
|
||||
PVP = 41,
|
||||
Raid = 62,
|
||||
Dungeon = 81,
|
||||
WorldEvent = 82,
|
||||
Legendary = 83,
|
||||
Escort = 84,
|
||||
Heroic = 85,
|
||||
Raid10 = 88,
|
||||
Raid25 = 89,
|
||||
Scenario = 98,
|
||||
Account = 102,
|
||||
SideQuest = 104
|
||||
}
|
||||
|
||||
public enum QuestSort
|
||||
{
|
||||
Epic = 1,
|
||||
HallowsEnd = 21,
|
||||
Seasonal = 22,
|
||||
Cataclysm = 23,
|
||||
Herbalism = 24,
|
||||
Battlegrounds = 25,
|
||||
DayOfTheDead = 41,
|
||||
Warlock = 61,
|
||||
Warrior = 81,
|
||||
Shaman = 82,
|
||||
Fishing = 101,
|
||||
Blacksmithing = 121,
|
||||
Paladin = 141,
|
||||
Mage = 161,
|
||||
Rogue = 162,
|
||||
Alchemy = 181,
|
||||
Leatherworking = 182,
|
||||
Engineering = 201,
|
||||
TreasureMap = 221,
|
||||
Tournament = 241,
|
||||
Hunter = 261,
|
||||
Priest = 262,
|
||||
Druid = 263,
|
||||
Tailoring = 264,
|
||||
Special = 284,
|
||||
Cooking = 304,
|
||||
FirstAid = 324,
|
||||
Legendary = 344,
|
||||
DarkmoonFaire = 364,
|
||||
AhnQirajWar = 365,
|
||||
LunarFestival = 366,
|
||||
Reputation = 367,
|
||||
Invasion = 368,
|
||||
Midsummer = 369,
|
||||
Brewfest = 370,
|
||||
Inscription = 371,
|
||||
DeathKnight = 372,
|
||||
Jewelcrafting = 373,
|
||||
Noblegarden = 374,
|
||||
PilgrimsBounty = 375,
|
||||
LoveIsInTheAir = 376,
|
||||
Archaeology = 377,
|
||||
ChildrensWeek = 378,
|
||||
FirelandsInvasion = 379,
|
||||
TheZandalari = 380,
|
||||
ElementalBonds = 381,
|
||||
PandarenBrewmaster = 391,
|
||||
Scenario = 392,
|
||||
BattlePets = 394,
|
||||
Monk = 395,
|
||||
Landfall = 396,
|
||||
PandarenCampaign = 397,
|
||||
Riding = 398,
|
||||
BrawlersGuild = 399,
|
||||
ProvingGrounds = 400,
|
||||
GarrisonCampaign = 401,
|
||||
AssaultOnTheDarkPortal = 402,
|
||||
GarrisonSupport = 403,
|
||||
Logging = 404,
|
||||
Pickpocketing = 405
|
||||
}
|
||||
|
||||
public enum QuestFailedReasons
|
||||
{
|
||||
None = 0,
|
||||
FailedLowLevel = 1, // "You Are Not High Enough Level For That Quest.""
|
||||
FailedWrongRace = 6, // "That Quest Is Not Available To Your Race."
|
||||
AlreadyDone = 7, // "You Have Completed That Daily Quest Today."
|
||||
OnlyOneTimed = 12, // "You Can Only Be On One Timed Quest At A Time"
|
||||
AlreadyOn1 = 13, // "You Are Already On That Quest"
|
||||
FailedExpansion = 16, // "This Quest Requires An Expansion Enabled Account."
|
||||
AlreadyOn2 = 18, // "You Are Already On That Quest"
|
||||
FailedMissingItems = 21, // "You Don'T Have The Required Items With You. Check Storage."
|
||||
FailedNotEnoughMoney = 23, // "You Don'T Have Enough Money For That Quest"
|
||||
FailedCais = 24, // "You Cannot Complete Quests Once You Have Reached Tired Time"
|
||||
AlreadyDoneDaily = 26, // "You Have Completed That Daily Quest Today."
|
||||
FailedSpell = 28, // "You Haven'T Learned The Required Spell."
|
||||
HasInProgress = 30 // "Progress Bar Objective Not Completed"
|
||||
}
|
||||
|
||||
public enum QuestPushReason
|
||||
{
|
||||
Success = 0,
|
||||
Invalid = 1,
|
||||
Accepted = 2,
|
||||
Declined = 3,
|
||||
Busy = 4,
|
||||
Dead = 5,
|
||||
LogFull = 6,
|
||||
OnQuest = 7,
|
||||
AlreadyDone = 8,
|
||||
NotDaily = 9,
|
||||
TimerExpired = 10,
|
||||
NotInParty = 11,
|
||||
DifferentServerDaily = 12,
|
||||
NotAllowed = 13
|
||||
}
|
||||
|
||||
public enum QuestTradeSkill
|
||||
{
|
||||
None = 0,
|
||||
Alchemy = 1,
|
||||
Blacksmithing = 2,
|
||||
Cooking = 3,
|
||||
Enchanting = 4,
|
||||
Engineering = 5,
|
||||
Firstaid = 6,
|
||||
Herbalism = 7,
|
||||
Leatherworking = 8,
|
||||
Poisons = 9,
|
||||
Tailoring = 10,
|
||||
Mining = 11,
|
||||
Fishing = 12,
|
||||
Skinning = 13,
|
||||
Jewelcrafting = 14
|
||||
}
|
||||
|
||||
public enum QuestStatus
|
||||
{
|
||||
None = 0,
|
||||
Complete = 1,
|
||||
//Unavailable = 2,
|
||||
Incomplete = 3,
|
||||
//Available = 4,
|
||||
Failed = 5,
|
||||
Rewarded = 6, // Not Used In Db
|
||||
Max
|
||||
}
|
||||
|
||||
public enum QuestGiverStatus
|
||||
{
|
||||
None = 0x000,
|
||||
Unk = 0x001,
|
||||
Unavailable = 0x002,
|
||||
LowLevelAvailable = 0x004,
|
||||
LowLevelRewardRep = 0x008,
|
||||
LowLevelAvailableRep = 0x010,
|
||||
Incomplete = 0x020,
|
||||
RewardRep = 0x040,
|
||||
AvailableRep = 0x080,
|
||||
Available = 0x100,
|
||||
Reward2 = 0x200, // No Yellow Dot On Minimap
|
||||
Reward = 0x400, // Yellow Dot On Minimap
|
||||
|
||||
// Custom value meaning that script call did not return any valid quest status
|
||||
ScriptedNoStatus = 0x1000
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum QuestFlags : uint
|
||||
{
|
||||
None = 0x00,
|
||||
StayAlive = 0x01, // Not Used Currently
|
||||
PartyAccept = 0x02, // Not Used Currently. If Player In Party, All Players That Can Accept This Quest Will Receive Confirmation Box To Accept Quest Cmsg_Quest_Confirm_Accept/Smsg_Quest_Confirm_Accept
|
||||
Exploration = 0x04, // Not Used Currently
|
||||
Sharable = 0x08, // Can Be Shared: Player.Cansharequest()
|
||||
HasCondition = 0x10, // Not Used Currently
|
||||
HideRewardPoi = 0x20, // Not Used Currently: Unsure Of Content
|
||||
Raid = 0x40, // Can be completed while in raid
|
||||
TBC = 0x80, // Not Used Currently: Available If Tbc Expansion Enabled Only
|
||||
NoMoneyFromXp = 0x100, // Not Used Currently: Experience Is Not Converted To Gold At Max Level
|
||||
HiddenRewards = 0x200, // Items And Money Rewarded Only Sent In Smsg_Questgiver_Offer_Reward (Not In Smsg_Questgiver_Quest_Details Or In Client Quest Log(Smsg_Quest_Query_Response))
|
||||
Tracking = 0x400, // These Quests Are Automatically Rewarded On Quest Complete And They Will Never Appear In Quest Log Client Side.
|
||||
DeprecateReputation = 0x800, // Not Used Currently
|
||||
Daily = 0x1000, // Used To Know Quest Is Daily One
|
||||
Pvp = 0x2000, // Having This Quest In Log Forces Pvp Flag
|
||||
Unavailable = 0x4000, // Used On Quests That Are Not Generically Available
|
||||
Weekly = 0x8000,
|
||||
AutoComplete = 0x10000, // Quests with this flag player submit automatically by special button in player gui
|
||||
DisplayItemInTracker = 0x20000, // Displays Usable Item In Quest Tracker
|
||||
ObjText = 0x40000, // Use Objective Text As Complete Text
|
||||
AutoAccept = 0x80000, // The client recognizes this flag as auto-accept.
|
||||
PlayerCastOnAccept = 0x100000,
|
||||
PlayerCastOnComplete = 0x200000,
|
||||
UpdatePhaseShift = 0x400000,
|
||||
SorWhitelist = 0x800000,
|
||||
LaunchGossipComplete = 0x1000000,
|
||||
RemoveExtraGetItems = 0x2000000,
|
||||
HideUntilDiscovered = 0x4000000,
|
||||
PortraitInQuestLog = 0x8000000,
|
||||
ShowItemWhenCompleted = 0x10000000,
|
||||
LaunchGossipAccept = 0x20000000,
|
||||
ItemsGlowWhenDone = 0x40000000,
|
||||
FailOnLogout = 0x80000000
|
||||
}
|
||||
|
||||
// last checked in 19802
|
||||
[Flags]
|
||||
public enum QuestFlagsEx
|
||||
{
|
||||
None = 0x00,
|
||||
KeepAdditionalItems = 0x01,
|
||||
SuppressGossipComplete = 0x02,
|
||||
SuppressGossipAccept = 0x04,
|
||||
DisallowPlayerAsQuestgiver = 0x08,
|
||||
DisplayClassChoiceRewards = 0x10,
|
||||
DisplaySpecChoiceRewards = 0x20,
|
||||
RemoveFromLogOnPeriodicReset = 0x40,
|
||||
AccountLevelQuest = 0x80,
|
||||
LegendaryQuest = 0x100,
|
||||
NoGuildXp = 0x200,
|
||||
ResetCacheOnAccept = 0x400,
|
||||
NoAbandonOnceAnyObjectiveComplete = 0x800,
|
||||
RecastAcceptSpellOnLogin = 0x1000,
|
||||
UpdateZoneAuras = 0x2000,
|
||||
NoCreditForProxy = 0x4000,
|
||||
DisplayAsDailyQuest = 0x8000,
|
||||
PartOfQuestLine = 0x10000,
|
||||
QuestForInternalBuildsOnly = 0x20000,
|
||||
SuppressSpellLearnTextLine = 0x40000,
|
||||
DisplayHeaderAsObjectiveForTasks = 0x80000,
|
||||
GarrisonNonOwnersAllowed = 0x100000,
|
||||
RemoveQuestOnWeeklyReset = 0x200000,
|
||||
SuppressFarewellAudioAfterQuestAccept = 0x0400000,
|
||||
RewardsBypassWeeklyCapsAndSeasonTotal = 0x0800000,
|
||||
ClearProgressOfCriteriaTreeObjectivesOnAccept = 0x1000000
|
||||
}
|
||||
|
||||
public enum QuestSpecialFlags
|
||||
{
|
||||
None = 0x00,
|
||||
// Flags For Set Specialflags In Db If Required But Used Only At Server
|
||||
Repeatable = 0x001,
|
||||
ExplorationOrEvent = 0x002, // If Required Area Explore, Spell Spell_Effect_Quest_Complete Casting, Table `*_Script` Command Script_Command_Quest_Explored Use, Set From Script)
|
||||
AutoAccept = 0x004, // Quest Is To Be Auto-Accepted.
|
||||
DfQuest = 0x008, // Quest Is Used By Dungeon Finder.
|
||||
Monthly = 0x010, // Quest Is Reset At The Begining Of The Month
|
||||
Cast = 0x20, // Set by 32 in SpecialFlags in DB if the quest requires RequiredOrNpcGo killcredit but NOT kill (a spell cast)
|
||||
// Room For More Custom Flags
|
||||
|
||||
DbAllowed = Repeatable | ExplorationOrEvent | AutoAccept | DfQuest | Monthly | Cast,
|
||||
|
||||
Deliver = 0x080, // Internal Flag Computed Only
|
||||
Speakto = 0x100, // Internal Flag Computed Only
|
||||
Kill = 0x200, // Internal Flag Computed Only
|
||||
Timed = 0x400, // Internal Flag Computed Only
|
||||
PlayerKill = 0x800 // Internal Flag Computed Only
|
||||
}
|
||||
|
||||
public enum QuestSaveType
|
||||
{
|
||||
Default = 0,
|
||||
Delete,
|
||||
ForceDelete
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
// AuraScript interface - enum used for runtime checks of script function calls
|
||||
public enum AuraScriptHookType
|
||||
{
|
||||
None = 0,
|
||||
Registration,
|
||||
Loading,
|
||||
Unloading,
|
||||
EffectApply,
|
||||
EffectAfterApply,
|
||||
EffectRemove,
|
||||
EffectAfterRemove,
|
||||
EffectPeriodic,
|
||||
EffectUpdatePeriodic,
|
||||
EffectCalcAmount,
|
||||
EffectCalcPeriodic,
|
||||
EffectCalcSpellmod,
|
||||
EffectAbsorb,
|
||||
EffectAfterAbsorb,
|
||||
EffectManaShield,
|
||||
EffectAfterManaShield,
|
||||
EffectSplit,
|
||||
CheckAreaTarget,
|
||||
Dispel,
|
||||
AfterDispel,
|
||||
// Spell Proc Hooks
|
||||
CheckProc,
|
||||
CheckEffectProc,
|
||||
PrepareProc,
|
||||
Proc,
|
||||
EffectProc,
|
||||
EffectAfterProc,
|
||||
AfterProc,
|
||||
//Apply,
|
||||
//Remove
|
||||
}
|
||||
|
||||
// SpellScript interface - enum used for runtime checks of script function calls
|
||||
public enum SpellScriptHookType
|
||||
{
|
||||
None = 0,
|
||||
Registration,
|
||||
Loading,
|
||||
Unloading,
|
||||
Launch,
|
||||
LaunchTarget,
|
||||
EffectHit,
|
||||
EffectHitTarget,
|
||||
EffectSuccessfulDispel,
|
||||
BeforeHit,
|
||||
OnHit,
|
||||
AfterHit,
|
||||
ObjectAreaTargetSelect,
|
||||
ObjectTargetSelect,
|
||||
DestinationTargetSelect,
|
||||
CheckCast,
|
||||
BeforeCast,
|
||||
OnCast,
|
||||
AfterCast
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum OriginalHash : uint
|
||||
{
|
||||
AccountService = 0x62DA0891u,
|
||||
AccountListener = 0x54DFDA17u,
|
||||
AuthenticationListener = 0x71240E35u,
|
||||
AuthenticationService = 0xDECFC01u,
|
||||
ChallengeService = 0xDBBF6F19u,
|
||||
ChallengeListener = 0xBBDA171Fu,
|
||||
ChannelService = 0xB732DB32u,
|
||||
ChannelListener = 0xBF8C8094u,
|
||||
ConnectionService = 0x65446991u,
|
||||
FriendsService = 0xA3DDB1BDu,
|
||||
FriendsListener = 0x6F259A13u,
|
||||
GameUtilitiesService = 0x3FC1274Du,
|
||||
PresenceService = 0xFA0796FFu,
|
||||
ReportService = 0x7CAF61C9u,
|
||||
ResourcesService = 0xECBE75BAu,
|
||||
UserManagerService = 0x3E19268Au,
|
||||
UserManagerListener = 0xBC872C22u
|
||||
}
|
||||
|
||||
public enum NameHash : uint
|
||||
{
|
||||
AccountService = 0x1E4DC42Fu,
|
||||
AccountListener = 0x7807483Cu,
|
||||
AuthenticationListener = 0x4DA86228u,
|
||||
AuthenticationService = 0xFF5A6AC3u,
|
||||
ChallengeService = 0x71BB6833u,
|
||||
ChallengeListener = 0xC6D90AB8u,
|
||||
ChannelService = 0xA913A87Bu,
|
||||
ChannelListener = 0xDA660990u,
|
||||
ConnectionService = 0x2782094Bu,
|
||||
FriendsService = 0xABDFED63u,
|
||||
FriendsListener = 0xA6717548u,
|
||||
GameUtilitiesService = 0x51923A28u,
|
||||
PresenceService = 0xD8F94B3Bu,
|
||||
ReportService = 0x724F5F47u,
|
||||
ResourcesService = 0x4B104C53u,
|
||||
UserManagerService = 0x8EE5694Eu,
|
||||
UserManagerListener = 0xB3426BB3u
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum SmartScriptType
|
||||
{
|
||||
Creature = 0,
|
||||
GameObject = 1,
|
||||
AreaTrigger = 2,
|
||||
Event = 3,
|
||||
Gossip = 4,
|
||||
Quest = 5,
|
||||
Spell = 6,
|
||||
Transport = 7,
|
||||
Instance = 8,
|
||||
TimedActionlist = 9,
|
||||
Scene = 10, // done
|
||||
Max = 11
|
||||
}
|
||||
|
||||
public struct SmartScriptTypeMaskId
|
||||
{
|
||||
public const uint Creature = 1;
|
||||
public const uint Gameobject = 2;
|
||||
public const uint Areatrigger = 4;
|
||||
public const uint Event = 8;
|
||||
public const uint Gossip = 16;
|
||||
public const uint Quest = 32;
|
||||
public const uint Spell = 64;
|
||||
public const uint Transport = 128;
|
||||
public const uint Instance = 256;
|
||||
public const uint TimedActionlist = 512;
|
||||
public const uint Scene = 1024;
|
||||
}
|
||||
|
||||
public enum SmartPhase
|
||||
{
|
||||
ALWAYS = 0,
|
||||
Phase1 = 1,
|
||||
Phase2 = 2,
|
||||
Phase3 = 3,
|
||||
Phase4 = 4,
|
||||
Phase5 = 5,
|
||||
Phase6 = 6,
|
||||
Max = 7,
|
||||
All = (Phase1 | Phase2 | Phase3 | Phase4 | Phase5 | Phase6),
|
||||
|
||||
Count = 6
|
||||
}
|
||||
|
||||
public enum SmartEventFlags
|
||||
{
|
||||
NotRepeatable = 0x01, //Event can not repeat
|
||||
Difficulty0 = 0x02, //Event only occurs in instance difficulty 0
|
||||
Difficulty1 = 0x04, //Event only occurs in instance difficulty 1
|
||||
Difficulty2 = 0x08, //Event only occurs in instance difficulty 2
|
||||
Difficulty3 = 0x10, //Event only occurs in instance difficulty 3
|
||||
Reserved5 = 0x20,
|
||||
Reserved6 = 0x40,
|
||||
DebugOnly = 0x80, //Event only occurs in debug build
|
||||
DontReset = 0x100, //Event will not reset in SmartScript.OnReset()
|
||||
WhileCharmed = 0x200, //Event occurs even if AI owner is charmed
|
||||
|
||||
DifficultyAll = (Difficulty0 | Difficulty1 | Difficulty2 | Difficulty3),
|
||||
All = (NotRepeatable | DifficultyAll | Reserved5 | Reserved6 | DebugOnly | DontReset | WhileCharmed)
|
||||
}
|
||||
|
||||
public enum SmartRespawnCondition
|
||||
{
|
||||
None = 0,
|
||||
Map = 1,
|
||||
Area = 2,
|
||||
End = 3
|
||||
}
|
||||
|
||||
public enum SmartAITemplate
|
||||
{
|
||||
Basic = 0, //nothing is preset
|
||||
Caster = 1, //spellid, repeatMin, repeatMax, range, manaPCT +JOIN: target_param1 as castFlag
|
||||
Turret = 2, //spellid, repeatMin, repeatMax +JOIN: target_param1 as castFlag
|
||||
Passive = 3,
|
||||
CagedGOPart = 4, //creatureID, give credit at point end?,
|
||||
CagedNPCPart = 5, //gameObjectID, despawntime, run?, dist, TextGroupID
|
||||
End = 6
|
||||
}
|
||||
|
||||
public enum SmartCastFlags
|
||||
{
|
||||
InterruptPrevious = 0x01, //Interrupt any spell casting
|
||||
Triggered = 0x02, //Triggered (this makes spell cost zero mana and have no cast time)
|
||||
//CAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range
|
||||
//CAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range
|
||||
//CAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself
|
||||
AuraNotPresent = 0x20, //Only casts the spell if the target does not have an aura from the spell
|
||||
CombatMove = 0x40 //Prevents combat movement if cast successful. Allows movement on range, OOM, LOS
|
||||
}
|
||||
|
||||
public enum SmartEvents
|
||||
{
|
||||
UpdateIc = 0, // Initialmin, Initialmax, Repeatmin, Repeatmax
|
||||
UpdateOoc = 1, // Initialmin, Initialmax, Repeatmin, Repeatmax
|
||||
HealtPct = 2, // Hpmin%, Hpmax%, Repeatmin, Repeatmax
|
||||
ManaPct = 3, // Manamin%, Manamax%, Repeatmin, Repeatmax
|
||||
Aggro = 4, // None
|
||||
Kill = 5, // Cooldownmin0, Cooldownmax1, Playeronly2, Else Creature Entry3
|
||||
Death = 6, // None
|
||||
Evade = 7, // None
|
||||
SpellHit = 8, // Spellid, School, Cooldownmin, Cooldownmax
|
||||
Range = 9, // Mindist, Maxdist, Repeatmin, Repeatmax
|
||||
OocLos = 10, // Nohostile, Maxrnage, Cooldownmin, Cooldownmax
|
||||
Respawn = 11, // Type, Mapid, Zoneid
|
||||
TargetHealthPct = 12, // Hpmin%, Hpmax%, Repeatmin, Repeatmax
|
||||
VictimCasting = 13, // Repeatmin, Repeatmax
|
||||
FriendlyHealth = 14, // Hpdeficit, Radius, Repeatmin, Repeatmax
|
||||
FriendlyIsCc = 15, // Radius, Repeatmin, Repeatmax
|
||||
FriendlyMissingBuff = 16, // Spellid, Radius, Repeatmin, Repeatmax
|
||||
SummonedUnit = 17, // Creatureid(0 All), Cooldownmin, Cooldownmax
|
||||
TargetManaPct = 18, // Manamin%, Manamax%, Repeatmin, Repeatmax
|
||||
AcceptedQuest = 19, // Questid(0any)
|
||||
RewardQuest = 20, // Questid(0any)
|
||||
ReachedHome = 21, // None
|
||||
ReceiveEmote = 22, // Emoteid, Cooldownmin, Cooldownmax, Condition, Val1, Val2, Val3
|
||||
HasAura = 23, // Param1 = Spellid, Param2 = Stack Amount, Param3/4 Repeatmin, Repeatmax
|
||||
TargetBuffed = 24, // Param1 = Spellid, Param2 = Stack Amount, Param3/4 Repeatmin, Repeatmax
|
||||
Reset = 25, // Called After Combat, When The Creature Respawn And Spawn.
|
||||
IcLos = 26, // Nohostile, Maxrnage, Cooldownmin, Cooldownmax
|
||||
PassengerBoarded = 27, // Cooldownmin, Cooldownmax
|
||||
PassengerRemoved = 28, // Cooldownmin, Cooldownmax
|
||||
Charmed = 29, // onRemove (0 - on apply, 1 - on remove)
|
||||
CharmedTarget = 30, // None
|
||||
SpellhitTarget = 31, // Spellid, School, Cooldownmin, Cooldownmax
|
||||
Damaged = 32, // Mindmg, Maxdmg, Cooldownmin, Cooldownmax
|
||||
DamagedTarget = 33, // Mindmg, Maxdmg, Cooldownmin, Cooldownmax
|
||||
Movementinform = 34, // Movementtype(Any), Pointid
|
||||
SummonDespawned = 35, // Entry, Cooldownmin, Cooldownmax
|
||||
CorpseRemoved = 36, // None
|
||||
AiInit = 37, // None
|
||||
DataSet = 38, // Id, Value, Cooldownmin, Cooldownmax
|
||||
WaypointStart = 39, // Pointid(0any), Pathid(0any)
|
||||
WaypointReached = 40, // Pointid(0any), Pathid(0any)
|
||||
TransportAddplayer = 41, // None
|
||||
TransportAddcreature = 42, // Entry (0 Any)
|
||||
TransportRemovePlayer = 43, // None
|
||||
TransportRelocate = 44, // Pointid
|
||||
InstancePlayerEnter = 45, // Team (0 Any), Cooldownmin, Cooldownmax
|
||||
AreatriggerOntrigger = 46, // Triggerid(0 Any)
|
||||
QuestAccepted = 47, // None
|
||||
QuestObjCompletion = 48, // None
|
||||
QuestCompletion = 49, // None
|
||||
QuestRewarded = 50, // None
|
||||
QuestFail = 51, // None
|
||||
TextOver = 52, // Groupid From CreatureText, Creature Entry Who Talks (0 Any)
|
||||
ReceiveHeal = 53, // Minheal, Maxheal, Cooldownmin, Cooldownmax
|
||||
JustSummoned = 54, // None
|
||||
WaypointPaused = 55, // Pointid(0any), Pathid(0any)
|
||||
WaypointResumed = 56, // Pointid(0any), Pathid(0any)
|
||||
WaypointStopped = 57, // Pointid(0any), Pathid(0any)
|
||||
WaypointEnded = 58, // Pointid(0any), Pathid(0any)
|
||||
TimedEventTriggered = 59, // Id
|
||||
Update = 60, // Initialmin, Initialmax, Repeatmin, Repeatmax
|
||||
Link = 61, // Internal Usage, No Params, Used To Link Together Multiple Events, Does Not Use Any Extra Resources To Iterate Event Lists Needlessly
|
||||
GossipSelect = 62, // Menuid, Actionid
|
||||
JustCreated = 63, // None
|
||||
GossipHello = 64, // None
|
||||
FollowCompleted = 65, // None
|
||||
DummyEffect = 66, // Spellid, Effectindex
|
||||
IsBehindTarget = 67, // Cooldownmin, Cooldownmax
|
||||
GameEventStart = 68, // GameEvent.Entry
|
||||
GameEventEnd = 69, // GameEvent.Entry
|
||||
GoStateChanged = 70, // Go State
|
||||
GoEventInform = 71, // Eventid
|
||||
ActionDone = 72, // Eventid (Shareddefines.Eventid)
|
||||
OnSpellclick = 73, // Clicker (Unit)
|
||||
FriendlyHealthPCT = 74,// minHpPct, maxHpPct, repeatMin, repeatMax
|
||||
DistanceCreature = 75, // guid, entry, distance, repeat
|
||||
DistanceGameobject = 76, // guid, entry, distance, repeat
|
||||
CounterSet = 77, // id, value, cooldownMin, cooldownMax
|
||||
SceneStart = 78, // none
|
||||
SceneTrigger = 79, // param_string : triggerName
|
||||
SceneCancel = 80, // none
|
||||
SceneComplete = 81, // none
|
||||
|
||||
//New
|
||||
SpellEffectHit = 82,
|
||||
SpellEffectHitTarget = 83,
|
||||
|
||||
End = 84
|
||||
}
|
||||
|
||||
public enum SmartActions
|
||||
{
|
||||
None = 0, // No Action
|
||||
Talk = 1, // Groupid From CreatureText, Duration To Wait Before TextOver Event Is Triggered, useTalkTarget (0/1) - use target as talk target
|
||||
SetFaction = 2, // Factionid (Or 0 For Default)
|
||||
MorphToEntryOrModel = 3, // CreatureTemplate Entry(Param1) Or Modelid (Param2) (Or 0 For Both To Demorph)
|
||||
Sound = 4, // Soundid, Textrange
|
||||
PlayEmote = 5, // Emoteid
|
||||
FailQuest = 6, // Questid
|
||||
OfferQuest = 7, // Questid, directAdd
|
||||
SetReactState = 8, // State
|
||||
ActivateGobject = 9, //
|
||||
RandomEmote = 10, // Emoteid1, Emoteid2, Emoteid3...
|
||||
Cast = 11, // Spellid, Castflags, TriggeredFlags
|
||||
SummonCreature = 12, // Creatureid, Summontype, Duration In Ms, Storageid, Attackinvoker,
|
||||
ThreatSinglePct = 13, // Threat%
|
||||
ThreatAllPct = 14, // Threat%
|
||||
CallAreaexploredoreventhappens = 15, // Questid
|
||||
SetIngamePhaseGroup = 16, // phaseGroupId, apply
|
||||
SetEmoteState = 17, // Emoteid
|
||||
SetUnitFlag = 18, // Flags (May Be More Than One Field Or'D Together), Target
|
||||
RemoveUnitFlag = 19, // Flags (May Be More Than One Field Or'D Together), Target
|
||||
AutoAttack = 20, // Allowattackstate (0 = Stop Attack, Anything Else Means Continue Attacking)
|
||||
AllowCombatMovement = 21, // Allowcombatmovement (0 = Stop Combat Based Movement, Anything Else Continue Attacking)
|
||||
SetEventPhase = 22, // Phase
|
||||
IncEventPhase = 23, // Value (May Be Negative To Decrement Phase, Should Not Be 0)
|
||||
Evade = 24, // No Params
|
||||
FleeForAssist = 25, // With Emote
|
||||
CallGroupeventhappens = 26, // Questid
|
||||
CombatStop = 27, //
|
||||
Removeaurasfromspell = 28, // Spellid, 0 Removes All Auras
|
||||
Follow = 29, // Distance (0 = Default), Angle (0 = Default), Endcreatureentry, Credit, Credittype (0monsterkill, 1event)
|
||||
RandomPhase = 30, // Phaseid1, Phaseid2, Phaseid3...
|
||||
RandomPhaseRange = 31, // Phasemin, Phasemax
|
||||
ResetGobject = 32, //
|
||||
CallKilledmonster = 33, // Creatureid,
|
||||
SetInstData = 34, // Field, Data, Type (0 = SetData, 1 = SetBossState)
|
||||
SetInstData64 = 35, // Field,
|
||||
UpdateTemplate = 36, // Entry
|
||||
Die = 37, // No Params
|
||||
SetInCombatWithZone = 38, // No Params
|
||||
CallForHelp = 39, // Radius, With Emote
|
||||
SetSheath = 40, // Sheath (0-Unarmed, 1-Melee, 2-Ranged)
|
||||
ForceDespawn = 41, // Timer
|
||||
SetInvincibilityHpLevel = 42, // Minhpvalue(+Pct, -Flat)
|
||||
MountToEntryOrModel = 43, // CreatureTemplate Entry(Param1) Or Modelid (Param2) (Or 0 For Both To Dismount)
|
||||
SetIngamePhaseId = 44, // Id
|
||||
SetData = 45, // Field, Data (Only Creature Todo)
|
||||
//46 Unused
|
||||
SetVisibility = 47, // On/Off
|
||||
SetActive = 48, // No Params
|
||||
AttackStart = 49, //
|
||||
SummonGo = 50, // Gameobjectid, Despawntime In Ms,
|
||||
KillUnit = 51, //
|
||||
ActivateTaxi = 52, // Taxiid
|
||||
WpStart = 53, // Run/Walk, Pathid, Canrepeat, Quest, Despawntime, Reactstate
|
||||
WpPause = 54, // Time
|
||||
WpStop = 55, // Despawntime, Quest, Fail?
|
||||
AddItem = 56, // Itemid, Count
|
||||
RemoveItem = 57, // Itemid, Count
|
||||
InstallAiTemplate = 58, // Aitemplateid
|
||||
SetRun = 59, // 0/1
|
||||
SetFly = 60, // 0/1
|
||||
SetSwim = 61, // 0/1
|
||||
Teleport = 62, // Mapid,
|
||||
SetCounter = 63, // id, value, reset (0/1)
|
||||
StoreTargetList = 64, // Varid,
|
||||
WpResume = 65, // None
|
||||
SetOrientation = 66, //
|
||||
CreateTimedEvent = 67, // Id, Initialmin, Initialmax, Repeatmin(Only If It Repeats), Repeatmax(Only If It Repeats), Chance
|
||||
Playmovie = 68, // Entry
|
||||
MoveToPos = 69, // PointId, transport, disablePathfinding
|
||||
RespawnTarget = 70, //
|
||||
Equip = 71, // Entry, Slotmask Slot1, Slot2, Slot3 , Only Slots With Mask Set Will Be Sent To Client, Bits Are 1, 2, 4, Leaving Mask 0 Is Defaulted To Mask 7 (Send All), Slots1-3 Are Only Used If No Entry Is Set
|
||||
CloseGossip = 72, // None
|
||||
TriggerTimedEvent = 73, // Id(>1)
|
||||
RemoveTimedEvent = 74, // Id(>1)
|
||||
AddAura = 75, // Spellid, Targets
|
||||
OverrideScriptBaseObject = 76, // Warning: Can Crash Core, Do Not Use If You Dont Know What You Are Doing
|
||||
ResetScriptBaseObject = 77, // None
|
||||
CallScriptReset = 78, // None
|
||||
SetRangedMovement = 79, // Distance, Angle
|
||||
CallTimedActionlist = 80, // Id (Overwrites Already Running Actionlist), Stop After Combat?(0/1), Timer Update Type(0-Ooc, 1-Ic, 2-Always)
|
||||
SetNpcFlag = 81, // Flags
|
||||
AddNpcFlag = 82, // Flags
|
||||
RemoveNpcFlag = 83, // Flags
|
||||
SimpleTalk = 84, // Groupid, Can Be Used To Make Players Say Groupid, TextOver Event Is Not Triggered, Whisper Can Not Be Used (Target Units Will Say The Text)
|
||||
InvokerCast = 85, // Spellid, Castflags, If Avaliable, Last Used Invoker Will Cast Spellid With Castflags On Targets
|
||||
CrossCast = 86, // Spellid, Castflags, Castertargettype, Castertarget Param1, Castertarget Param2, Castertarget Param3, ( + The Origonal Target Fields As Destination Target), Castertargets Will Cast Spellid On All Targets (Use With Caution If Targeting Multiple * Multiple Units)
|
||||
CallRandomTimedActionlist = 87, // Script9 Ids 1-9
|
||||
CallRandomRangeTimedActionlist = 88, // Script9 Id Min, Max
|
||||
RandomMove = 89, // Maxdist
|
||||
SetUnitFieldBytes1 = 90, // Bytes, Target
|
||||
RemoveUnitFieldBytes1 = 91, // Bytes, Target
|
||||
InterruptSpell = 92,
|
||||
SendGoCustomAnim = 93, // Anim Id
|
||||
SetDynamicFlag = 94, // Flags
|
||||
AddDynamicFlag = 95, // Flags
|
||||
RemoveDynamicFlag = 96, // Flags
|
||||
JumpToPos = 97, // Speedxy, Speedz, Targetx, Targety, Targetz
|
||||
SendGossipMenu = 98, // Menuid, Optionid
|
||||
GoSetLootState = 99, // State
|
||||
SendTargetToTarget = 100, // Id
|
||||
SetHomePos = 101, // None
|
||||
SetHealthRegen = 102, // 0/1
|
||||
SetRoot = 103, // Off/On
|
||||
SetGoFlag = 104, // Flags
|
||||
AddGoFlag = 105, // Flags
|
||||
RemoveGoFlag = 106, // Flags
|
||||
SummonCreatureGroup = 107, // Group, Attackinvoker
|
||||
SetPower = 108, // PowerType, newPower
|
||||
AddPower = 109, // PowerType, newPower
|
||||
RemovePower = 110, // PowerType, newPower
|
||||
GameEventStop = 111, // GameEventId
|
||||
GameEventStart = 112, // GameEventId
|
||||
StartClosestWaypoint = 113, // wp1, wp2, wp3, wp4, wp5, wp6, wp7
|
||||
MoveOffset = 114,
|
||||
RandomSound = 115, // SoundId1, SoundId2, SoundId3, SoundId4, SoundId5, onlySelf
|
||||
SetCorpseDelay = 116, // timer
|
||||
DisableEvade = 117, // 0/1 (1 = disabled, 0 = enabled)
|
||||
// 118 - 127 : 3.3.5 reserved
|
||||
PlayAnimkit = 128,
|
||||
ScenePlay = 129, // sceneId
|
||||
SceneCancel = 130, // sceneId
|
||||
|
||||
End = 131
|
||||
}
|
||||
|
||||
public enum SmartTargets
|
||||
{
|
||||
None = 0, // None, Defaulting To Invoket
|
||||
Self = 1, // Self Cast
|
||||
Victim = 2, // Our Current Target (Ie: Highest Aggro)
|
||||
HostileSecondAggro = 3, // Second Highest Aggro
|
||||
HostileLastAggro = 4, // Dead Last On Aggro
|
||||
HostileRandom = 5, // Just Any Random Target On Our Threat List
|
||||
HostileRandomNotTop = 6, // Any Random Target Except Top Threat
|
||||
ActionInvoker = 7, // Unit Who Caused This Event To Occur
|
||||
Position = 8, // Use Xyz From Event Params
|
||||
CreatureRange = 9, // Creatureentry(0any), Mindist, Maxdist
|
||||
CreatureGuid = 10, // Guid, Entry
|
||||
CreatureDistance = 11, // Creatureentry(0any), Maxdist
|
||||
Stored = 12, // Id, Uses Pre-Stored Target(List)
|
||||
GameobjectRange = 13, // Entry(0any), Min, Max
|
||||
GameobjectGuid = 14, // Guid, Entry
|
||||
GameobjectDistance = 15, // Entry(0any), Maxdist
|
||||
InvokerParty = 16, // Invoker'S Party Members
|
||||
PlayerRange = 17, // Min, Max
|
||||
PlayerDistance = 18, // Maxdist
|
||||
ClosestCreature = 19, // Creatureentry(0any), Maxdist, Dead?
|
||||
ClosestGameobject = 20, // Entry(0any), Maxdist
|
||||
ClosestPlayer = 21, // Maxdist
|
||||
ActionInvokerVehicle = 22, // Unit'S Vehicle Who Caused This Event To Occur
|
||||
OwnerOrSummoner = 23, // Unit'S Owner Or Summoner
|
||||
ThreatList = 24, // All Units On Creature'S Threat List
|
||||
ClosestEnemy = 25, // maxDist, playerOnly
|
||||
ClosestFriendly = 26, // maxDist, playerOnly
|
||||
LootRecipients = 27, // all players that have tagged this creature (for kill credit)
|
||||
Farthest = 28, // maxDist, playerOnly, isInLos
|
||||
VehicleAccessory = 29, // seat number (vehicle can target it's own accessory)
|
||||
SpellTarget = 30,
|
||||
|
||||
End = 31
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public struct SkillConst
|
||||
{
|
||||
public const int MaxPlayerSkills = 128;
|
||||
public const uint MaxSkillStep = 15;
|
||||
}
|
||||
|
||||
public enum SkillType
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Swords = 43,
|
||||
Axes = 44,
|
||||
Bows = 45,
|
||||
Guns = 46,
|
||||
Maces = 54,
|
||||
TwoHandedSwords = 55,
|
||||
Defense = 95,
|
||||
LangCommon = 98,
|
||||
RacialDwarf = 101,
|
||||
LangOrcish = 109,
|
||||
LangDwarven = 111,
|
||||
LangDarnassian = 113,
|
||||
LangTaurahe = 115,
|
||||
DualWield = 118,
|
||||
RacialTauren = 124,
|
||||
RacialOrc = 125,
|
||||
RacialNightElf = 126,
|
||||
FirstAid = 129,
|
||||
Staves = 136,
|
||||
LangThalassian = 137,
|
||||
LangDraconic = 138,
|
||||
LangDemonTongue = 139,
|
||||
LangTitan = 140,
|
||||
LangOldTongue = 141,
|
||||
Survival = 142,
|
||||
HorseRiding = 148,
|
||||
WolfRiding = 149,
|
||||
TigerRiding = 150,
|
||||
RamRiding = 152,
|
||||
Swimming = 155,
|
||||
TwoHandedMaces = 160,
|
||||
Unarmed = 162,
|
||||
Blacksmithing = 164,
|
||||
Leatherworking = 165,
|
||||
Alchemy = 171,
|
||||
TwoHandedAxes = 172,
|
||||
Daggers = 173,
|
||||
Herbalism = 182,
|
||||
GenericDnd = 183,
|
||||
Cooking = 185,
|
||||
Mining = 186,
|
||||
PetImp = 188,
|
||||
PetFelhunter = 189,
|
||||
Tailoring = 197,
|
||||
Engineering = 202,
|
||||
PetSpider = 203,
|
||||
PetVoidwalker = 204,
|
||||
PetSuccubus = 205,
|
||||
PetInfernal = 206,
|
||||
PetDoomguard = 207,
|
||||
PetWolf = 208,
|
||||
PetCat = 209,
|
||||
PetBear = 210,
|
||||
PetBoar = 211,
|
||||
PetCrocolisk = 212,
|
||||
PetCarrionBird = 213,
|
||||
PetCrab = 214,
|
||||
PetGorilla = 215,
|
||||
PetRaptor = 217,
|
||||
PetTallstrider = 218,
|
||||
RacialUndead = 220,
|
||||
Crossbows = 226,
|
||||
Wands = 228,
|
||||
Polearms = 229,
|
||||
PetScorpid = 236,
|
||||
PetTurtle = 251,
|
||||
PetGenericHunter = 270,
|
||||
PlateMail = 293,
|
||||
LangGnomish = 313,
|
||||
LangTroll = 315,
|
||||
Enchanting = 333,
|
||||
Fishing = 356,
|
||||
Skinning = 393,
|
||||
Mail = 413,
|
||||
Leather = 414,
|
||||
Cloth = 415,
|
||||
Shield = 433,
|
||||
FistWeapons = 473,
|
||||
RaptorRiding = 533,
|
||||
MechanostriderPiloting = 553,
|
||||
UndeadHorsemanship = 554,
|
||||
PetBat = 653,
|
||||
PetHyena = 654,
|
||||
PetBirdOfPrey = 655,
|
||||
PetWindSerpent = 656,
|
||||
LangForsaken = 673,
|
||||
KodoRiding = 713,
|
||||
RacialTroll = 733,
|
||||
RacialGnome = 753,
|
||||
RacialHuman = 754,
|
||||
Jewelcrafting = 755,
|
||||
RacialBloodElf = 756,
|
||||
PetEventRemoteControl = 758,
|
||||
LangDraenei = 759,
|
||||
RacialDraenei = 760,
|
||||
PetFelguard = 761,
|
||||
Riding = 762,
|
||||
PetDragonhawk = 763,
|
||||
PetNetherRay = 764,
|
||||
PetSporebat = 765,
|
||||
PetWarpStalker = 766,
|
||||
PetRavager = 767,
|
||||
PetSerpent = 768,
|
||||
Internal = 769,
|
||||
Inscription = 773,
|
||||
PetMoth = 775,
|
||||
Mounts = 777,
|
||||
Companions = 778,
|
||||
PetExoticChimaera = 780,
|
||||
PetExoticDevilsaur = 781,
|
||||
PetGhoul = 782,
|
||||
PetExoticSilithid = 783,
|
||||
PetExoticWorm = 784,
|
||||
PetWasp = 785,
|
||||
PetExoticClefthoof = 786,
|
||||
PetExoticCoreHound = 787,
|
||||
PetExoticSpiritBeast = 788,
|
||||
RacialWorgen = 789,
|
||||
RacialGoblin = 790,
|
||||
LangGilnean = 791,
|
||||
LangGoblin = 792,
|
||||
Archaeology = 794,
|
||||
Hunter = 795,
|
||||
DeathKnight = 796,
|
||||
Druid = 798,
|
||||
Paladin = 800,
|
||||
Priest = 804,
|
||||
PetWaterElemental = 805,
|
||||
PetFox = 808,
|
||||
AllGlyphs = 810,
|
||||
PetDog = 811,
|
||||
PetMonkey = 815,
|
||||
PetShaleSpider = 817,
|
||||
Beetle = 818,
|
||||
AllGuildPerks = 821,
|
||||
PetHydra = 824,
|
||||
Monk = 829,
|
||||
Warrior = 840,
|
||||
Warlock = 849,
|
||||
RacialPandaren = 899,
|
||||
Mage = 904,
|
||||
LangPandarenNeutral = 905,
|
||||
LangPandarenAlliance = 906,
|
||||
LangPandarenHorde = 907,
|
||||
Rogue = 921,
|
||||
Shaman = 924,
|
||||
FelImp = 927,
|
||||
Voidlord = 928,
|
||||
Shivarra = 929,
|
||||
Observer = 930,
|
||||
Wrathguard = 931,
|
||||
AllSpecializations = 934,
|
||||
Runeforging = 960,
|
||||
PetPrimalFireElemental = 962,
|
||||
PetPrimalEarthElemental = 963,
|
||||
WayOfTheGrill = 975,
|
||||
WayOfTheWok = 976,
|
||||
WayOfThePot = 977,
|
||||
WayOfTheSteamer = 978,
|
||||
WayOfTheOven = 979,
|
||||
WayOfTheBrew = 980,
|
||||
ApprenticeCooking = 981,
|
||||
JourneymanCookbook = 982,
|
||||
Porcupine = 983,
|
||||
Crane = 984,
|
||||
WaterStrider = 985,
|
||||
PetExoticQuilen = 986,
|
||||
PetGoat = 987,
|
||||
Basilisk = 988,
|
||||
NoPlayers = 999,
|
||||
Direhorn = 1305,
|
||||
PetPrimalStormElemental = 1748,
|
||||
PetWaterElementalMinorTalentVersion = 1777,
|
||||
PetExoticRylak = 1818,
|
||||
PetRiverbeast = 1819,
|
||||
Unused = 1830,
|
||||
DemonHunter = 1848,
|
||||
Logging = 1945,
|
||||
PetTerrorguard = 1981,
|
||||
PetAbyssal = 1982,
|
||||
PetStag = 1993,
|
||||
TradingPost = 2000,
|
||||
Warglaives = 2152,
|
||||
PetMechanical = 2189,
|
||||
PetAbomination = 2216,
|
||||
}
|
||||
|
||||
public enum SkillState
|
||||
{
|
||||
Unchanged = 0,
|
||||
Changed = 1,
|
||||
New = 2,
|
||||
Deleted = 3
|
||||
}
|
||||
|
||||
public enum SkillCategory : byte
|
||||
{
|
||||
Unk = 0,
|
||||
Attributes = 5,
|
||||
Weapon = 6,
|
||||
Class = 7,
|
||||
Armor = 8,
|
||||
Secondary = 9,
|
||||
Languages = 10,
|
||||
Profession = 11,
|
||||
Generic = 12
|
||||
}
|
||||
|
||||
public enum SkillRangeType
|
||||
{
|
||||
Language, // 300..300
|
||||
Level, // 1..max skill for level
|
||||
Mono, // 1..1, grey monolite bar
|
||||
Rank, // 1..skill for known rank
|
||||
None // 0..0 always
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,567 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum AuraType
|
||||
{
|
||||
Any = -1,
|
||||
|
||||
None = 0,
|
||||
BindSight = 1,
|
||||
ModPossess = 2,
|
||||
PeriodicDamage = 3,
|
||||
Dummy = 4,
|
||||
ModConfuse = 5,
|
||||
ModCharm = 6,
|
||||
ModFear = 7,
|
||||
PeriodicHeal = 8,
|
||||
ModAttackspeed = 9,
|
||||
ModThreat = 10,
|
||||
ModTaunt = 11,
|
||||
ModStun = 12,
|
||||
ModDamageDone = 13,
|
||||
ModDamageTaken = 14,
|
||||
DamageShield = 15,
|
||||
ModStealth = 16,
|
||||
ModStealthDetect = 17,
|
||||
ModInvisibility = 18,
|
||||
ModInvisibilityDetect = 19,
|
||||
ObsModHealth = 20, // 20, 21 Unofficial
|
||||
ObsModPower = 21,
|
||||
ModResistance = 22,
|
||||
PeriodicTriggerSpell = 23,
|
||||
PeriodicEnergize = 24,
|
||||
ModPacify = 25,
|
||||
ModRoot = 26,
|
||||
ModSilence = 27,
|
||||
ReflectSpells = 28,
|
||||
ModStat = 29,
|
||||
ModSkill = 30,
|
||||
ModIncreaseSpeed = 31,
|
||||
ModIncreaseMountedSpeed = 32,
|
||||
ModDecreaseSpeed = 33,
|
||||
ModIncreaseHealth = 34,
|
||||
ModIncreaseEnergy = 35,
|
||||
ModShapeshift = 36,
|
||||
EffectImmunity = 37,
|
||||
StateImmunity = 38,
|
||||
SchoolImmunity = 39,
|
||||
DamageImmunity = 40,
|
||||
DispelImmunity = 41,
|
||||
ProcTriggerSpell = 42,
|
||||
ProcTriggerDamage = 43,
|
||||
TrackCreatures = 44,
|
||||
TrackResources = 45,
|
||||
Unk46 = 46, // Ignore All Gear Test Spells
|
||||
ModParryPercent = 47,
|
||||
Unk48 = 48, // One Periodic Spell
|
||||
ModDodgePercent = 49,
|
||||
ModCriticalHealingAmount = 50,
|
||||
ModBlockPercent = 51,
|
||||
ModWeaponCritPercent = 52,
|
||||
PeriodicLeech = 53,
|
||||
ModHitChance = 54,
|
||||
ModSpellHitChance = 55,
|
||||
Transform = 56,
|
||||
ModSpellCritChance = 57,
|
||||
ModIncreaseSwimSpeed = 58,
|
||||
ModDamageDoneCreature = 59,
|
||||
ModPacifySilence = 60,
|
||||
ModScale = 61,
|
||||
PeriodicHealthFunnel = 62,
|
||||
ModAdditionalPowerCost = 63, // NYI
|
||||
PeriodicManaLeech = 64,
|
||||
ModCastingSpeedNotStack = 65,
|
||||
FeignDeath = 66,
|
||||
ModDisarm = 67,
|
||||
ModStalked = 68,
|
||||
SchoolAbsorb = 69,
|
||||
ExtraAttacks = 70,
|
||||
Unk71 = 71,
|
||||
ModPowerCostSchoolPct = 72,
|
||||
ModPowerCostSchool = 73,
|
||||
ReflectSpellsSchool = 74,
|
||||
ModLanguage = 75,
|
||||
FarSight = 76,
|
||||
MechanicImmunity = 77,
|
||||
Mounted = 78,
|
||||
ModDamagePercentDone = 79,
|
||||
ModPercentStat = 80,
|
||||
SplitDamagePct = 81,
|
||||
WaterBreathing = 82,
|
||||
ModBaseResistance = 83,
|
||||
ModRegen = 84,
|
||||
ModPowerRegen = 85,
|
||||
ChannelDeathItem = 86,
|
||||
ModDamagePercentTaken = 87,
|
||||
ModHealthRegenPercent = 88,
|
||||
PeriodicDamagePercent = 89,
|
||||
Unk90 = 90, // Old ModResistChance
|
||||
ModDetectRange = 91,
|
||||
PreventsFleeing = 92,
|
||||
ModUnattackable = 93,
|
||||
InterruptRegen = 94,
|
||||
Ghost = 95,
|
||||
SpellMagnet = 96,
|
||||
ManaShield = 97,
|
||||
ModSkillTalent = 98,
|
||||
ModAttackPower = 99,
|
||||
AurasVisible = 100,
|
||||
ModResistancePct = 101,
|
||||
ModMeleeAttackPowerVersus = 102,
|
||||
ModTotalThreat = 103,
|
||||
WaterWalk = 104,
|
||||
FeatherFall = 105,
|
||||
Hover = 106,
|
||||
AddFlatModifier = 107,
|
||||
AddPctModifier = 108,
|
||||
AddTargetTrigger = 109,
|
||||
ModPowerRegenPercent = 110,
|
||||
InterceptMeleeRangedAttacks = 111,
|
||||
OverrideClassScripts = 112,
|
||||
ModRangedDamageTaken = 113,
|
||||
ModRangedDamageTakenPct = 114,
|
||||
ModHealing = 115,
|
||||
ModRegenDuringCombat = 116,
|
||||
ModMechanicResistance = 117,
|
||||
ModHealingPct = 118,
|
||||
Unk119 = 119, // Old SharePetTracking
|
||||
Untrackable = 120,
|
||||
Empathy = 121,
|
||||
ModOffhandDamagePct = 122,
|
||||
ModTargetResistance = 123,
|
||||
ModRangedAttackPower = 124,
|
||||
ModMeleeDamageTaken = 125,
|
||||
ModMeleeDamageTakenPct = 126,
|
||||
RangedAttackPowerAttackerBonus = 127,
|
||||
ModPossessPet = 128,
|
||||
ModSpeedAlways = 129,
|
||||
ModMountedSpeedAlways = 130,
|
||||
ModRangedAttackPowerVersus = 131,
|
||||
ModIncreaseEnergyPercent = 132,
|
||||
ModIncreaseHealthPercent = 133,
|
||||
ModManaRegenInterrupt = 134,
|
||||
ModHealingDone = 135,
|
||||
ModHealingDonePercent = 136,
|
||||
ModTotalStatPercentage = 137,
|
||||
ModMeleeHaste = 138,
|
||||
ForceReaction = 139,
|
||||
ModRangedHaste = 140,
|
||||
Unk141 = 141, // Old ModRangedAmmoHaste, Unused Now
|
||||
ModBaseResistancePct = 142,
|
||||
ModRecoveryRate = 143, // NYI
|
||||
SafeFall = 144,
|
||||
ModPetTalentPoints = 145,
|
||||
AllowTamePetType = 146,
|
||||
MechanicImmunityMask = 147,
|
||||
RetainComboPoints = 148,
|
||||
ReducePushback = 149, // Reduce Pushback
|
||||
ModShieldBlockvaluePct = 150,
|
||||
TrackStealthed = 151, // Track Stealthed
|
||||
ModDetectedRange = 152, // Mod Detected Range
|
||||
Unk153 = 153, // Old SplitDamageFlat. Unused 4.3.4
|
||||
ModStealthLevel = 154, // Stealth Level Modifier
|
||||
ModWaterBreathing = 155, // Mod Water Breathing
|
||||
ModReputationGain = 156, // Mod Reputation Gain
|
||||
PetDamageMulti = 157, // Mod Pet Damage
|
||||
AllowTalentSwapping = 158,
|
||||
NoPvpCredit = 159,
|
||||
Unk160 = 160, // Old ModAoeAvoidance. Unused 4.3.4
|
||||
ModHealthRegenInCombat = 161,
|
||||
PowerBurn = 162,
|
||||
ModCritDamageBonus = 163,
|
||||
Unk164 = 164,
|
||||
MeleeAttackPowerAttackerBonus = 165,
|
||||
ModAttackPowerPct = 166,
|
||||
ModRangedAttackPowerPct = 167,
|
||||
ModDamageDoneVersus = 168,
|
||||
Unk169 = 169, // Old ModCritPercentVersus. Unused 4.3.4
|
||||
DetectAmore = 170,
|
||||
ModSpeedNotStack = 171,
|
||||
ModMountedSpeedNotStack = 172,
|
||||
ModRecoveryRate2 = 173, // NYI
|
||||
ModSpellDamageOfStatPercent = 174, // By Defeult Intelect, Dependent From ModSpellHealingOfStatPercent
|
||||
ModSpellHealingOfStatPercent = 175,
|
||||
SpiritOfRedemption = 176,
|
||||
AoeCharm = 177,
|
||||
ModMaxPowerPct = 178, // NYI
|
||||
ModPowerDisplay = 179,
|
||||
ModFlatSpellDamageVersus = 180,
|
||||
Unk181 = 181, // Old ModFlatSpellCritDamageVersus - Possible Flat Spell Crit Damage Versus
|
||||
ModResistanceOfStatPercent = 182,
|
||||
ModCriticalThreat = 183,
|
||||
ModAttackerMeleeHitChance = 184,
|
||||
ModAttackerRangedHitChance = 185,
|
||||
ModAttackerSpellHitChance = 186,
|
||||
ModAttackerMeleeCritChance = 187,
|
||||
ModAttackerRangedCritChance = 188,
|
||||
ModRating = 189,
|
||||
ModFactionReputationGain = 190,
|
||||
UseNormalMovementSpeed = 191,
|
||||
ModMeleeRangedHaste = 192,
|
||||
MeleeSlow = 193,
|
||||
ModTargetAbsorbSchool = 194,
|
||||
ModTargetAbilityAbsorbSchool = 195,
|
||||
ModCooldown = 196, // Only 24818 Noxious Breath
|
||||
ModAttackerSpellAndWeaponCritChance = 197,
|
||||
Unk198 = 198, // Old ModAllWeaponSkills
|
||||
Unk199 = 199, // Old ModIncreasesSpellPctToHit. Unused 4.3.4
|
||||
ModXpPct = 200,
|
||||
Fly = 201,
|
||||
IgnoreCombatResult = 202,
|
||||
PreventInterrupt = 203, // NYI
|
||||
PreventCorpseRelease = 204, // NYI
|
||||
ModChargeCooldown = 205, // NYI
|
||||
ModIncreaseVehicleFlightSpeed = 206,
|
||||
ModIncreaseMountedFlightSpeed = 207,
|
||||
ModIncreaseFlightSpeed = 208,
|
||||
ModMountedFlightSpeedAlways = 209,
|
||||
ModVehicleSpeedAlways = 210,
|
||||
ModFlightSpeedNotStack = 211,
|
||||
ModHonorGainPct = 212,
|
||||
ModRageFromDamageDealt = 213,
|
||||
Unk214 = 214,
|
||||
ArenaPreparation = 215,
|
||||
HasteSpells = 216,
|
||||
ModMeleeHaste2 = 217,
|
||||
Unk218 = 218, // old SPELL_AURA_HASTE_RANGED
|
||||
ModManaRegenFromStat = 219,
|
||||
ModRatingFromStat = 220,
|
||||
ModDetaunt = 221,
|
||||
Unk222 = 222,
|
||||
Unk223 = 223,
|
||||
Unk224 = 224,
|
||||
ModVisibilityRange = 225,
|
||||
PeriodicDummy = 226,
|
||||
PeriodicTriggerSpellWithValue = 227,
|
||||
DetectStealth = 228,
|
||||
ModAoeDamageAvoidance = 229,
|
||||
ModMaxHealth = 230,
|
||||
ProcTriggerSpellWithValue = 231,
|
||||
MechanicDurationMod = 232,
|
||||
ChangeModelForAllHumanoids = 233, // Client-Side Only
|
||||
MechanicDurationModNotStack = 234,
|
||||
ModDispelResist = 235,
|
||||
ControlVehicle = 236,
|
||||
ModSpellDamageOfAttackPower = 237,
|
||||
ModSpellHealingOfAttackPower = 238,
|
||||
ModScale2 = 239,
|
||||
ModExpertise = 240,
|
||||
ForceMoveForward = 241,
|
||||
ModSpellDamageFromHealing = 242,
|
||||
ModFaction = 243,
|
||||
ComprehendLanguage = 244,
|
||||
ModAuraDurationByDispel = 245,
|
||||
ModAuraDurationByDispelNotStack = 246,
|
||||
CloneCaster = 247,
|
||||
ModCombatResultChance = 248,
|
||||
ConvertRune = 249,
|
||||
ModIncreaseHealth2 = 250,
|
||||
ModEnemyDodge = 251,
|
||||
ModSpeedSlowAll = 252,
|
||||
ModBlockCritChance = 253,
|
||||
ModDisarmOffhand = 254,
|
||||
ModMechanicDamageTakenPercent = 255,
|
||||
NoReagentUse = 256,
|
||||
ModTargetResistBySpellClass = 257,
|
||||
OverrideSummonedObject = 258,
|
||||
Unk259 = 259, // Old ModHotPct, Unused 4.3.4
|
||||
ScreenEffect = 260,
|
||||
Phase = 261,
|
||||
AbilityIgnoreAurastate = 262,
|
||||
AllowOnlyAbility = 263,
|
||||
Unk264 = 264,
|
||||
Unk265 = 265,
|
||||
Unk266 = 266,
|
||||
ModImmuneAuraApplySchool = 267,
|
||||
Unk268 = 268, // Old ModAttackPowerOfStatPercent. Unused 4.3.4
|
||||
ModIgnoreTargetResist = 269,
|
||||
ModSchoolMaskDamageFromCaster = 270, // NYI
|
||||
ModSpellDamageFromCaster = 271,
|
||||
IgnoreMeleeReset = 272,
|
||||
XRay = 273,
|
||||
Unk274 = 274, // Old AbilityConsumeNoAmmo, Unused 4.3.4
|
||||
ModIgnoreShapeshift = 275,
|
||||
ModDamageDoneForMechanic = 276,
|
||||
Unk277 = 277, // Old ModMaxAffectedTargets. Unused 4.3.4
|
||||
ModDisarmRanged = 278,
|
||||
InitializeImages = 279,
|
||||
Unk280 = 280, // Old ModArmorPenetrationPct Unused 4.3.4
|
||||
ModGuildReputationGainPct = 281, // NYI
|
||||
ModBaseHealthPct = 282,
|
||||
ModHealingReceived = 283, // Possibly Only For Some Spell Family Class Spells
|
||||
Linked = 284,
|
||||
ModAttackPowerOfArmor = 285,
|
||||
AbilityPeriodicCrit = 286,
|
||||
DeflectSpells = 287,
|
||||
IgnoreHitDirection = 288,
|
||||
PreventDurabilityLoss = 289,
|
||||
ModCritPct = 290,
|
||||
ModXpQuestPct = 291,
|
||||
OpenStable = 292,
|
||||
OverrideSpells = 293,
|
||||
PreventRegeneratePower = 294,
|
||||
Unk295 = 295,
|
||||
SetVehicleId = 296,
|
||||
BlockSpellFamily = 297,
|
||||
Strangulate = 298,
|
||||
Unk299 = 299,
|
||||
ShareDamagePct = 300,
|
||||
SchoolHealAbsorb = 301,
|
||||
Unk302 = 302,
|
||||
ModDamageDoneVersusAurastate = 303,
|
||||
ModFakeInebriate = 304,
|
||||
ModMinimumSpeed = 305,
|
||||
Unk306 = 306,
|
||||
HealAbsorbTest = 307,
|
||||
ModCritChanceForCaster = 308,
|
||||
ModResilience = 309, // NYI
|
||||
ModCreatureAoeDamageAvoidance = 310,
|
||||
Unk311 = 311,
|
||||
AnimReplacementSet = 312,
|
||||
Unk313 = 313, // Not Used In 4.3.4 - Related To Mounts
|
||||
PreventResurrection = 314,
|
||||
UnderwaterWalking = 315,
|
||||
PeriodicHaste = 316, // Not Used In 4.3.4 (Name From 3.3.5a)
|
||||
ModSpellPowerPct = 317,
|
||||
Mastery = 318,
|
||||
ModMeleeHaste3 = 319,
|
||||
ModRangedHaste2 = 320,
|
||||
ModNoActions = 321,
|
||||
InterfereTargetting = 322,
|
||||
Unk323 = 323, // Not Used In 4.3.4
|
||||
Unk324 = 324, // Spell Critical Chance (Probably By School Mask)
|
||||
Unk325 = 325, // Not Used In 4.3.4
|
||||
PhaseGroup = 326, // Phase Related
|
||||
Unk327 = 327, // Not Used In 4.3.4
|
||||
TriggerSpellOnPowerPct = 328,
|
||||
ModPowerGainPct = 329, // Nyi
|
||||
CastWhileWalking = 330,
|
||||
ForceWeather = 331,
|
||||
OverrideActionbarSpells = 332,
|
||||
OverrideActionbarSpellsTriggered = 333, // Spells cast with this override have no cast time or power cost
|
||||
ModBlind = 334, // Nyi
|
||||
Unk335 = 335,
|
||||
ModFlyingRestrictions = 336, // Nyi
|
||||
ModVendorItemsPrices = 337,
|
||||
ModDurabilityLoss = 338,
|
||||
IncreaseSkillGainChance = 339, // Nyi
|
||||
ModResurrectedHealthByGuildMember = 340, // Increases Health Gained When Resurrected By A Guild Member By X
|
||||
ModSpellCategoryCooldown = 341,
|
||||
ModMeleeRangedHaste2 = 342,
|
||||
ModMeleeDamageFromCaster = 343,
|
||||
ModAutoattackDamage = 344,
|
||||
BypassArmorForCaster = 345,
|
||||
EnableAltPower = 346, // Nyi
|
||||
ModSpellCooldownByHaste = 347,
|
||||
DepositBonusMoneyInGuildBankOnLoot = 348, // Nyi
|
||||
ModCurrencyGain = 349,
|
||||
ModGatheringItemsGainedPercent = 350, // Nyi
|
||||
Unk351 = 351,
|
||||
Unk352 = 352,
|
||||
ModCamouflage = 353, // Nyi
|
||||
Unk354 = 354, // Restoration Shaman Mastery - Mod Healing Based On Target'S Health (Less = More Healing)
|
||||
ModCastingSpeed = 355, // NYI
|
||||
Unk356 = 356, // Arcane Mage Mastery - Mod Damage Based On Current Mana
|
||||
EnableBoss1UnitFrame = 357,
|
||||
WorgenAlteredForm = 358,
|
||||
Unk359 = 359,
|
||||
ProcTriggerSpellCopy = 360, // Procs The Same Spell That Caused This Proc (Dragonwrath, Tarecgosa'S Rest)
|
||||
OverrideAutoattackWithMeleeSpell = 361, // NYI
|
||||
Unk362 = 362, // Not Used In 4.3.4
|
||||
ModNextSpell = 363, // Used By 101601 Throw Totem - Causes The Client To Initialize Spell Cast With Specified Spell
|
||||
Unk364 = 364, // Not Used In 4.3.4
|
||||
MaxFarClipPlane = 365, // Overrides Client'S View Distance Setting To Max("Fair", CurrentSetting) And Turns Off Terrain Display
|
||||
OverrideSpellPowerByApPct = 366, // Sets Spellpower Equal To % Of Attack Power, Discarding All Other Bonuses (From Gear And Buffs)
|
||||
OverrideAutoattackWithRangedSpell = 367, // NYI
|
||||
Unk368 = 368, // Not Used In 4.3.4
|
||||
EnablePowerBarTimer = 369,
|
||||
SetFairFarClip = 370, // Overrides Client'S View Distance Setting To Max("Fair", CurrentSetting)
|
||||
Unk371 = 371,
|
||||
Unk372 = 372,
|
||||
ModSpeedNoControl = 373, // NYI
|
||||
ModifyFallDamagePct = 374,
|
||||
Unk375 = 375,
|
||||
ModCurrencyGainFromSource = 376, // NYI
|
||||
CastWhileWalking2 = 377, // NYI
|
||||
Unk378 = 378,
|
||||
Unk379 = 379,
|
||||
ModGlobalCooldownByHaste = 380, // Allows melee abilities to benefit from haste GCD reduction
|
||||
Unk381 = 381,
|
||||
ModPetStatPct = 382, // NYI
|
||||
IgnoreSpellCooldown = 383,
|
||||
Unk384 = 384,
|
||||
ChanceOverrideAutoattackWithSpellOnSelf = 385,// NYI (with triggered spell cast by the initial caster?)
|
||||
Unk386 = 386,
|
||||
Unk387 = 387,
|
||||
ModTaxiFlightSpeed = 388,
|
||||
Unk389 = 389,
|
||||
Unk390 = 390,
|
||||
Unk391 = 391,
|
||||
Unk392 = 392,
|
||||
Unk393 = 393,
|
||||
ShowConfirmationPrompt = 394,
|
||||
AreaTrigger = 395, // NYI
|
||||
TriggerSpellOnPowerAmount = 396,
|
||||
Unk397 = 397,
|
||||
Unk398 = 398,
|
||||
Unk399 = 399,
|
||||
ModSkill2 = 400,
|
||||
Unk401 = 401,
|
||||
ModOverridePowerDisplay = 402,
|
||||
OverrideSpellVisual = 403,
|
||||
OverrideAttackPowerBySpPct = 404,
|
||||
ModRatingPct = 405, // NYI
|
||||
KeyboundOverride = 406, // NYI
|
||||
ModFear2 = 407,
|
||||
Unk408 = 408,
|
||||
CanTurnWhileFalling = 409,
|
||||
Unk410 = 410,
|
||||
ModMaxCharges = 411,
|
||||
Unk412 = 412,
|
||||
Unk413 = 413,
|
||||
Unk414 = 414,
|
||||
Unk415 = 415,
|
||||
ModCooldownByHasteRegen = 416,
|
||||
ModGlobalCooldownByHasteRegen = 417,
|
||||
ModMaxPower = 418, // NYI
|
||||
ModBaseManaPct = 419,
|
||||
ModBattlePetXpPct = 420,
|
||||
ModAbsorbEffectsAmountPct = 421, // NYI
|
||||
Unk422 = 422,
|
||||
Unk423 = 423,
|
||||
Unk424 = 424,
|
||||
Unk425 = 425,
|
||||
Unk426 = 426,
|
||||
ScalePlayerLevel = 427, // NYI
|
||||
Unk428 = 428,
|
||||
Unk429 = 429,
|
||||
PlayScene = 430,
|
||||
ModOverrideZonePvpType = 431, // NYI
|
||||
Unk432 = 432,
|
||||
Unk433 = 433,
|
||||
Unk434 = 434,
|
||||
Unk435 = 435,
|
||||
ModEnvironmentalDamageTaken = 436, // NYI
|
||||
ModMinimumSpeedRate = 437,
|
||||
PreloadPhase = 438, // NYI
|
||||
Unk439 = 439,
|
||||
ModMultistrikeDamage = 440, // NYI
|
||||
ModMultistrikeChance = 441, // NYI
|
||||
ModReadiness = 442, // NYI
|
||||
ModLeech = 443, // NYI
|
||||
Unk444 = 444,
|
||||
Unk445 = 445,
|
||||
Unk446 = 446,
|
||||
ModXpFromCreatureType = 447,
|
||||
Unk448 = 448,
|
||||
Unk449 = 449,
|
||||
Unk450 = 450,
|
||||
OverridePetSpecs = 451,
|
||||
Unk452 = 452,
|
||||
ChargeRecoveryMod = 453,
|
||||
ChargeRecoveryMultiplier = 454,
|
||||
ModRoot2 = 455,
|
||||
ChargeRecoveryAffectedByHaste = 456,
|
||||
ChargeRecoveryAffectedByHasteRegen = 457,
|
||||
IgnoreDualWieldHitPenalty = 458,
|
||||
IgnoreMovementForces = 459,
|
||||
ResetCooldownsOnDuelStart = 460,
|
||||
Unk461 = 461,
|
||||
ModHealingAndAbsorbFromCaster = 462, // NYI
|
||||
ConvertCritRatingPctToParryRating = 463, // NYI
|
||||
ModAttackPowerOfBonusArmor = 464, // NYI
|
||||
ModBonusArmor = 465, // NYI
|
||||
ModBonusArmorPct = 466,
|
||||
ModStatBonusPct = 467,
|
||||
TriggerSpellOnHealthPct = 468,
|
||||
ShowConfirmationPromptWithDifficulty = 469,
|
||||
Unk470 = 470,
|
||||
ModVersatility = 471, // NYI
|
||||
Unk472 = 472,
|
||||
PreventDurabilityLossFromCombat = 473,
|
||||
Unk474 = 474,
|
||||
AllowUsingGameobjectsWhileMounted = 475,
|
||||
ModCurrencyGainLooted = 476,
|
||||
Unk477 = 477,
|
||||
Unk478 = 478,
|
||||
Unk479 = 479,
|
||||
Unk480 = 480,
|
||||
ConvertConsumedRune = 481,
|
||||
Unk482 = 482,
|
||||
SuppressTransforms = 483, // NYI
|
||||
Unk484 = 484,
|
||||
Unk485 = 485,
|
||||
Unk486 = 486,
|
||||
Unk487 = 487,
|
||||
Unk488 = 488,
|
||||
Unk489 = 489,
|
||||
Unk490 = 490,
|
||||
Unk491 = 491,
|
||||
Total = 492
|
||||
}
|
||||
|
||||
public enum AuraEffectHandleModes
|
||||
{
|
||||
Default = 0x0,
|
||||
Real = 0x01, // Handler Applies/Removes Effect From Unit
|
||||
SendForClient = 0x02, // Handler Sends Apply/Remove Packet To Unit
|
||||
ChangeAmount = 0x04, // Handler Updates Effect On Target After Effect Amount Change
|
||||
Reapply = 0x08, // Handler Updates Effect On Target After Aura Is Reapplied On Target
|
||||
Stat = 0x10, // Handler Updates Effect On Target When Stat Removal/Apply Is Needed For Calculations By Core
|
||||
Skill = 0x20, // Handler Updates Effect On Target When Skill Removal/Apply Is Needed For Calculations By Core
|
||||
SendForClientMask = (SendForClient | Real), // Any Case Handler Need To Send Packet
|
||||
ChangeAmountMask = (ChangeAmount | Real), // Any Case Handler Applies Effect Depending On Amount
|
||||
ChangeAmountSendForClientMask = (ChangeAmountMask | SendForClientMask),
|
||||
RealOrReapplyMask = (Reapply | Real)
|
||||
}
|
||||
|
||||
// Diminishing Returns Types
|
||||
public enum DiminishingReturnsType
|
||||
{
|
||||
None = 0, // this spell is not diminished, but may have its duration limited
|
||||
Player = 1, // this spell is diminished only when applied on players
|
||||
All = 2 // this spell is diminished in every case
|
||||
}
|
||||
|
||||
// Diminishing Return Groups
|
||||
public enum DiminishingGroup
|
||||
{
|
||||
None = 0,
|
||||
Root = 1,
|
||||
Stun = 2,
|
||||
Incapacitate = 3,
|
||||
Disorient = 4,
|
||||
Silence = 5,
|
||||
AOEKnockback = 6,
|
||||
Taunt = 7,
|
||||
LimitOnly = 8,
|
||||
|
||||
Max
|
||||
}
|
||||
|
||||
public enum DiminishingLevels
|
||||
{
|
||||
Level1 = 0,
|
||||
Level2 = 1,
|
||||
Level3 = 2,
|
||||
Immune = 3,
|
||||
Level4 = 3,
|
||||
TauntImmune = 4
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum GMTicketSystemStatus
|
||||
{
|
||||
Disabled = 0,
|
||||
Enabled = 1
|
||||
}
|
||||
|
||||
public enum GMSupportComplaintType
|
||||
{
|
||||
None = 0,
|
||||
Language = 2,
|
||||
PlayerName = 4,
|
||||
Cheat = 15,
|
||||
GuildName = 23,
|
||||
Spamming = 24
|
||||
}
|
||||
|
||||
public enum SupportSpamType
|
||||
{
|
||||
Mail = 0,
|
||||
Chat = 1,
|
||||
Calendar = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,577 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum VehicleSeatFlags : uint
|
||||
{
|
||||
HasLowerAnimForEnter = 0x01,
|
||||
HasLowerAnimForRide = 0x02,
|
||||
Unk3 = 0x04,
|
||||
ShouldUseVehSeatExitAnimOnVoluntaryExit = 0x08,
|
||||
Unk5 = 0x10,
|
||||
Unk6 = 0x20,
|
||||
Unk7 = 0x40,
|
||||
Unk8 = 0x80,
|
||||
Unk9 = 0x100,
|
||||
HidePassenger = 0x200, // Passenger Is Hidden
|
||||
AllowTurning = 0x400, // Needed For CgcameraSyncfreelookfacing
|
||||
CanControl = 0x800, // LuaUnitinvehiclecontrolseat
|
||||
CanCastMountSpell = 0x1000, // Can Cast Spells With SpellAuraMounted From Seat (Possibly 4.X Only, 0 Seats On 3.3.5a)
|
||||
Uncontrolled = 0x2000, // Can Override !& CanEnterOrExit
|
||||
CanAttack = 0x4000, // Can Attack, Cast Spells And Use Items From Vehicle
|
||||
ShouldUseVehSeatExitAnimOnForcedExit = 0x8000,
|
||||
Unk17 = 0x10000,
|
||||
Unk18 = 0x20000, // Needs Research And Support (28 Vehicles): Allow Entering Vehicles While Keeping Specific Permanent(?) Auras That Impose Visuals (States Like Beeing Under Freeze/Stun Mechanic, Emote State Animations).
|
||||
HasVehExitAnimVoluntaryExit = 0x40000,
|
||||
HasVehExitAnimForcedExit = 0x80000,
|
||||
PassengerNotSelectable = 0x100000,
|
||||
Unk22 = 0x200000,
|
||||
RecHasVehicleEnterAnim = 0x400000,
|
||||
IsUsingVehicleControls = 0x800000, // LuaIsusingvehiclecontrols
|
||||
EnableVehicleZoom = 0x1000000,
|
||||
CanEnterOrExit = 0x2000000, // LuaCanexitvehicle - Can Enter And Exit At Free Will
|
||||
CanSwitch = 0x4000000, // LuaCanswitchvehicleseats
|
||||
HasStartWaritingForVehTransitionAnimEnter = 0x8000000,
|
||||
HasStartWaritingForVehTransitionAnimExit = 0x10000000,
|
||||
CanCast = 0x20000000, // LuaUnithasvehicleui
|
||||
Unk2 = 0x40000000, // Checked In Conjunction With 0x800 In Castspell2
|
||||
AllowsInteraction = 0x80000000
|
||||
}
|
||||
|
||||
public enum VehicleSeatFlagsB : uint
|
||||
{
|
||||
None = 0x00,
|
||||
UsableForced = 0x02,
|
||||
TargetsInRaidUi = 0x08, // Lua_Unittargetsvehicleinraidui
|
||||
Ejectable = 0x20, // Ejectable
|
||||
UsableForced2 = 0x40,
|
||||
UsableForced3 = 0x100,
|
||||
KeepPet = 0x20000,
|
||||
UsableForced4 = 0x02000000,
|
||||
CanSwitch = 0x4000000,
|
||||
VehiclePlayerframeUi = 0x80000000 // Lua_Unithasvehicleplayerframeui - Actually Checked For Flagsb &~ 0x80000000
|
||||
}
|
||||
|
||||
public enum SpellClickCastFlags
|
||||
{
|
||||
CasterClicker = 0x01,
|
||||
TargetClicker = 0x02,
|
||||
OrigCasterOwner = 0x04
|
||||
}
|
||||
|
||||
|
||||
public enum SummonSlot
|
||||
{
|
||||
Pet = 0,
|
||||
Totem = 1,
|
||||
MiniPet = 5,
|
||||
Quest = 6,
|
||||
}
|
||||
public enum PlayerTotemType
|
||||
{
|
||||
Fire = 63,
|
||||
Earth = 81,
|
||||
Water = 82,
|
||||
Air = 83
|
||||
}
|
||||
|
||||
public enum BaseModType
|
||||
{
|
||||
FlatMod,
|
||||
PCTmod,
|
||||
End
|
||||
}
|
||||
|
||||
//To all Immune system, if target has immunes,
|
||||
//some spell that related to ImmuneToDispel or ImmuneToSchool or ImmuneToDamage type can't cast to it,
|
||||
//some spell_effects that related to ImmuneToEffect<effect>(only this effect in the spell) can't cast to it,
|
||||
//some aura(related to Mechanics or ImmuneToState<aura>) can't apply to it.
|
||||
public enum SpellImmunity
|
||||
{
|
||||
Effect = 0, // enum SpellEffects
|
||||
State = 1, // enum AuraType
|
||||
School = 2, // enum SpellSchoolMask
|
||||
Damage = 3, // enum SpellSchoolMask
|
||||
Dispel = 4, // enum DispelType
|
||||
Mechanic = 5, // enum Mechanics
|
||||
Id = 6,
|
||||
Max = 7
|
||||
}
|
||||
|
||||
|
||||
public enum BaseModGroup
|
||||
{
|
||||
CritPercentage,
|
||||
RangedCritPercentage,
|
||||
OffhandCritPercentage,
|
||||
ShieldBlockValue,
|
||||
End
|
||||
}
|
||||
|
||||
public enum DamageEffectType
|
||||
{
|
||||
Direct = 0, // used for normal weapon damage (not for class abilities or spells)
|
||||
SpellDirect = 1, // spell/class abilities damage
|
||||
DOT = 2,
|
||||
Heal = 3,
|
||||
NoDamage = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
|
||||
Self = 5
|
||||
}
|
||||
public enum WeaponDamageRange
|
||||
{
|
||||
MinDamage,
|
||||
MaxDamage
|
||||
}
|
||||
public enum UnitMods
|
||||
{
|
||||
StatStrength, // STAT_STRENGTH..UNIT_MOD_STAT_INTELLECT must be in existed order, it's accessed by index values of Stats enum.
|
||||
StatAgility,
|
||||
StatStamina,
|
||||
StatIntellect,
|
||||
Health,
|
||||
Mana, // MANA..RUNIC_POWER must be in existed order, it's accessed by index values of Powers enum.
|
||||
Rage,
|
||||
Focus,
|
||||
Energy,
|
||||
Unused, // Old HAPPINESS
|
||||
Rune,
|
||||
RunicPower,
|
||||
SoulShards,
|
||||
Eclipse,
|
||||
HolyPower,
|
||||
Alternative,
|
||||
Maelstrom,
|
||||
Chi,
|
||||
Insanity,
|
||||
BurningEmbers,
|
||||
DemonicFury,
|
||||
ArcaneCharges,
|
||||
Fury,
|
||||
Pain,
|
||||
Armor, // ARMOR..RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum.
|
||||
ResistanceHoly,
|
||||
ResistanceFire,
|
||||
ResistanceNature,
|
||||
ResistanceFrost,
|
||||
ResistanceShadow,
|
||||
ResistanceArcane,
|
||||
AttackPower,
|
||||
AttackPowerRanged,
|
||||
DamageMainHand,
|
||||
DamageOffHand,
|
||||
DamageRanged,
|
||||
End,
|
||||
// synonyms
|
||||
StatStart = StatStrength,
|
||||
StatEnd = StatIntellect + 1,
|
||||
ResistanceStart = Armor,
|
||||
ResistanceEnd = ResistanceArcane + 1,
|
||||
PowerStart = Mana,
|
||||
PowerEnd = Pain + 1
|
||||
}
|
||||
public enum UnitModifierType
|
||||
{
|
||||
BaseValue = 0,
|
||||
BasePCTExcludeCreate = 1, // percent modifier affecting all stat values from auras and gear but not player base for level
|
||||
BasePCT = 2,
|
||||
TotalValue = 3,
|
||||
TotalPCT = 4,
|
||||
End = 5
|
||||
}
|
||||
public enum VictimState
|
||||
{
|
||||
Intact = 0, // set when attacker misses
|
||||
Hit = 1, // victim got clear/blocked hit
|
||||
Dodge = 2,
|
||||
Parry = 3,
|
||||
Imterrupt = 4,
|
||||
Blocks = 5, // unused? not set when blocked, even on full block
|
||||
Evades = 6,
|
||||
Immune = 7,
|
||||
Deflects = 8
|
||||
}
|
||||
|
||||
public enum HitInfo
|
||||
{
|
||||
NormalSwing = 0x0,
|
||||
Unk1 = 0x01, // req correct packet structure
|
||||
AffectsVictim = 0x02,
|
||||
OffHand = 0x04,
|
||||
Unk2 = 0x08,
|
||||
Miss = 0x10,
|
||||
FullAbsorb = 0x20,
|
||||
PartialAbsorb = 0x40,
|
||||
FullResist = 0x80,
|
||||
PartialResist = 0x100,
|
||||
CriticalHit = 0x200, // critical hit
|
||||
Unk10 = 0x400,
|
||||
Unk11 = 0x800,
|
||||
Unk12 = 0x1000,
|
||||
Block = 0x2000, // blocked damage
|
||||
Unk14 = 0x4000, // set only if meleespellid is present// no world text when victim is hit for 0 dmg(HideWorldTextForNoDamage?)
|
||||
Unk15 = 0x8000, // player victim?// something related to blod sprut visual (BloodSpurtInBack?)
|
||||
Glancing = 0x10000,
|
||||
Crushing = 0x20000,
|
||||
NoAnimation = 0x40000,
|
||||
Unk19 = 0x80000,
|
||||
Unk20 = 0x100000,
|
||||
SwingNoHitSound = 0x200000, // unused?
|
||||
Unk22 = 0x00400000,
|
||||
RageGain = 0x800000,
|
||||
FakeDamage = 0x1000000 // enables damage animation even if no damage done, set only if no damage
|
||||
}
|
||||
|
||||
public enum ReactStates
|
||||
{
|
||||
Passive = 0,
|
||||
Defensive = 1,
|
||||
Aggressive = 2,
|
||||
Assist = 3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UnitStandStateType
|
||||
/// </summary>
|
||||
public enum UnitStandStateType
|
||||
{
|
||||
Stand = 0,
|
||||
Sit = 1,
|
||||
SitChair = 2,
|
||||
Sleep = 3,
|
||||
SitLowChair = 4,
|
||||
SitMediumChair = 5,
|
||||
SitHighChair = 6,
|
||||
Dead = 7,
|
||||
Kneel = 8,
|
||||
Submerged = 9
|
||||
}
|
||||
|
||||
public struct UnitBytes0Offsets
|
||||
{
|
||||
public const byte Race = 0;
|
||||
public const byte Class = 1;
|
||||
public const byte PlayerClass = 2;
|
||||
public const byte Gender = 3;
|
||||
}
|
||||
|
||||
public struct UnitBytes1Offsets
|
||||
{
|
||||
public const byte StandState = 0;
|
||||
public const byte PetTalents = 1; // unused
|
||||
public const byte VisFlag = 2;
|
||||
public const byte AnimTier = 3;
|
||||
}
|
||||
|
||||
public enum UnitStandFlags
|
||||
{
|
||||
Unk1 = 0x01,
|
||||
Creep = 0x02,
|
||||
Untrackable = 0x04,
|
||||
Unk4 = 0x08,
|
||||
Unk5 = 0x10,
|
||||
All = 0xFF
|
||||
}
|
||||
|
||||
public enum UnitBytes1Flags
|
||||
{
|
||||
AlwaysStand = 0x01,
|
||||
Hover = 0x02,
|
||||
Unk3 = 0x04,
|
||||
All = 0xFF
|
||||
}
|
||||
|
||||
public struct UnitBytes2Offsets
|
||||
{
|
||||
public const byte SheathState = 0;
|
||||
public const byte PvpFlag = 1;
|
||||
public const byte PetFlags = 2;
|
||||
public const byte ShapeshiftForm = 3;
|
||||
}
|
||||
|
||||
public enum UnitBytes2Flags
|
||||
{
|
||||
PvP = 0x01,
|
||||
Unk1 = 0x02,
|
||||
FFAPvp = 0x04,
|
||||
Sanctuary = 0x08,
|
||||
Unk4 = 0x10,
|
||||
Unk5 = 0x20,
|
||||
Unk6 = 0x40,
|
||||
Unk7 = 0x80,
|
||||
}
|
||||
|
||||
public enum UnitPetFlags
|
||||
{
|
||||
CanBeRenamed = 0x01,
|
||||
CanBeAbandoned = 0x02
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UnitFields.Bytes2, 3
|
||||
/// </summary>
|
||||
public enum ShapeShiftForm
|
||||
{
|
||||
None = 0,
|
||||
CatForm = 1,
|
||||
TreeOfLife = 2,
|
||||
TravelForm = 3,
|
||||
AquaticForm = 4,
|
||||
BearForm = 5,
|
||||
Ambient = 6,
|
||||
Ghoul = 7,
|
||||
DireBearForm = 8,
|
||||
CraneStance = 9,
|
||||
TharonjaSkeleton = 10,
|
||||
DarkmoonTestOfStrength = 11,
|
||||
BlbPlayer = 12,
|
||||
ShadowDance = 13,
|
||||
CreatureBear = 14,
|
||||
CreatureCat = 15,
|
||||
GhostWolf = 16,
|
||||
BattleStance = 17,
|
||||
DefensiveStance = 18,
|
||||
BerserkerStance = 19,
|
||||
SerpentStance = 20,
|
||||
Zombie = 21,
|
||||
Metamorphosis = 22,
|
||||
OxStance = 23,
|
||||
TigerStance = 24,
|
||||
Undead = 25,
|
||||
Frenzy = 26,
|
||||
FlightFormEpic = 27,
|
||||
Shadowform = 28,
|
||||
FlightForm = 29,
|
||||
Stealth = 30,
|
||||
MoonkinForm = 31,
|
||||
SpiritOfRedemption = 32,
|
||||
GladiatorStance = 33
|
||||
}
|
||||
|
||||
public enum ReactiveType
|
||||
{
|
||||
Defense = 0,
|
||||
HunterParry = 1,
|
||||
OverPower = 2,
|
||||
Max = 3
|
||||
}
|
||||
|
||||
public enum SpellValueMod
|
||||
{
|
||||
BasePoint0,
|
||||
BasePoint1,
|
||||
BasePoint2,
|
||||
BasePoint3,
|
||||
BasePoint4,
|
||||
BasePoint5,
|
||||
BasePoint6,
|
||||
BasePoint7,
|
||||
BasePoint8,
|
||||
BasePoint9,
|
||||
BasePoint10,
|
||||
BasePoint11,
|
||||
BasePoint12,
|
||||
BasePoint13,
|
||||
BasePoint14,
|
||||
BasePoint15,
|
||||
BasePoint16,
|
||||
BasePoint17,
|
||||
BasePoint18,
|
||||
BasePoint19,
|
||||
BasePoint20,
|
||||
BasePoint21,
|
||||
BasePoint22,
|
||||
BasePoint23,
|
||||
BasePoint24,
|
||||
BasePoint25,
|
||||
BasePoint26,
|
||||
BasePoint27,
|
||||
BasePoint28,
|
||||
BasePoint29,
|
||||
BasePoint30,
|
||||
BasePoint31,
|
||||
End,
|
||||
RadiusMod,
|
||||
MaxTargets,
|
||||
AuraStack
|
||||
}
|
||||
|
||||
public enum CombatRating
|
||||
{
|
||||
Amplify = 0,
|
||||
DefenseSkill = 1,
|
||||
Dodge = 2,
|
||||
Parry = 3,
|
||||
Block = 4,
|
||||
HitMelee = 5,
|
||||
HitRanged = 6,
|
||||
HitSpell = 7,
|
||||
CritMelee = 8,
|
||||
CritRanged = 9,
|
||||
CritSpell = 10,
|
||||
Multistrike = 11,
|
||||
Readiness = 12,
|
||||
Speed = 13,
|
||||
ResilienceCritTaken = 14,
|
||||
ResiliencePlayerDamage = 15,
|
||||
Lifesteal = 16,
|
||||
HasteMelee = 17,
|
||||
HasteRanged = 18,
|
||||
HasteSpell = 19,
|
||||
Avoidance = 20,
|
||||
Studiness = 21,
|
||||
Unused7 = 22,
|
||||
Expertise = 23,
|
||||
ArmorPenetration = 24,
|
||||
Mastery = 25,
|
||||
PvpPower = 26,
|
||||
Cleave = 27,
|
||||
VersatilityDamageDone = 28,
|
||||
VersatilityHealingDone = 29,
|
||||
VersatilityDamageTaken = 30,
|
||||
Unused12 = 31,
|
||||
Max = 32
|
||||
}
|
||||
|
||||
public enum DeathState
|
||||
{
|
||||
Alive = 0,
|
||||
JustDied = 1,
|
||||
Corpse = 2,
|
||||
Dead = 3,
|
||||
JustRespawned = 4
|
||||
}
|
||||
public enum UnitState : uint
|
||||
{
|
||||
Died = 0x01, // Player Has Fake Death Aura
|
||||
MeleeAttacking = 0x02, // Player Is Melee Attacking Someone
|
||||
//Melee_Attack_By = 0x04, // Player Is Melee Attack By Someone
|
||||
Stunned = 0x08,
|
||||
Roaming = 0x10,
|
||||
Chase = 0x20,
|
||||
//Searching = 0x40,
|
||||
Fleeing = 0x80,
|
||||
InFlight = 0x100, // Player Is In Flight Mode
|
||||
Follow = 0x200,
|
||||
Root = 0x400,
|
||||
Confused = 0x800,
|
||||
Distracted = 0x1000,
|
||||
Isolated = 0x2000, // Area Auras Do Not Affect Other Players
|
||||
AttackPlayer = 0x4000,
|
||||
Casting = 0x8000,
|
||||
Possessed = 0x10000,
|
||||
Charging = 0x20000,
|
||||
Jumping = 0x40000,
|
||||
//Onvehicle = 0x80000,
|
||||
Move = 0x100000,
|
||||
Rotating = 0x200000,
|
||||
Evade = 0x400000,
|
||||
RoamingMove = 0x800000,
|
||||
ConfusedMove = 0x1000000,
|
||||
FleeingMove = 0x2000000,
|
||||
ChaseMove = 0x4000000,
|
||||
FollowMove = 0x8000000,
|
||||
IgnorePathfinding = 0x10000000,
|
||||
Unattackable = InFlight,
|
||||
// For Real Move Using Movegen Check And Stop (Except Unstoppable Flight)
|
||||
Moving = RoamingMove | ConfusedMove | FleeingMove | ChaseMove | FollowMove,
|
||||
Controlled = (Confused | Stunned | Fleeing),
|
||||
LostControl = (Controlled | Jumping | Charging),
|
||||
Sightless = (LostControl | Evade),
|
||||
CannotAutoattack = (LostControl | Casting),
|
||||
CannotTurn = (LostControl | Rotating),
|
||||
// Stay By Different Reasons
|
||||
NotMove = Root | Stunned | Died | Distracted,
|
||||
AllState = 0xffffffff //(Stopped | Moving | In_Combat | In_Flight)
|
||||
}
|
||||
|
||||
public enum UnitMoveType
|
||||
{
|
||||
Walk = 0,
|
||||
Run = 1,
|
||||
RunBack = 2,
|
||||
Swim = 3,
|
||||
SwimBack = 4,
|
||||
TurnRate = 5,
|
||||
Flight = 6,
|
||||
FlightBack = 7,
|
||||
PitchRate = 8,
|
||||
Max = 9
|
||||
}
|
||||
public enum WeaponAttackType
|
||||
{
|
||||
BaseAttack = 0,
|
||||
OffAttack = 1,
|
||||
RangedAttack = 2,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum UnitTypeMask
|
||||
{
|
||||
None = 0x0,
|
||||
Summon = 0x01,
|
||||
Minion = 0x02,
|
||||
Guardian = 0x04,
|
||||
Totem = 0x08,
|
||||
Pet = 0x10,
|
||||
Vehicle = 0x20,
|
||||
Puppet = 0x40,
|
||||
HunterPet = 0x80,
|
||||
ControlableGuardian = 0x100,
|
||||
Accessory = 0x200
|
||||
}
|
||||
|
||||
public enum CurrentSpellTypes
|
||||
{
|
||||
Melee = 0,
|
||||
Generic = 1,
|
||||
Channeled = 2,
|
||||
AutoRepeat = 3,
|
||||
Max = 4
|
||||
}
|
||||
public enum SheathState
|
||||
{
|
||||
Unarmed = 0, // non prepared weapon
|
||||
Melee = 1, // prepared melee weapon
|
||||
Ranged = 2, // prepared ranged weapon
|
||||
Max = 3
|
||||
}
|
||||
public enum MeleeHitOutcome
|
||||
{
|
||||
Evade,
|
||||
Miss,
|
||||
Dodge,
|
||||
Block,
|
||||
Parry,
|
||||
Glancing,
|
||||
Crit,
|
||||
Crushing,
|
||||
Normal
|
||||
}
|
||||
|
||||
public enum UnitDynFlags
|
||||
{
|
||||
None = 0x00,
|
||||
HideModel = 0x02, // Object model is not shown with this flag
|
||||
Lootable = 0x04,
|
||||
TrackUnit = 0x08,
|
||||
Tapped = 0x10, // Lua_UnitIsTapped
|
||||
SpecialInfo = 0x20,
|
||||
Dead = 0x40,
|
||||
ReferAFriend = 0x80
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum ObjectFields
|
||||
{
|
||||
Guid = 0x000, // Size: 4, Flags: Public
|
||||
Data = 0x004, // Size: 4, Flags: Public
|
||||
Type = 0x008, // Size: 1, Flags: Public
|
||||
Entry = 0x009, // Size: 1, Flags: Dynamic
|
||||
DynamicFlags = 0x00a, // Size: 1, Flags: Dynamic, Urgent
|
||||
ScaleX = 0x00b, // Size: 1, Flags: Public
|
||||
End = 0x00c,
|
||||
}
|
||||
|
||||
public enum ItemFields
|
||||
{
|
||||
Owner = ObjectFields.End + 0x000, // Size: 4, Flags: Public
|
||||
Contained = ObjectFields.End + 0x004, // Size: 4, Flags: Public
|
||||
Creator = ObjectFields.End + 0x008, // Size: 4, Flags: Public
|
||||
GiftCreator = ObjectFields.End + 0x00c, // Size: 4, Flags: Public
|
||||
StackCount = ObjectFields.End + 0x010, // Size: 1, Flags: Owner
|
||||
Duration = ObjectFields.End + 0x011, // Size: 1, Flags: Owner
|
||||
SpellCharges = ObjectFields.End + 0x012, // Size: 5, Flags: Owner
|
||||
Flags = ObjectFields.End + 0x017, // Size: 1, Flags: Public
|
||||
Enchantment = ObjectFields.End + 0x018, // Size: 39, Flags: Public
|
||||
PropertySeed = ObjectFields.End + 0x03f, // Size: 1, Flags: Public
|
||||
RandomPropertiesId = ObjectFields.End + 0x040, // Size: 1, Flags: Public
|
||||
Durability = ObjectFields.End + 0x041, // Size: 1, Flags: Owner
|
||||
MaxDurability = ObjectFields.End + 0x042, // Size: 1, Flags: Owner
|
||||
CreatePlayedTime = ObjectFields.End + 0x043, // Size: 1, Flags: Public
|
||||
ModifiersMask = ObjectFields.End + 0x044, // Size: 1, Flags: Owner
|
||||
Context = ObjectFields.End + 0x045, // Size: 1, Flags: Public
|
||||
ArtifactXp = ObjectFields.End + 0x046, // Size: 2, Flags: OWNER
|
||||
AppearanceModId = ObjectFields.End + 0x048, // Size: 1, Flags: OWNER
|
||||
End = ObjectFields.End + 0x049,
|
||||
}
|
||||
|
||||
public enum ItemDynamicFields
|
||||
{
|
||||
Modifiers = 0x000, // Flags: Owner
|
||||
BonusListIds = 0x001, // Flags: Owner, 0x100
|
||||
ArtifactPowers = 0x002, // Flags: OWNER
|
||||
Gems = 0x003, // Flags: OWNER
|
||||
End = 0x004,
|
||||
}
|
||||
|
||||
public enum ContainerFields
|
||||
{
|
||||
Slot1 = ItemFields.End + 0x000, // Size: 144, Flags: Public
|
||||
NumSlots = ItemFields.End + 0x090, // Size: 1, Flags: Public
|
||||
End = ItemFields.End + 0x091,
|
||||
}
|
||||
|
||||
public enum UnitFields
|
||||
{
|
||||
Charm = ObjectFields.End + 0x000, // Size: 4, Flags: Public
|
||||
Summon = ObjectFields.End + 0x004, // Size: 4, Flags: Public
|
||||
Critter = ObjectFields.End + 0x008, // Size: 4, Flags: Private
|
||||
CharmedBy = ObjectFields.End + 0x00c, // Size: 4, Flags: Public
|
||||
SummonedBy = ObjectFields.End + 0x010, // Size: 4, Flags: Public
|
||||
CreatedBy = ObjectFields.End + 0x014, // Size: 4, Flags: Public
|
||||
DemonCreator = ObjectFields.End + 0x018, // Size: 4, Flags: Public
|
||||
Target = ObjectFields.End + 0x01c, // Size: 4, Flags: Public
|
||||
BattlePetCompanionGuid = ObjectFields.End + 0x020, // Size: 4, Flags: Public
|
||||
BattlePetDbId = ObjectFields.End + 0x024, // Size: 2, Flags: Public
|
||||
ChannelSpell = ObjectFields.End + 0x026, // Size: 1, Flags: Public, Urgent
|
||||
ChannelSpellXSpellVisual = ObjectFields.End + 0x027, // Size: 1, Flags: Public, Urgent
|
||||
SummonedByHomeRealm = ObjectFields.End + 0x028, // Size: 1, Flags: Public
|
||||
Bytes0 = ObjectFields.End + 0x029, // Size: 1, Flags: Public
|
||||
DisplayPower = ObjectFields.End + 0x02a, // Size: 1, Flags: Public
|
||||
OverrideDisplayPowerId = ObjectFields.End + 0x02b, // Size: 1, Flags: Public
|
||||
Health = ObjectFields.End + 0x02c, // Size: 2, Flags: Public
|
||||
Power = ObjectFields.End + 0x02e, // Size: 6, Flags: Public, UrgentSelfOnly
|
||||
MaxHealth = ObjectFields.End + 0x034, // Size: 2, Flags: Public
|
||||
MaxPower = ObjectFields.End + 0x036, // Size: 6, Flags: Public
|
||||
PowerRegenFlatModifier = ObjectFields.End + 0x03c, // Size: 6, Flags: Private, Owner, UnitAll
|
||||
PowerRegenInterruptedFlatModifier = ObjectFields.End + 0x042, // Size: 6, Flags: Private, Owner, UnitAll
|
||||
Level = ObjectFields.End + 0x048, // Size: 1, Flags: Public
|
||||
EffectiveLevel = ObjectFields.End + 0x049, // Size: 1, Flags: Public
|
||||
ScalingLevelMin = ObjectFields.End + 0x04a, // Size: 1, Flags: Public
|
||||
ScalingLevelMax = ObjectFields.End + 0x04b, // Size: 1, Flags: Public
|
||||
ScalingLevelDelta = ObjectFields.End + 0x04c, // Size: 1, Flags: Public
|
||||
FactionTemplate = ObjectFields.End + 0x04d, // Size: 1, Flags: Public
|
||||
VirtualItemSlotId = ObjectFields.End + 0x04e, // Size: 6, Flags: Public
|
||||
Flags = ObjectFields.End + 0x054, // Size: 1, Flags: Public, Urgent
|
||||
Flags2 = ObjectFields.End + 0x055, // Size: 1, Flags: Public, Urgent
|
||||
Flags3 = ObjectFields.End + 0x056, // Size: 1, Flags: Public, Urgent
|
||||
AuraState = ObjectFields.End + 0x057, // Size: 1, Flags: Public
|
||||
BaseAttackTime = ObjectFields.End + 0x058, // Size: 2, Flags: Public
|
||||
RangedAttackTime = ObjectFields.End + 0x05a, // Size: 1, Flags: Private
|
||||
BoundingRadius = ObjectFields.End + 0x05b, // Size: 1, Flags: Public
|
||||
CombatReach = ObjectFields.End + 0x05c, // Size: 1, Flags: Public
|
||||
DisplayId = ObjectFields.End + 0x05d, // Size: 1, Flags: Dynamic, Urgent
|
||||
NativeDisplayId = ObjectFields.End + 0x05e, // Size: 1, Flags: Public, Urgent
|
||||
MountDisplayId = ObjectFields.End + 0x05f, // Size: 1, Flags: Public, Urgent
|
||||
MinDamage = ObjectFields.End + 0x060, // Size: 1, Flags: Private, Owner, SpecialInfo
|
||||
MaxDamage = ObjectFields.End + 0x061, // Size: 1, Flags: Private, Owner, SpecialInfo
|
||||
MinOffHandDamage = ObjectFields.End + 0x062, // Size: 1, Flags: Private, Owner, SpecialInfo
|
||||
MaxOffHandDamage = ObjectFields.End + 0x063, // Size: 1, Flags: Private, Owner, SpecialInfo
|
||||
Bytes1 = ObjectFields.End + 0x064, // Size: 1, Flags: Public
|
||||
PetNumber = ObjectFields.End + 0x065, // Size: 1, Flags: Public
|
||||
PetNameTimestamp = ObjectFields.End + 0x066, // Size: 1, Flags: Public
|
||||
PetExperience = ObjectFields.End + 0x067, // Size: 1, Flags: Owner
|
||||
PetNextLevelExp = ObjectFields.End + 0x068, // Size: 1, Flags: Owner
|
||||
ModCastSpeed = ObjectFields.End + 0x069, // Size: 1, Flags: Public
|
||||
ModCastHaste = ObjectFields.End + 0x06a, // Size: 1, Flags: Public
|
||||
ModHaste = ObjectFields.End + 0x06b, // Size: 1, Flags: Public
|
||||
ModRangedHaste = ObjectFields.End + 0x06c, // Size: 1, Flags: Public
|
||||
ModHasteRegen = ObjectFields.End + 0x06d, // Size: 1, Flags: Public
|
||||
ModTimeRate = ObjectFields.End + 0x06e, // Size: 1, Flags: Public
|
||||
CreatedBySpell = ObjectFields.End + 0x06f, // Size: 1, Flags: Public
|
||||
NpcFlags = ObjectFields.End + 0x070, // Size: 2, Flags: Public, Dynamic
|
||||
NpcEmotestate = ObjectFields.End + 0x072, // Size: 1, Flags: Public
|
||||
Stat = ObjectFields.End + 0x073, // Size: 4, Flags: Private, Owner
|
||||
PosStat = ObjectFields.End + 0x077, // Size: 4, Flags: Private, Owner
|
||||
NegStat = ObjectFields.End + 0x07b, // Size: 4, Flags: Private, Owner
|
||||
Resistances = ObjectFields.End + 0x07f, // Size: 7, Flags: Private, Owner, SpecialInfo
|
||||
ResistanceBuffModsPositive = ObjectFields.End + 0x086, // Size: 7, Flags: Private, Owner
|
||||
ResistanceBuffModsNegative = ObjectFields.End + 0x08d, // Size: 7, Flags: Private, Owner
|
||||
ModBonusArmor = ObjectFields.End + 0x094, // Size: 1, Flags: Private, Owner
|
||||
BaseMana = ObjectFields.End + 0x095, // Size: 1, Flags: Public
|
||||
BaseHealth = ObjectFields.End + 0x096, // Size: 1, Flags: Private, Owner
|
||||
Bytes2 = ObjectFields.End + 0x097, // Size: 1, Flags: Public
|
||||
AttackPower = ObjectFields.End + 0x098, // Size: 1, Flags: Private, Owner
|
||||
AttackPowerModPos = ObjectFields.End + 0x099, // Size: 1, Flags: Private, Owner
|
||||
AttackPowerModNeg = ObjectFields.End + 0x09a, // Size: 1, Flags: Private, Owner
|
||||
AttackPowerMultiplier = ObjectFields.End + 0x09b, // Size: 1, Flags: Private, Owner
|
||||
RangedAttackPower = ObjectFields.End + 0x09c, // Size: 1, Flags: Private, Owner
|
||||
RangedAttackPowerModPos = ObjectFields.End + 0x09d, // Size: 1, Flags: Private, Owner
|
||||
RangedAttackPowerModNeg = ObjectFields.End + 0x09e, // Size: 1, Flags: Private, Owner
|
||||
RangedAttackPowerMultiplier = ObjectFields.End + 0x09f, // Size: 1, Flags: Private, Owner
|
||||
AttackSpeedAura = ObjectFields.End + 0x0a0, // Size: 1, Flags: Private, Owner
|
||||
MinRangedDamage = ObjectFields.End + 0x0a1, // Size: 1, Flags: Private, Owner
|
||||
MaxRangedDamage = ObjectFields.End + 0x0a2, // Size: 1, Flags: Private, Owner
|
||||
PowerCostModifier = ObjectFields.End + 0x0a3, // Size: 7, Flags: Private, Owner
|
||||
PowerCostMultiplier = ObjectFields.End + 0x0aa, // Size: 7, Flags: Private, Owner
|
||||
Maxhealthmodifier = ObjectFields.End + 0x0b1, // Size: 1, Flags: Private, Owner
|
||||
HoverHeight = ObjectFields.End + 0x0b2, // Size: 1, Flags: Public
|
||||
MinItemLevelCutoff = ObjectFields.End + 0x0b3, // Size: 1, Flags: Public
|
||||
MinItemLevel = ObjectFields.End + 0x0b4, // Size: 1, Flags: Public
|
||||
Maxitemlevel = ObjectFields.End + 0x0b5, // Size: 1, Flags: Public
|
||||
WildBattlepetLevel = ObjectFields.End + 0x0b6, // Size: 1, Flags: Public
|
||||
BattlepetCompanionNameTimestamp = ObjectFields.End + 0x0b7, // Size: 1, Flags: Public
|
||||
InteractSpellid = ObjectFields.End + 0x0b8, // Size: 1, Flags: Public
|
||||
StateSpellVisualId = ObjectFields.End + 0x0b9, // Size: 1, Flags: Dynamic, Urgent
|
||||
StateAnimId = ObjectFields.End + 0x0ba, // Size: 1, Flags: Dynamic, Urgent
|
||||
StateAnimKitId = ObjectFields.End + 0x0bb, // Size: 1, Flags: Dynamic, Urgent
|
||||
StateWorldEffectId = ObjectFields.End + 0x0bc, // Size: 4, Flags: Dynamic, Urgent
|
||||
ScaleDuration = ObjectFields.End + 0x0c0, // Size: 1, Flags: Public
|
||||
LooksLikeMountId = ObjectFields.End + 0x0c1, // Size: 1, Flags: Public
|
||||
LooksLikeCreatureId = ObjectFields.End + 0x0c2, // Size: 1, Flags: Public
|
||||
LookAtControllerId = ObjectFields.End + 0x0c3, // Size: 1, Flags: Public
|
||||
LookAtControllerTarget = ObjectFields.End + 0x0c4, // Size: 4, Flags: Public
|
||||
End = ObjectFields.End + 0x0c8,
|
||||
}
|
||||
|
||||
public enum UnitDynamicFields
|
||||
{
|
||||
PassiveSpells = 0x000, // Flags: Public, Urgent
|
||||
WorldEffects = 0x001, // Flags: Public, Urgent
|
||||
ChannelObjects = 0x002, // Flags: PUBLIC, URGENT
|
||||
End = 0x003,
|
||||
}
|
||||
|
||||
public enum PlayerFields
|
||||
{
|
||||
DuelArbiter = UnitFields.End + 0x000, // Size: 4, Flags: Public
|
||||
WowAccount = UnitFields.End + 0x004, // Size: 4, Flags: Public
|
||||
LootTargetGuid = UnitFields.End + 0x008, // Size: 4, Flags: Public
|
||||
Flags = UnitFields.End + 0x00c, // Size: 1, Flags: Public
|
||||
FlagsEx = UnitFields.End + 0x00d, // Size: 1, Flags: Public
|
||||
GuildRank = UnitFields.End + 0x00e, // Size: 1, Flags: Public
|
||||
GuildDeleteDate = UnitFields.End + 0x00f, // Size: 1, Flags: Public
|
||||
GuildLevel = UnitFields.End + 0x010, // Size: 1, Flags: Public
|
||||
Bytes = UnitFields.End + 0x011, // Size: 1, Flags: Public
|
||||
Bytes2 = UnitFields.End + 0x012, // Size: 1, Flags: Public
|
||||
Bytes3 = UnitFields.End + 0x013, // Size: 1, Flags: Public
|
||||
Bytes4 = UnitFields.End + 0x014, // Size: 1, Flags: Public
|
||||
DuelTeam = UnitFields.End + 0x015, // Size: 1, Flags: Public
|
||||
GuildTimestamp = UnitFields.End + 0x016, // Size: 1, Flags: Public
|
||||
QuestLog = UnitFields.End + 0x017, // Size: 800, Flags: PartyMember
|
||||
VisibleItem = UnitFields.End + 0x337, // Size: 38, Flags: Public
|
||||
ChosenTitle = UnitFields.End + 0x35d, // Size: 1, Flags: Public
|
||||
FakeInebriation = UnitFields.End + 0x35e, // Size: 1, Flags: Public
|
||||
VirtualRealm = UnitFields.End + 0x35f, // Size: 1, Flags: Public
|
||||
CurrentSpecId = UnitFields.End + 0x360, // Size: 1, Flags: Public
|
||||
TaxiMountAnimKitId = UnitFields.End + 0x361, // Size: 1, Flags: Public
|
||||
AvgItemLevel = UnitFields.End + 0x362, // Size: 4, Flags: Public
|
||||
CurrentBattlePetBreedQuality = UnitFields.End + 0x366, // Size: 1, Flags: Public
|
||||
Prestige = UnitFields.End + 0x367, // Size: 1, Flags: Public
|
||||
HonorLevel = UnitFields.End + 0x368, // Size: 1, Flags: Public
|
||||
InvSlotHead = UnitFields.End + 0x369, // Size: 748, Flags: Private
|
||||
EndNotSelf = UnitFields.End + 0x369,
|
||||
|
||||
Farsight = UnitFields.End + 0x655, // Size: 4, Flags: Private
|
||||
SummonedBattlePetId = UnitFields.End + 0x659, // Size: 4, Flags: Private
|
||||
KnownTitles = UnitFields.End + 0x65d, // Size: 12, Flags: Private
|
||||
Coinage = UnitFields.End + 0x669, // Size: 2, Flags: Private
|
||||
Xp = UnitFields.End + 0x66b, // Size: 1, Flags: Private
|
||||
NextLevelXp = UnitFields.End + 0x66c, // Size: 1, Flags: Private
|
||||
SkillLineId = UnitFields.End + 0x66d, // Size: 448, Flags: Private
|
||||
SkillLineStep = UnitFields.End + 0x6AD,
|
||||
SkillLineRank = UnitFields.End + 0x6ED,
|
||||
SkillLineSubStartRank = UnitFields.End + 0x72D,
|
||||
SkillLineMaxRank = UnitFields.End + 0x76D,
|
||||
SkillLineTempBonus = UnitFields.End + 0x7AD,
|
||||
SkillLinePermBonus = UnitFields.End + 0x7ED,
|
||||
CharacterPoints = UnitFields.End + 0x82d, // Size: 1, Flags: Private
|
||||
MaxTalentTiers = UnitFields.End + 0x82e, // Size: 1, Flags: Private
|
||||
TrackCreatures = UnitFields.End + 0x82f, // Size: 1, Flags: Private
|
||||
TrackResources = UnitFields.End + 0x830, // Size: 1, Flags: Private
|
||||
Expertise = UnitFields.End + 0x831, // Size: 1, Flags: Private
|
||||
OffhandExpertise = UnitFields.End + 0x832, // Size: 1, Flags: Private
|
||||
RangedExpertise = UnitFields.End + 0x833, // Size: 1, Flags: Private
|
||||
CombatRatingExpertise = UnitFields.End + 0x834, // Size: 1, Flags: Private
|
||||
BlockPercentage = UnitFields.End + 0x835, // Size: 1, Flags: Private
|
||||
DodgePercentage = UnitFields.End + 0x836, // Size: 1, Flags: Private
|
||||
DodgePercentageFromAttribute = UnitFields.End + 0x837, // Size: 1, Flags: Private
|
||||
ParryPercentage = UnitFields.End + 0x838, // Size: 1, Flags: Private
|
||||
ParryPercentageFromAttribute = UnitFields.End + 0x839, // Size: 1, Flags: Private
|
||||
CritPercentage = UnitFields.End + 0x83a, // Size: 1, Flags: Private
|
||||
RangedCritPercentage = UnitFields.End + 0x83b, // Size: 1, Flags: Private
|
||||
OffhandCritPercentage = UnitFields.End + 0x83c, // Size: 1, Flags: Private
|
||||
SpellCritPercentage1 = UnitFields.End + 0x83d, // Size: 1, Flags: Private
|
||||
ShieldBlock = UnitFields.End + 0x83e, // Size: 1, Flags: Private
|
||||
ShieldBlockCritPercentage = UnitFields.End + 0x83f, // Size: 1, Flags: Private
|
||||
Mastery = UnitFields.End + 0x840, // Size: 1, Flags: Private
|
||||
Speed = UnitFields.End + 0x841, // Size: 1, Flags: Private
|
||||
Lifesteal = UnitFields.End + 0x842, // Size: 1, Flags: Private
|
||||
Avoidance = UnitFields.End + 0x843, // Size: 1, Flags: Private
|
||||
Sturdiness = UnitFields.End + 0x844, // Size: 1, Flags: Private
|
||||
Versatility = UnitFields.End + 0x845, // Size: 1, Flags: Private
|
||||
VersatilityBonus = UnitFields.End + 0x846, // Size: 1, Flags: Private
|
||||
FieldPvpPowerDamage = UnitFields.End + 0x847, // Size: 1, Flags: Private
|
||||
FieldPvpPowerHealing = UnitFields.End + 0x848, // Size: 1, Flags: Private
|
||||
ExploredZones1 = UnitFields.End + 0x849, // Size: 256, Flags: Private
|
||||
RestInfo = UnitFields.End + 0x949, // Size: 4, Flags: Private
|
||||
ModDamageDonePos = UnitFields.End + 0x94d, // Size: 7, Flags: Private
|
||||
ModDamageDoneNeg = UnitFields.End + 0x954, // Size: 7, Flags: Private
|
||||
ModDamageDonePct = UnitFields.End + 0x95b, // Size: 7, Flags: Private
|
||||
ModHealingDonePos = UnitFields.End + 0x962, // Size: 1, Flags: Private
|
||||
ModHealingPct = UnitFields.End + 0x963, // Size: 1, Flags: Private
|
||||
ModHealingDonePct = UnitFields.End + 0x964, // Size: 1, Flags: Private
|
||||
ModPeriodicHealingDonePercent = UnitFields.End + 0x965, // Size: 1, Flags: Private
|
||||
WeaponDmgMultipliers = UnitFields.End + 0x966, // Size: 3, Flags: Private
|
||||
WeaponAtkSpeedMultipliers = UnitFields.End + 0x969, // Size: 3, Flags: Private
|
||||
ModSpellPowerPct = UnitFields.End + 0x96c, // Size: 1, Flags: Private
|
||||
ModResiliencePercent = UnitFields.End + 0x96d, // Size: 1, Flags: Private
|
||||
OverrideSpellPowerByApPct = UnitFields.End + 0x96e, // Size: 1, Flags: Private
|
||||
OverrideApBySpellPowerPercent = UnitFields.End + 0x96f, // Size: 1, Flags: Private
|
||||
ModTargetResistance = UnitFields.End + 0x970, // Size: 1, Flags: Private
|
||||
ModTargetPhysicalResistance = UnitFields.End + 0x971, // Size: 1, Flags: Private
|
||||
LocalFlags = UnitFields.End + 0x972, // Size: 1, Flags: Private
|
||||
FieldBytes = UnitFields.End + 0x973, // Size: 1, Flags: Private
|
||||
SelfResSpell = UnitFields.End + 0x974, // Size: 1, Flags: Private
|
||||
PvpMedals = UnitFields.End + 0x975, // Size: 1, Flags: Private
|
||||
BuyBackPrice1 = UnitFields.End + 0x976, // Size: 12, Flags: Private
|
||||
BuyBackTimestamp1 = UnitFields.End + 0x982, // Size: 12, Flags: Private
|
||||
Kills = UnitFields.End + 0x98e, // Size: 1, Flags: Private
|
||||
LifetimeHonorableKills = UnitFields.End + 0x98f, // Size: 1, Flags: Private
|
||||
WatchedFactionIndex = UnitFields.End + 0x990, // Size: 1, Flags: Private
|
||||
CombatRating1 = UnitFields.End + 0x991, // Size: 32, Flags: Private
|
||||
ArenaTeamInfo11 = UnitFields.End + 0x9b1, // Size: 42, Flags: Private
|
||||
MaxLevel = UnitFields.End + 0x9db, // Size: 1, Flags: Private
|
||||
ScalingLevelDelta = UnitFields.End + 0x9dc, // Size: 1, Flags: Private
|
||||
MaxCreatureScalingLevel = UnitFields.End + 0x9dd, // Size: 1, Flags: Private
|
||||
NoReagentCost1 = UnitFields.End + 0x9de, // Size: 4, Flags: Private
|
||||
PetSpellPower = UnitFields.End + 0x9e2, // Size: 1, Flags: Private
|
||||
Researching1 = UnitFields.End + 0x9e3, // Size: 10, Flags: Private
|
||||
ProfessionSkillLine1 = UnitFields.End + 0x9ed, // Size: 2, Flags: Private
|
||||
UiHitModifier = UnitFields.End + 0x9ef, // Size: 1, Flags: Private
|
||||
UiSpellHitModifier = UnitFields.End + 0x9f0, // Size: 1, Flags: Private
|
||||
HomeRealmTimeOffset = UnitFields.End + 0x9f1, // Size: 1, Flags: Private
|
||||
ModPetHaste = UnitFields.End + 0x9f2, // Size: 1, Flags: Private
|
||||
FieldBytes2 = UnitFields.End + 0x9f3, // Size: 1, Flags: Private
|
||||
FieldBytes3 = UnitFields.End + 0x9f4, // Size: 1, Flags: Private, UrgentSelfOnly
|
||||
LfgBonusFactionId = UnitFields.End + 0x9f5, // Size: 1, Flags: Private
|
||||
LootSpecId = UnitFields.End + 0x9f6, // Size: 1, Flags: Private
|
||||
OverrideZonePvpType = UnitFields.End + 0x9f7, // Size: 1, Flags: Private, UrgentSelfOnly
|
||||
BagSlotFlags = UnitFields.End + 0x9f8, // Size: 4, Flags: Private
|
||||
BankBagSlotFlags = UnitFields.End + 0x9fc, // Size: 7, Flags: Private
|
||||
InsertItemsLeftToRight = UnitFields.End + 0xa03, // Size: 1, Flags: Private
|
||||
QuestCompleted = UnitFields.End + 0xa04, // Size: 1750, Flags: Private
|
||||
Honor = UnitFields.End + 0x10DA, // Size: 1, Flags: Private
|
||||
HonorNextLevel = UnitFields.End + 0x10DB, // Size: 1, Flags: Private
|
||||
End = UnitFields.End + 0x10DC,
|
||||
}
|
||||
|
||||
public enum PlayerDynamicFields
|
||||
{
|
||||
ReserachSite = UnitDynamicFields.End + 0x000, // Flags: Private
|
||||
ResearchSiteProgress = UnitDynamicFields.End + 0x001, // Flags: Private
|
||||
DailyQuests = UnitDynamicFields.End + 0x002, // Flags: Private
|
||||
AvailableQuestLineXQuestId = UnitDynamicFields.End + 0x003, // Flags: Private
|
||||
Heirlooms = UnitDynamicFields.End + 0x004, // Flags: Private
|
||||
HeirloomsFlags = UnitDynamicFields.End + 0x005, // Flags: PRIVATE
|
||||
Toys = UnitDynamicFields.End + 0x006, // Flags: Private
|
||||
Transmog = UnitDynamicFields.End + 0x007, // Flags: PRIVATE
|
||||
ConditionalTransmog = UnitDynamicFields.End + 0x008, // Flags: PRIVATE
|
||||
CharacterRestrictions = UnitDynamicFields.End + 0x009, // Flags: PRIVATE
|
||||
SpellPctModByLabel = UnitDynamicFields.End + 0x00A, // Flags: PRIVATE
|
||||
SpellFlatModByLabel = UnitDynamicFields.End + 0x00B, // Flags: PRIVATE
|
||||
ArenaCooldowns = UnitDynamicFields.End + 0x00C, // Flags: PUBLIC
|
||||
End = UnitDynamicFields.End + 0x00D,
|
||||
}
|
||||
|
||||
public enum GameObjectFields
|
||||
{
|
||||
CreatedBy = ObjectFields.End + 0x000, // Size: 4, Flags: Public
|
||||
DisplayId = ObjectFields.End + 0x004, // Size: 1, Flags: Dynamic, Urgent
|
||||
Flags = ObjectFields.End + 0x005, // Size: 1, Flags: Public, Urgent
|
||||
ParentRotation = ObjectFields.End + 0x006, // Size: 4, Flags: Public
|
||||
Faction = ObjectFields.End + 0x00a, // Size: 1, Flags: Public
|
||||
Level = ObjectFields.End + 0x00b, // Size: 1, Flags: Public
|
||||
Bytes1 = ObjectFields.End + 0x00c, // Size: 1, Flags: Public, Urgent
|
||||
SpellVisualId = ObjectFields.End + 0x00d, // Size: 1, Flags: Public, Dynamic, Urgent
|
||||
StateSpellVisualId = ObjectFields.End + 0x00e, // Size: 1, Flags: Dynamic, Urgent
|
||||
StateAnumId = ObjectFields.End + 0x00f, // Size: 1, Flags: Dynamic, Urgent
|
||||
StateAnimKitId = ObjectFields.End + 0x010, // Size: 1, Flags: Dynamic, Urgent
|
||||
StateWorldEffectId = ObjectFields.End + 0x011, // Size: 4, Flags: Dynamic, Urgent
|
||||
End = ObjectFields.End + 0x015,
|
||||
}
|
||||
|
||||
public enum GameObjectDynamicFields
|
||||
{
|
||||
EnableDoodadSets = 0x000, // Flags: PUBLIC
|
||||
End = 0x001,
|
||||
}
|
||||
|
||||
public enum DynamicObjectFields
|
||||
{
|
||||
Caster = ObjectFields.End + 0x000, // Size: 4, Flags: Public
|
||||
Type = ObjectFields.End + 0x004, // Size: 1, Flags: Public
|
||||
SpellXSpellVisualId = ObjectFields.End + 0x005, // Size: 1, Flags: Public
|
||||
SpellId = ObjectFields.End + 0x006, // Size: 1, Flags: Public
|
||||
Radius = ObjectFields.End + 0x007, // Size: 1, Flags: Public
|
||||
CastTime = ObjectFields.End + 0x008, // Size: 1, Flags: Public
|
||||
End = ObjectFields.End + 0x009,
|
||||
}
|
||||
|
||||
public enum CorpseFields
|
||||
{
|
||||
Owner = ObjectFields.End + 0x000, // Size: 4, Flags: Public
|
||||
Party = ObjectFields.End + 0x004, // Size: 4, Flags: Public
|
||||
DisplayId = ObjectFields.End + 0x008, // Size: 1, Flags: Public
|
||||
Item = ObjectFields.End + 0x009, // Size: 19, Flags: Public
|
||||
Bytes1 = ObjectFields.End + 0x01c, // Size: 1, Flags: Public
|
||||
Bytes2 = ObjectFields.End + 0x01d, // Size: 1, Flags: Public
|
||||
Flags = ObjectFields.End + 0x01e, // Size: 1, Flags: Public
|
||||
DynamicFlags = ObjectFields.End + 0x01f, // Size: 1, Flags: Dynamic
|
||||
FactionTemplate = ObjectFields.End + 0x020, // Size: 1, Flags: Public
|
||||
CustomDisplayOption = ObjectFields.End + 0x021, // Size: 1, Flags: PUBLIC
|
||||
End = ObjectFields.End + 0x022,
|
||||
}
|
||||
|
||||
public enum AreaTriggerFields
|
||||
{
|
||||
OverrideScaleCurve = ObjectFields.End + 0x000, // Size: 7, Flags: Public, Urgent
|
||||
ExtraScaleCurve = ObjectFields.End + 0x007, // Size: 7, Flags: Public, Urgent
|
||||
Caster = ObjectFields.End + 0x00e, // Size: 4, Flags: Public
|
||||
Duration = ObjectFields.End + 0x012, // Size: 1, Flags: Public
|
||||
TimeToTarget = ObjectFields.End + 0x013, // Size: 1, Flags: Public, Urgent
|
||||
TimeToTargetScale = ObjectFields.End + 0x014, // Size: 1, Flags: Public, Urgent
|
||||
TimeToTargetExtraScale = ObjectFields.End + 0x015, // Size: 1, Flags: Public, Urgent
|
||||
SpellId = ObjectFields.End + 0x016, // Size: 1, Flags: Public
|
||||
SpellForVisuals = ObjectFields.End + 0x017, // Size: 1, Flags: PUBLIC
|
||||
SpellXSpellVisualId = ObjectFields.End + 0x018, // Size: 1, Flags: Dynamic
|
||||
BoundsRadius2d = ObjectFields.End + 0x019, // Size: 1, Flags: Dynamic, Urgent
|
||||
DecalPropertiesId = ObjectFields.End + 0x01A, // Size: 1, Flags: Public
|
||||
CreatingEffectGuid = ObjectFields.End + 0x01B, // Size: 4, Flags: PUBLIC
|
||||
End = ObjectFields.End + 0x01F,
|
||||
}
|
||||
|
||||
public enum SceneObjectFields
|
||||
{
|
||||
ScriptPackageId = ObjectFields.End + 0x000, // Size: 1, Flags: Public
|
||||
RndSeedVal = ObjectFields.End + 0x001, // Size: 1, Flags: Public
|
||||
Createdby = ObjectFields.End + 0x002, // Size: 4, Flags: Public
|
||||
SceneType = ObjectFields.End + 0x006, // Size: 1, Flags: Public
|
||||
End = ObjectFields.End + 0x007,
|
||||
}
|
||||
|
||||
public enum ConversationFields
|
||||
{
|
||||
LastLineEndTime = ObjectFields.End + 0x000, // Size: 1, Flags: DYNAMIC
|
||||
End = ObjectFields.End + 0x001,
|
||||
}
|
||||
|
||||
public enum ConversationDynamicFields
|
||||
{
|
||||
Actors = 0x000, // Flags: Public
|
||||
Lines = 0x001, // Flags: 0x100
|
||||
End = 0x002,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
[Flags]
|
||||
public enum UpdateFlag
|
||||
{
|
||||
None = 0x0,
|
||||
Self = 0x1,
|
||||
Transport = 0x2,
|
||||
HasTarget = 0x4,
|
||||
Living = 0x8,
|
||||
StationaryPosition = 0x10,
|
||||
Vehicle = 0x20,
|
||||
TransportPosition = 0x40,
|
||||
Rotation = 0x80,
|
||||
AnimKits = 0x100,
|
||||
Areatrigger = 0x0200,
|
||||
//UPDATEFLAG_GAMEOBJECT = 0x0400,
|
||||
//UPDATEFLAG_REPLACE_ACTIVE = 0x0800,
|
||||
//UPDATEFLAG_NO_BIRTH_ANIM = 0x1000,
|
||||
//UPDATEFLAG_ENABLE_PORTALS = 0x2000,
|
||||
//UPDATEFLAG_PLAY_HOVER_ANIM = 0x4000,
|
||||
//UPDATEFLAG_IS_SUPPRESSING_GREETINGS = 0x8000
|
||||
//UPDATEFLAG_SCENEOBJECT = 0x10000,
|
||||
//UPDATEFLAG_SCENE_PENDING_INSTANCE = 0x20000
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum UpdateType
|
||||
{
|
||||
Values = 0,
|
||||
CreateObject = 1,
|
||||
CreateObject2 = 2,
|
||||
OutOfRangeObjects = 3,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Constants
|
||||
{
|
||||
public enum VehiclePowerType
|
||||
{
|
||||
Steam = 61,
|
||||
Pyrite = 41,
|
||||
Heat = 101,
|
||||
Ooze = 121,
|
||||
Blood = 141,
|
||||
Wrath = 142,
|
||||
ArcaneEnergy = 143,
|
||||
LifeEnergy = 144,
|
||||
SunEnergy = 145,
|
||||
SwingVelocity = 146,
|
||||
ShadowflameEnergy = 147,
|
||||
BluePower = 148,
|
||||
PurplePower = 149,
|
||||
GreenPower = 150,
|
||||
OrangePower = 151,
|
||||
Energy2 = 153,
|
||||
Arcaneenergy = 161,
|
||||
Wind1 = 162,
|
||||
Wind2 = 163,
|
||||
Wind3 = 164,
|
||||
Fuel = 165,
|
||||
SunPower = 166,
|
||||
TwilightEnergy = 169,
|
||||
Venom = 174,
|
||||
Orange2 = 176,
|
||||
ConsumingFlame = 177,
|
||||
PyroclasticFrenzy = 178,
|
||||
Flashfire = 179,
|
||||
}
|
||||
|
||||
public enum VehicleFlags
|
||||
{
|
||||
NoStrafe = 0x01, // Sets Moveflag2NoStrafe
|
||||
NoJumping = 0x02, // Sets Moveflag2NoJumping
|
||||
Fullspeedturning = 0x04, // Sets Moveflag2Fullspeedturning
|
||||
AllowPitching = 0x10, // Sets Moveflag2AllowPitching
|
||||
Fullspeedpitching = 0x20, // Sets Moveflag2Fullspeedpitching
|
||||
CustomPitch = 0x40, // If Set Use Pitchmin And Pitchmax From Dbc, Otherwise Pitchmin = -Pi/2, Pitchmax = Pi/2
|
||||
AdjustAimAngle = 0x400, // LuaIsvehicleaimangleadjustable
|
||||
AdjustAimPower = 0x800, // LuaIsvehicleaimpoweradjustable
|
||||
FixedPosition = 0x200000 // Used for cannons, when they should be rooted
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Framework.Cryptography
|
||||
{
|
||||
public sealed class WorldCrypt : IDisposable
|
||||
{
|
||||
static readonly byte[] ServerEncryptionKey = { 0x08, 0xF1, 0x95, 0x9F, 0x47, 0xE5, 0xD2, 0xDB, 0xA1, 0x3D, 0x77, 0x8F, 0x3F, 0x3E, 0xE7, 0x00 };
|
||||
static readonly byte[] ServerDecryptionKey = { 0x40, 0xAA, 0xD3, 0x92, 0x26, 0x71, 0x43, 0x47, 0x3A, 0x31, 0x08, 0xA6, 0xE7, 0xDC, 0x98, 0x2A };
|
||||
|
||||
public void Initialize(byte[] sessionKey)
|
||||
{
|
||||
if (IsInitialized)
|
||||
throw new InvalidOperationException("PacketCrypt already initialized!");
|
||||
|
||||
SARC4Encrypt = new SARC4();
|
||||
SARC4Decrypt = new SARC4();
|
||||
|
||||
var encryptSHA1 = new HMACSHA1(ServerEncryptionKey);
|
||||
var decryptSHA1 = new HMACSHA1(ServerDecryptionKey);
|
||||
|
||||
SARC4Encrypt.PrepareKey(encryptSHA1.ComputeHash(sessionKey));
|
||||
SARC4Decrypt.PrepareKey(decryptSHA1.ComputeHash(sessionKey));
|
||||
|
||||
var PacketEncryptionDummy = new byte[0x400];
|
||||
var PacketDecryptionDummy = new byte[0x400];
|
||||
|
||||
SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
|
||||
SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
public void Initialize(byte[] sessionKey, byte[] serverSeed, byte[] clientSeed)
|
||||
{
|
||||
if (IsInitialized)
|
||||
throw new InvalidOperationException("PacketCrypt already initialized!");
|
||||
|
||||
SARC4Encrypt = new SARC4();
|
||||
SARC4Decrypt = new SARC4();
|
||||
|
||||
var encryptSHA1 = new HMACSHA1(serverSeed);
|
||||
var decryptSHA1 = new HMACSHA1(clientSeed);
|
||||
|
||||
SARC4Encrypt.PrepareKey(encryptSHA1.ComputeHash(sessionKey));
|
||||
SARC4Decrypt.PrepareKey(decryptSHA1.ComputeHash(sessionKey));
|
||||
|
||||
var PacketEncryptionDummy = new byte[0x400];
|
||||
var PacketDecryptionDummy = new byte[0x400];
|
||||
|
||||
SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
|
||||
SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
public void Encrypt(byte[] data, int count)
|
||||
{
|
||||
if (!IsInitialized)
|
||||
throw new InvalidOperationException("PacketCrypt not initialized!");
|
||||
|
||||
SARC4Encrypt.ProcessBuffer(data, count);
|
||||
}
|
||||
|
||||
public void Decrypt(byte[] data, int count)
|
||||
{
|
||||
if (!IsInitialized)
|
||||
throw new InvalidOperationException("PacketCrypt not initialized!");
|
||||
|
||||
SARC4Decrypt.ProcessBuffer(data, count);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
IsInitialized = false;
|
||||
}
|
||||
|
||||
public bool IsInitialized { get; set; }
|
||||
SARC4 SARC4Encrypt;
|
||||
SARC4 SARC4Decrypt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Framework.Cryptography
|
||||
{
|
||||
public class RsaCrypt : IDisposable
|
||||
{
|
||||
public RsaCrypt()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void InitializeEncryption<T>(T p, T q, T dp, T dq, T iq, bool isBigEndian = false)
|
||||
{
|
||||
this._p = p.ToBigInteger(isBigEndian);
|
||||
this._q = q.ToBigInteger(isBigEndian);
|
||||
this._dp = dp.ToBigInteger(isBigEndian);
|
||||
this._dq = dq.ToBigInteger(isBigEndian);
|
||||
this._iq = iq.ToBigInteger(isBigEndian);
|
||||
|
||||
if (this._p.IsZero && this._q.IsZero)
|
||||
throw new InvalidOperationException("'0' isn't allowed for p or q");
|
||||
else
|
||||
_isEncryptionInitialized = true;
|
||||
}
|
||||
|
||||
public void InitializeDecryption<T>(T e, T n, bool reverseBytes = false)
|
||||
{
|
||||
this._e = e.ToBigInteger(reverseBytes);
|
||||
this._n = n.ToBigInteger(reverseBytes);
|
||||
|
||||
_isDecryptionInitialized = true;
|
||||
}
|
||||
|
||||
public byte[] Encrypt<T>(T data, bool isBigEndian = false)
|
||||
{
|
||||
if (!_isEncryptionInitialized)
|
||||
throw new InvalidOperationException("Encryption not initialized");
|
||||
|
||||
var bData = data.ToBigInteger(isBigEndian);
|
||||
|
||||
var m1 = BigInteger.ModPow(bData % _p, _dp, _p);
|
||||
var m2 = BigInteger.ModPow(bData % _q, _dq, _q);
|
||||
|
||||
var h = (_iq * (m1 - m2)) % _p;
|
||||
|
||||
// Be sure to use the positive remainder
|
||||
if (h.Sign == -1)
|
||||
h = _p + h;
|
||||
|
||||
var m = m2 + h * _q;
|
||||
|
||||
return m.ToByteArray();
|
||||
}
|
||||
|
||||
public byte[] Decrypt<T>(T data, bool isBigEndian = false)
|
||||
{
|
||||
if (!_isDecryptionInitialized)
|
||||
throw new InvalidOperationException("Encryption not initialized");
|
||||
|
||||
var c = data.ToBigInteger(isBigEndian);
|
||||
|
||||
return BigInteger.ModPow(c, _e, _n).ToByteArray();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this._e = 0;
|
||||
this._n = 0;
|
||||
this._p = 0;
|
||||
this._q = 0;
|
||||
this._dp = 0;
|
||||
this._dq = 0;
|
||||
this._iq = 0;
|
||||
|
||||
_isEncryptionInitialized = false;
|
||||
_isDecryptionInitialized = false;
|
||||
}
|
||||
|
||||
BigInteger _e;
|
||||
BigInteger _n;
|
||||
BigInteger _p;
|
||||
BigInteger _q;
|
||||
BigInteger _dp;
|
||||
BigInteger _dq;
|
||||
BigInteger _iq;
|
||||
bool _isEncryptionInitialized;
|
||||
bool _isDecryptionInitialized;
|
||||
}
|
||||
|
||||
public class RsaStore
|
||||
{
|
||||
public static byte[] DP = { 0xE1, 0xA6, 0x22, 0xAB, 0xFF, 0x57, 0x83, 0x45, 0x3F, 0x93, 0x76, 0xC8, 0xFA, 0xD9, 0x17, 0xE1, 0x49, 0x73, 0xC2, 0x13, 0x28, 0x0B, 0x1F, 0xE2, 0x9A, 0xF4, 0x7F, 0x7C, 0x37, 0x56, 0xA1, 0xDF, 0x51, 0x97, 0x2F, 0x15, 0x10, 0x97, 0xCD, 0x2A, 0x40, 0x09, 0xFC, 0x0A, 0xC3, 0x3F, 0x88, 0x86, 0xA9, 0x51, 0x13, 0xE1, 0x76, 0xCF, 0xA8, 0x37, 0x9A, 0x91, 0x3B, 0xD0, 0x70, 0xA1, 0xD7, 0x03, 0x71, 0x59, 0x6C, 0xB3, 0x41, 0xB8, 0x32, 0x68, 0x56, 0xC8, 0xB8, 0xD1, 0xF9, 0x1D, 0x04, 0xC5, 0x13, 0xB5, 0x8E, 0x57, 0x73, 0x02, 0x97, 0x7B, 0x33, 0x60, 0x68, 0xA9, 0xC2, 0x40, 0x96, 0x3C, 0x57, 0x4E, 0x4F, 0xC0, 0xAB, 0x21, 0x5C, 0xBA, 0x7D, 0x65, 0xAA, 0x1B, 0xD6, 0x43, 0x06, 0xCE, 0x3E, 0x0C, 0xB9, 0xB2, 0x82, 0xB0, 0xC9, 0x54, 0x59, 0x32, 0xC5, 0x88, 0x08, 0x9C, 0x9B, 0xBF };
|
||||
public static byte[] DQ = { 0xE3, 0xB1, 0xED, 0x52, 0xEF, 0xE6, 0x88, 0x40, 0x50, 0x89, 0x4C, 0x99, 0xE5, 0xF7, 0xED, 0x03, 0x1C, 0x54, 0x11, 0x24, 0x2F, 0x9D, 0xE8, 0xE6, 0x39, 0xFA, 0x19, 0xF4, 0x06, 0x55, 0x0B, 0x8B, 0x95, 0xC8, 0xB1, 0xE2, 0x7C, 0x75, 0x3B, 0x2A, 0x40, 0xC3, 0xE7, 0xE0, 0x25, 0x18, 0xBF, 0xB5, 0x03, 0x1B, 0x5A, 0x57, 0x92, 0x3C, 0x85, 0x7D, 0x7F, 0x43, 0x56, 0x1F, 0x1E, 0x80, 0xC3, 0xBA, 0xF0, 0x53, 0xD7, 0x6A, 0xD0, 0xF2, 0xDD, 0x9C, 0xC6, 0x53, 0xE7, 0xB4, 0xD3, 0x9D, 0xAB, 0xBF, 0xE0, 0x97, 0x50, 0x92, 0x23, 0xB9, 0xB7, 0xDC, 0xAA, 0xC4, 0x20, 0x93, 0x5A, 0xF5, 0xDE, 0x76, 0x28, 0x93, 0x91, 0x44, 0x1E, 0x4C, 0x15, 0x2F, 0x7F, 0x45, 0x3C, 0x3B, 0x7D, 0x36, 0x3B, 0x24, 0xC7, 0x8C, 0x65, 0x43, 0xAE, 0x65, 0x84, 0xBC, 0xF9, 0x76, 0x4E, 0x3C, 0x44, 0x05, 0xBC, 0xFA };
|
||||
public static byte[] InverseQ = { 0x63, 0xC1, 0x14, 0x2B, 0x57, 0x0B, 0x8A, 0x3C, 0x27, 0xDB, 0x96, 0x82, 0x27, 0xEB, 0xF6, 0x45, 0x6D, 0x07, 0x50, 0xE8, 0x4A, 0xD4, 0xB6, 0x7A, 0x3C, 0x8B, 0x4D, 0x65, 0xF0, 0x50, 0x70, 0x84, 0x71, 0x2B, 0xC6, 0x6D, 0x28, 0x2D, 0x76, 0x38, 0x73, 0x93, 0xDB, 0x44, 0xD7, 0xC0, 0x7F, 0xD9, 0x57, 0x18, 0x28, 0x57, 0xF1, 0x13, 0x38, 0xA4, 0x91, 0x67, 0x1E, 0x13, 0x73, 0x55, 0xFC, 0x7B, 0xAF, 0x50, 0xFA, 0xFD, 0x16, 0x12, 0x6F, 0xA4, 0x95, 0x15, 0x9C, 0x07, 0x18, 0xA6, 0x46, 0xFD, 0xB3, 0xCF, 0xA5, 0x0E, 0x05, 0x30, 0xEC, 0x2C, 0xCD, 0x62, 0xDD, 0x6F, 0xB1, 0xFE, 0x6C, 0x05, 0x2F, 0x11, 0xA6, 0xA0, 0x98, 0xAC, 0x9B, 0x15, 0xF0, 0x04, 0xC4, 0x7B, 0x79, 0xAA, 0x51, 0x25, 0x2A, 0x84, 0x73, 0xE6, 0x77, 0x47, 0xA3, 0xEB, 0xCF, 0x6D, 0xC8, 0x96, 0x3A, 0x1B, 0x02, 0x52 };
|
||||
public static byte[] P = { 0x7D, 0xBD, 0xB9, 0xE1, 0x2D, 0xAE, 0x42, 0x56, 0x6E, 0x2B, 0xE2, 0x89, 0xD9, 0xBB, 0x0C, 0x1F, 0x67, 0x28, 0xC1, 0x4D, 0x91, 0x3C, 0xAD, 0x5F, 0xF0, 0x43, 0x86, 0x5C, 0x27, 0xDC, 0x58, 0xB3, 0x0E, 0x75, 0x77, 0x78, 0x49, 0x35, 0xE7, 0xE7, 0xDF, 0xFD, 0x74, 0xAB, 0x4E, 0xFE, 0xD3, 0xAB, 0x6B, 0x96, 0xF7, 0x89, 0xB2, 0x5A, 0x6A, 0x25, 0x03, 0x5A, 0x92, 0x1A, 0xF1, 0xFC, 0x05, 0x4E, 0xCE, 0xDD, 0x37, 0xA4, 0x02, 0x53, 0x76, 0xCB, 0xC2, 0xD9, 0x63, 0xCB, 0x51, 0x94, 0xEC, 0x5C, 0x39, 0xCC, 0xB2, 0x17, 0x0C, 0xA3, 0x43, 0x9A, 0xD0, 0x83, 0x27, 0x67, 0x52, 0x64, 0x37, 0x0E, 0x38, 0xB7, 0x9B, 0xF4, 0x2D, 0xB8, 0x0F, 0x30, 0x72, 0xD3, 0x15, 0xF3, 0x2C, 0x39, 0x55, 0x72, 0x2C, 0x55, 0x80, 0x63, 0xA0, 0xA1, 0x6F, 0x28, 0xF3, 0xF3, 0x5A, 0x6F, 0x68, 0x59, 0xB3, 0xF3 };
|
||||
public static byte[] Q = { 0x0B, 0x1A, 0x13, 0x07, 0x12, 0xEF, 0xDD, 0x97, 0x01, 0x9A, 0x21, 0x7D, 0xFA, 0xA3, 0xB7, 0xE2, 0x39, 0x2E, 0x04, 0x92, 0x96, 0x45, 0x2A, 0xEB, 0x57, 0x03, 0xAC, 0xB1, 0x83, 0xCD, 0x25, 0x4F, 0x2C, 0xA9, 0xA1, 0x54, 0x26, 0x54, 0xCF, 0xE6, 0x1B, 0x53, 0x51, 0x3A, 0xC1, 0x15, 0xF4, 0x17, 0xBB, 0x17, 0x1F, 0x37, 0x66, 0x36, 0x1A, 0xD4, 0xB1, 0x5B, 0x49, 0xA8, 0xF1, 0x02, 0xB0, 0x42, 0xA9, 0x66, 0xA0, 0xE2, 0x52, 0x2C, 0x8C, 0x89, 0xA2, 0xDD, 0xA6, 0xF1, 0xA3, 0xDF, 0xB6, 0x80, 0x63, 0xB8, 0x10, 0xDA, 0xDE, 0x84, 0x56, 0xFA, 0xFB, 0x72, 0x65, 0x5E, 0xA3, 0x9C, 0x78, 0x65, 0xD0, 0x73, 0x07, 0x34, 0x1D, 0xE1, 0x4D, 0x77, 0xE8, 0x00, 0x0F, 0x80, 0x1C, 0x5A, 0x21, 0x55, 0x0A, 0x8C, 0xF4, 0x93, 0xF5, 0xF8, 0x40, 0xF2, 0x40, 0xEA, 0x52, 0x12, 0x40, 0xF0, 0xBF, 0xFA };
|
||||
public static byte[] WherePacketHmac = { 0x2C, 0x1F, 0x1D, 0x80, 0xC3, 0x8C, 0x23, 0x64, 0xDA, 0x90, 0xCA, 0x8E, 0x2C, 0xFC, 0x0C, 0xCE, 0x09, 0xD3, 0x62, 0xF9, 0xF3, 0x8B, 0xBE, 0x9F, 0x19, 0xEF, 0x58, 0xA1, 0x1C, 0x34, 0x14, 0x41, 0x3F, 0x23, 0xFD, 0xD3, 0xE8, 0x14, 0xEC, 0x2A, 0xFD, 0x4F, 0x95, 0xBA, 0x30, 0x7E, 0x56, 0x5D, 0x83, 0x95, 0x81, 0x69, 0xB0, 0x5A, 0xB4, 0x9D, 0xA8, 0x55, 0xFF, 0xFC, 0xEE, 0x58, 0x0A, 0x2F };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2014 Arctium Emulation<http://arctium.org>
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Cryptography
|
||||
{
|
||||
//Thx Fabian over at Arctium.
|
||||
public sealed class SARC4
|
||||
{
|
||||
public SARC4()
|
||||
{
|
||||
_s = new byte[0x100];
|
||||
_tmp = 0;
|
||||
_tmp2 = 0;
|
||||
}
|
||||
|
||||
public void PrepareKey(byte[] key)
|
||||
{
|
||||
for (int i = 0; i < 0x100; i++)
|
||||
_s[i] = (byte)i;
|
||||
|
||||
var j = 0;
|
||||
for (int i = 0; i < 0x100; i++)
|
||||
{
|
||||
j = (byte)((j + key[i % key.Length] + _s[i]) & 255);
|
||||
|
||||
var tempS = _s[i];
|
||||
|
||||
_s[i] = _s[j];
|
||||
_s[j] = tempS;
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessBuffer(byte[] data, int length)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
_tmp = (byte)((_tmp + 1) % 0x100);
|
||||
_tmp2 = (byte)((_tmp2 + _s[_tmp]) % 0x100);
|
||||
|
||||
var sTemp = _s[_tmp];
|
||||
|
||||
_s[_tmp] = _s[_tmp2];
|
||||
_s[_tmp2] = sTemp;
|
||||
|
||||
data[i] = (byte)(_s[(_s[_tmp] + _s[_tmp2]) % 0x100] ^ data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] _s;
|
||||
byte _tmp;
|
||||
byte _tmp2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Security.Cryptography;
|
||||
|
||||
namespace Framework.Cryptography
|
||||
{
|
||||
public class SessionKeyGenerator
|
||||
{
|
||||
public SessionKeyGenerator(byte[] buff, int size)
|
||||
{
|
||||
int halfSize = size / 2;
|
||||
|
||||
sh = SHA256.Create();
|
||||
sh.TransformFinalBlock(buff, 0, halfSize);
|
||||
o1 = sh.Hash;
|
||||
|
||||
sh.Initialize();
|
||||
sh.TransformFinalBlock(buff, halfSize, size - halfSize);
|
||||
o2 = sh.Hash;
|
||||
|
||||
FillUp();
|
||||
}
|
||||
|
||||
public void Generate(byte[] buf, uint sz)
|
||||
{
|
||||
for (uint i = 0; i < sz; ++i)
|
||||
{
|
||||
if (taken == 32)
|
||||
FillUp();
|
||||
|
||||
buf[i] = o0[taken];
|
||||
taken++;
|
||||
}
|
||||
}
|
||||
|
||||
void FillUp()
|
||||
{
|
||||
sh.Initialize();
|
||||
sh.TransformBlock(o1, 0, 32, o1, 0);
|
||||
sh.TransformBlock(o0, 0, 32, o0, 0);
|
||||
sh.TransformFinalBlock(o2, 0, 32);
|
||||
o0 = sh.Hash;
|
||||
|
||||
taken = 0;
|
||||
}
|
||||
|
||||
SHA256 sh;
|
||||
uint taken;
|
||||
byte[] o0 = new byte[32];
|
||||
byte[] o1 = new byte[32];
|
||||
byte[] o2 = new byte[32];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2012-2014 Arctium Emulation <http://arctium.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Framework.Cryptography
|
||||
{
|
||||
public class Sha256
|
||||
{
|
||||
public byte[] Digest { get; private set; }
|
||||
|
||||
public Sha256()
|
||||
{
|
||||
sha.Initialize();
|
||||
}
|
||||
|
||||
public void Process(byte[] data, int length)
|
||||
{
|
||||
sha.TransformBlock(data, 0, length, data, 0);
|
||||
}
|
||||
|
||||
public void Process(uint data)
|
||||
{
|
||||
var bytes = BitConverter.GetBytes(data);
|
||||
|
||||
sha.TransformBlock(bytes, 0, 4, bytes, 0);
|
||||
}
|
||||
|
||||
public void Process(string data)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(data);
|
||||
|
||||
sha.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
|
||||
}
|
||||
|
||||
public void Finish(byte[] data, int length)
|
||||
{
|
||||
sha.TransformFinalBlock(data, 0, data.Length);
|
||||
|
||||
Digest = sha.Hash;
|
||||
}
|
||||
|
||||
public void Finish(byte[] data, int offset, int length)
|
||||
{
|
||||
sha.TransformFinalBlock(data, offset, length);
|
||||
|
||||
Digest = sha.Hash;
|
||||
}
|
||||
|
||||
SHA256 sha;
|
||||
}
|
||||
|
||||
public class HmacHash : HMACSHA1
|
||||
{
|
||||
public byte[] Digest { get; private set; }
|
||||
|
||||
public HmacHash(byte[] key) : base(key, true)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Process(byte[] data, int length)
|
||||
{
|
||||
TransformBlock(data, 0, length, data, 0);
|
||||
}
|
||||
|
||||
public void Process(uint data)
|
||||
{
|
||||
var bytes = BitConverter.GetBytes(data);
|
||||
|
||||
TransformBlock(bytes, 0, bytes.Length, bytes, 0);
|
||||
}
|
||||
|
||||
public void Process(string data)
|
||||
{
|
||||
var bytes = Encoding.ASCII.GetBytes(data);
|
||||
|
||||
TransformBlock(bytes, 0, bytes.Length, bytes, 0);
|
||||
}
|
||||
|
||||
public void Finish(byte[] data, int length)
|
||||
{
|
||||
TransformFinalBlock(data, 0, length);
|
||||
|
||||
Digest = Hash;
|
||||
}
|
||||
|
||||
public void Finish(string data)
|
||||
{
|
||||
var bytes = Encoding.ASCII.GetBytes(data);
|
||||
|
||||
TransformFinalBlock(bytes, 0, bytes.Length);
|
||||
|
||||
Digest = Hash;
|
||||
}
|
||||
}
|
||||
|
||||
public class HmacSha256 : HMACSHA256
|
||||
{
|
||||
public HmacSha256() : base()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public HmacSha256(byte[] key) : base(key)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Process(byte[] data, int length)
|
||||
{
|
||||
TransformBlock(data, 0, length, data, 0);
|
||||
}
|
||||
|
||||
public void Process(uint data)
|
||||
{
|
||||
var bytes = BitConverter.GetBytes(data);
|
||||
|
||||
TransformBlock(bytes, 0, bytes.Length, bytes, 0);
|
||||
}
|
||||
|
||||
public void Process(string data)
|
||||
{
|
||||
var bytes = Encoding.ASCII.GetBytes(data);
|
||||
|
||||
TransformBlock(bytes, 0, bytes.Length, bytes, 0);
|
||||
}
|
||||
|
||||
public void Finish(byte[] data, int length)
|
||||
{
|
||||
TransformFinalBlock(data, 0, length);
|
||||
|
||||
Digest = Hash;
|
||||
}
|
||||
|
||||
public byte[] Digest { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public static class DB
|
||||
{
|
||||
public static LoginDatabase Login = new LoginDatabase();
|
||||
public static CharacterDatabase Characters = new CharacterDatabase();
|
||||
public static WorldDatabase World = new WorldDatabase();
|
||||
public static HotfixDatabase Hotfix = new HotfixDatabase();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 Framework.Configuration;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class DatabaseLoader
|
||||
{
|
||||
public DatabaseLoader(DatabaseTypeFlags defaultUpdateMask)
|
||||
{
|
||||
_autoSetup = ConfigMgr.GetDefaultValue("Updates.AutoSetup", true);
|
||||
_updateFlags = ConfigMgr.GetDefaultValue("Updates.EnableDatabases", defaultUpdateMask);
|
||||
}
|
||||
|
||||
public void AddDatabase<T>(MySqlBase<T> database, string dbName)
|
||||
{
|
||||
bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags);
|
||||
_open.Add(() =>
|
||||
{
|
||||
MySqlConnectionInfo connectionObject = new MySqlConnectionInfo
|
||||
{
|
||||
Host = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Host", ""),
|
||||
Port = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Port", ""),
|
||||
Username = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Username", ""),
|
||||
Password = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Password", ""),
|
||||
Database = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Database", "")
|
||||
};
|
||||
|
||||
var error = database.Initialize(connectionObject);
|
||||
if (error != MySqlErrorCode.None)
|
||||
{
|
||||
// Database does not exist
|
||||
if (error == MySqlErrorCode.UnknownDatabase && updatesEnabled && _autoSetup)
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Database \"{dbName}\" does not exist, do you want to create it? [yes (default) / no]: ");
|
||||
|
||||
string answer = Console.ReadLine();
|
||||
if (string.IsNullOrEmpty(answer) || answer[0] != 'y')
|
||||
return false;
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, $"Creating database \"{dbName}\"...");
|
||||
string sqlString = $"CREATE DATABASE `{dbName}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
|
||||
// Try to create the database and connect again if auto setup is enabled
|
||||
if (database.Apply(sqlString) && database.Initialize(connectionObject) == MySqlErrorCode.None)
|
||||
error = MySqlErrorCode.None;
|
||||
}
|
||||
|
||||
// If the error wasn't handled quit
|
||||
if (error != MySqlErrorCode.None)
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"\nDatabase {dbName} NOT opened. There were errors opening the MySQL connections. Check your SQLErrors for specific errors.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Done.");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (updatesEnabled)
|
||||
{
|
||||
// Populate and update only if updates are enabled for this pool
|
||||
_populate.Add(() =>
|
||||
{
|
||||
//Hack used to allow big querys
|
||||
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
|
||||
if (!database.GetUpdater().Populate())
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"Could not populate the {dbName} database, see log for details.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
_update.Add(() =>
|
||||
{
|
||||
//Hack used to allow big querys
|
||||
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
|
||||
if (!database.GetUpdater().Update())
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"Could not update the {dbName} database, see log for details.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
_prepare.Add(() =>
|
||||
{
|
||||
database.LoadPreparedStatements();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public bool Load()
|
||||
{
|
||||
if (_updateFlags == 0)
|
||||
Log.outInfo(LogFilter.SqlUpdates, "Automatic database updates are disabled for all databases!");
|
||||
|
||||
if (!OpenDatabases())
|
||||
return false;
|
||||
|
||||
if (!PopulateDatabases())
|
||||
return false;
|
||||
|
||||
if (!UpdateDatabases())
|
||||
return false;
|
||||
|
||||
if (!PrepareStatements())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenDatabases()
|
||||
{
|
||||
return Process(_open);
|
||||
}
|
||||
|
||||
// Processes the elements of the given stack until a predicate returned false.
|
||||
bool Process(List<Func<bool>> list)
|
||||
{
|
||||
while (!list.Empty())
|
||||
{
|
||||
if (!list[0].Invoke())
|
||||
return false;
|
||||
|
||||
list.RemoveAt(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PopulateDatabases()
|
||||
{
|
||||
return Process(_populate);
|
||||
}
|
||||
|
||||
bool UpdateDatabases()
|
||||
{
|
||||
return Process(_update);
|
||||
}
|
||||
|
||||
bool PrepareStatements()
|
||||
{
|
||||
return Process(_prepare);
|
||||
}
|
||||
|
||||
bool _autoSetup;
|
||||
DatabaseTypeFlags _updateFlags;
|
||||
List<Func<bool>> _open = new List<Func<bool>>();
|
||||
List<Func<bool>> _populate = new List<Func<bool>>();
|
||||
List<Func<bool>> _update = new List<Func<bool>>();
|
||||
List<Func<bool>> _prepare = new List<Func<bool>>();
|
||||
}
|
||||
|
||||
public enum DatabaseTypeFlags
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Login = 1,
|
||||
Character = 2,
|
||||
World = 4,
|
||||
Hotfix = 8,
|
||||
|
||||
All = Login | Character | World | Hotfix
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,462 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 Framework.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class DatabaseUpdater<T>
|
||||
{
|
||||
public DatabaseUpdater(MySqlBase<T> database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public bool Populate()
|
||||
{
|
||||
SQLResult result = _database.Query("SHOW TABLES");
|
||||
if (!result.IsEmpty() && result.GetRowCount() > 0)
|
||||
return true;
|
||||
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Database {_database.GetDatabaseName()} is empty, auto populating it...");
|
||||
|
||||
string path = GetSourceDirectory();
|
||||
string fileName = "Unknown";
|
||||
switch (_database.GetType().Name)
|
||||
{
|
||||
case "LoginDatabase":
|
||||
fileName = @"\sql\base\auth_database.sql";
|
||||
break;
|
||||
case "CharacterDatabase":
|
||||
fileName = @"\sql\base\characters_database.sql";
|
||||
break;
|
||||
case "WorldDatabase":
|
||||
fileName = @"\sql\base\TDB_world_703.00_2016_10_17.sql";
|
||||
break;
|
||||
case "HotfixDatabase":
|
||||
fileName = @"\sql\base\TDB_hotfixes_703.00_2016_10_17.sql";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!File.Exists(path + fileName))
|
||||
{
|
||||
Log.outError(LogFilter.SqlUpdates, $"File \"{fileName}\" is missing, download it from \"http://www.trinitycore.org/f/files/category/1-database/\"" +
|
||||
" and place it in your worldserver directory.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update database
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Applying \'{fileName}\'...");
|
||||
_database.ApplyFile(path + fileName);
|
||||
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Done Applying \'{fileName}\'");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update()
|
||||
{
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Updating {_database.GetDatabaseName()} database...");
|
||||
|
||||
string sourceDirectory = GetSourceDirectory();
|
||||
|
||||
if (!Directory.Exists(sourceDirectory))
|
||||
{
|
||||
Log.outError(LogFilter.SqlUpdates, $"DBUpdater: Given source directory {sourceDirectory} does not exist, skipped!");
|
||||
return false;
|
||||
}
|
||||
|
||||
var availableFiles = GetFileList();
|
||||
var appliedFiles = ReceiveAppliedFiles();
|
||||
|
||||
bool redundancyChecks = ConfigMgr.GetDefaultValue("Updates.Redundancy", true);
|
||||
bool archivedRedundancy = ConfigMgr.GetDefaultValue("Updates.Redundancy", true);
|
||||
|
||||
UpdateResult result = new UpdateResult();
|
||||
|
||||
// Count updates
|
||||
foreach (var entry in appliedFiles)
|
||||
{
|
||||
if (entry.Value.State == State.RELEASED)
|
||||
++result.recent;
|
||||
else
|
||||
++result.archived;
|
||||
}
|
||||
|
||||
foreach (var availableQuery in availableFiles)
|
||||
{
|
||||
Log.outDebug(LogFilter.SqlUpdates, $"Checking update \"{availableQuery.GetFileName()}\"...");
|
||||
|
||||
var applied = appliedFiles.LookupByKey(availableQuery.GetFileName());
|
||||
if (applied != null)
|
||||
{
|
||||
// If redundancy is disabled skip it since the update is already applied.
|
||||
if (!redundancyChecks)
|
||||
{
|
||||
Log.outDebug(LogFilter.SqlUpdates, "Update is already applied, skipping redundancy checks.");
|
||||
appliedFiles.Remove(availableQuery.GetFileName());
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the update is in an archived directory and is marked as archived in our database skip redundancy checks (archived updates never change).
|
||||
if (!archivedRedundancy && (applied.State == State.ARCHIVED) && (availableQuery.state == State.ARCHIVED))
|
||||
{
|
||||
Log.outDebug(LogFilter.SqlUpdates, "Update is archived and marked as archived in database, skipping redundancy checks.");
|
||||
appliedFiles.Remove(availableQuery.GetFileName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate hash
|
||||
string hash = CalculateHash(availableQuery.path);
|
||||
|
||||
UpdateMode mode = UpdateMode.Apply;
|
||||
|
||||
// Update is not in our applied list
|
||||
if (applied == null)
|
||||
{
|
||||
// Catch renames (different filename but same hash)
|
||||
var hashIter = appliedFiles.Values.FirstOrDefault(p => p.Hash == hash);
|
||||
if (hashIter != null)
|
||||
{
|
||||
// Check if the original file was removed if not we've got a problem.
|
||||
var renameFile = availableFiles.Find(p => p.GetFileName() == hashIter.Name);
|
||||
if (renameFile != null)
|
||||
{
|
||||
Log.outWarn(LogFilter.SqlUpdates, $"Seems like update \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\' was renamed, but the old file is still there! " +
|
||||
$"Trade it as a new file! (Probably its an unmodified copy of file \"{renameFile.GetFileName()}\")");
|
||||
}
|
||||
// Its save to trade the file as renamed here
|
||||
else
|
||||
{
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Renaming update \"{hashIter.Name}\" to \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\'.");
|
||||
|
||||
RenameEntry(hashIter.Name, availableQuery.GetFileName());
|
||||
appliedFiles.Remove(hashIter.Name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Apply the update if it was never seen before.
|
||||
else
|
||||
{
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Applying update \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\'...");
|
||||
}
|
||||
}
|
||||
// Rehash the update entry if it is contained in our database but with an empty hash.
|
||||
else if (ConfigMgr.GetDefaultValue("Updates.AllowRehash", true) && string.IsNullOrEmpty(applied.Hash))
|
||||
{
|
||||
mode = UpdateMode.Rehash;
|
||||
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Re-hashing update \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\'...");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the hash of the files differs from the one stored in our database reapply the update (because it was changed).
|
||||
if (applied.Hash != hash)
|
||||
{
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Reapplying update \"{availableQuery.GetFileName()}\" \'{applied.Hash.Substring(0, 7)}\' . \'{hash.Substring(0, 7)}\' (it changed)...");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the file wasn't changed and just moved update its state if necessary.
|
||||
if (applied.State != availableQuery.state)
|
||||
{
|
||||
Log.outDebug(LogFilter.SqlUpdates, $"Updating state of \"{availableQuery.GetFileName()}\" to \'{availableQuery.state}\'...");
|
||||
|
||||
UpdateState(availableQuery.GetFileName(), availableQuery.state);
|
||||
}
|
||||
|
||||
Log.outDebug(LogFilter.SqlUpdates, $"Update is already applied and is matching hash \'{hash.Substring(0, 7)}\'.");
|
||||
|
||||
appliedFiles.Remove(applied.Name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
uint speed = 0;
|
||||
AppliedFileEntry file = new AppliedFileEntry(availableQuery.GetFileName(), hash, availableQuery.state, 0);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case UpdateMode.Apply:
|
||||
speed = ApplyTimedFile(availableQuery.path);
|
||||
goto case UpdateMode.Rehash;
|
||||
case UpdateMode.Rehash:
|
||||
UpdateEntry(file, speed);
|
||||
break;
|
||||
}
|
||||
|
||||
if (applied != null)
|
||||
appliedFiles.Remove(applied.Name);
|
||||
|
||||
if (mode == UpdateMode.Apply)
|
||||
++result.updated;
|
||||
}
|
||||
|
||||
// Cleanup up orphaned entries if enabled
|
||||
if (!appliedFiles.Empty())
|
||||
{
|
||||
int cleanDeadReferencesMaxCount = ConfigMgr.GetDefaultValue("Updates.CleanDeadRefMaxCount", 3);
|
||||
bool doCleanup = (cleanDeadReferencesMaxCount < 0) || (appliedFiles.Count <= cleanDeadReferencesMaxCount);
|
||||
|
||||
foreach (var entry in appliedFiles)
|
||||
{
|
||||
Log.outWarn(LogFilter.SqlUpdates, $"File \'{entry.Key}\' was applied to the database but is missing in your update directory now!");
|
||||
|
||||
if (doCleanup)
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Deleting orphaned entry \'{entry.Key}\'...");
|
||||
}
|
||||
|
||||
if (doCleanup)
|
||||
CleanUp(appliedFiles);
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.SqlUpdates, $"Cleanup is disabled! There are {appliedFiles.Count} dirty files that were applied to your database but are now missing in your source directory!");
|
||||
}
|
||||
}
|
||||
|
||||
string info = $"Containing {result.recent} new and {result.archived} archived updates.";
|
||||
|
||||
if (result.updated == 0)
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"{_database.GetDatabaseName()} database is up-to-date! {info}");
|
||||
else
|
||||
Log.outInfo(LogFilter.SqlUpdates, $"Applied {result.updated} query(s). {info}");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
string GetSourceDirectory()
|
||||
{
|
||||
string entry = ConfigMgr.GetDefaultValue("Updates.SourcePath", Environment.CurrentDirectory);
|
||||
if (!string.IsNullOrEmpty(entry))
|
||||
return entry;
|
||||
else
|
||||
return Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
|
||||
}
|
||||
|
||||
uint ApplyTimedFile(string path)
|
||||
{
|
||||
// Benchmark query speed
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// Update database
|
||||
_database.ApplyFile(path);
|
||||
|
||||
// Return time the query took to apply
|
||||
return Time.GetMSTimeDiffToNow(oldMSTime);
|
||||
}
|
||||
|
||||
void UpdateEntry(AppliedFileEntry entry, uint speed)
|
||||
{
|
||||
string update = $"REPLACE INTO `updates` (`name`, `hash`, `state`, `speed`) VALUES (\"{entry.Name}\", \"{entry.Hash}\", \'{entry.State}\', {speed})";
|
||||
|
||||
// Update database
|
||||
_database.Execute(update);
|
||||
}
|
||||
|
||||
void RenameEntry(string from, string to)
|
||||
{
|
||||
// Delete target if it exists
|
||||
{
|
||||
string update = $"DELETE FROM `updates` WHERE `name`=\"{to}\"";
|
||||
|
||||
// Update database
|
||||
_database.Execute(update);
|
||||
}
|
||||
|
||||
// Rename
|
||||
{
|
||||
string update = $"UPDATE `updates` SET `name`=\"{to}\" WHERE `name`=\"{from}\"";
|
||||
|
||||
// Update database
|
||||
_database.Execute(update);
|
||||
}
|
||||
}
|
||||
|
||||
void CleanUp(Dictionary<string, AppliedFileEntry> storage)
|
||||
{
|
||||
if (storage.Empty())
|
||||
return;
|
||||
|
||||
int remaining = storage.Count;
|
||||
string update = "DELETE FROM `updates` WHERE `name` IN(";
|
||||
|
||||
foreach (var entry in storage)
|
||||
{
|
||||
update += $"\"{entry.Key}\"";
|
||||
if ((--remaining) > 0)
|
||||
update += ", ";
|
||||
}
|
||||
|
||||
update += ")";
|
||||
|
||||
// Update database
|
||||
_database.Execute(update);
|
||||
}
|
||||
|
||||
void UpdateState(string name, State state)
|
||||
{
|
||||
string update = $"UPDATE `updates` SET `state`=\'{state}\' WHERE `name`=\"{name}\"";
|
||||
|
||||
// Update database
|
||||
_database.Execute(update);
|
||||
}
|
||||
|
||||
public List<FileEntry> GetFileList()
|
||||
{
|
||||
List<FileEntry> fileList = new List<FileEntry>();
|
||||
|
||||
SQLResult result = _database.Query("SELECT `path`, `state` FROM `updates_include`");
|
||||
if (result.IsEmpty())
|
||||
return fileList;
|
||||
|
||||
do
|
||||
{
|
||||
string path = result.Read<string>(0);
|
||||
if (path[0] == '$')
|
||||
path = GetSourceDirectory() + path.Substring(1);
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Log.outWarn(LogFilter.SqlUpdates, $"DBUpdater: Given update include directory \"{path}\" isn't existing, skipped!");
|
||||
continue;
|
||||
}
|
||||
|
||||
State state = result.Read<string>(1).ToEnum<State>();
|
||||
fileList.AddRange(GetFilesFromDirectory(path, state));
|
||||
|
||||
Log.outDebug(LogFilter.SqlUpdates, $"Added applied file \"{path}\" from remote.");
|
||||
|
||||
} while (result.NextRow());
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
public Dictionary<string, AppliedFileEntry> ReceiveAppliedFiles()
|
||||
{
|
||||
Dictionary<string, AppliedFileEntry> map = new Dictionary<string, AppliedFileEntry>();
|
||||
|
||||
SQLResult result = _database.Query("SELECT `name`, `hash`, `state`, UNIX_TIMESTAMP(`timestamp`) FROM `updates` ORDER BY `name` ASC");
|
||||
if (result.IsEmpty())
|
||||
return map;
|
||||
|
||||
do
|
||||
{
|
||||
AppliedFileEntry entry = new AppliedFileEntry(result.Read<string>(0), result.Read<string>(1), result.Read<string>(2).ToEnum<State>(), result.Read<ulong>(3));
|
||||
map.Add(entry.Name, entry);
|
||||
}
|
||||
while (result.NextRow());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
IEnumerable<FileEntry> GetFilesFromDirectory(string directory, State state)
|
||||
{
|
||||
Queue<string> queue = new Queue<string>();
|
||||
queue.Enqueue(directory);
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
directory = queue.Dequeue();
|
||||
try
|
||||
{
|
||||
foreach (string subDir in Directory.GetDirectories(directory))
|
||||
{
|
||||
queue.Enqueue(subDir);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine(ex);
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(directory, "*.sql");
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
yield return new FileEntry(files[i], state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string CalculateHash(string fileName)
|
||||
{
|
||||
using (SHA1 sha1 = new SHA1Managed())
|
||||
{
|
||||
string text = File.ReadAllText(fileName).Replace("\r", "");
|
||||
return sha1.ComputeHash(Encoding.UTF8.GetBytes(text)).ToHexString();
|
||||
}
|
||||
}
|
||||
|
||||
protected MySqlBase<T> _database;
|
||||
}
|
||||
|
||||
public class AppliedFileEntry
|
||||
{
|
||||
public AppliedFileEntry(string name, string hash, State state, ulong timestamp)
|
||||
{
|
||||
Name = name;
|
||||
Hash = hash;
|
||||
State = state;
|
||||
Timestamp = timestamp;
|
||||
}
|
||||
|
||||
public string Name;
|
||||
public string Hash;
|
||||
public State State;
|
||||
public ulong Timestamp;
|
||||
}
|
||||
|
||||
public class FileEntry
|
||||
{
|
||||
public FileEntry(string _path, State _state)
|
||||
{
|
||||
path = _path;
|
||||
state = _state;
|
||||
}
|
||||
|
||||
public string GetFileName()
|
||||
{
|
||||
return Path.GetFileName(path);
|
||||
}
|
||||
|
||||
public string path;
|
||||
public State state;
|
||||
}
|
||||
|
||||
struct UpdateResult
|
||||
{
|
||||
public int updated;
|
||||
public int recent;
|
||||
public int archived;
|
||||
}
|
||||
|
||||
public enum State
|
||||
{
|
||||
RELEASED,
|
||||
ARCHIVED
|
||||
}
|
||||
|
||||
enum UpdateMode
|
||||
{
|
||||
Apply,
|
||||
Rehash
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class LoginDatabase : MySqlBase<LoginStatements>
|
||||
{
|
||||
public override void PreparedStatements()
|
||||
{
|
||||
const string BnetAccountInfo = "ba.id, ba.email, ba.locked, ba.lock_country, ba.last_ip, ba.LoginTicketExpiry, bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate, bab.unbandate = bab.bandate";
|
||||
const string BnetGameAccountInfo = "a.id, a.username, ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, ab.unbandate = ab.bandate, aa.gmlevel";
|
||||
|
||||
PrepareStatement(LoginStatements.SEL_REALMLIST, "SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild, Region, Battlegroup FROM realmlist WHERE flag <> 3 ORDER BY name");
|
||||
PrepareStatement(LoginStatements.DEL_EXPIRED_IP_BANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
|
||||
PrepareStatement(LoginStatements.UPD_EXPIRED_ACCOUNT_BANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
|
||||
PrepareStatement(LoginStatements.SEL_IP_INFO, "(SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?) " +
|
||||
"UNION (SELECT NULL AS banned, country FROM ip2nation WHERE INET_NTOA(ip) = ?)");
|
||||
|
||||
PrepareStatement(LoginStatements.INS_IP_AUTO_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Cypher Auth', 'Failed login autoban')");
|
||||
PrepareStatement(LoginStatements.SEL_IP_BANNED_ALL, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) ORDER BY unbandate");
|
||||
PrepareStatement(LoginStatements.SEL_IP_BANNED_BY_IP, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) AND ip LIKE CONCAT('%%', ?, '%%') ORDER BY unbandate");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_BANNED_ALL, "SELECT account.id, username FROM account, account_banned WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_BANNED_BY_USERNAME, "SELECT account.id, username FROM account, account_banned WHERE account.id = account_banned.id AND active = 1 AND username LIKE CONCAT('%%', ?, '%%') GROUP BY account.id");
|
||||
PrepareStatement(LoginStatements.DEL_ACCOUNT_BANNED, "DELETE FROM account_banned WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_ACCOUNT_INFO_CONTINUED_SESSION, "UPDATE account SET sessionkey = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_INFO_CONTINUED_SESSION, "SELECT username, sessionkey FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_VS, "UPDATE account SET v = ?, s = ? WHERE username = ?");
|
||||
PrepareStatement(LoginStatements.SEL_LOGON_COUNTRY, "SELECT country FROM ip2nation WHERE ip < ? ORDER BY ip DESC LIMIT 0,1");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_ID_BY_NAME, "SELECT id FROM account WHERE username = ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_LIST_BY_NAME, "SELECT id, username FROM account WHERE username = ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_INFO_BY_NAME, "SELECT a.id, a.sessionkey, ba.last_ip, ba.locked, ba.lock_country, a.expansion, a.mutetime, ba.locale, a.recruiter, a.os, ba.id, aa.gmLevel, " +
|
||||
"bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate, ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, r.id " +
|
||||
"FROM account a LEFT JOIN account r ON a.id = r.recruiter LEFT JOIN battlenet_accounts ba ON a.battlenet_account = ba.id " +
|
||||
"LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID IN (-1, ?) LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 " +
|
||||
"WHERE a.username = ? ORDER BY aa.RealmID DESC LIMIT 1");
|
||||
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_LIST_BY_EMAIL, "SELECT id, username FROM account WHERE email = ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_BY_IP, "SELECT id, username FROM account WHERE last_ip = ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_BY_ID, "SELECT 1 FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.INS_IP_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, ?, ?)");
|
||||
PrepareStatement(LoginStatements.DEL_IP_NOT_BANNED, "DELETE FROM ip_banned WHERE ip = ?");
|
||||
PrepareStatement(LoginStatements.INS_ACCOUNT_BANNED, "INSERT INTO account_banned VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, ?, ?, 1)");
|
||||
PrepareStatement(LoginStatements.UPD_ACCOUNT_NOT_BANNED, "UPDATE account_banned SET active = 0 WHERE id = ? AND active != 0");
|
||||
PrepareStatement(LoginStatements.DEL_REALM_CHARACTERS_BY_REALM, "DELETE FROM realmcharacters WHERE acctid = ? AND realmid = ?");
|
||||
PrepareStatement(LoginStatements.DEL_REALM_CHARACTERS, "DELETE FROM realmcharacters WHERE acctid = ?");
|
||||
PrepareStatement(LoginStatements.INS_REALM_CHARACTERS, "INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (?, ?, ?)");
|
||||
PrepareStatement(LoginStatements.SEL_SUM_REALM_CHARACTERS, "SELECT SUM(numchars) FROM realmcharacters WHERE acctid = ?");
|
||||
PrepareStatement(LoginStatements.INS_ACCOUNT, "INSERT INTO account(username, sha_pass_hash, reg_mail, email, joindate, battlenet_account, battlenet_index) VALUES(?, ?, ?, ?, NOW(), ?, ?)");
|
||||
PrepareStatement(LoginStatements.INS_REALM_CHARACTERS_INIT, "INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist, account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL");
|
||||
PrepareStatement(LoginStatements.UPD_EXPANSION, "UPDATE account SET expansion = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_ACCOUNT_LOCK, "UPDATE account SET locked = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_ACCOUNT_LOCK_CONTRY, "UPDATE account SET lock_country = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.INS_LOG, "INSERT INTO logs (time, realm, type, level, string) VALUES (?, ?, ?, ?, ?)");
|
||||
PrepareStatement(LoginStatements.UPD_USERNAME, "UPDATE account SET v = 0, s = 0, username = ?, sha_pass_hash = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_PASSWORD, "UPDATE account SET v = 0, s = 0, sha_pass_hash = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_EMAIL, "UPDATE account SET email = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_REG_EMAIL, "UPDATE account SET reg_mail = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_MUTE_TIME, "UPDATE account SET mutetime = ? , mutereason = ? , muteby = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_MUTE_TIME_LOGIN, "UPDATE account SET mutetime = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_LAST_IP, "UPDATE account SET last_ip = ? WHERE username = ?");
|
||||
PrepareStatement(LoginStatements.UPD_LAST_ATTEMPT_IP, "UPDATE account SET last_attempt_ip = ? WHERE username = ?");
|
||||
PrepareStatement(LoginStatements.UPD_ACCOUNT_ONLINE, "UPDATE account SET online = 1 WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_UPTIME_PLAYERS, "UPDATE uptime SET uptime = ?, maxplayers = ? WHERE realmid = ? AND starttime = ?");
|
||||
PrepareStatement(LoginStatements.DEL_OLD_LOGS, "DELETE FROM logs WHERE (time + ?) < ? AND realm = ?");
|
||||
PrepareStatement(LoginStatements.DEL_ACCOUNT_ACCESS, "DELETE FROM account_access WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.DEL_ACCOUNT_ACCESS_BY_REALM, "DELETE FROM account_access WHERE id = ? AND (RealmID = ? OR RealmID = -1)");
|
||||
PrepareStatement(LoginStatements.INS_ACCOUNT_ACCESS, "INSERT INTO account_access (id,gmlevel,RealmID) VALUES (?, ?, ?)");
|
||||
PrepareStatement(LoginStatements.GET_ACCOUNT_ID_BY_USERNAME, "SELECT id FROM account WHERE username = ?");
|
||||
PrepareStatement(LoginStatements.GET_ACCOUNT_ACCESS_GMLEVEL, "SELECT gmlevel FROM account_access WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.GET_GMLEVEL_BY_REALMID, "SELECT gmlevel FROM account_access WHERE id = ? AND (RealmID = ? OR RealmID = -1)");
|
||||
PrepareStatement(LoginStatements.GET_USERNAME_BY_ID, "SELECT username FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_CHECK_PASSWORD, "SELECT 1 FROM account WHERE id = ? AND sha_pass_hash = ?");
|
||||
PrepareStatement(LoginStatements.SEL_CHECK_PASSWORD_BY_NAME, "SELECT 1 FROM account WHERE username = ? AND sha_pass_hash = ?");
|
||||
PrepareStatement(LoginStatements.SEL_PINFO, "SELECT a.username, aa.gmlevel, a.email, a.reg_mail, a.last_ip, DATE_FORMAT(a.last_login, '%Y-%m-%d %T'), a.mutetime, a.mutereason, a.muteby, a.failed_logins, a.locked, a.OS FROM account a LEFT JOIN account_access aa ON (a.id = aa.id AND (aa.RealmID = ? OR aa.RealmID = -1)) WHERE a.id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_PINFO_BANS, "SELECT unbandate, bandate = unbandate, bannedby, banreason FROM account_banned WHERE id = ? AND active ORDER BY bandate ASC LIMIT 1");
|
||||
PrepareStatement(LoginStatements.SEL_GM_ACCOUNTS, "SELECT a.username, aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel >= ? AND (aa.realmid = -1 OR aa.realmid = ?)");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_INFO, "SELECT a.username, a.last_ip, aa.gmlevel, a.expansion FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_ACCESS_GMLEVEL_TEST, "SELECT 1 FROM account_access WHERE id = ? AND gmlevel > ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_ACCESS, "SELECT a.id, aa.gmlevel, aa.RealmID FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = ?");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_WHOIS, "SELECT username, email, last_ip FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_LAST_ATTEMPT_IP, "SELECT last_attempt_ip FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_LAST_IP, "SELECT last_ip FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_REALMLIST_SECURITY_LEVEL, "SELECT allowedSecurityLevel from realmlist WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.DEL_ACCOUNT, "DELETE FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_IP2NATION_COUNTRY, "SELECT c.country FROM ip2nationCountries c, ip2nation i WHERE i.ip < ? AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1");
|
||||
PrepareStatement(LoginStatements.SEL_AUTOBROADCAST, "SELECT id, weight, text FROM autobroadcast WHERE realmid = ? OR realmid = -1");
|
||||
PrepareStatement(LoginStatements.GET_EMAIL_BY_ID, "SELECT email FROM account WHERE id = ?");
|
||||
// 0: uint32, 1: uint32, 2: uint8, 3: uint32, 4: string // Complete name: "Login_Insert_AccountLoginDeLete_IP_Logging"
|
||||
PrepareStatement(LoginStatements.INS_ALDL_IP_LOGGING, "INSERT INTO logs_ip_actions (account_id,character_guid,type,ip,systemnote,unixtime,time) VALUES (?, ?, ?, (SELECT last_ip FROM account WHERE id = ?), ?, unix_timestamp(NOW()), NOW())");
|
||||
// 0: uint32, 1: uint32, 2: uint8, 3: uint32, 4: string // Complete name: "Login_Insert_FailedAccountLogin_IP_Logging"
|
||||
PrepareStatement(LoginStatements.INS_FACL_IP_LOGGING, "INSERT INTO logs_ip_actions (account_id,character_guid,type,ip,systemnote,unixtime,time) VALUES (?, ?, ?, (SELECT last_attempt_ip FROM account WHERE id = ?), ?, unix_timestamp(NOW()), NOW())");
|
||||
// 0: uint32, 1: uint32, 2: uint8, 3: string, 4: string // Complete name: "Login_Insert_CharacterDelete_IP_Logging"
|
||||
PrepareStatement(LoginStatements.INS_CHAR_IP_LOGGING, "INSERT INTO logs_ip_actions (account_id,character_guid,type,ip,systemnote,unixtime,time) VALUES (?, ?, ?, ?, ?, unix_timestamp(NOW()), NOW())");
|
||||
// 0: string, 1: string, 2: string // Complete name: "Login_Insert_Failed_Account_Login_due_password_IP_Logging"
|
||||
PrepareStatement(LoginStatements.INS_FALP_IP_LOGGING, "INSERT INTO logs_ip_actions (account_id,character_guid,type,ip,systemnote,unixtime,time) VALUES (?, 0, 1, ?, ?, unix_timestamp(NOW()), NOW())");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_ACCESS_BY_ID, "SELECT gmlevel, RealmID FROM account_access WHERE id = ? and (RealmID = ? OR RealmID = -1) ORDER BY gmlevel desc");
|
||||
|
||||
PrepareStatement(LoginStatements.SEL_RBAC_ACCOUNT_PERMISSIONS, "SELECT permissionId, granted FROM rbac_account_permissions WHERE accountId = ? AND (realmId = ? OR realmId = -1) ORDER BY permissionId, realmId");
|
||||
PrepareStatement(LoginStatements.INS_RBAC_ACCOUNT_PERMISSION, "INSERT INTO rbac_account_permissions (accountId, permissionId, granted, realmId) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE granted = VALUES(granted)");
|
||||
PrepareStatement(LoginStatements.DEL_RBAC_ACCOUNT_PERMISSION, "DELETE FROM rbac_account_permissions WHERE accountId = ? AND permissionId = ? AND (realmId = ? OR realmId = -1)");
|
||||
|
||||
PrepareStatement(LoginStatements.INS_ACCOUNT_MUTE, "INSERT INTO account_muted VALUES (?, UNIX_TIMESTAMP(), ?, ?, ?)");
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_MUTE_INFO, "SELECT mutedate, mutetime, mutereason, mutedby FROM account_muted WHERE guid = ? ORDER BY mutedate ASC");
|
||||
PrepareStatement(LoginStatements.DEL_ACCOUNT_MUTED, "DELETE FROM account_muted WHERE guid = ?");
|
||||
|
||||
PrepareStatement(LoginStatements.SEL_BNET_AUTHENTICATION, "SELECT ba.id, ba.sha_pass_hash, ba.failed_logins, ba.LoginTicket, ba.LoginTicketExpiry, bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id WHERE email = ?");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_AUTHENTICATION, "UPDATE battlenet_accounts SET LoginTicket = ?, LoginTicketExpiry = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_ACCOUNT_INFO, "SELECT " + BnetAccountInfo + ", " + BnetGameAccountInfo +
|
||||
" FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id LEFT JOIN account a ON ba.id = a.battlenet_account" +
|
||||
" LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID = -1 WHERE ba.LoginTicket = ? ORDER BY a.id");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_LAST_LOGIN_INFO, "UPDATE battlenet_accounts SET last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_GAME_ACCOUNT_LOGIN_INFO, "UPDATE account SET sessionkey = ?, last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE username = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_ACCOUNT_ID, "SELECT rc.acctid, rc.numchars, r.id, r.Region, r.Battlegroup FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id WHERE rc.acctid = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID, "SELECT rc.acctid, rc.numchars, r.id, r.Region, r.Battlegroup FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id LEFT JOIN account a ON rc.acctid = a.id WHERE a.battlenet_account = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_LAST_PLAYER_CHARACTERS, "SELECT lpc.accountId, lpc.region, lpc.battlegroup, lpc.realmId, lpc.characterName, lpc.characterGUID, lpc.lastPlayedTime FROM account_last_played_character lpc LEFT JOIN account a ON lpc.accountId = a.id WHERE a.battlenet_account = ?");
|
||||
PrepareStatement(LoginStatements.DEL_BNET_LAST_PLAYER_CHARACTERS, "DELETE FROM account_last_played_character WHERE accountId = ? AND region = ? AND battlegroup = ?");
|
||||
PrepareStatement(LoginStatements.INS_BNET_LAST_PLAYER_CHARACTERS, "INSERT INTO account_last_played_character (accountId, region, battlegroup, realmId, characterName, characterGUID, lastPlayedTime) VALUES (?,?,?,?,?,?,?)");
|
||||
PrepareStatement(LoginStatements.INS_BNET_ACCOUNT, "INSERT INTO battlenet_accounts (`email`,`sha_pass_hash`) VALUES (?, ?)");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_ACCOUNT_EMAIL_BY_ID, "SELECT email FROM battlenet_accounts WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_ACCOUNT_ID_BY_EMAIL, "SELECT id FROM battlenet_accounts WHERE email = ?");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_PASSWORD, "UPDATE battlenet_accounts SET sha_pass_hash = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_CHECK_PASSWORD, "SELECT 1 FROM battlenet_accounts WHERE id = ? AND sha_pass_hash = ?");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_ACCOUNT_LOCK, "UPDATE battlenet_accounts SET locked = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_ACCOUNT_LOCK_CONTRY, "UPDATE battlenet_accounts SET lock_country = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT, "SELECT battlenet_account FROM account WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_GAME_ACCOUNT_LINK, "UPDATE account SET battlenet_account = ?, battlenet_index = ? WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_MAX_ACCOUNT_INDEX, "SELECT MAX(battlenet_index) FROM account WHERE battlenet_account = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_GAME_ACCOUNT_LIST, "SELECT a.id, a.username FROM account a LEFT JOIN battlenet_accounts ba ON a.battlenet_account = ba.id WHERE ba.email = ?");
|
||||
|
||||
PrepareStatement(LoginStatements.UPD_BNET_FAILED_LOGINS, "UPDATE battlenet_accounts SET failed_logins = failed_logins + 1 WHERE id = ?");
|
||||
PrepareStatement(LoginStatements.INS_BNET_ACCOUNT_AUTO_BANNED, "INSERT INTO battlenet_account_bans(id, bandate, unbandate, bannedby, banreason) VALUES(?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban')");
|
||||
PrepareStatement(LoginStatements.DEL_BNET_EXPIRED_ACCOUNT_BANNED, "DELETE FROM battlenet_account_bans WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()");
|
||||
PrepareStatement(LoginStatements.UPD_BNET_RESET_FAILED_LOGINS, "UPDATE battlenet_accounts SET failed_logins = 0 WHERE id = ?");
|
||||
|
||||
PrepareStatement(LoginStatements.SEL_LAST_CHAR_UNDELETE, "SELECT LastCharacterUndelete FROM battlenet_accounts WHERE Id = ?");
|
||||
PrepareStatement(LoginStatements.UPD_LAST_CHAR_UNDELETE, "UPDATE battlenet_accounts SET LastCharacterUndelete = UNIX_TIMESTAMP() WHERE Id = ?");
|
||||
|
||||
// Account wide toys
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_TOYS, "SELECT itemId, isFavourite FROM battlenet_account_toys WHERE accountId = ?");
|
||||
PrepareStatement(LoginStatements.REP_ACCOUNT_TOYS, "REPLACE INTO battlenet_account_toys (accountId, itemId, isFavourite) VALUES (?, ?, ?)");
|
||||
|
||||
// Battle Pets
|
||||
PrepareStatement(LoginStatements.SEL_BATTLE_PETS, "SELECT guid, species, breed, level, exp, health, quality, flags, name FROM battle_pets WHERE battlenetAccountId = ?");
|
||||
PrepareStatement(LoginStatements.INS_BATTLE_PETS, "INSERT INTO battle_pets (guid, battlenetAccountId, species, breed, level, exp, health, quality, flags, name) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PrepareStatement(LoginStatements.DEL_BATTLE_PETS, "DELETE FROM battle_pets WHERE battlenetAccountId = ? AND guid = ?");
|
||||
PrepareStatement(LoginStatements.UPD_BATTLE_PETS, "UPDATE battle_pets SET level = ?, exp = ?, health = ?, quality = ?, flags = ?, name = ? WHERE battlenetAccountId = ? AND guid = ?");
|
||||
PrepareStatement(LoginStatements.SEL_BATTLE_PET_SLOTS, "SELECT id, battlePetGuid, locked FROM battle_pet_slots WHERE battlenetAccountId = ?");
|
||||
PrepareStatement(LoginStatements.INS_BATTLE_PET_SLOTS, "INSERT INTO battle_pet_slots (id, battlenetAccountId, battlePetGuid, locked) VALUES (?, ?, ?, ?)");
|
||||
PrepareStatement(LoginStatements.DEL_BATTLE_PET_SLOTS, "DELETE FROM battle_pet_slots WHERE battlenetAccountId = ?");
|
||||
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_HEIRLOOMS, "SELECT itemId, flags FROM battlenet_account_heirlooms WHERE accountId = ?");
|
||||
PrepareStatement(LoginStatements.REP_ACCOUNT_HEIRLOOMS, "REPLACE INTO battlenet_account_heirlooms (accountId, itemId, flags) VALUES (?, ?, ?)");
|
||||
|
||||
// Account wide mounts
|
||||
PrepareStatement(LoginStatements.SEL_ACCOUNT_MOUNTS, "SELECT mountSpellId, flags FROM battlenet_account_mounts WHERE battlenetAccountId = ?");
|
||||
PrepareStatement(LoginStatements.REP_ACCOUNT_MOUNTS, "REPLACE INTO battlenet_account_mounts (battlenetAccountId, mountSpellId, flags) VALUES (?, ?, ?)");
|
||||
|
||||
// Transmog collection
|
||||
PrepareStatement(LoginStatements.SEL_BNET_ITEM_APPEARANCES, "SELECT blobIndex, appearanceMask FROM battlenet_item_appearances WHERE battlenetAccountId = ? ORDER BY blobIndex DESC");
|
||||
PrepareStatement(LoginStatements.INS_BNET_ITEM_APPEARANCES, "INSERT INTO battlenet_item_appearances (battlenetAccountId, blobIndex, appearanceMask) VALUES (?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE appearanceMask = appearanceMask | VALUES(appearanceMask)");
|
||||
PrepareStatement(LoginStatements.SEL_BNET_ITEM_FAVORITE_APPEARANCES, "SELECT itemModifiedAppearanceId FROM battlenet_item_favorite_appearances WHERE battlenetAccountId = ?");
|
||||
PrepareStatement(LoginStatements.INS_BNET_ITEM_FAVORITE_APPEARANCE, "INSERT INTO battlenet_item_favorite_appearances (battlenetAccountId, itemModifiedAppearanceId) VALUES (?, ?)");
|
||||
PrepareStatement(LoginStatements.DEL_BNET_ITEM_FAVORITE_APPEARANCE, "DELETE FROM battlenet_item_favorite_appearances WHERE battlenetAccountId = ? AND itemModifiedAppearanceId = ?");
|
||||
}
|
||||
}
|
||||
|
||||
public enum LoginStatements
|
||||
{
|
||||
SEL_REALMLIST,
|
||||
DEL_EXPIRED_IP_BANS,
|
||||
UPD_EXPIRED_ACCOUNT_BANS,
|
||||
SEL_IP_INFO,
|
||||
INS_IP_AUTO_BANNED,
|
||||
SEL_ACCOUNT_BANNED_ALL,
|
||||
SEL_ACCOUNT_BANNED_BY_USERNAME,
|
||||
DEL_ACCOUNT_BANNED,
|
||||
UPD_ACCOUNT_INFO_CONTINUED_SESSION,
|
||||
SEL_ACCOUNT_INFO_CONTINUED_SESSION,
|
||||
UPD_VS,
|
||||
SEL_LOGON_COUNTRY,
|
||||
SEL_ACCOUNT_ID_BY_NAME,
|
||||
SEL_ACCOUNT_LIST_BY_NAME,
|
||||
SEL_ACCOUNT_INFO_BY_NAME,
|
||||
SEL_ACCOUNT_LIST_BY_EMAIL,
|
||||
SEL_ACCOUNT_BY_IP,
|
||||
INS_IP_BANNED,
|
||||
DEL_IP_NOT_BANNED,
|
||||
SEL_IP_BANNED_ALL,
|
||||
SEL_IP_BANNED_BY_IP,
|
||||
SEL_ACCOUNT_BY_ID,
|
||||
INS_ACCOUNT_BANNED,
|
||||
UPD_ACCOUNT_NOT_BANNED,
|
||||
DEL_REALM_CHARACTERS_BY_REALM,
|
||||
DEL_REALM_CHARACTERS,
|
||||
INS_REALM_CHARACTERS,
|
||||
SEL_SUM_REALM_CHARACTERS,
|
||||
INS_ACCOUNT,
|
||||
INS_REALM_CHARACTERS_INIT,
|
||||
UPD_EXPANSION,
|
||||
UPD_ACCOUNT_LOCK,
|
||||
UPD_ACCOUNT_LOCK_CONTRY,
|
||||
INS_LOG,
|
||||
UPD_USERNAME,
|
||||
UPD_PASSWORD,
|
||||
UPD_EMAIL,
|
||||
UPD_REG_EMAIL,
|
||||
UPD_MUTE_TIME,
|
||||
UPD_MUTE_TIME_LOGIN,
|
||||
UPD_LAST_IP,
|
||||
UPD_LAST_ATTEMPT_IP,
|
||||
UPD_ACCOUNT_ONLINE,
|
||||
UPD_UPTIME_PLAYERS,
|
||||
DEL_OLD_LOGS,
|
||||
DEL_ACCOUNT_ACCESS,
|
||||
DEL_ACCOUNT_ACCESS_BY_REALM,
|
||||
INS_ACCOUNT_ACCESS,
|
||||
GET_ACCOUNT_ID_BY_USERNAME,
|
||||
GET_ACCOUNT_ACCESS_GMLEVEL,
|
||||
GET_GMLEVEL_BY_REALMID,
|
||||
GET_USERNAME_BY_ID,
|
||||
SEL_CHECK_PASSWORD,
|
||||
SEL_CHECK_PASSWORD_BY_NAME,
|
||||
SEL_PINFO,
|
||||
SEL_PINFO_BANS,
|
||||
SEL_GM_ACCOUNTS,
|
||||
SEL_ACCOUNT_INFO,
|
||||
SEL_ACCOUNT_ACCESS_GMLEVEL_TEST,
|
||||
SEL_ACCOUNT_ACCESS,
|
||||
SEL_ACCOUNT_RECRUITER,
|
||||
SEL_BANS,
|
||||
SEL_ACCOUNT_WHOIS,
|
||||
SEL_REALMLIST_SECURITY_LEVEL,
|
||||
DEL_ACCOUNT,
|
||||
SEL_IP2NATION_COUNTRY,
|
||||
SEL_AUTOBROADCAST,
|
||||
SEL_LAST_ATTEMPT_IP,
|
||||
SEL_LAST_IP,
|
||||
GET_EMAIL_BY_ID,
|
||||
INS_ALDL_IP_LOGGING,
|
||||
INS_FACL_IP_LOGGING,
|
||||
INS_CHAR_IP_LOGGING,
|
||||
INS_FALP_IP_LOGGING,
|
||||
|
||||
SEL_ACCOUNT_ACCESS_BY_ID,
|
||||
SEL_RBAC_ACCOUNT_PERMISSIONS,
|
||||
INS_RBAC_ACCOUNT_PERMISSION,
|
||||
DEL_RBAC_ACCOUNT_PERMISSION,
|
||||
|
||||
INS_ACCOUNT_MUTE,
|
||||
SEL_ACCOUNT_MUTE_INFO,
|
||||
DEL_ACCOUNT_MUTED,
|
||||
|
||||
SEL_BNET_AUTHENTICATION,
|
||||
UPD_BNET_AUTHENTICATION,
|
||||
SEL_BNET_ACCOUNT_INFO,
|
||||
UPD_BNET_LAST_LOGIN_INFO,
|
||||
UPD_BNET_GAME_ACCOUNT_LOGIN_INFO,
|
||||
SEL_BNET_CHARACTER_COUNTS_BY_ACCOUNT_ID,
|
||||
SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID,
|
||||
SEL_BNET_LAST_PLAYER_CHARACTERS,
|
||||
DEL_BNET_LAST_PLAYER_CHARACTERS,
|
||||
INS_BNET_LAST_PLAYER_CHARACTERS,
|
||||
INS_BNET_ACCOUNT,
|
||||
SEL_BNET_ACCOUNT_EMAIL_BY_ID,
|
||||
SEL_BNET_ACCOUNT_ID_BY_EMAIL,
|
||||
UPD_BNET_PASSWORD,
|
||||
SEL_BNET_ACCOUNT_SALT_BY_ID,
|
||||
SEL_BNET_CHECK_PASSWORD,
|
||||
UPD_BNET_ACCOUNT_LOCK,
|
||||
UPD_BNET_ACCOUNT_LOCK_CONTRY,
|
||||
SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT,
|
||||
UPD_BNET_GAME_ACCOUNT_LINK,
|
||||
SEL_BNET_MAX_ACCOUNT_INDEX,
|
||||
SEL_BNET_GAME_ACCOUNT_LIST,
|
||||
|
||||
UPD_BNET_FAILED_LOGINS,
|
||||
INS_BNET_ACCOUNT_AUTO_BANNED,
|
||||
DEL_BNET_EXPIRED_ACCOUNT_BANNED,
|
||||
UPD_BNET_RESET_FAILED_LOGINS,
|
||||
|
||||
SEL_LAST_CHAR_UNDELETE,
|
||||
UPD_LAST_CHAR_UNDELETE,
|
||||
|
||||
SEL_ACCOUNT_TOYS,
|
||||
REP_ACCOUNT_TOYS,
|
||||
|
||||
SEL_BATTLE_PETS,
|
||||
INS_BATTLE_PETS,
|
||||
DEL_BATTLE_PETS,
|
||||
UPD_BATTLE_PETS,
|
||||
SEL_BATTLE_PET_SLOTS,
|
||||
INS_BATTLE_PET_SLOTS,
|
||||
DEL_BATTLE_PET_SLOTS,
|
||||
|
||||
SEL_ACCOUNT_HEIRLOOMS,
|
||||
REP_ACCOUNT_HEIRLOOMS,
|
||||
|
||||
SEL_ACCOUNT_MOUNTS,
|
||||
REP_ACCOUNT_MOUNTS,
|
||||
|
||||
SEL_BNET_ITEM_APPEARANCES,
|
||||
INS_BNET_ITEM_APPEARANCES,
|
||||
SEL_BNET_ITEM_FAVORITE_APPEARANCES,
|
||||
INS_BNET_ITEM_FAVORITE_APPEARANCE,
|
||||
DEL_BNET_ITEM_FAVORITE_APPEARANCE,
|
||||
|
||||
MAX_LOGINDATABASE_STATEMENTS
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class WorldDatabase : MySqlBase<WorldStatements>
|
||||
{
|
||||
public override void PreparedStatements()
|
||||
{
|
||||
PrepareStatement(WorldStatements.SEL_QUEST_POOLS, "SELECT entry, pool_entry FROM pool_quest");
|
||||
PrepareStatement(WorldStatements.DEL_CRELINKED_RESPAWN, "DELETE FROM linked_respawn WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.REP_CREATURE_LINKED_RESPAWN, "REPLACE INTO linked_respawn (guid, linkedGuid) VALUES (?, ?)");
|
||||
PrepareStatement(WorldStatements.SEL_CREATURE_TEXT, "SELECT entry, groupid, id, text, type, language, probability, emote, duration, sound, BroadcastTextID, TextRange FROM creature_text");
|
||||
PrepareStatement(WorldStatements.SEL_SMART_SCRIPTS, "SELECT entryorguid, source_type, id, link, event_type, event_phase_mask, event_chance, event_flags, event_param1, event_param2, event_param3, event_param4, event_param_string, action_type, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, target_type, target_param1, target_param2, target_param3, target_x, target_y, target_z, target_o FROM smart_scripts ORDER BY entryorguid, source_type, id, link");
|
||||
PrepareStatement(WorldStatements.SEL_SMARTAI_WP, "SELECT entry, pointid, position_x, position_y, position_z FROM waypoints ORDER BY entry, pointid");
|
||||
PrepareStatement(WorldStatements.DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.DEL_EVENT_GAMEOBJECT, "DELETE FROM game_event_gameobject WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.INS_GRAVEYARD_ZONE, "INSERT INTO graveyard_zone (ID, GhostZone, faction) VALUES (?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.DEL_GRAVEYARD_ZONE, "DELETE FROM graveyard_zone WHERE ID = ? AND GhostZone = ? AND faction = ?");
|
||||
PrepareStatement(WorldStatements.INS_GAME_TELE, "INSERT INTO game_tele (id, position_x, position_y, position_z, orientation, map, name) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.DEL_GAME_TELE, "DELETE FROM game_tele WHERE name = ?");
|
||||
PrepareStatement(WorldStatements.INS_NPC_VENDOR, "INSERT INTO npc_vendor (entry, item, maxcount, incrtime, extendedcost, type) VALUES(?, ?, ?, ?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.DEL_NPC_VENDOR, "DELETE FROM npc_vendor WHERE entry = ? AND item = ? AND type = ?");
|
||||
PrepareStatement(WorldStatements.SEL_NPC_VENDOR_REF, "SELECT item, maxcount, incrtime, ExtendedCost, type, BonusListIDs, PlayerConditionID, IgnoreFiltering FROM npc_vendor WHERE entry = ? ORDER BY slot ASC");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_MOVEMENT_TYPE, "UPDATE creature SET MovementType = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_FACTION, "UPDATE creature_template SET faction = ? WHERE entry = ?");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_NPCFLAG, "UPDATE creature_template SET npcflag = ? WHERE entry = ?");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_POSITION, "UPDATE creature SET position_x = ?, position_y = ?, position_z = ?, orientation = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_SPAWN_DISTANCE, "UPDATE creature SET spawndist = ?, MovementType = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_SPAWN_TIME_SECS, "UPDATE creature SET spawntimesecs = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.INS_CREATURE_FORMATION, "INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES (?, ?, ?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.INS_WAYPOINT_DATA, "INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES (?, ?, ?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.DEL_WAYPOINT_DATA, "DELETE FROM waypoint_data WHERE id = ? AND point = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_POINT, "UPDATE waypoint_data SET point = point - 1 WHERE id = ? AND point > ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_POSITION, "UPDATE waypoint_data SET position_x = ?, position_y = ?, position_z = ? where id = ? AND point = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_WPGUID, "UPDATE waypoint_data SET wpguid = ? WHERE id = ? and point = ?");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_MAX_ID, "SELECT MAX(id) FROM waypoint_data");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_MAX_POINT, "SELECT MAX(point) FROM waypoint_data WHERE id = ?");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, move_type, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_BY_ID, "SELECT point, position_x, position_y, position_z FROM waypoint_data WHERE id = ?");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, "SELECT position_x, position_y, position_z FROM waypoint_data WHERE point = 1 AND id = ?");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_LAST_BY_ID, "SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE id = ? ORDER BY point DESC LIMIT 1");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_BY_WPGUID, "SELECT id, point FROM waypoint_data WHERE wpguid = ?");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_ALL_BY_WPGUID, "SELECT id, point, delay, move_type, action, action_chance FROM waypoint_data WHERE wpguid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_ALL_WPGUID, "UPDATE waypoint_data SET wpguid = 0");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_BY_POS, "SELECT id, point FROM waypoint_data WHERE (abs(position_x - ?) <= ?) and (abs(position_y - ?) <= ?) and (abs(position_z - ?) <= ?)");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_WPGUID_BY_ID, "SELECT wpguid FROM waypoint_data WHERE id = ? and wpguid <> 0");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_ACTION, "SELECT DISTINCT action FROM waypoint_data");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_SCRIPTS_MAX_ID, "SELECT MAX(guid) FROM waypoint_scripts");
|
||||
PrepareStatement(WorldStatements.INS_CREATURE_ADDON, "INSERT INTO creature_addon(guid, path_id) VALUES (?, ?)");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_ADDON_PATH, "UPDATE creature_addon SET path_id = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.DEL_CREATURE_ADDON, "DELETE FROM creature_addon WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.SEL_CREATURE_ADDON_BY_GUID, "SELECT guid FROM creature_addon WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.INS_WAYPOINT_SCRIPT, "INSERT INTO waypoint_scripts (guid) VALUES (?)");
|
||||
PrepareStatement(WorldStatements.DEL_WAYPOINT_SCRIPT, "DELETE FROM waypoint_scripts WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_ID, "UPDATE waypoint_scripts SET id = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_X, "UPDATE waypoint_scripts SET x = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Y, "UPDATE waypoint_scripts SET y = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Z, "UPDATE waypoint_scripts SET z = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_O, "UPDATE waypoint_scripts SET o = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_ID_BY_GUID, "SELECT id FROM waypoint_scripts WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.DEL_CREATURE, "DELETE FROM creature WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.SEL_COMMANDS, "SELECT name, permission, help FROM command");
|
||||
PrepareStatement(WorldStatements.SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, femaleName, subname, IconName, gossip_menu_id, minlevel, maxlevel, HealthScalingExpansion, RequiredExpansion, VignetteID, faction, npcflag, speed_walk, speed_run, scale, rank, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, unit_flags3, dynamicflags, family, trainer_class, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?");
|
||||
PrepareStatement(WorldStatements.SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?");
|
||||
PrepareStatement(WorldStatements.SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?");
|
||||
PrepareStatement(WorldStatements.SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_");
|
||||
PrepareStatement(WorldStatements.SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_");
|
||||
PrepareStatement(WorldStatements.INS_CREATURE, "INSERT INTO creature (guid, id , map, spawnMask, PhaseId, PhaseGroup, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, unit_flags2, unit_flags3, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.INS_GAMEOBJECT, "INSERT INTO gameobject (guid, id, map, spawnMask, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.INS_DISABLES, "INSERT INTO disables (entry, sourceType, flags, comment) VALUES (?, ?, ?, ?)");
|
||||
PrepareStatement(WorldStatements.SEL_DISABLES, "SELECT entry FROM disables WHERE entry = ? AND sourceType = ?");
|
||||
PrepareStatement(WorldStatements.DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?");
|
||||
PrepareStatement(WorldStatements.UPD_CREATURE_ZONE_AREA_DATA, "UPDATE creature SET zoneId = ?, areaId = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.UPD_GAMEOBJECT_ZONE_AREA_DATA, "UPDATE gameobject SET zoneId = ?, areaId = ? WHERE guid = ?");
|
||||
PrepareStatement(WorldStatements.SEL_GUILD_REWARDS_REQ_ACHIEVEMENTS, "SELECT AchievementRequired FROM guild_rewards_req_achievements WHERE ItemID = ?");
|
||||
}
|
||||
}
|
||||
|
||||
public enum WorldStatements
|
||||
{
|
||||
SEL_QUEST_POOLS,
|
||||
DEL_CRELINKED_RESPAWN,
|
||||
REP_CREATURE_LINKED_RESPAWN,
|
||||
SEL_CREATURE_TEXT,
|
||||
SEL_SMART_SCRIPTS,
|
||||
SEL_SMARTAI_WP,
|
||||
DEL_GAMEOBJECT,
|
||||
DEL_EVENT_GAMEOBJECT,
|
||||
INS_GRAVEYARD_ZONE,
|
||||
DEL_GRAVEYARD_ZONE,
|
||||
INS_GAME_TELE,
|
||||
DEL_GAME_TELE,
|
||||
INS_NPC_VENDOR,
|
||||
DEL_NPC_VENDOR,
|
||||
SEL_NPC_VENDOR_REF,
|
||||
UPD_CREATURE_MOVEMENT_TYPE,
|
||||
UPD_CREATURE_FACTION,
|
||||
UPD_CREATURE_NPCFLAG,
|
||||
UPD_CREATURE_POSITION,
|
||||
UPD_CREATURE_SPAWN_DISTANCE,
|
||||
UPD_CREATURE_SPAWN_TIME_SECS,
|
||||
INS_CREATURE_FORMATION,
|
||||
INS_WAYPOINT_DATA,
|
||||
DEL_WAYPOINT_DATA,
|
||||
UPD_WAYPOINT_DATA_POINT,
|
||||
UPD_WAYPOINT_DATA_POSITION,
|
||||
UPD_WAYPOINT_DATA_WPGUID,
|
||||
UPD_WAYPOINT_DATA_ALL_WPGUID,
|
||||
SEL_WAYPOINT_DATA_MAX_ID,
|
||||
SEL_WAYPOINT_DATA_BY_ID,
|
||||
SEL_WAYPOINT_DATA_POS_BY_ID,
|
||||
SEL_WAYPOINT_DATA_POS_FIRST_BY_ID,
|
||||
SEL_WAYPOINT_DATA_POS_LAST_BY_ID,
|
||||
SEL_WAYPOINT_DATA_BY_WPGUID,
|
||||
SEL_WAYPOINT_DATA_ALL_BY_WPGUID,
|
||||
SEL_WAYPOINT_DATA_MAX_POINT,
|
||||
SEL_WAYPOINT_DATA_BY_POS,
|
||||
SEL_WAYPOINT_DATA_WPGUID_BY_ID,
|
||||
SEL_WAYPOINT_DATA_ACTION,
|
||||
SEL_WAYPOINT_SCRIPTS_MAX_ID,
|
||||
UPD_CREATURE_ADDON_PATH,
|
||||
INS_CREATURE_ADDON,
|
||||
DEL_CREATURE_ADDON,
|
||||
SEL_CREATURE_ADDON_BY_GUID,
|
||||
INS_WAYPOINT_SCRIPT,
|
||||
DEL_WAYPOINT_SCRIPT,
|
||||
UPD_WAYPOINT_SCRIPT_ID,
|
||||
UPD_WAYPOINT_SCRIPT_X,
|
||||
UPD_WAYPOINT_SCRIPT_Y,
|
||||
UPD_WAYPOINT_SCRIPT_Z,
|
||||
UPD_WAYPOINT_SCRIPT_O,
|
||||
SEL_WAYPOINT_SCRIPT_ID_BY_GUID,
|
||||
DEL_CREATURE,
|
||||
SEL_COMMANDS,
|
||||
SEL_CREATURE_TEMPLATE,
|
||||
SEL_WAYPOINT_SCRIPT_BY_ID,
|
||||
SEL_CREATURE_BY_ID,
|
||||
SEL_GAMEOBJECT_NEAREST,
|
||||
SEL_CREATURE_NEAREST,
|
||||
SEL_GAMEOBJECT_TARGET,
|
||||
INS_CREATURE,
|
||||
DEL_GAME_EVENT_CREATURE,
|
||||
DEL_GAME_EVENT_MODEL_EQUIP,
|
||||
INS_GAMEOBJECT,
|
||||
SEL_DISABLES,
|
||||
INS_DISABLES,
|
||||
DEL_DISABLES,
|
||||
UPD_CREATURE_ZONE_AREA_DATA,
|
||||
UPD_GAMEOBJECT_ZONE_AREA_DATA,
|
||||
SEL_GUILD_REWARDS_REQ_ACHIEVEMENTS,
|
||||
|
||||
MAX_WORLDDATABASE_STATEMENTS
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class MySqlConnectionInfo
|
||||
{
|
||||
public MySqlConnectionInfo(int poolSize = 10)
|
||||
{
|
||||
Poolsize = poolSize;
|
||||
}
|
||||
|
||||
public MySqlConnection GetConnection()
|
||||
{
|
||||
return new MySqlConnection($"Server={Host};Port={Port};User Id={Username};Password={Password};Database={Database};Allow Zero Datetime=True;Allow User Variables=True;Pooling=true;MaximumPoolSize={Poolsize};");
|
||||
}
|
||||
|
||||
public MySqlConnection GetConnectionNoDatabase()
|
||||
{
|
||||
return new MySqlConnection($"Server={Host};Port={Port};User Id={Username};Password={Password};Allow Zero Datetime=True;Allow User Variables=True;Pooling=true;MaximumPoolSize={Poolsize};");
|
||||
}
|
||||
|
||||
public string Host;
|
||||
public string Port;
|
||||
public string Username;
|
||||
public string Password;
|
||||
public string Database;
|
||||
public int Poolsize;
|
||||
}
|
||||
|
||||
public abstract class MySqlBase<T>
|
||||
{
|
||||
public MySqlErrorCode Initialize(MySqlConnectionInfo connectionInfo)
|
||||
{
|
||||
_connectionInfo = connectionInfo;
|
||||
_updater = new DatabaseUpdater<T>(this);
|
||||
|
||||
try
|
||||
{
|
||||
using (var connection = _connectionInfo.GetConnection())
|
||||
{
|
||||
connection.Open();
|
||||
Log.outInfo(LogFilter.SqlDriver, $"Connected to MySQL(ver: {connection.ServerVersion}) Database: {_connectionInfo.Database}");
|
||||
return MySqlErrorCode.None;
|
||||
}
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
return HandleMySQLException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(string sql, params object[] args)
|
||||
{
|
||||
Execute(new PreparedStatement(string.Format(sql, args)));
|
||||
}
|
||||
public void Execute(PreparedStatement stmt)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var Connection = _connectionInfo.GetConnection())
|
||||
{
|
||||
Connection.Open();
|
||||
using (MySqlCommand cmd = Connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = stmt.CommandText;
|
||||
foreach (var parameter in stmt.Parameters)
|
||||
cmd.Parameters.AddWithValue("@" + parameter.Key, parameter.Value);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
HandleMySQLException(ex, stmt.CommandText);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteOrAppend(SQLTransaction trans, PreparedStatement stmt)
|
||||
{
|
||||
if (trans == null)
|
||||
Execute(stmt);
|
||||
else
|
||||
trans.Append(stmt);
|
||||
}
|
||||
|
||||
public SQLResult Query(string sql, params object[] args)
|
||||
{
|
||||
return Query(new PreparedStatement(string.Format(sql, args)));
|
||||
}
|
||||
|
||||
public SQLResult Query(PreparedStatement stmt)
|
||||
{
|
||||
List<object[]> rows = new List<object[]>();
|
||||
try
|
||||
{
|
||||
using (var Connection = _connectionInfo.GetConnection())
|
||||
{
|
||||
Connection.Open();
|
||||
using (MySqlCommand cmd = Connection.CreateCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = stmt.CommandText;
|
||||
foreach (var parameter in stmt.Parameters)
|
||||
cmd.Parameters.AddWithValue("@" + parameter.Key, parameter.Value);
|
||||
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read() && reader.HasRows)
|
||||
{
|
||||
do
|
||||
{
|
||||
var row = new object[reader.FieldCount];
|
||||
|
||||
reader.GetValues(row);
|
||||
rows.Add(row);
|
||||
}
|
||||
while (reader.Read());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
HandleMySQLException(ex, stmt.CommandText);
|
||||
}
|
||||
|
||||
return new SQLResult(rows);
|
||||
}
|
||||
|
||||
public QueryCallback AsyncQuery(string sql, params object[] args)
|
||||
{
|
||||
return AsyncQuery(new PreparedStatement(string.Format(sql, args)));
|
||||
}
|
||||
|
||||
public QueryCallback AsyncQuery(PreparedStatement stmt)
|
||||
{
|
||||
return new QueryCallback(_AsyncQuery(stmt));
|
||||
}
|
||||
|
||||
async Task<SQLResult> _AsyncQuery(PreparedStatement stmt)
|
||||
{
|
||||
List<object[]> rows = new List<object[]>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var Connection = _connectionInfo.GetConnection())
|
||||
{
|
||||
await Connection.OpenAsync();
|
||||
using (MySqlCommand cmd = Connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = stmt.CommandText;
|
||||
foreach (var parameter in stmt.Parameters)
|
||||
cmd.Parameters.AddWithValue("@" + parameter.Key, parameter.Value);
|
||||
|
||||
using (var reader = await cmd.ExecuteReaderAsync())
|
||||
{
|
||||
if (await reader.ReadAsync() && reader.HasRows)
|
||||
{
|
||||
do
|
||||
{
|
||||
var row = new object[reader.FieldCount];
|
||||
|
||||
reader.GetValues(row);
|
||||
rows.Add(row);
|
||||
}
|
||||
while (await reader.ReadAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
HandleMySQLException(ex, stmt.CommandText);
|
||||
}
|
||||
|
||||
return new SQLResult(rows);
|
||||
}
|
||||
|
||||
public async Task<SQLQueryHolder<R>> DelayQueryHolder<R>(SQLQueryHolder<R> holder)
|
||||
{
|
||||
string query = "";
|
||||
|
||||
try
|
||||
{
|
||||
using (var Connection = _connectionInfo.GetConnection())
|
||||
{
|
||||
await Connection.OpenAsync();
|
||||
|
||||
foreach (var pair in holder.m_queries)
|
||||
{
|
||||
List<object[]> rows = new List<object[]>();
|
||||
using (MySqlCommand cmd = Connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = pair.Value.stmt.CommandText;
|
||||
foreach (var parameter in pair.Value.stmt.Parameters)
|
||||
cmd.Parameters.AddWithValue("@" + parameter.Key, parameter.Value);
|
||||
|
||||
query = cmd.CommandText;
|
||||
using (var reader = await cmd.ExecuteReaderAsync())
|
||||
{
|
||||
if (await reader.ReadAsync() && reader.HasRows)
|
||||
{
|
||||
do
|
||||
{
|
||||
var row = new object[reader.FieldCount];
|
||||
|
||||
reader.GetValues(row);
|
||||
rows.Add(row);
|
||||
}
|
||||
while (await reader.ReadAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
holder.SetResult(pair.Key, new SQLResult(rows));
|
||||
}
|
||||
}
|
||||
|
||||
return holder;
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
HandleMySQLException(ex, query);
|
||||
return holder;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadPreparedStatements()
|
||||
{
|
||||
PreparedStatements();
|
||||
}
|
||||
|
||||
public void PrepareStatement(T statement, string sql)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int index = 0;
|
||||
for (var i = 0; i < sql.Length; i++)
|
||||
{
|
||||
if (sql[i].Equals('?'))
|
||||
sb.Append("@" + index++);
|
||||
else
|
||||
sb.Append(sql[i]);
|
||||
}
|
||||
|
||||
_queries[statement] = sb.ToString();
|
||||
}
|
||||
|
||||
public PreparedStatement GetPreparedStatement(T statement)
|
||||
{
|
||||
return new PreparedStatement(_queries[statement]);
|
||||
}
|
||||
|
||||
public bool Apply(string sql)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var Connection = _connectionInfo.GetConnectionNoDatabase())
|
||||
{
|
||||
using (MySqlCommand cmd = Connection.CreateCommand())
|
||||
{
|
||||
|
||||
Connection.Open();
|
||||
cmd.CommandText = sql;
|
||||
return cmd.ExecuteNonQuery() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
HandleMySQLException(ex, sql);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ApplyFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = _connectionInfo.GetConnection())
|
||||
{
|
||||
using (MySqlCommand cmd = connection.CreateCommand())
|
||||
{
|
||||
connection.Open();
|
||||
cmd.CommandText = File.ReadAllText(path);
|
||||
return cmd.ExecuteNonQuery() > 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
HandleMySQLException(ex, path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void EscapeString(ref string str)
|
||||
{
|
||||
str = MySqlHelper.EscapeString(str);
|
||||
}
|
||||
|
||||
public void CommitTransaction(SQLTransaction transaction)
|
||||
{
|
||||
using (var Connection = _connectionInfo.GetConnection())
|
||||
{
|
||||
string query = "";
|
||||
|
||||
Connection.Open();
|
||||
using (MySqlTransaction trans = Connection.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var scope = new TransactionScope())
|
||||
{
|
||||
foreach (var cmd in transaction.commands)
|
||||
{
|
||||
cmd.Transaction = trans;
|
||||
cmd.Connection = Connection;
|
||||
cmd.ExecuteNonQuery();
|
||||
query = cmd.CommandText;
|
||||
}
|
||||
|
||||
trans.Commit();
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
catch (MySqlException ex) //error occurred
|
||||
{
|
||||
HandleMySQLException(ex, query);
|
||||
trans.Rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MySqlErrorCode HandleMySQLException(MySqlException ex, string query = "")
|
||||
{
|
||||
MySqlErrorCode code = (MySqlErrorCode)ex.Number;
|
||||
if (ex.InnerException != null)
|
||||
code = (MySqlErrorCode)((MySqlException)ex.InnerException).Number;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case MySqlErrorCode.BadFieldError:
|
||||
case MySqlErrorCode.NoSuchTable:
|
||||
Log.outError(LogFilter.Sql, "Your database structure is not up to date. Please make sure you've executed all queries in the sql/updates folders.");
|
||||
break;
|
||||
case MySqlErrorCode.ParseError:
|
||||
Log.outError(LogFilter.Sql, "Error while parsing SQL. Core fix required.");
|
||||
break;
|
||||
}
|
||||
|
||||
Log.outError(LogFilter.Sql, $"SqlException: {ex.Message} SqlQuery: {query}");
|
||||
return code;
|
||||
}
|
||||
|
||||
public DatabaseUpdater<T> GetUpdater()
|
||||
{
|
||||
return _updater;
|
||||
}
|
||||
|
||||
public bool IsAutoUpdateEnabled(DatabaseTypeFlags updateMask)
|
||||
{
|
||||
switch (GetType().Name)
|
||||
{
|
||||
case "LoginDatabase":
|
||||
return updateMask.HasAnyFlag(DatabaseTypeFlags.Login);
|
||||
case "CharacterDatabase":
|
||||
return updateMask.HasAnyFlag(DatabaseTypeFlags.Character);
|
||||
case "WorldDatabase":
|
||||
return updateMask.HasAnyFlag(DatabaseTypeFlags.World);
|
||||
case "HotfixDatabase":
|
||||
return updateMask.HasAnyFlag(DatabaseTypeFlags.Hotfix);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetDatabaseName()
|
||||
{
|
||||
return _connectionInfo.Database;
|
||||
}
|
||||
|
||||
public abstract void PreparedStatements();
|
||||
|
||||
Dictionary<T, string> _queries = new Dictionary<T, string>();
|
||||
MySqlConnectionInfo _connectionInfo;
|
||||
DatabaseUpdater<T> _updater;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Collections.Generic;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class PreparedStatement
|
||||
{
|
||||
public PreparedStatement(string commandText)
|
||||
{
|
||||
CommandText = commandText;
|
||||
}
|
||||
|
||||
public void AddValue(int index, object value)
|
||||
{
|
||||
Parameters.Add(index, value);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Parameters.Clear();
|
||||
}
|
||||
|
||||
public string CommandText;
|
||||
public Dictionary<int, object> Parameters = new Dictionary<int, object>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class QueryCallback
|
||||
{
|
||||
public QueryCallback(Task<SQLResult> result)
|
||||
{
|
||||
_result = result;
|
||||
}
|
||||
|
||||
public QueryCallback WithCallback(Action<SQLResult> callback)
|
||||
{
|
||||
return WithChainingCallback((queryCallback, result) => callback(result));
|
||||
}
|
||||
|
||||
public QueryCallback WithCallback<T>(Action<T, SQLResult> callback, T obj)
|
||||
{
|
||||
return WithChainingCallback((queryCallback, result) => callback(obj, result));
|
||||
}
|
||||
|
||||
public QueryCallback WithChainingCallback(Action<QueryCallback, SQLResult> callback)
|
||||
{
|
||||
_callbacks.Enqueue(new QueryCallbackData(callback));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void SetNextQuery(QueryCallback next)
|
||||
{
|
||||
_result = next._result;
|
||||
}
|
||||
|
||||
public QueryCallbackStatus InvokeIfReady()
|
||||
{
|
||||
QueryCallbackData callback = _callbacks.Dequeue();
|
||||
|
||||
bool hasNext = true;
|
||||
while (hasNext)
|
||||
{
|
||||
if (_result != null && _result.Wait(0))
|
||||
{
|
||||
Task<SQLResult> f = _result;
|
||||
Action<QueryCallback, SQLResult> cb = callback._result;
|
||||
_result = null;
|
||||
|
||||
cb(this, f.Result);
|
||||
|
||||
hasNext = _result != null;
|
||||
if (_callbacks.Count == 0)
|
||||
{
|
||||
Contract.Assert(!hasNext);
|
||||
return QueryCallbackStatus.Completed;
|
||||
}
|
||||
|
||||
// abort chain
|
||||
if (!hasNext)
|
||||
return QueryCallbackStatus.Completed;
|
||||
|
||||
callback = _callbacks.Dequeue();
|
||||
}
|
||||
else
|
||||
return QueryCallbackStatus.NotReady;
|
||||
}
|
||||
|
||||
return QueryCallbackStatus.Completed;
|
||||
}
|
||||
|
||||
Task<SQLResult> _result;
|
||||
Queue<QueryCallbackData> _callbacks = new Queue<QueryCallbackData>();
|
||||
}
|
||||
|
||||
struct QueryCallbackData
|
||||
{
|
||||
public QueryCallbackData(Action<QueryCallback, SQLResult> callback)
|
||||
{
|
||||
_result = callback;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_result = null;
|
||||
}
|
||||
|
||||
public Action<QueryCallback, SQLResult> _result;
|
||||
}
|
||||
|
||||
public enum QueryCallbackStatus
|
||||
{
|
||||
NotReady,
|
||||
NextStep,
|
||||
Completed
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Collections.Generic;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class QueryCallbackProcessor
|
||||
{
|
||||
public void AddQuery(QueryCallback query)
|
||||
{
|
||||
_callbacks.Add(query);
|
||||
}
|
||||
|
||||
public void ProcessReadyQueries()
|
||||
{
|
||||
if (_callbacks.Empty())
|
||||
return;
|
||||
|
||||
_callbacks.RemoveAll(callback =>
|
||||
{
|
||||
return callback.InvokeIfReady() == QueryCallbackStatus.Completed;
|
||||
});
|
||||
}
|
||||
|
||||
List<QueryCallback> _callbacks = new List<QueryCallback>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Collections.Generic;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class SQLQueryHolder<T>
|
||||
{
|
||||
public void SetQuery(T index, PreparedStatement _stmt)
|
||||
{
|
||||
m_queries[index] = new SQLResultPair(_stmt);
|
||||
}
|
||||
|
||||
public void SetQuery(T index, string sql, params object[] args)
|
||||
{
|
||||
SetQuery(index, new PreparedStatement(string.Format(sql, args)));
|
||||
}
|
||||
|
||||
public void SetResult(T index, SQLResult _result)
|
||||
{
|
||||
m_queries[index].result = _result;
|
||||
}
|
||||
|
||||
public SQLResult GetResult(T index)
|
||||
{
|
||||
if (!m_queries.ContainsKey(index))
|
||||
return new SQLResult();
|
||||
|
||||
return m_queries[index].result;
|
||||
}
|
||||
|
||||
public Dictionary<T, SQLResultPair> m_queries = new Dictionary<T, SQLResultPair>();
|
||||
|
||||
public class SQLResultPair
|
||||
{
|
||||
public SQLResultPair(PreparedStatement _stmt)
|
||||
{
|
||||
stmt = _stmt;
|
||||
}
|
||||
|
||||
public PreparedStatement stmt;
|
||||
public SQLResult result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class SQLResult
|
||||
{
|
||||
public SQLResult()
|
||||
{
|
||||
_rows = new List<object[]>();
|
||||
}
|
||||
public SQLResult(List<object[]> values)
|
||||
{
|
||||
_rows = values;
|
||||
}
|
||||
|
||||
public T Read<T>(int column)
|
||||
{
|
||||
var value = _rows[_rowIndex][column];
|
||||
|
||||
if (value.GetType() == typeof(T))
|
||||
return (T)value;
|
||||
|
||||
if (value != DBNull.Value)
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
|
||||
if (typeof(T).Name == "String")
|
||||
return (T)Convert.ChangeType("", typeof(T));
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public T[] ReadValues<T>(int startIndex, int numColumns)
|
||||
{
|
||||
T[] values = new T[numColumns];
|
||||
for (var c = 0; c < numColumns; ++c)
|
||||
values[c] = Read<T>(startIndex + c);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
public bool IsNull(int column)
|
||||
{
|
||||
return _rows[_rowIndex][column] == DBNull.Value;
|
||||
}
|
||||
|
||||
public int GetRowCount() { return _rows.Count; }
|
||||
|
||||
public bool IsEmpty() { return GetRowCount() == 0; }
|
||||
|
||||
public SQLFields GetFields() { return new SQLFields(_rows[_rowIndex]); }
|
||||
|
||||
public bool NextRow()
|
||||
{
|
||||
if (_rowIndex >= GetRowCount() - 1)
|
||||
{
|
||||
_rowIndex = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ResetRowIndex()
|
||||
{
|
||||
_rowIndex = 0;
|
||||
}
|
||||
|
||||
private int _rowIndex;
|
||||
List<object[]> _rows;
|
||||
}
|
||||
|
||||
public class SQLFields
|
||||
{
|
||||
public SQLFields(object[] row) { _currentRow = row; }
|
||||
|
||||
public T Read<T>(int column)
|
||||
{
|
||||
var value = _currentRow[column];
|
||||
|
||||
if (value.GetType() == typeof(T))
|
||||
return (T)value;
|
||||
|
||||
if (value != DBNull.Value)
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
|
||||
if (typeof(T).Name == "String")
|
||||
return (T)Convert.ChangeType("", typeof(T));
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public T[] ReadValues<T>(int startIndex, int numColumns)
|
||||
{
|
||||
T[] values = new T[numColumns];
|
||||
for (var c = 0; c < numColumns; ++c)
|
||||
values[c] = Read<T>(startIndex + c);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
object[] _currentRow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 MySql.Data.MySqlClient;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Framework.Database
|
||||
{
|
||||
public class SQLTransaction
|
||||
{
|
||||
public List<MySqlCommand> commands { get; set; }
|
||||
|
||||
public SQLTransaction()
|
||||
{
|
||||
commands = new List<MySqlCommand>();
|
||||
}
|
||||
|
||||
public void Append(PreparedStatement stmt)
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand(stmt.CommandText);
|
||||
foreach (var parameter in stmt.Parameters)
|
||||
cmd.Parameters.AddWithValue("@" + parameter.Key, parameter.Value);
|
||||
|
||||
commands.Add(cmd);
|
||||
}
|
||||
|
||||
public void Append(string sql, params object[] args)
|
||||
{
|
||||
commands.Add(new MySqlCommand(string.Format(sql, args)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Framework.Dynamic
|
||||
{
|
||||
public class EventMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes all scheduled events and resets time and phase.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_eventMap.Clear();
|
||||
_time = 0;
|
||||
_phase = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the timer of the event map.
|
||||
/// </summary>
|
||||
/// <param name="time">Value in ms to be added to time.</param>
|
||||
public void Update(uint time)
|
||||
{
|
||||
_time += time;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Current timer in ms value.</returns>
|
||||
uint GetTimer()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Active phases as mask.</returns>
|
||||
byte GetPhaseMask()
|
||||
{
|
||||
return _phase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>True, if there are no events scheduled.</returns>
|
||||
public bool Empty()
|
||||
{
|
||||
return _eventMap.Empty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the phase of the map (absolute).
|
||||
/// </summary>
|
||||
/// <param name="phase">Phase which should be set. Values: 1 - 8. 0 resets phase.</param>
|
||||
public void SetPhase(byte phase)
|
||||
{
|
||||
if (phase == 0)
|
||||
_phase = 0;
|
||||
else if (phase <= 8)
|
||||
_phase = (byte)(1 << (phase - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates the given phase (bitwise).
|
||||
/// </summary>
|
||||
/// <param name="phase">Phase which should be activated. Values: 1 - 8</param>
|
||||
void AddPhase(byte phase)
|
||||
{
|
||||
if (phase != 0 && phase <= 8)
|
||||
_phase |= (byte)(1 << (phase - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deactivates the given phase (bitwise).
|
||||
/// </summary>
|
||||
/// <param name="phase">Phase which should be deactivated. Values: 1 - 8.</param>
|
||||
void RemovePhase(byte phase)
|
||||
{
|
||||
if (phase != 0 && phase <= 8)
|
||||
_phase &= (byte)~(1 << (phase - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new event entry in map.
|
||||
/// </summary>
|
||||
/// <param name="eventId">The id of the new event.</param>
|
||||
/// <param name="time">The time in milliseconds as TimeSpan until the event occurs.</param>
|
||||
/// <param name="group">The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.</param>
|
||||
/// <param name="phase">The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.</param>
|
||||
public void ScheduleEvent(uint eventId, TimeSpan time, uint group = 0, byte phase = 0)
|
||||
{
|
||||
ScheduleEvent(eventId, (uint)time.TotalMilliseconds, group, phase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new event entry in map.
|
||||
/// </summary>
|
||||
/// <param name="eventId">The id of the new event.</param>
|
||||
/// <param name="minTime">The minimum time until the event occurs as TimeSpan type.</param>
|
||||
/// <param name="maxTime">The maximum time until the event occurs as TimeSpan type.</param>
|
||||
/// <param name="group">The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.</param>
|
||||
/// <param name="phase">The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.</param>
|
||||
public void ScheduleEvent(uint eventId, TimeSpan minTime, TimeSpan maxTime, uint group = 0, byte phase = 0)
|
||||
{
|
||||
ScheduleEvent(eventId, RandomHelper.URand(minTime.TotalMilliseconds, maxTime.TotalMilliseconds), group, phase);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates new event entry in map.
|
||||
/// </summary>
|
||||
/// <param name="eventId">The id of the new event.</param>
|
||||
/// <param name="time">The time in milliseconds until the event occurs.</param>
|
||||
/// <param name="group">The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.</param>
|
||||
/// <param name="phase">The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.</param>
|
||||
public void ScheduleEvent(uint eventId, uint time, uint group = 0, byte phase = 0)
|
||||
{
|
||||
if (group != 0 && group <= 8)
|
||||
eventId |= (uint)(1 << ((int)group + 15));
|
||||
|
||||
if (phase != 0 && phase <= 8)
|
||||
eventId |= (uint)(1 << (phase + 23));
|
||||
|
||||
_eventMap.Add(_time + time, eventId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the given event and reschedules it.
|
||||
/// </summary>
|
||||
/// <param name="eventId">The id of the event.</param>
|
||||
/// <param name="time">The time in milliseconds as TimeSpan until the event occurs.</param>
|
||||
/// <param name="group">The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.</param>
|
||||
/// <param name="phase">The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.</param>
|
||||
public void RescheduleEvent(uint eventId, TimeSpan time, uint group = 0, byte phase = 0)
|
||||
{
|
||||
RescheduleEvent(eventId, (uint)time.TotalMilliseconds, group, phase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the given event and reschedules it.
|
||||
/// </summary>
|
||||
/// <param name="eventId">The id of the event.</param>
|
||||
/// <param name="minTime">The minimum time until the event occurs as TimeSpan type.</param>
|
||||
/// <param name="maxTime">The maximum time until the event occurs as TimeSpan type.</param>
|
||||
/// <param name="group">The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.</param>
|
||||
/// <param name="phase">The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.</param>
|
||||
void RescheduleEvent(uint eventId, TimeSpan minTime, TimeSpan maxTime, uint group = 0, byte phase = 0)
|
||||
{
|
||||
RescheduleEvent(eventId, RandomHelper.URand(minTime.TotalMilliseconds, maxTime.TotalMilliseconds), group, phase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the given event and reschedules it.
|
||||
/// </summary>
|
||||
/// <param name="eventId">The id of the event.</param>
|
||||
/// <param name="time">The time in milliseconds until the event occurs.</param>
|
||||
/// <param name="group">The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.</param>
|
||||
/// <param name="phase">The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.</param>
|
||||
public void RescheduleEvent(uint eventId, uint time, uint group = 0, byte phase = 0)
|
||||
{
|
||||
CancelEvent(eventId);
|
||||
ScheduleEvent(eventId, time, group, phase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repeats the mostly recently executed event.
|
||||
/// </summary>
|
||||
/// <param name="time">Time until in ms as TimeSpan the event occurs</param>
|
||||
public void Repeat(TimeSpan time)
|
||||
{
|
||||
Repeat((uint)time.TotalMilliseconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repeats the mostly recently executed event.
|
||||
/// </summary>
|
||||
/// <param name="time">Time until the event occurs</param>
|
||||
public void Repeat(uint time)
|
||||
{
|
||||
_eventMap.Add(_time + time, _lastEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repeats the mostly recently executed event. Equivalent to Repeat(urand(minTime, maxTime)
|
||||
/// </summary>
|
||||
/// <param name="minTime">Min Time as TimeSpan until the event occurs.</param>
|
||||
/// <param name="maxTime">Max Time as TimeSpan until the event occurs.</param>
|
||||
public void Repeat(TimeSpan minTime, TimeSpan maxTime)
|
||||
{
|
||||
Repeat((uint)minTime.TotalMilliseconds, (uint)maxTime.TotalMilliseconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repeats the mostly recently executed event. Equivalent to Repeat(urand(minTime, maxTime)
|
||||
/// </summary>
|
||||
/// <param name="minTime">Min Time until the event occurs.</param>
|
||||
/// <param name="maxTime">Max Time until the event occurs.</param>
|
||||
public void Repeat(uint minTime, uint maxTime)
|
||||
{
|
||||
Repeat(RandomHelper.URand(minTime, maxTime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the next event to execute and removes it from map.
|
||||
/// </summary>
|
||||
/// <returns>Id of the event to execute.</returns>
|
||||
///
|
||||
public uint ExecuteEvent()
|
||||
{
|
||||
while (!Empty())
|
||||
{
|
||||
var pair = _eventMap.FirstOrDefault();
|
||||
|
||||
if (pair.Key > _time)
|
||||
return 0;
|
||||
else if (_phase != 0 && Convert.ToBoolean(pair.Value & 0xFF000000) && !Convert.ToBoolean((pair.Value >> 24) & _phase))
|
||||
_eventMap.Remove(pair);
|
||||
else
|
||||
{
|
||||
uint eventId = (pair.Value & 0x0000FFFF);
|
||||
_lastEvent = pair.Value; // include phase/group
|
||||
_eventMap.Remove(pair);
|
||||
return eventId;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void ExecuteEvents(Action<uint> action)
|
||||
{
|
||||
uint id;
|
||||
while ((id = ExecuteEvent()) != 0)
|
||||
action(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all events in the map. If delay is greater than or equal internal timer, delay will be 0.
|
||||
/// </summary>
|
||||
/// <param name="delay">Amount of delay in ms as TimeSpan.</param>
|
||||
public void DelayEvents(TimeSpan delay)
|
||||
{
|
||||
DelayEvents((uint)delay.TotalMilliseconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all events in the map. If delay is greater than or equal internal timer, delay will be 0.
|
||||
/// </summary>
|
||||
/// <param name="delay">Amount of delay.</param>
|
||||
public void DelayEvents(uint delay)
|
||||
{
|
||||
_time = delay < _time ? _time - delay : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delay all events of the same group.
|
||||
/// </summary>
|
||||
/// <param name="delay">Amount of delay.</param>
|
||||
/// <param name="group">Group of the events.</param>
|
||||
public void DelayEvents(uint delay, uint group)
|
||||
{
|
||||
if (group == 0 || group > 8 || Empty())
|
||||
return;
|
||||
MultiMap<uint, uint> delayed = new MultiMap<uint, uint>();
|
||||
|
||||
foreach (var pair in _eventMap.KeyValueList)
|
||||
{
|
||||
if (Convert.ToBoolean(pair.Value & (1 << (int)(group + 15))))
|
||||
{
|
||||
delayed.Add(pair.Key + delay, pair.Value);
|
||||
_eventMap.Remove(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var del in delayed)
|
||||
_eventMap.Add(del);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels all events of the specified id.
|
||||
/// </summary>
|
||||
/// <param name="eventId">Event id to cancel.</param>
|
||||
public void CancelEvent(uint eventId)
|
||||
{
|
||||
if (Empty())
|
||||
return;
|
||||
|
||||
foreach (var pair in _eventMap.KeyValueList)
|
||||
{
|
||||
if (eventId == (pair.Value & 0x0000FFFF))
|
||||
_eventMap.Remove(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel events belonging to specified group.
|
||||
/// </summary>
|
||||
/// <param name="group">Group to cancel.</param>
|
||||
void CancelEventGroup(uint group)
|
||||
{
|
||||
if (group == 0 || group > 8 || Empty())
|
||||
return;
|
||||
|
||||
foreach (var pair in _eventMap.KeyValueList)
|
||||
{
|
||||
if (Convert.ToBoolean(pair.Value & (uint)(1 << ((int)group + 15))))
|
||||
_eventMap.Remove(pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns closest occurence of specified event.
|
||||
/// </summary>
|
||||
/// <param name="eventId">Wanted event id.</param>
|
||||
/// <returns>Time of found event.</returns>
|
||||
uint GetNextEventTime(uint eventId)
|
||||
{
|
||||
if (Empty())
|
||||
return 0;
|
||||
|
||||
foreach (var pair in _eventMap.KeyValueList)
|
||||
if (eventId == (pair.Value & 0x0000FFFF))
|
||||
return pair.Key;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Time of next event.</returns>
|
||||
uint GetNextEventTime()
|
||||
{
|
||||
return Empty() ? 0 : _eventMap[0][0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns time in milliseconds until next event.
|
||||
/// </summary>
|
||||
/// <param name="eventId">Id of the event.</param>
|
||||
/// <returns>Time of next event.</returns>
|
||||
public uint GetTimeUntilEvent(uint eventId)
|
||||
{
|
||||
foreach (var pair in _eventMap)
|
||||
if (eventId == (pair.Value & 0x0000FFFF))
|
||||
return pair.Key - _time;
|
||||
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns wether event map is in specified phase or not.
|
||||
/// </summary>
|
||||
/// <param name="phase">Wanted phase.</param>
|
||||
/// <returns>True, if phase of event map contains specified phase.</returns>
|
||||
public bool IsInPhase(byte phase)
|
||||
{
|
||||
return phase <= 8 && (phase == 0 || Convert.ToBoolean(_phase & (1 << (phase - 1))));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal timer.
|
||||
/// This does not represent the real date/time value.
|
||||
/// It's more like a stopwatch: It can run, it can be stopped,
|
||||
/// it can be resetted and so on. Events occur when this timer
|
||||
/// has reached their time value. Its value is changed in the Update method.
|
||||
/// </summary>
|
||||
uint _time;
|
||||
|
||||
/// <summary>
|
||||
/// Phase mask of the event map.
|
||||
/// Contains the phases the event map is in. Multiple
|
||||
/// phases from 1 to 8 can be set with SetPhase or
|
||||
/// AddPhase. RemovePhase deactives a phase.
|
||||
/// </summary>
|
||||
byte _phase;
|
||||
|
||||
/// <summary>
|
||||
/// Stores information on the most recently executed event
|
||||
/// </summary>
|
||||
uint _lastEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Key: Time as uint when the event should occur.
|
||||
/// Value: The event data as uint.
|
||||
///
|
||||
/// Structure of event data:
|
||||
/// - Bit 0 - 15: Event Id.
|
||||
/// - Bit 16 - 23: Group
|
||||
/// - Bit 24 - 31: Phase
|
||||
/// - Pattern: 0xPPGGEEEE
|
||||
/// </summary>
|
||||
SortedMultiMap<uint, uint> _eventMap = new SortedMultiMap<uint, uint>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Framework.Dynamic
|
||||
{
|
||||
public class EventSystem
|
||||
{
|
||||
public EventSystem()
|
||||
{
|
||||
m_time = 0;
|
||||
}
|
||||
|
||||
public void Update(uint p_time)
|
||||
{
|
||||
// update time
|
||||
m_time += p_time;
|
||||
|
||||
// main event loop
|
||||
KeyValuePair<ulong, BasicEvent> i;
|
||||
while ((i = m_events.FirstOrDefault()).Value != null && i.Key <= m_time)
|
||||
{
|
||||
var Event = i.Value;
|
||||
m_events.Remove(i);
|
||||
|
||||
if (Event.IsRunning())
|
||||
{
|
||||
Event.Execute(m_time, p_time);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Event.IsAbortScheduled())
|
||||
{
|
||||
Event.Abort(m_time);
|
||||
// Mark the event as aborted
|
||||
Event.SetAborted();
|
||||
}
|
||||
|
||||
if (Event.IsDeletable())
|
||||
continue;
|
||||
|
||||
// Reschedule non deletable events to be checked at
|
||||
// the next update tick
|
||||
AddEvent(Event, CalculateTime(1), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void KillAllEvents(bool force)
|
||||
{
|
||||
foreach (var pair in m_events.KeyValueList)
|
||||
{
|
||||
// Abort events which weren't aborted already
|
||||
if (!pair.Value.IsAborted())
|
||||
{
|
||||
pair.Value.SetAborted();
|
||||
pair.Value.Abort(m_time);
|
||||
}
|
||||
|
||||
// Skip non-deletable events when we are
|
||||
// not forcing the event cancellation.
|
||||
if (!force && !pair.Value.IsDeletable())
|
||||
continue;
|
||||
|
||||
if (!force)
|
||||
m_events.Remove(pair);
|
||||
}
|
||||
|
||||
// fast clear event list (in force case)
|
||||
if (force)
|
||||
m_events.Clear();
|
||||
}
|
||||
|
||||
public void AddEvent(BasicEvent Event, ulong e_time, bool set_addtime = true)
|
||||
{
|
||||
if (set_addtime)
|
||||
Event.m_addTime = m_time;
|
||||
|
||||
Event.m_execTime = e_time;
|
||||
m_events.Add(e_time, Event);
|
||||
}
|
||||
|
||||
public ulong CalculateTime(ulong t_offset)
|
||||
{
|
||||
return (m_time + t_offset);
|
||||
}
|
||||
|
||||
ulong m_time;
|
||||
SortedMultiMap<ulong, BasicEvent> m_events = new SortedMultiMap<ulong, BasicEvent>();
|
||||
}
|
||||
|
||||
public class BasicEvent
|
||||
{
|
||||
public BasicEvent() { m_abortState = AbortState.Running; }
|
||||
|
||||
public void ScheduleAbort()
|
||||
{
|
||||
Contract.Assert(IsRunning(), "Tried to scheduled the abortion of an event twice!");
|
||||
m_abortState = AbortState.Scheduled;
|
||||
}
|
||||
|
||||
public void SetAborted()
|
||||
{
|
||||
Contract.Assert(!IsAborted(), "Tried to abort an already aborted event!");
|
||||
m_abortState = AbortState.Aborted;
|
||||
}
|
||||
|
||||
// this method executes when the event is triggered
|
||||
// return false if event does not want to be deleted
|
||||
// e_time is execution time, p_time is update interval
|
||||
public virtual bool Execute(ulong e_time, uint p_time) { return true; }
|
||||
|
||||
public virtual bool IsDeletable() { return true; } // this event can be safely deleted
|
||||
|
||||
public virtual void Abort(ulong e_time) { } // this method executes when the event is aborted
|
||||
|
||||
public bool IsRunning() { return m_abortState == AbortState.Running; }
|
||||
public bool IsAbortScheduled() { return m_abortState == AbortState.Scheduled; }
|
||||
public bool IsAborted() { return m_abortState == AbortState.Aborted; }
|
||||
|
||||
AbortState m_abortState; // set by externals when the event is aborted, aborted events don't execute
|
||||
public ulong m_addTime; // time when the event was added to queue, filled by event handler
|
||||
public ulong m_execTime; // planned time of next execution, filled by event handler
|
||||
}
|
||||
|
||||
enum AbortState
|
||||
{
|
||||
Running,
|
||||
Scheduled,
|
||||
Aborted
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Dynamic
|
||||
{
|
||||
public class FlagArray128
|
||||
{
|
||||
public FlagArray128(params uint[] parts)
|
||||
{
|
||||
_values = new uint[4];
|
||||
for (var i = 0; i < parts.Length; ++i)
|
||||
_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)
|
||||
if (_values[i] == parts[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Set(params uint[] parts)
|
||||
{
|
||||
for (var i = 0; i < parts.Length; ++i)
|
||||
_values[i] = parts[i];
|
||||
}
|
||||
|
||||
public static bool operator <(FlagArray128 left, FlagArray128 right)
|
||||
{
|
||||
for (var i = left._values.Length; i > 0; --i)
|
||||
{
|
||||
if (left._values[i - 1] < right._values[i - 1])
|
||||
return true;
|
||||
else if (left._values[i - 1] > right._values[i - 1])
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool operator >(FlagArray128 left, FlagArray128 right)
|
||||
{
|
||||
for (var i = left._values.Length; i > 0; --i)
|
||||
{
|
||||
if (left._values[i - 1] > right._values[i - 1])
|
||||
return true;
|
||||
else if (left._values[i - 1] < right._values[i - 1])
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static FlagArray128 operator &(FlagArray128 left, FlagArray128 right)
|
||||
{
|
||||
FlagArray128 fl = new FlagArray128();
|
||||
for (var i = 0; i < left._values.Length; ++i)
|
||||
fl[i] = left._values[i] & right._values[i];
|
||||
return fl;
|
||||
}
|
||||
public static FlagArray128 operator |(FlagArray128 left, FlagArray128 right)
|
||||
{
|
||||
FlagArray128 fl = new FlagArray128();
|
||||
for (var i = 0; i < left._values.Length; ++i)
|
||||
fl[i] = left._values[i] | right._values[i];
|
||||
return fl;
|
||||
}
|
||||
public static FlagArray128 operator ^(FlagArray128 left, FlagArray128 right)
|
||||
{
|
||||
FlagArray128 fl = new FlagArray128();
|
||||
for (var i = 0; i < left._values.Length; ++i)
|
||||
fl[i] = left._values[i] ^ right._values[i];
|
||||
return fl;
|
||||
}
|
||||
|
||||
public static implicit operator bool (FlagArray128 left)
|
||||
{
|
||||
for (var i = 0; i < left._values.Length; ++i)
|
||||
if (left._values[i] != 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public uint this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _values[i];
|
||||
}
|
||||
set
|
||||
{
|
||||
_values[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
uint[] _values { get; set; }
|
||||
}
|
||||
|
||||
public class FlaggedArray<T> where T : struct
|
||||
{
|
||||
int[] m_values;
|
||||
uint m_flags;
|
||||
|
||||
public FlaggedArray(byte arraysize)
|
||||
{
|
||||
m_values = new int[4 * arraysize];
|
||||
}
|
||||
|
||||
public uint GetFlags() { return m_flags; }
|
||||
public bool HasFlag(T flag) { return Convert.ToBoolean(Convert.ToInt32(m_flags) & 1 << Convert.ToInt32(flag)); }
|
||||
public void AddFlag(T flag) { m_flags |= (uint)(1 << Convert.ToInt32(flag)); }
|
||||
public void DelFlag(T flag) { m_flags &= ~(uint)(1 << Convert.ToInt32(flag)); }
|
||||
|
||||
public int GetValue(T flag) { return m_values[Convert.ToInt32(flag)]; }
|
||||
public void SetValue(T flag, object value) { m_values[Convert.ToInt32(flag)] = Convert.ToInt32(value); }
|
||||
public void AddValue(T flag, object value) { m_values[Convert.ToInt32(flag)] += Convert.ToInt32(value); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Framework.Dynamic
|
||||
{
|
||||
public struct Optional<T> where T : new()
|
||||
{
|
||||
private bool _hasValue;
|
||||
public T Value;
|
||||
|
||||
public bool HasValue
|
||||
{
|
||||
get { return _hasValue; }
|
||||
set
|
||||
{
|
||||
_hasValue = value;
|
||||
Value = _hasValue ? new T() : default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public void Set(T v)
|
||||
{
|
||||
_hasValue = true;
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_hasValue = false;
|
||||
Value = default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 Framework.Collections;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Framework.Dynamic
|
||||
{
|
||||
public class Reference<TO, FROM> : LinkedListElement where TO : class where FROM : class
|
||||
{
|
||||
TO _RefTo;
|
||||
FROM _RefFrom;
|
||||
|
||||
// Tell our refTo (target) object that we have a link
|
||||
public virtual void targetObjectBuildLink() { }
|
||||
|
||||
// Tell our refTo (taget) object, that the link is cut
|
||||
public virtual void targetObjectDestroyLink() { }
|
||||
|
||||
// Tell our refFrom (source) object, that the link is cut (Target destroyed)
|
||||
public virtual void sourceObjectDestroyLink() { }
|
||||
|
||||
public Reference()
|
||||
{
|
||||
_RefTo = null; _RefFrom = null;
|
||||
}
|
||||
|
||||
// Create new link
|
||||
public void link(TO toObj, FROM fromObj)
|
||||
{
|
||||
Contract.Assert(fromObj != null); // fromObj MUST not be NULL
|
||||
if (isValid())
|
||||
unlink();
|
||||
if (toObj != null)
|
||||
{
|
||||
_RefTo = toObj;
|
||||
_RefFrom = fromObj;
|
||||
targetObjectBuildLink();
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need the reference anymore. Call comes from the refFrom object
|
||||
// Tell our refTo object, that the link is cut
|
||||
public void unlink()
|
||||
{
|
||||
targetObjectDestroyLink();
|
||||
delink();
|
||||
_RefTo = null;
|
||||
_RefFrom = null;
|
||||
}
|
||||
|
||||
// Link is invalid due to destruction of referenced target object. Call comes from the refTo object
|
||||
// Tell our refFrom object, that the link is cut
|
||||
public void invalidate() // the iRefFrom MUST remain!!
|
||||
{
|
||||
sourceObjectDestroyLink();
|
||||
delink();
|
||||
_RefTo = null;
|
||||
}
|
||||
|
||||
public bool isValid() // Only check the iRefTo
|
||||
{
|
||||
return _RefTo != null;
|
||||
}
|
||||
|
||||
public Reference<TO, FROM> next() { return ((Reference<TO, FROM>)GetNextElement()); }
|
||||
public Reference<TO, FROM> prev() { return ((Reference<TO, FROM>)GetPrevElement()); }
|
||||
|
||||
public TO getTarget() { return _RefTo; }
|
||||
|
||||
public FROM GetSource() { return _RefFrom; }
|
||||
}
|
||||
|
||||
public class RefManager<TO, FROM> : LinkedListHead where TO : class where FROM : class
|
||||
{
|
||||
~RefManager() { clearReferences(); }
|
||||
|
||||
public Reference<TO, FROM> getFirst() { return (Reference<TO, FROM>)base.GetFirstElement(); }
|
||||
public Reference<TO, FROM> getLast() { return (Reference<TO, FROM>)base.GetLastElement(); }
|
||||
|
||||
public void clearReferences()
|
||||
{
|
||||
Reference<TO, FROM> refe;
|
||||
while ((refe = getFirst()) != null)
|
||||
refe.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,846 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
|
||||
namespace Framework.Dynamic
|
||||
{
|
||||
public class TaskScheduler
|
||||
{
|
||||
public TaskScheduler()
|
||||
{
|
||||
_now = DateTime.Now;
|
||||
_task_holder = new TaskQueue();
|
||||
_asyncHolder = new List<Action>();
|
||||
_predicate = EmptyValidator;
|
||||
}
|
||||
|
||||
public TaskScheduler(predicate_t predicate)
|
||||
{
|
||||
_now = DateTime.Now;
|
||||
_task_holder = new TaskQueue();
|
||||
_asyncHolder = new List<Action>();
|
||||
_predicate = predicate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the validator which is asked if tasks are allowed to be executed.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TaskScheduler ClearValidator()
|
||||
{
|
||||
_predicate = EmptyValidator;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a validator which is asked if tasks are allowed to be executed.
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler SetValidator(predicate_t predicate)
|
||||
{
|
||||
_predicate = predicate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the scheduler to the current time.
|
||||
/// Calls the optional callback on successfully finish.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler Update(success_t callback = null)
|
||||
{
|
||||
_now = DateTime.Now;
|
||||
Dispatch(callback);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the scheduler with a difftime in ms.
|
||||
/// Calls the optional callback on successfully finish.
|
||||
/// </summary>
|
||||
/// <param name="milliseconds"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler Update(uint milliseconds, success_t callback = null)
|
||||
{
|
||||
return Update(TimeSpan.FromMilliseconds(milliseconds), callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the scheduler with a difftime.
|
||||
/// Calls the optional callback on successfully finish.
|
||||
/// </summary>
|
||||
/// <param name="difftime"></param>
|
||||
/// <returns></returns>
|
||||
TaskScheduler Update(TimeSpan difftime, success_t callback = null)
|
||||
{
|
||||
_now += difftime;
|
||||
Dispatch(callback);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskScheduler Async(Action callable)
|
||||
{
|
||||
_asyncHolder.Add(callable);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a fixed rate.
|
||||
/// Never call this from within a task context! Use TaskContext.Schedule instead!
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler Schedule(TimeSpan time, Action<TaskContext> task)
|
||||
{
|
||||
return ScheduleAt(_now, time, task);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a fixed rate.
|
||||
/// Never call this from within a task context! Use TaskContext.Schedule instead!
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler Schedule(TimeSpan time, uint group, Action<TaskContext> task)
|
||||
{
|
||||
return ScheduleAt(_now, time, group, task);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a randomized rate between min and max rate.
|
||||
/// Never call this from within a task context! Use TaskContext.Schedule instead!
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler Schedule(TimeSpan min, TimeSpan max, Action<TaskContext> task)
|
||||
{
|
||||
return Schedule(RandomDurationBetween(min, max), task);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a fixed rate.
|
||||
/// Never call this from within a task context! Use TaskContext.Schedule instead!
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler Schedule(TimeSpan min, TimeSpan max, uint group, Action<TaskContext> task)
|
||||
{
|
||||
return Schedule(RandomDurationBetween(min, max), group, task);
|
||||
}
|
||||
|
||||
public TaskScheduler CancelAll()
|
||||
{
|
||||
/// Clear the task holder
|
||||
_task_holder.Clear();
|
||||
_asyncHolder.Clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskScheduler CancelGroup(uint group)
|
||||
{
|
||||
_task_holder.RemoveIf(task =>
|
||||
{
|
||||
return task.IsInGroup(group);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskScheduler CancelGroupsOf(List<uint> groups)
|
||||
{
|
||||
groups.ForEach(group => CancelGroup(group));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks with the given duration.
|
||||
/// </summary>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler DelayAll(TimeSpan duration)
|
||||
{
|
||||
_task_holder.ModifyIf(task =>
|
||||
{
|
||||
task._end += duration;
|
||||
return true;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks with a random duration between min and max.
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler DelayAll(TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return DelayAll(RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks of a group with the given duration.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler DelayGroup(uint group, TimeSpan duration)
|
||||
{
|
||||
_task_holder.ModifyIf(task =>
|
||||
{
|
||||
if (task.IsInGroup(group))
|
||||
{
|
||||
task._end += duration;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks of a group with a random duration between min and max.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler DelayGroup(uint group, TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return DelayGroup(group, RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks with a given duration.
|
||||
/// </summary>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler RescheduleAll(TimeSpan duration)
|
||||
{
|
||||
var end = _now + duration;
|
||||
_task_holder.ModifyIf(task =>
|
||||
{
|
||||
task._end = end;
|
||||
return true;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks with a random duration between min and max.
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler RescheduleAll(TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return RescheduleAll(RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks of a group with the given duration.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler RescheduleGroup(uint group, TimeSpan duration)
|
||||
{
|
||||
var end = _now + duration;
|
||||
_task_holder.ModifyIf(task =>
|
||||
{
|
||||
if (task.IsInGroup(group))
|
||||
{
|
||||
task._end = end;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks of a group with a random duration between min and max.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskScheduler RescheduleGroup(uint group, TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return RescheduleGroup(group, RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
internal TaskScheduler InsertTask(Task task)
|
||||
{
|
||||
_task_holder.Push(task);
|
||||
return this;
|
||||
}
|
||||
|
||||
internal TaskScheduler ScheduleAt(DateTime end, TimeSpan time, Action<TaskContext> task)
|
||||
{
|
||||
return InsertTask(new Task(end + time, time, task));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a fixed rate.
|
||||
/// Never call this from within a task context! Use TaskContext.schedule instead!
|
||||
/// </summary>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
internal TaskScheduler ScheduleAt(DateTime end, TimeSpan time, uint group, Action<TaskContext> task)
|
||||
{
|
||||
return InsertTask(new Task(end + time, time, group, 0, task));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a random duration between min and max
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns>TimeSpan</returns>
|
||||
public static TimeSpan RandomDurationBetween(TimeSpan min, TimeSpan max)
|
||||
{
|
||||
var milli_min = min.TotalMilliseconds;
|
||||
var milli_max = max.TotalMilliseconds;
|
||||
|
||||
// TC specific: use SFMT URandom
|
||||
return TimeSpan.FromMilliseconds(RandomHelper.URand(milli_min, milli_max));
|
||||
}
|
||||
|
||||
void Dispatch(success_t callback = null)
|
||||
{
|
||||
// If the validation failed abort the dispatching here.
|
||||
if (!_predicate())
|
||||
return;
|
||||
|
||||
// Process all asyncs
|
||||
while (!_asyncHolder.Empty())
|
||||
{
|
||||
_asyncHolder.First().Invoke();
|
||||
_asyncHolder.RemoveAt(0);
|
||||
|
||||
// If the validation failed abort the dispatching here.
|
||||
if (!_predicate())
|
||||
return;
|
||||
}
|
||||
|
||||
while (!_task_holder.IsEmpty())
|
||||
{
|
||||
if (_task_holder.First()._end > _now)
|
||||
break;
|
||||
|
||||
// Perfect forward the context to the handler
|
||||
// Use weak references to catch destruction before callbacks.
|
||||
TaskContext context = new TaskContext(_task_holder.Pop(), this);
|
||||
|
||||
// Invoke the context
|
||||
context.Invoke();
|
||||
|
||||
// If the validation failed abort the dispatching here.
|
||||
if (!_predicate())
|
||||
return;
|
||||
}
|
||||
|
||||
callback?.Invoke();
|
||||
}
|
||||
|
||||
// The current time point (now)
|
||||
DateTime _now;
|
||||
|
||||
// The Task Queue which contains all task objects.
|
||||
TaskQueue _task_holder;
|
||||
|
||||
// Contains all asynchronous tasks which will be invoked at
|
||||
// the next update tick.
|
||||
List<Action> _asyncHolder;
|
||||
|
||||
predicate_t _predicate;
|
||||
|
||||
static bool EmptyValidator()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Predicate type
|
||||
public delegate bool predicate_t();
|
||||
// Success handle type
|
||||
public delegate void success_t();
|
||||
}
|
||||
|
||||
public class Task : IComparable<Task>
|
||||
{
|
||||
public Task(DateTime end, TimeSpan duration, uint group, uint repeated, Action<TaskContext> task)
|
||||
{
|
||||
_end = end;
|
||||
_duration = duration;
|
||||
_group.Set(group);
|
||||
_repeated = repeated;
|
||||
_task = task;
|
||||
}
|
||||
|
||||
public Task(DateTime end, TimeSpan duration, Action<TaskContext> task)
|
||||
{
|
||||
_end = end;
|
||||
_duration = duration;
|
||||
_task = task;
|
||||
}
|
||||
|
||||
public int CompareTo(Task other)
|
||||
{
|
||||
return _end.CompareTo(other._end);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the task is in the given group
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInGroup(uint group)
|
||||
{
|
||||
return _group.HasValue && _group.Value == group;
|
||||
}
|
||||
|
||||
internal DateTime _end;
|
||||
internal TimeSpan _duration;
|
||||
internal Optional<uint> _group;
|
||||
internal uint _repeated;
|
||||
internal Action<TaskContext> _task;
|
||||
}
|
||||
|
||||
class TaskQueue
|
||||
{
|
||||
/// <summary>
|
||||
/// Pushes the task in the container
|
||||
/// </summary>
|
||||
/// <param name="task"></param>
|
||||
public void Push(Task task)
|
||||
{
|
||||
if (!container.Add(task))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pops the task out of the container
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task Pop()
|
||||
{
|
||||
Task result = container.First();
|
||||
container.Remove(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task First()
|
||||
{
|
||||
return container.First();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
container.Clear();
|
||||
}
|
||||
|
||||
public void RemoveIf(Predicate<Task> filter)
|
||||
{
|
||||
container.RemoveWhere(filter);
|
||||
}
|
||||
|
||||
public void ModifyIf(Func<Task, bool> filter)
|
||||
{
|
||||
List<Task> cache = new List<Task>();
|
||||
foreach (var task in container.Where(filter))
|
||||
{
|
||||
if (filter(task))
|
||||
{
|
||||
cache.Add(task);
|
||||
container.Remove(task);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var task in cache)
|
||||
container.Add(task);
|
||||
}
|
||||
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return container.Empty();
|
||||
}
|
||||
|
||||
SortedSet<Task> container = new SortedSet<Task>();
|
||||
}
|
||||
|
||||
public class TaskContext
|
||||
{
|
||||
public TaskContext(Task task, TaskScheduler owner)
|
||||
{
|
||||
_task = task;
|
||||
_owner = owner;
|
||||
_consumed = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatches an action safe on the TaskScheduler
|
||||
/// </summary>
|
||||
/// <param name="apply"></param>
|
||||
/// <returns></returns>
|
||||
TaskContext Dispatch(Action apply)
|
||||
{
|
||||
apply();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
TaskContext Dispatch(Func<TaskScheduler, TaskScheduler> apply)
|
||||
{
|
||||
apply(_owner);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
bool IsExpired()
|
||||
{
|
||||
return _owner == null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the event is in the given group
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
bool IsInGroup(uint group)
|
||||
{
|
||||
return _task.IsInGroup(group);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the event in the given group
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
TaskContext SetGroup(uint group)
|
||||
{
|
||||
_task._group.Set(group);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the group from the event
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TaskContext ClearGroup()
|
||||
{
|
||||
_task._group.HasValue = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the repeat counter which increases every time the task is repeated.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
uint GetRepeatCounter()
|
||||
{
|
||||
return _task._repeated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule a callable function that is executed at the next update tick from within the context.
|
||||
/// Its safe to modify the TaskScheduler from within the callable.
|
||||
/// </summary>
|
||||
/// <param name="callable"></param>
|
||||
/// <returns></returns>
|
||||
TaskContext Async(Action callable)
|
||||
{
|
||||
return Dispatch(() => _owner.Async(callable));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels all tasks from within the context.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TaskContext CancelAll()
|
||||
{
|
||||
return Dispatch(() => _owner.CancelAll());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel all tasks of a single group from within the context.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext CancelGroup(uint group)
|
||||
{
|
||||
return Dispatch(() => CancelGroup(group));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels all groups in the given std.vector from within the context.
|
||||
/// </summary>
|
||||
/// <param name="groups"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext CancelGroupsOf(List<uint> groups)
|
||||
{
|
||||
return Dispatch(() => CancelGroupsOf(groups));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts if the task was consumed already.
|
||||
/// </summary>
|
||||
void AssertOnConsumed()
|
||||
{
|
||||
// This was adapted to TC to prevent static analysis tools from complaining.
|
||||
// If you encounter this assertion check if you repeat a TaskContext more then 1 time!
|
||||
Contract.Assert(!_consumed, "Bad task logic, task context was consumed already!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the associated hook of the task.
|
||||
/// </summary>
|
||||
public void Invoke()
|
||||
{
|
||||
_task._task(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repeats the event and sets a new duration.
|
||||
/// This will consume the task context, its not possible to repeat the task again
|
||||
/// from the same task context!
|
||||
/// </summary>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext Repeat(TimeSpan duration)
|
||||
{
|
||||
AssertOnConsumed();
|
||||
|
||||
// Set new duration, in-context timing and increment repeat counter
|
||||
_task._duration = duration;
|
||||
_task._end += duration;
|
||||
_task._repeated += 1;
|
||||
_consumed = true;
|
||||
return Dispatch(() => _owner.InsertTask(_task));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repeats the event with the same duration.
|
||||
/// This will consume the task context, its not possible to repeat the task again
|
||||
/// from the same task context!
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TaskContext Repeat()
|
||||
{
|
||||
return Repeat(_task._duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repeats the event and set a new duration that is randomized between min and max.
|
||||
/// This will consume the task context, its not possible to repeat the task again
|
||||
/// from the same task context!
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext Repeat(TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return Repeat(TaskScheduler.RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a fixed rate from within the context.
|
||||
/// Its possible that the new event is executed immediately!
|
||||
/// Use TaskScheduler.Async to create a task
|
||||
/// which will be called at the next update tick.
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext Schedule(TimeSpan time, Action<TaskContext> task)
|
||||
{
|
||||
var end = _task._end;
|
||||
return Dispatch(scheduler =>
|
||||
{
|
||||
return scheduler.ScheduleAt(end, time, task);
|
||||
});
|
||||
}
|
||||
public TaskContext Schedule(TimeSpan time, Action task) { return Schedule(time, delegate (TaskContext task1) { task(); }); }
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a fixed rate from within the context.
|
||||
/// Its possible that the new event is executed immediately!
|
||||
/// Use TaskScheduler.Async to create a task
|
||||
/// which will be called at the next update tick.
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext Schedule(TimeSpan time, uint group, Action<TaskContext> task)
|
||||
{
|
||||
var end = _task._end;
|
||||
return Dispatch(scheduler => { return scheduler.ScheduleAt(end, time, group, task); });
|
||||
}
|
||||
public TaskContext Schedule(TimeSpan time, uint group, Action task) { return Schedule(time, group, delegate (TaskContext task1) { task(); }); }
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a randomized rate between min and max rate from within the context.
|
||||
/// Its possible that the new event is executed immediately!
|
||||
/// Use TaskScheduler.Async to create a task
|
||||
/// which will be called at the next update tick.
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext Schedule(TimeSpan min, TimeSpan max, Action<TaskContext> task)
|
||||
{
|
||||
return Schedule(TaskScheduler.RandomDurationBetween(min, max), task);
|
||||
}
|
||||
public TaskContext Schedule(TimeSpan min, TimeSpan max, Action task) { return Schedule(min, max, delegate (TaskContext task1) { task(); }); }
|
||||
|
||||
/// <summary>
|
||||
/// Schedule an event with a randomized rate between min and max rate from within the context.
|
||||
/// Its possible that the new event is executed immediately!
|
||||
/// Use TaskScheduler.Async to create a task
|
||||
/// which will be called at the next update tick.
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext Schedule(TimeSpan min, TimeSpan max, uint group, Action<TaskContext> task)
|
||||
{
|
||||
return Schedule(TaskScheduler.RandomDurationBetween(min, max), group, task);
|
||||
}
|
||||
public TaskContext Schedule(TimeSpan min, TimeSpan max, uint group, Action task) { return Schedule(min, max, group, delegate (TaskContext task1) { task(); }); }
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks with the given duration from within the context.
|
||||
/// </summary>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext DelayAll(TimeSpan duration)
|
||||
{
|
||||
return Dispatch(() => _owner.DelayAll(duration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks with a random duration between min and max from within the context.
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext DelayAll(TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return DelayAll(TaskScheduler.RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks of a group with the given duration from within the context.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext DelayGroup(uint group, TimeSpan duration)
|
||||
{
|
||||
return Dispatch(() => _owner.DelayGroup(group, duration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delays all tasks of a group with a random duration between min and max from within the context.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext DelayGroup(uint group, TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return DelayGroup(group, TaskScheduler.RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks with the given duration.
|
||||
/// </summary>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext RescheduleAll(TimeSpan duration)
|
||||
{
|
||||
return Dispatch(() => _owner.RescheduleAll(duration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks with a random duration between min and max.
|
||||
/// </summary>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext RescheduleAll(TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return RescheduleAll(TaskScheduler.RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks of a group with the given duration.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext RescheduleGroup(uint group, TimeSpan duration)
|
||||
{
|
||||
return Dispatch(() => _owner.RescheduleGroup(group, duration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reschedule all tasks of a group with a random duration between min and max.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public TaskContext RescheduleGroup(uint group, TimeSpan min, TimeSpan max)
|
||||
{
|
||||
return RescheduleGroup(group, TaskScheduler.RandomDurationBetween(min, max));
|
||||
}
|
||||
|
||||
// Associated task
|
||||
Task _task;
|
||||
|
||||
// Owner
|
||||
TaskScheduler _owner;
|
||||
|
||||
// Marks the task as consumed
|
||||
bool _consumed = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Deps\Source\Google.Protobuf\Google.Protobuf.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MySql.Data" Version="6.10.4" />
|
||||
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an axis aligned box in 3D space.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// An axis-aligned box is a box whose faces coincide with the standard basis axes.
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public struct AxisAlignedBox : ISerializable, ICloneable
|
||||
{
|
||||
#region Private Fields
|
||||
private Vector3 _lo;
|
||||
private Vector3 _hi;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AxisAlignedBox"/> class using given minimum and maximum points.
|
||||
/// </summary>
|
||||
/// <param name="min">A <see cref="Vector3"/> instance representing the minimum point.</param>
|
||||
/// <param name="max">A <see cref="Vector3"/> instance representing the maximum point.</param>
|
||||
public AxisAlignedBox(Vector3 min, Vector3 max)
|
||||
{
|
||||
_lo = min;
|
||||
_hi = max;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AxisAlignedBox"/> class using given values from another box instance.
|
||||
/// </summary>
|
||||
/// <param name="box">A <see cref="AxisAlignedBox"/> instance to take values from.</param>
|
||||
public AxisAlignedBox(AxisAlignedBox box)
|
||||
{
|
||||
_lo = box.Lo;
|
||||
_hi = box.Hi;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AxisAlignedBox"/> class with serialized data.
|
||||
/// </summary>
|
||||
/// <param name="info">The object that holds the serialized object data.</param>
|
||||
/// <param name="context">The contextual information about the source or destination.</param>
|
||||
private AxisAlignedBox(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
_lo = (Vector3)info.GetValue("Min", typeof(Vector3));
|
||||
_hi = (Vector3)info.GetValue("Max", typeof(Vector3));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum point which is the box's minimum X and Y coordinates.
|
||||
/// </summary>
|
||||
public Vector3 Lo
|
||||
{
|
||||
get { return _lo; }
|
||||
set { _lo = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum point which is the box's maximum X and Y coordinates.
|
||||
/// </summary>
|
||||
public Vector3 Hi
|
||||
{
|
||||
get { return _hi; }
|
||||
set { _hi = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Populates a <see cref="SerializationInfo"/> with the data needed to serialize the target object.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="SerializationInfo"/> to populate with data. </param>
|
||||
/// <param name="context">The destination (see <see cref="StreamingContext"/>) for this serialization.</param>
|
||||
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("Max", _hi, typeof(Vector3));
|
||||
info.AddValue("Min", _lo, typeof(Vector3));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="AxisAlignedBox"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="AxisAlignedBox"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new AxisAlignedBox(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="AxisAlignedBox"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="AxisAlignedBox"/> object this method creates.</returns>
|
||||
public AxisAlignedBox Clone()
|
||||
{
|
||||
return new AxisAlignedBox(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Computes the box vertices.
|
||||
/// </summary>
|
||||
/// <returns>An array of <see cref="Vector3"/> containing the box vertices.</returns>
|
||||
public Vector3[] ComputeVertices()
|
||||
{
|
||||
Vector3[] vertices = new Vector3[8];
|
||||
|
||||
vertices[0] = _lo;
|
||||
vertices[1] = new Vector3(_hi.X, _lo.Y, _lo.Z);
|
||||
vertices[2] = new Vector3(_hi.X, _hi.Y, _lo.Z);
|
||||
vertices[3] = new Vector3(_lo.X, _hi.Y, _lo.Z);
|
||||
|
||||
vertices[4] = new Vector3(_lo.X, _lo.Y, _hi.Z);
|
||||
vertices[5] = new Vector3(_hi.X, _lo.Y, _hi.Z);
|
||||
vertices[6] = _hi;
|
||||
vertices[7] = new Vector3(_lo.X, _hi.Y, _hi.Z);
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _lo.GetHashCode() ^ _hi.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns>True if <paramref name="obj"/> is a <see cref="Vector3"/> and has the same values as this instance; otherwise, False.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is AxisAlignedBox)
|
||||
{
|
||||
AxisAlignedBox box = (AxisAlignedBox)obj;
|
||||
return (_lo == box.Lo) && (_hi == box.Hi);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("AxisAlignedBox(Min={0}, Max={1})", _lo, _hi);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Comparison Operators
|
||||
/// <summary>
|
||||
/// Checks if the two given boxes are equal.
|
||||
/// </summary>
|
||||
/// <param name="a">The first of two boxes to compare.</param>
|
||||
/// <param name="b">The second of two boxes to compare.</param>
|
||||
/// <returns><b>true</b> if the boxes are equal; otherwise, <b>false</b>.</returns>
|
||||
public static bool operator ==(AxisAlignedBox a, AxisAlignedBox b)
|
||||
{
|
||||
if (Equals(a, null))
|
||||
{
|
||||
return Equals(b, null);
|
||||
}
|
||||
|
||||
if (Equals(b, null))
|
||||
{
|
||||
return Equals(a, null);
|
||||
}
|
||||
|
||||
return (a.Lo == b.Lo) && (a.Hi == b.Hi);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the two given boxes are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a">The first of two boxes to compare.</param>
|
||||
/// <param name="b">The second of two boxes to compare.</param>
|
||||
/// <returns><b>true</b> if the vectors are not equal; otherwise, <b>false</b>.</returns>
|
||||
public static bool operator !=(AxisAlignedBox a, AxisAlignedBox b)
|
||||
{
|
||||
if (Object.Equals(a, null) == true)
|
||||
{
|
||||
return !Object.Equals(b, null);
|
||||
}
|
||||
else if (Object.Equals(b, null) == true)
|
||||
{
|
||||
return !Object.Equals(a, null);
|
||||
}
|
||||
return !((a.Lo == b.Lo) && (a.Hi == b.Hi));
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool contains(Vector3 point)
|
||||
{
|
||||
return
|
||||
(point.X >= _lo.X) &&
|
||||
(point.Y >= _lo.Y) &&
|
||||
(point.Z >= _lo.Z) &&
|
||||
(point.X <= _hi.X) &&
|
||||
(point.Y <= _hi.Y) &&
|
||||
(point.Z <= _hi.Z);
|
||||
}
|
||||
|
||||
public void merge(AxisAlignedBox a)
|
||||
{
|
||||
Lo = Lo.Min(a.Lo);
|
||||
Hi = Hi.Max(a.Hi);
|
||||
}
|
||||
|
||||
public void merge(Vector3 a)
|
||||
{
|
||||
_lo = _lo.Min(a);
|
||||
_hi = _hi.Max(a);
|
||||
}
|
||||
|
||||
public static AxisAlignedBox Zero()
|
||||
{
|
||||
return new AxisAlignedBox(Vector3.Zero, Vector3.Zero);
|
||||
}
|
||||
|
||||
public Vector3 corner(int index)
|
||||
{
|
||||
// default constructor inits all components to 0
|
||||
Vector3 v = new Vector3();
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
v.X = _lo.X;
|
||||
v.Y = _lo.Y;
|
||||
v.Z = _hi.Z;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
v.X = _hi.X;
|
||||
v.Y = _lo.Y;
|
||||
v.Z = _hi.Z;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
v.X = _hi.X;
|
||||
v.Y = _hi.Y;
|
||||
v.Z = _hi.Z;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
v.X = _lo.X;
|
||||
v.Y = _hi.Y;
|
||||
v.Z = _hi.Z;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
v.X = _lo.X;
|
||||
v.Y = _lo.Y;
|
||||
v.Z = _lo.Z;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
v.X = _hi.X;
|
||||
v.Y = _lo.Y;
|
||||
v.Z = _lo.Z;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
v.X = _hi.X;
|
||||
v.Y = _hi.Y;
|
||||
v.Z = _lo.Z;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
v.X = _lo.X;
|
||||
v.Y = _hi.Y;
|
||||
v.Z = _lo.Z;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public static AxisAlignedBox operator +(AxisAlignedBox box, Vector3 v)
|
||||
{
|
||||
AxisAlignedBox outt = new AxisAlignedBox();
|
||||
outt.Lo = box.Lo + v;
|
||||
outt.Hi = box.Hi + v;
|
||||
return outt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.GameMath
|
||||
{
|
||||
class CollisionDetection
|
||||
{
|
||||
public static float collisionTimeForMovingPointFixedAABox(Vector3 origin, Vector3 dir, AxisAlignedBox box, ref Vector3 location, out bool Inside)
|
||||
{
|
||||
Vector3 normal = Vector3.Zero;
|
||||
if (collisionLocationForMovingPointFixedAABox(origin, dir, box, ref location, out Inside, ref normal))
|
||||
{
|
||||
return (location - origin).magnitude();
|
||||
}
|
||||
else
|
||||
{
|
||||
return float.PositiveInfinity;
|
||||
}
|
||||
}
|
||||
public static bool collisionLocationForMovingPointFixedAABox(Vector3 origin, Vector3 dir, AxisAlignedBox box, ref Vector3 location, out bool Inside, ref Vector3 normal)
|
||||
{
|
||||
Inside = true;
|
||||
Vector3 MinB = box.Lo;
|
||||
Vector3 MaxB = box.Hi;
|
||||
Vector3 MaxT = new Vector3(-1.0f, -1.0f, -1.0f);
|
||||
|
||||
// Find candidate planes.
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (origin[i] < MinB[i])
|
||||
{
|
||||
location[i] = MinB[i];
|
||||
Inside = false;
|
||||
|
||||
// Calculate T distances to candidate planes
|
||||
if ((uint)dir[i] != 0)
|
||||
{
|
||||
MaxT[i] = (MinB[i] - origin[i]) / dir[i];
|
||||
}
|
||||
}
|
||||
else if (origin[i] > MaxB[i])
|
||||
{
|
||||
location[i] = MaxB[i];
|
||||
Inside = false;
|
||||
|
||||
// Calculate T distances to candidate planes
|
||||
if ((uint)dir[i] != 0)
|
||||
{
|
||||
MaxT[i] = (MaxB[i] - origin[i]) / dir[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Inside)
|
||||
{
|
||||
// Ray origin inside bounding box
|
||||
location = origin;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get largest of the maxT's for final choice of intersection
|
||||
int WhichPlane = 0;
|
||||
if (MaxT[1] > MaxT[WhichPlane])
|
||||
{
|
||||
WhichPlane = 1;
|
||||
}
|
||||
|
||||
if (MaxT[2] > MaxT[WhichPlane])
|
||||
{
|
||||
WhichPlane = 2;
|
||||
}
|
||||
|
||||
// Check final candidate actually inside box
|
||||
if (Convert.ToBoolean((uint)MaxT[WhichPlane] & 0x80000000))
|
||||
{
|
||||
// Miss the box
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (i != WhichPlane)
|
||||
{
|
||||
location[i] = origin[i] + MaxT[WhichPlane] * dir[i];
|
||||
if ((location[i] < MinB[i]) ||
|
||||
(location[i] > MaxB[i]))
|
||||
{
|
||||
// On this plane we're outside the box extents, so
|
||||
// we miss the box
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Choose the normal to be the plane normal facing into the ray
|
||||
normal = Vector3.Zero;
|
||||
normal[WhichPlane] = (float)((dir[WhichPlane] > 0) ? -1.0 : 1.0);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,615 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2003-2004 Eran Kampf eran@ekampf.com http://www.ekampf.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a 2-dimentional single-precision floating point matrix.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public struct Matrix2 : ICloneable
|
||||
{
|
||||
#region Private Fields
|
||||
private float _m11, _m12;
|
||||
private float _m21, _m22;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix2"/> structure with the specified values.
|
||||
/// </summary>
|
||||
public Matrix2(float m11, float m12, float m21, float m22)
|
||||
{
|
||||
_m11 = m11; _m12 = m12;
|
||||
_m21 = m21; _m22 = m22;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix2"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="elements">An array containing the matrix values in row-major order.</param>
|
||||
public Matrix2(float[] elements)
|
||||
{
|
||||
Debug.Assert(elements != null);
|
||||
Debug.Assert(elements.Length >= 4);
|
||||
|
||||
_m11 = elements[0]; _m12 = elements[1];
|
||||
_m21 = elements[2]; _m22 = elements[3];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix4"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="elements">An array containing the matrix values in row-major order.</param>
|
||||
public Matrix2(List<float> elements)
|
||||
{
|
||||
Debug.Assert(elements != null);
|
||||
Debug.Assert(elements.Count >= 4);
|
||||
|
||||
_m11 = elements[0]; _m12 = elements[1];
|
||||
_m21 = elements[2]; _m22 = elements[3];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix2"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="column1">A <see cref="Vector2"/> instance holding values for the first column.</param>
|
||||
/// <param name="column2">A <see cref="Vector2"/> instance holding values for the second column.</param>
|
||||
public Matrix2(Vector2 column1, Vector2 column2)
|
||||
{
|
||||
_m11 = column1.X; _m12 = column2.X;
|
||||
_m21 = column1.Y; _m22 = column2.Y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix2"/> class using a given matrix.
|
||||
/// </summary>
|
||||
public Matrix2(Matrix2 m)
|
||||
{
|
||||
_m11 = m.M11; _m12 = m.M12;
|
||||
_m21 = m.M21; _m22 = m.M22;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// 4-dimentional single-precision floating point zero matrix.
|
||||
/// </summary>
|
||||
public static readonly Matrix2 Zero = new Matrix2(0, 0, 0, 0);
|
||||
/// <summary>
|
||||
/// 4-dimentional single-precision floating point identity matrix.
|
||||
/// </summary>
|
||||
public static readonly Matrix2 Identity = new Matrix2(1, 0, 0, 1);
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M11
|
||||
{
|
||||
get { return _m11; }
|
||||
set { _m11 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M12
|
||||
{
|
||||
get { return _m12; }
|
||||
set { _m12 = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M21
|
||||
{
|
||||
get { return _m21; }
|
||||
set { _m21 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M22
|
||||
{
|
||||
get { return _m22; }
|
||||
set { _m22 = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the matrix's trace value.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float Trace
|
||||
{
|
||||
get
|
||||
{
|
||||
return _m11 + _m22;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Matrix2"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Matrix2"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new Matrix2(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Matrix2"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Matrix2"/> object this method creates.</returns>
|
||||
public Matrix2 Clone()
|
||||
{
|
||||
return new Matrix2(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Parse Methods
|
||||
private const string regularExp = @"2x2\s*\[(?<m11>.*),(?<m12>.*),(?<m21>.*),(?<m22>.*)\]";
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Matrix2"/> equivalent.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Matrix2"/>.</param>
|
||||
/// <returns>A <see cref="Matrix2"/> that represents the vector specified by the <paramref name="value"/> parameter.</returns>
|
||||
/// <remarks>
|
||||
/// The string should be in the following form: "2x2..matrix elements..>".<br/>
|
||||
/// Exmaple : "2x2[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]"
|
||||
/// </remarks>
|
||||
public static Matrix2 Parse(string value)
|
||||
{
|
||||
Regex r = new Regex(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
return new Matrix2(
|
||||
float.Parse(m.Result("${m11}")),
|
||||
float.Parse(m.Result("${m12}")),
|
||||
|
||||
float.Parse(m.Result("${m21}")),
|
||||
float.Parse(m.Result("${m22}"))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsuccessful Match.");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Matrix2"/> equivalent.
|
||||
/// A return value indicates whether the conversion succeeded or failed.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Matrix2"/>.</param>
|
||||
/// <param name="result">
|
||||
/// When this method returns, if the conversion succeeded,
|
||||
/// contains a <see cref="Matrix2"/> representing the vector specified by <paramref name="value"/>.
|
||||
/// </param>
|
||||
/// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The string should be in the following form: "2x2..matrix elements..>".<br/>
|
||||
/// Exmaple : "2x2[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]"
|
||||
/// </remarks>
|
||||
public static bool TryParse(string value, out Matrix2 result)
|
||||
{
|
||||
Regex r = new Regex(regularExp, RegexOptions.Singleline);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
result = new Matrix2(
|
||||
float.Parse(m.Result("${m11}")),
|
||||
float.Parse(m.Result("${m12}")),
|
||||
|
||||
float.Parse(m.Result("${m21}")),
|
||||
float.Parse(m.Result("${m22}"))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result = Matrix2.Zero;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Matrix Arithmetics
|
||||
/// <summary>
|
||||
/// Adds two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the sum.</returns>
|
||||
public static Matrix2 Add(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return new Matrix2(
|
||||
left.M11 + right.M11, left.M12 + right.M12,
|
||||
left.M21 + right.M21, left.M22 + right.M22
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the sum.</returns>
|
||||
public static Matrix2 Add(Matrix2 matrix, float scalar)
|
||||
{
|
||||
return new Matrix2(
|
||||
matrix.M11 + scalar, matrix.M12 + scalar,
|
||||
matrix.M21 + scalar, matrix.M22 + scalar
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds two matrices and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Matrix2"/> instance to hold the result.</param>
|
||||
public static void Add(Matrix2 left, Matrix2 right, ref Matrix2 result)
|
||||
{
|
||||
result.M11 = left.M11 + right.M11;
|
||||
result.M12 = left.M12 + right.M12;
|
||||
|
||||
result.M21 = left.M21 + right.M21;
|
||||
result.M22 = left.M22 + right.M22;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Matrix2"/> instance to hold the result.</param>
|
||||
public static void Add(Matrix2 matrix, float scalar, ref Matrix2 result)
|
||||
{
|
||||
result.M11 = matrix.M11 + scalar;
|
||||
result.M12 = matrix.M12 + scalar;
|
||||
|
||||
result.M21 = matrix.M21 + scalar;
|
||||
result.M22 = matrix.M22 + scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance to subtract from.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance to subtract.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the difference.</returns>
|
||||
/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
|
||||
public static Matrix2 Subtract(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return new Matrix2(
|
||||
left.M11 - right.M11, left.M12 - right.M12,
|
||||
left.M21 - right.M21, left.M22 - right.M22
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the difference.</returns>
|
||||
public static Matrix2 Subtract(Matrix2 matrix, float scalar)
|
||||
{
|
||||
return new Matrix2(
|
||||
matrix.M11 - scalar, matrix.M12 - scalar,
|
||||
matrix.M21 - scalar, matrix.M22 - scalar
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance to subtract from.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance to subtract.</param>
|
||||
/// <param name="result">A <see cref="Matrix2"/> instance to hold the result.</param>
|
||||
/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
|
||||
public static void Subtract(Matrix2 left, Matrix2 right, ref Matrix2 result)
|
||||
{
|
||||
result.M11 = left.M11 - right.M11;
|
||||
result.M12 = left.M12 - right.M12;
|
||||
|
||||
result.M21 = left.M21 - right.M21;
|
||||
result.M22 = left.M22 - right.M22;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Matrix2"/> instance to hold the result.</param>
|
||||
public static void Subtract(Matrix2 matrix, float scalar, ref Matrix2 result)
|
||||
{
|
||||
result.M11 = matrix.M11 - scalar;
|
||||
result.M12 = matrix.M12 - scalar;
|
||||
|
||||
result.M21 = matrix.M21 - scalar;
|
||||
result.M22 = matrix.M22 - scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the result.</returns>
|
||||
public static Matrix2 Multiply(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return new Matrix2(
|
||||
left.M11 * right.M11 + left.M12 * right.M21,
|
||||
left.M11 * right.M12 + left.M12 * right.M22,
|
||||
left.M21 * right.M11 + left.M22 * right.M21,
|
||||
left.M21 * right.M12 + left.M22 * right.M22
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Matrix2"/> instance to hold the result.</param>
|
||||
public static void Multiply(Matrix2 left, Matrix2 right, ref Matrix2 result)
|
||||
{
|
||||
result.M11 = left.M11 * right.M11 + left.M12 * right.M21;
|
||||
result.M12 = left.M11 * right.M12 + left.M12 * right.M22;
|
||||
|
||||
result.M21 = left.M21 * right.M11 + left.M22 * right.M21;
|
||||
result.M22 = left.M21 * right.M12 + left.M22 * right.M22;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the result.</returns>
|
||||
public static Vector2 Transform(Matrix2 matrix, Vector2 vector)
|
||||
{
|
||||
return new Vector2(
|
||||
(matrix.M11 * vector.X) + (matrix.M12 * vector.Y),
|
||||
(matrix.M21 * vector.X) + (matrix.M22 * vector.Y));
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix and put the result in a vector.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
public static void Transform(Matrix2 matrix, Vector2 vector, ref Vector2 result)
|
||||
{
|
||||
result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y);
|
||||
result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Transposes a matrix.
|
||||
/// </summary>
|
||||
/// <param name="m">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the transposed matrix.</returns>
|
||||
public static Matrix2 Transpose(Matrix2 m)
|
||||
{
|
||||
Matrix2 t = new Matrix2(m);
|
||||
t.Transpose();
|
||||
return t;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region System.Object overrides
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return
|
||||
_m11.GetHashCode() ^ _m12.GetHashCode() ^
|
||||
_m21.GetHashCode() ^ _m22.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="obj"/> is a <see cref="Matrix2"/> and has the same values as this instance; otherwise, <see langword="false"/>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Matrix2)
|
||||
{
|
||||
Matrix2 m = (Matrix2)obj;
|
||||
return
|
||||
(_m11 == m.M11) && (_m12 == m.M12) &&
|
||||
(_m21 == m.M21) && (_m22 == m.M22);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("2x2[{0}, {1}, {2}, {3}]",
|
||||
_m11, _m12, _m21, _m22);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Calculates the determinant value of the matrix.
|
||||
/// </summary>
|
||||
/// <returns>The determinant value of the matrix.</returns>
|
||||
public float GetDeterminant()
|
||||
{
|
||||
return (_m11 * _m22) - (_m12 * _m21);
|
||||
}
|
||||
/// <summary>
|
||||
/// Transposes this matrix.
|
||||
/// </summary>
|
||||
public void Transpose()
|
||||
{
|
||||
MathFunctions.Swap(ref _m12, ref _m21);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Comparison Operators
|
||||
/// <summary>
|
||||
/// Tests whether two specified matrices are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two matrices are equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator ==(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return ValueType.Equals(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two specified matrices are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two matrices are not equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator !=(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return !ValueType.Equals(left, right);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Binary Operators
|
||||
/// <summary>
|
||||
/// Adds two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the sum.</returns>
|
||||
public static Matrix2 operator +(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return Matrix2.Add(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the sum.</returns>
|
||||
public static Matrix2 operator +(Matrix2 matrix, float scalar)
|
||||
{
|
||||
return Matrix2.Add(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the sum.</returns>
|
||||
public static Matrix2 operator +(float scalar, Matrix2 matrix)
|
||||
{
|
||||
return Matrix2.Add(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the difference.</returns>
|
||||
public static Matrix2 operator -(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return Matrix2.Subtract(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the difference.</returns>
|
||||
public static Matrix2 operator -(Matrix2 matrix, float scalar)
|
||||
{
|
||||
return Matrix2.Subtract(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the result.</returns>
|
||||
public static Matrix2 operator *(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return Matrix2.Multiply(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix2"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the result.</returns>
|
||||
public static Vector2 operator *(Matrix2 matrix, Vector2 vector)
|
||||
{
|
||||
return Matrix2.Transform(matrix, vector);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Indexing Operators
|
||||
/// <summary>
|
||||
/// Indexer allowing to access the matrix elements by an index
|
||||
/// where index = 2*row + column.
|
||||
/// </summary>
|
||||
public unsafe float this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= 4)
|
||||
throw new IndexOutOfRangeException("Invalid matrix index!");
|
||||
|
||||
fixed (float* f = &_m11)
|
||||
{
|
||||
return *(f + index);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= 4)
|
||||
throw new IndexOutOfRangeException("Invalid matrix index!");
|
||||
|
||||
fixed (float* f = &_m11)
|
||||
{
|
||||
*(f + index) = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Indexer allowing to access the matrix elements by row and column.
|
||||
/// </summary>
|
||||
public float this[int row, int column]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this[(row - 1) * 2 + (column - 1)];
|
||||
}
|
||||
set
|
||||
{
|
||||
this[(row - 1) * 2 + (column - 1)] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,808 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2003-2004 Eran Kampf eran@ekampf.com http://www.ekampf.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a 3-dimentional single-precision floating point matrix.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public struct Matrix3 : ICloneable
|
||||
{
|
||||
#region Private Fields
|
||||
private float _m11, _m12, _m13;
|
||||
private float _m21, _m22, _m23;
|
||||
private float _m31, _m32, _m33;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix3"/> structure with the specified values.
|
||||
/// </summary>
|
||||
public Matrix3(float m11, float m12, float m13, float m21, float m22, float m23, float m31, float m32, float m33)
|
||||
{
|
||||
_m11 = m11; _m12 = m12; _m13 = m13;
|
||||
_m21 = m21; _m22 = m22; _m23 = m23;
|
||||
_m31 = m31; _m32 = m32; _m33 = m33;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix3"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="elements">An array containing the matrix values in row-major order.</param>
|
||||
public Matrix3(float[] elements)
|
||||
{
|
||||
Debug.Assert(elements != null);
|
||||
Debug.Assert(elements.Length >= 9);
|
||||
|
||||
_m11 = elements[0]; _m12 = elements[1]; _m13 = elements[2];
|
||||
_m21 = elements[3]; _m22 = elements[4]; _m23 = elements[5];
|
||||
_m31 = elements[6]; _m32 = elements[7]; _m33 = elements[8];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix4"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="elements">An array containing the matrix values in row-major order.</param>
|
||||
public Matrix3(List<float> elements)
|
||||
{
|
||||
Debug.Assert(elements != null);
|
||||
Debug.Assert(elements.Count >= 9);
|
||||
|
||||
_m11 = elements[0]; _m12 = elements[1]; _m13 = elements[2];
|
||||
_m21 = elements[3]; _m22 = elements[4]; _m23 = elements[5];
|
||||
_m31 = elements[6]; _m32 = elements[7]; _m33 = elements[8];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix3"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="column1">A <see cref="Vector3"/> instance holding values for the first column.</param>
|
||||
/// <param name="column2">A <see cref="Vector3"/> instance holding values for the second column.</param>
|
||||
/// <param name="column3">A <see cref="Vector3"/> instance holding values for the third column.</param>
|
||||
public Matrix3(Vector3 column1, Vector3 column2, Vector3 column3)
|
||||
{
|
||||
_m11 = column1.X; _m12 = column2.X; _m13 = column3.X;
|
||||
_m21 = column1.Y; _m22 = column2.Y; _m23 = column3.Y;
|
||||
_m31 = column1.Z; _m32 = column2.Z; _m33 = column3.Z;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix3"/> class using a given matrix.
|
||||
/// </summary>
|
||||
public Matrix3(Matrix3 m)
|
||||
{
|
||||
_m11 = m.M11; _m12 = m.M12; _m13 = m.M13;
|
||||
_m21 = m.M21; _m22 = m.M22; _m23 = m.M23;
|
||||
_m31 = m.M31; _m32 = m.M32; _m33 = m.M33;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// 4-dimentional single-precision floating point zero matrix.
|
||||
/// </summary>
|
||||
public static readonly Matrix3 Zero = new Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
/// <summary>
|
||||
/// 4-dimentional single-precision floating point identity matrix.
|
||||
/// </summary>
|
||||
public static readonly Matrix3 Identity = new Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1);
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M11
|
||||
{
|
||||
get { return _m11; }
|
||||
set { _m11 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M12
|
||||
{
|
||||
get { return _m12; }
|
||||
set { _m12 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,3] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M13
|
||||
{
|
||||
get { return _m13; }
|
||||
set { _m13 = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M21
|
||||
{
|
||||
get { return _m21; }
|
||||
set { _m21 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M22
|
||||
{
|
||||
get { return _m22; }
|
||||
set { _m22 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,3] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M23
|
||||
{
|
||||
get { return _m23; }
|
||||
set { _m23 = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [3,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M31
|
||||
{
|
||||
get { return _m31; }
|
||||
set { _m31 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [3,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M32
|
||||
{
|
||||
get { return _m32; }
|
||||
set { _m32 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [3,3] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M33
|
||||
{
|
||||
get { return _m33; }
|
||||
set { _m33 = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the matrix's trace value.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float Trace
|
||||
{
|
||||
get
|
||||
{
|
||||
return _m11 + _m22 + _m33;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Matrix3"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Matrix3"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new Matrix3(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Matrix3"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Matrix3"/> object this method creates.</returns>
|
||||
public Matrix3 Clone()
|
||||
{
|
||||
return new Matrix3(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Parse Methods
|
||||
private const string regularExp = @"3x3\s*\[(?<m11>.*),(?<m12>.*),(?<m13>.*),(?<m21>.*),(?<m22>.*),(?<m23>.*),(?<m31>.*),(?<m32>.*),(?<m33>.*)\]";
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Matrix3"/> equivalent.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Matrix3"/>.</param>
|
||||
/// <returns>A <see cref="Matrix3"/> that represents the vector specified by the <paramref name="value"/> parameter.</returns>
|
||||
/// <remarks>
|
||||
/// The string should be in the following form: "3x3..matrix elements..>".<br/>
|
||||
/// Exmaple : "3x3[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]"
|
||||
/// </remarks>
|
||||
public static Matrix3 Parse(string value)
|
||||
{
|
||||
Regex r = new Regex(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
return new Matrix3(
|
||||
float.Parse(m.Result("${m11}")),
|
||||
float.Parse(m.Result("${m12}")),
|
||||
float.Parse(m.Result("${m13}")),
|
||||
|
||||
float.Parse(m.Result("${m21}")),
|
||||
float.Parse(m.Result("${m22}")),
|
||||
float.Parse(m.Result("${m23}")),
|
||||
|
||||
float.Parse(m.Result("${m31}")),
|
||||
float.Parse(m.Result("${m32}")),
|
||||
float.Parse(m.Result("${m33}"))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsuccessful Match.");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Matrix3"/> equivalent.
|
||||
/// A return value indicates whether the conversion succeeded or failed.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Matrix3"/>.</param>
|
||||
/// <param name="result">
|
||||
/// When this method returns, if the conversion succeeded,
|
||||
/// contains a <see cref="Matrix3"/> representing the vector specified by <paramref name="value"/>.
|
||||
/// </param>
|
||||
/// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The string should be in the following form: "3x3..matrix elements..>".<br/>
|
||||
/// Exmaple : "3x3[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]"
|
||||
/// </remarks>
|
||||
public static bool TryParse(string value, out Matrix3 result)
|
||||
{
|
||||
Regex r = new Regex(regularExp, RegexOptions.Singleline);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
result = new Matrix3(
|
||||
float.Parse(m.Result("${m11}")),
|
||||
float.Parse(m.Result("${m12}")),
|
||||
float.Parse(m.Result("${m13}")),
|
||||
|
||||
float.Parse(m.Result("${m21}")),
|
||||
float.Parse(m.Result("${m22}")),
|
||||
float.Parse(m.Result("${m23}")),
|
||||
|
||||
float.Parse(m.Result("${m31}")),
|
||||
float.Parse(m.Result("${m32}")),
|
||||
float.Parse(m.Result("${m33}"))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result = Matrix3.Zero;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Matrix Arithmetics
|
||||
/// <summary>
|
||||
/// Adds two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the sum.</returns>
|
||||
public static Matrix3 Add(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return new Matrix3(
|
||||
left.M11 + right.M11, left.M12 + right.M12, left.M13 + right.M13,
|
||||
left.M21 + right.M21, left.M22 + right.M22, left.M23 + right.M23,
|
||||
left.M31 + right.M31, left.M32 + right.M32, left.M33 + right.M33
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the sum.</returns>
|
||||
public static Matrix3 Add(Matrix3 matrix, float scalar)
|
||||
{
|
||||
return new Matrix3(
|
||||
matrix.M11 + scalar, matrix.M12 + scalar, matrix.M13 + scalar,
|
||||
matrix.M21 + scalar, matrix.M22 + scalar, matrix.M23 + scalar,
|
||||
matrix.M31 + scalar, matrix.M32 + scalar, matrix.M33 + scalar
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds two matrices and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Matrix3"/> instance to hold the result.</param>
|
||||
public static void Add(Matrix3 left, Matrix3 right, ref Matrix3 result)
|
||||
{
|
||||
result.M11 = left.M11 + right.M11;
|
||||
result.M12 = left.M12 + right.M12;
|
||||
result.M13 = left.M13 + right.M13;
|
||||
|
||||
result.M21 = left.M21 + right.M21;
|
||||
result.M22 = left.M22 + right.M22;
|
||||
result.M23 = left.M23 + right.M23;
|
||||
|
||||
result.M31 = left.M31 + right.M31;
|
||||
result.M32 = left.M32 + right.M32;
|
||||
result.M33 = left.M33 + right.M33;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Matrix3"/> instance to hold the result.</param>
|
||||
public static void Add(Matrix3 matrix, float scalar, ref Matrix3 result)
|
||||
{
|
||||
result.M11 = matrix.M11 + scalar;
|
||||
result.M12 = matrix.M12 + scalar;
|
||||
result.M13 = matrix.M13 + scalar;
|
||||
|
||||
result.M21 = matrix.M21 + scalar;
|
||||
result.M22 = matrix.M22 + scalar;
|
||||
result.M23 = matrix.M23 + scalar;
|
||||
|
||||
result.M31 = matrix.M31 + scalar;
|
||||
result.M32 = matrix.M32 + scalar;
|
||||
result.M33 = matrix.M33 + scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance to subtract from.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance to subtract.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the difference.</returns>
|
||||
/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
|
||||
public static Matrix3 Subtract(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return new Matrix3(
|
||||
left.M11 - right.M11, left.M12 - right.M12, left.M13 - right.M13,
|
||||
left.M21 - right.M21, left.M22 - right.M22, left.M23 - right.M23,
|
||||
left.M31 - right.M31, left.M32 - right.M32, left.M33 - right.M33
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the difference.</returns>
|
||||
public static Matrix3 Subtract(Matrix3 matrix, float scalar)
|
||||
{
|
||||
return new Matrix3(
|
||||
matrix.M11 - scalar, matrix.M12 - scalar, matrix.M13 - scalar,
|
||||
matrix.M21 - scalar, matrix.M22 - scalar, matrix.M23 - scalar,
|
||||
matrix.M31 - scalar, matrix.M32 - scalar, matrix.M33 - scalar
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance to subtract from.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance to subtract.</param>
|
||||
/// <param name="result">A <see cref="Matrix3"/> instance to hold the result.</param>
|
||||
/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
|
||||
public static void Subtract(Matrix3 left, Matrix3 right, ref Matrix3 result)
|
||||
{
|
||||
result.M11 = left.M11 - right.M11;
|
||||
result.M12 = left.M12 - right.M12;
|
||||
result.M13 = left.M13 - right.M13;
|
||||
|
||||
result.M21 = left.M21 - right.M21;
|
||||
result.M22 = left.M22 - right.M22;
|
||||
result.M23 = left.M23 - right.M23;
|
||||
|
||||
result.M31 = left.M31 - right.M31;
|
||||
result.M32 = left.M32 - right.M32;
|
||||
result.M33 = left.M33 - right.M33;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Matrix3"/> instance to hold the result.</param>
|
||||
public static void Subtract(Matrix3 matrix, float scalar, ref Matrix3 result)
|
||||
{
|
||||
result.M11 = matrix.M11 - scalar;
|
||||
result.M12 = matrix.M12 - scalar;
|
||||
result.M13 = matrix.M13 - scalar;
|
||||
|
||||
result.M21 = matrix.M21 - scalar;
|
||||
result.M22 = matrix.M22 - scalar;
|
||||
result.M23 = matrix.M23 - scalar;
|
||||
|
||||
result.M31 = matrix.M31 - scalar;
|
||||
result.M32 = matrix.M32 - scalar;
|
||||
result.M33 = matrix.M33 - scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the result.</returns>
|
||||
public static Matrix3 Multiply(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return new Matrix3(
|
||||
left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31,
|
||||
left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32,
|
||||
left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33,
|
||||
|
||||
left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31,
|
||||
left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32,
|
||||
left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33,
|
||||
|
||||
left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31,
|
||||
left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32,
|
||||
left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Matrix3"/> instance to hold the result.</param>
|
||||
public static void Multiply(Matrix3 left, Matrix3 right, ref Matrix3 result)
|
||||
{
|
||||
result.M11 = left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31;
|
||||
result.M12 = left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32;
|
||||
result.M13 = left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33;
|
||||
|
||||
result.M21 = left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31;
|
||||
result.M22 = left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32;
|
||||
result.M23 = left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33;
|
||||
|
||||
result.M31 = left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31;
|
||||
result.M32 = left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32;
|
||||
result.M33 = left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector3"/> instance containing the result.</returns>
|
||||
public static Vector3 Transform(Matrix3 matrix, Vector3 vector)
|
||||
{
|
||||
return new Vector3(
|
||||
(matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z),
|
||||
(matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z),
|
||||
(matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z));
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix and put the result in a vector.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector3"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Vector3"/> instance to hold the result.</param>
|
||||
public static void Transform(Matrix3 matrix, Vector3 vector, ref Vector3 result)
|
||||
{
|
||||
result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z);
|
||||
result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z);
|
||||
result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z);
|
||||
}
|
||||
/// <summary>
|
||||
/// Transposes a matrix.
|
||||
/// </summary>
|
||||
/// <param name="m">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the transposed matrix.</returns>
|
||||
public static Matrix3 Transpose(Matrix3 m)
|
||||
{
|
||||
Matrix3 t = new Matrix3(m);
|
||||
t.Transpose();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Matrix3 fromEulerAnglesZYX(float fYAngle, float fPAngle, float fRAngle)
|
||||
{
|
||||
float fCos, fSin;
|
||||
|
||||
fCos = (float)Math.Cos(fYAngle);
|
||||
fSin = (float)Math.Sin(fYAngle);
|
||||
Matrix3 kZMat = new Matrix3(fCos, -fSin, 0.0f, fSin, fCos, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
fCos = (float)Math.Cos(fPAngle);
|
||||
fSin = (float)Math.Sin(fPAngle);
|
||||
Matrix3 kYMat = new Matrix3(fCos, 0.0f, fSin, 0.0f, 1.0f, 0.0f, -fSin, 0.0f, fCos);
|
||||
|
||||
fCos = (float)Math.Cos(fRAngle);
|
||||
fSin = (float)Math.Sin(fRAngle);
|
||||
Matrix3 kXMat = new Matrix3(1.0f, 0.0f, 0.0f, 0.0f, fCos, -fSin, 0.0f, fSin, fCos);
|
||||
|
||||
return (kZMat * (kYMat * kXMat));
|
||||
}
|
||||
|
||||
public Matrix3 inverse(float fTolerance = (float)1e-06)
|
||||
{
|
||||
Matrix3 kInverse = Matrix3.Zero;
|
||||
inverse(ref kInverse, fTolerance);
|
||||
return kInverse;
|
||||
}
|
||||
bool inverse(ref Matrix3 rkInverse, float fTolerance)
|
||||
{
|
||||
// Invert a 3x3 using cofactors. This is about 8 times faster than
|
||||
// the Numerical Recipes code which uses Gaussian elimination.
|
||||
rkInverse.M11 = M22 * M33 -
|
||||
M23 * M32;
|
||||
rkInverse.M12 = M13 * M32 -
|
||||
M12 * M33;
|
||||
rkInverse.M13 = M12 * M23 -
|
||||
M13 * M22;
|
||||
rkInverse.M21 = M23 * M31 -
|
||||
M21 * M33;
|
||||
rkInverse.M22 = M11 * M33 -
|
||||
M13 * M31;
|
||||
rkInverse.M23 = M13 * M21 -
|
||||
M11 * M23;
|
||||
rkInverse.M31 = M21 * M32 -
|
||||
M22 * M31;
|
||||
rkInverse.M32 = M12 * M31 -
|
||||
M11 * M32;
|
||||
rkInverse.M33 = M11 * M22 -
|
||||
M12 * M21;
|
||||
|
||||
|
||||
float fDet =
|
||||
M11 * rkInverse.M11 +
|
||||
M12 * rkInverse.M21 +
|
||||
M13 * rkInverse.M31;
|
||||
|
||||
if (Math.Abs(fDet) <= fTolerance)
|
||||
return false;
|
||||
|
||||
float fInvDet = (float)(1.0 / fDet);
|
||||
|
||||
rkInverse.M11 *= fInvDet;
|
||||
rkInverse.M12 *= fInvDet;
|
||||
rkInverse.M13 *= fInvDet;
|
||||
rkInverse.M21 *= fInvDet;
|
||||
rkInverse.M22 *= fInvDet;
|
||||
rkInverse.M23 *= fInvDet;
|
||||
rkInverse.M31 *= fInvDet;
|
||||
rkInverse.M32 *= fInvDet;
|
||||
rkInverse.M33 *= fInvDet;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region System.Object overrides
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return
|
||||
_m11.GetHashCode() ^ _m12.GetHashCode() ^ _m13.GetHashCode() ^
|
||||
_m21.GetHashCode() ^ _m22.GetHashCode() ^ _m23.GetHashCode() ^
|
||||
_m31.GetHashCode() ^ _m32.GetHashCode() ^ _m33.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="obj"/> is a <see cref="Matrix3"/> and has the same values as this instance; otherwise, <see langword="false"/>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Matrix3)
|
||||
{
|
||||
Matrix3 m = (Matrix3)obj;
|
||||
return
|
||||
(_m11 == m.M11) && (_m12 == m.M12) && (_m13 == m.M13) &&
|
||||
(_m21 == m.M21) && (_m22 == m.M22) && (_m23 == m.M23) &&
|
||||
(_m31 == m.M31) && (_m32 == m.M32) && (_m33 == m.M33);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("3x3[{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}]",
|
||||
_m11, _m12, _m13, _m21, _m22, _m23, _m31, _m32, _m33);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Calculates the determinant value of the matrix.
|
||||
/// </summary>
|
||||
/// <returns>The determinant value of the matrix.</returns>
|
||||
public float GetDeterminant()
|
||||
{
|
||||
// rule of Sarrus
|
||||
return
|
||||
_m11 * _m22 * _m33 + _m12 * _m23 * _m31 + _m13 * _m21 * _m32 -
|
||||
_m13 * _m22 * _m31 - _m11 * _m23 * _m32 - _m12 * _m21 * _m33;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transposes this matrix.
|
||||
/// </summary>
|
||||
public void Transpose()
|
||||
{
|
||||
MathFunctions.Swap<float>(ref _m12, ref _m21);
|
||||
MathFunctions.Swap<float>(ref _m13, ref _m31);
|
||||
MathFunctions.Swap<float>(ref _m23, ref _m32);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Comparison Operators
|
||||
/// <summary>
|
||||
/// Tests whether two specified matrices are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two matrices are equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator ==(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return ValueType.Equals(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two specified matrices are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two matrices are not equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator !=(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return !ValueType.Equals(left, right);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Binary Operators
|
||||
/// <summary>
|
||||
/// Adds two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the sum.</returns>
|
||||
public static Matrix3 operator +(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return Matrix3.Add(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the sum.</returns>
|
||||
public static Matrix3 operator +(Matrix3 matrix, float scalar)
|
||||
{
|
||||
return Matrix3.Add(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the sum.</returns>
|
||||
public static Matrix3 operator +(float scalar, Matrix3 matrix)
|
||||
{
|
||||
return Matrix3.Add(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the difference.</returns>
|
||||
public static Matrix3 operator -(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return Matrix3.Subtract(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the difference.</returns>
|
||||
public static Matrix3 operator -(Matrix3 matrix, float scalar)
|
||||
{
|
||||
return Matrix3.Subtract(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the result.</returns>
|
||||
public static Matrix3 operator *(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return Matrix3.Multiply(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix3"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector3"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector3"/> instance containing the result.</returns>
|
||||
public static Vector3 operator *(Matrix3 matrix, Vector3 vector)
|
||||
{
|
||||
return Matrix3.Transform(matrix, vector);
|
||||
}
|
||||
public static Vector3 operator *(Vector3 rkPoint, Matrix3 rkMatrix)
|
||||
{
|
||||
return (Matrix3.Transpose(rkMatrix) * rkPoint);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Indexing Operators
|
||||
/// <summary>
|
||||
/// Indexer allowing to access the matrix elements by an index
|
||||
/// where index = 2*row + column.
|
||||
/// </summary>
|
||||
public unsafe float this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= 9)
|
||||
throw new IndexOutOfRangeException("Invalid matrix index!");
|
||||
|
||||
fixed (float* f = &_m11)
|
||||
{
|
||||
return *(f + index);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= 9)
|
||||
throw new IndexOutOfRangeException("Invalid matrix index!");
|
||||
|
||||
fixed (float* f = &_m11)
|
||||
{
|
||||
*(f + index) = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Indexer allowing to access the matrix elements by row and column.
|
||||
/// </summary>
|
||||
public float this[int row, int column]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this[row * 3 + column];
|
||||
}
|
||||
set
|
||||
{
|
||||
this[row * 3 + column] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,900 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2003-2004 Eran Kampf eran@ekampf.com http://www.ekampf.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a 4-dimentional single-precision floating point matrix.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public struct Matrix4 : ICloneable
|
||||
{
|
||||
#region Private Fields
|
||||
private float _m11, _m12, _m13, _m14;
|
||||
private float _m21, _m22, _m23, _m24;
|
||||
private float _m31, _m32, _m33, _m34;
|
||||
private float _m41, _m42, _m43, _m44;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix4"/> structure with the specified values.
|
||||
/// </summary>
|
||||
public Matrix4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
|
||||
{
|
||||
_m11 = m11; _m12 = m12; _m13 = m13; _m14 = m14;
|
||||
_m21 = m21; _m22 = m22; _m23 = m23; _m24 = m24;
|
||||
_m31 = m31; _m32 = m32; _m33 = m33; _m34 = m34;
|
||||
_m41 = m41; _m42 = m42; _m43 = m43; _m44 = m44;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix4"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="elements">An array containing the matrix values in row-major order.</param>
|
||||
public Matrix4(float[] elements)
|
||||
{
|
||||
Debug.Assert(elements != null);
|
||||
Debug.Assert(elements.Length >= 16);
|
||||
|
||||
_m11 = elements[0]; _m12 = elements[1]; _m13 = elements[2]; _m14 = elements[3];
|
||||
_m21 = elements[4]; _m22 = elements[5]; _m23 = elements[6]; _m24 = elements[7];
|
||||
_m31 = elements[8]; _m32 = elements[9]; _m33 = elements[10]; _m34 = elements[11];
|
||||
_m41 = elements[12]; _m42 = elements[13]; _m43 = elements[14]; _m44 = elements[15];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix4"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="elements">An array containing the matrix values in row-major order.</param>
|
||||
public Matrix4(List<float> elements)
|
||||
{
|
||||
Debug.Assert(elements != null);
|
||||
Debug.Assert(elements.Count >= 16);
|
||||
|
||||
_m11 = elements[0]; _m12 = elements[1]; _m13 = elements[2]; _m14 = elements[3];
|
||||
_m21 = elements[4]; _m22 = elements[5]; _m23 = elements[6]; _m24 = elements[7];
|
||||
_m31 = elements[8]; _m32 = elements[9]; _m33 = elements[10]; _m34 = elements[11];
|
||||
_m41 = elements[12]; _m42 = elements[13]; _m43 = elements[14]; _m44 = elements[15];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix4"/> structure with the specified values.
|
||||
/// </summary>
|
||||
/// <param name="column1">A <see cref="Vector4"/> instance holding values for the first column.</param>
|
||||
/// <param name="column2">A <see cref="Vector4"/> instance holding values for the second column.</param>
|
||||
/// <param name="column3">A <see cref="Vector4"/> instance holding values for the third column.</param>
|
||||
/// <param name="column4">A <see cref="Vector4"/> instance holding values for the fourth column.</param>
|
||||
public Matrix4(Vector4 column1, Vector4 column2, Vector4 column3, Vector4 column4)
|
||||
{
|
||||
_m11 = column1.X; _m12 = column2.X; _m13 = column3.X; _m14 = column4.X;
|
||||
_m21 = column1.Y; _m22 = column2.Y; _m23 = column3.Y; _m24 = column4.Y;
|
||||
_m31 = column1.Z; _m32 = column2.Z; _m33 = column3.Z; _m34 = column4.Z;
|
||||
_m41 = column1.W; _m42 = column2.W; _m43 = column3.W; _m44 = column4.W;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Matrix4"/> class using a given matrix.
|
||||
/// </summary>
|
||||
public Matrix4(Matrix4 m)
|
||||
{
|
||||
_m11 = m.M11; _m12 = m.M12; _m13 = m.M13; _m14 = m.M14;
|
||||
_m21 = m.M21; _m22 = m.M22; _m23 = m.M23; _m24 = m.M24;
|
||||
_m31 = m.M31; _m32 = m.M32; _m33 = m.M33; _m34 = m.M34;
|
||||
_m41 = m.M41; _m42 = m.M42; _m43 = m.M43; _m44 = m.M44;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// 4-dimentional single-precision floating point zero matrix.
|
||||
/// </summary>
|
||||
public static readonly Matrix4 Zero = new Matrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
/// <summary>
|
||||
/// 4-dimentional single-precision floating point identity matrix.
|
||||
/// </summary>
|
||||
public static readonly Matrix4 Identity = new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M11
|
||||
{
|
||||
get { return _m11; }
|
||||
set { _m11 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M12
|
||||
{
|
||||
get { return _m12; }
|
||||
set { _m12 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,3] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M13
|
||||
{
|
||||
get { return _m13; }
|
||||
set { _m13 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [1,4] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M14
|
||||
{
|
||||
get { return _m14; }
|
||||
set { _m14 = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M21
|
||||
{
|
||||
get { return _m21; }
|
||||
set { _m21 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M22
|
||||
{
|
||||
get { return _m22; }
|
||||
set { _m22 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,3] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M23
|
||||
{
|
||||
get { return _m23; }
|
||||
set { _m23 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [2,4] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M24
|
||||
{
|
||||
get { return _m24; }
|
||||
set { _m24 = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [3,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M31
|
||||
{
|
||||
get { return _m31; }
|
||||
set { _m31 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [3,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M32
|
||||
{
|
||||
get { return _m32; }
|
||||
set { _m32 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [3,3] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M33
|
||||
{
|
||||
get { return _m33; }
|
||||
set { _m33 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [3,4] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M34
|
||||
{
|
||||
get { return _m34; }
|
||||
set { _m34 = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [4,1] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M41
|
||||
{
|
||||
get { return _m41; }
|
||||
set { _m41 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [4,2] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M42
|
||||
{
|
||||
get { return _m42; }
|
||||
set { _m42 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [4,3] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M43
|
||||
{
|
||||
get { return _m43; }
|
||||
set { _m43 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the [4,4] matrix element.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float M44
|
||||
{
|
||||
get { return _m44; }
|
||||
set { _m44 = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the matrix's trace value.
|
||||
/// </summary>
|
||||
/// <value>A single-precision floating-point number.</value>
|
||||
public float Trace
|
||||
{
|
||||
get
|
||||
{
|
||||
return _m11 + _m22 + _m33 + _m44;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Matrix4"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Matrix4"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new Matrix4(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Matrix4"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Matrix4"/> object this method creates.</returns>
|
||||
public Matrix4 Clone()
|
||||
{
|
||||
return new Matrix4(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Parse Methods
|
||||
private const string regularExp = @"4x4\s*\[(?<m11>.*),(?<m12>.*),(?<m13>.*),(?<m14>.*),(?<m21>.*),(?<m22>.*),(?<m23>.*),(?<m24>.*),(?<m31>.*),(?<m32>.*),(?<m33>.*),(?<m34>.*),(?<m41>.*),(?<m42>.*),(?<m43>.*),(?<m44>.*)\]";
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Matrix4"/> equivalent.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Matrix4"/>.</param>
|
||||
/// <returns>A <see cref="Matrix4"/> that represents the vector specified by the <paramref name="value"/> parameter.</returns>
|
||||
/// <remarks>
|
||||
/// The string should be in the following form: "4x4..matrix elements..>".<br/>
|
||||
/// Exmaple : "4x4[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]"
|
||||
/// </remarks>
|
||||
public static Matrix4 Parse(string value)
|
||||
{
|
||||
Regex r = new Regex(regularExp, RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
return new Matrix4(
|
||||
float.Parse(m.Result("${m11}")),
|
||||
float.Parse(m.Result("${m12}")),
|
||||
float.Parse(m.Result("${m13}")),
|
||||
float.Parse(m.Result("${m14}")),
|
||||
|
||||
float.Parse(m.Result("${m21}")),
|
||||
float.Parse(m.Result("${m22}")),
|
||||
float.Parse(m.Result("${m23}")),
|
||||
float.Parse(m.Result("${m24}")),
|
||||
|
||||
float.Parse(m.Result("${m31}")),
|
||||
float.Parse(m.Result("${m32}")),
|
||||
float.Parse(m.Result("${m33}")),
|
||||
float.Parse(m.Result("${m34}")),
|
||||
|
||||
float.Parse(m.Result("${m41}")),
|
||||
float.Parse(m.Result("${m42}")),
|
||||
float.Parse(m.Result("${m43}")),
|
||||
float.Parse(m.Result("${m44}"))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsuccessful Match.");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Matrix4"/> equivalent.
|
||||
/// A return value indicates whether the conversion succeeded or failed.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Matrix4"/>.</param>
|
||||
/// <param name="result">
|
||||
/// When this method returns, if the conversion succeeded,
|
||||
/// contains a <see cref="Matrix4"/> representing the vector specified by <paramref name="value"/>.
|
||||
/// </param>
|
||||
/// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The string should be in the following form: "4x4..matrix elements..>".<br/>
|
||||
/// Exmaple : "4x4[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]"
|
||||
/// </remarks>
|
||||
public static bool TryParse(string value, out Matrix4 result)
|
||||
{
|
||||
Regex r = new Regex(regularExp, RegexOptions.Singleline);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
result = new Matrix4(
|
||||
float.Parse(m.Result("${m11}")),
|
||||
float.Parse(m.Result("${m12}")),
|
||||
float.Parse(m.Result("${m13}")),
|
||||
float.Parse(m.Result("${m14}")),
|
||||
|
||||
float.Parse(m.Result("${m21}")),
|
||||
float.Parse(m.Result("${m22}")),
|
||||
float.Parse(m.Result("${m23}")),
|
||||
float.Parse(m.Result("${m24}")),
|
||||
|
||||
float.Parse(m.Result("${m31}")),
|
||||
float.Parse(m.Result("${m32}")),
|
||||
float.Parse(m.Result("${m33}")),
|
||||
float.Parse(m.Result("${m34}")),
|
||||
|
||||
float.Parse(m.Result("${m41}")),
|
||||
float.Parse(m.Result("${m42}")),
|
||||
float.Parse(m.Result("${m43}")),
|
||||
float.Parse(m.Result("${m44}"))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result = Matrix4.Zero;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Matrix Arithmetics
|
||||
/// <summary>
|
||||
/// Adds two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the sum.</returns>
|
||||
public static Matrix4 Add(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return new Matrix4(
|
||||
left.M11 + right.M11, left.M12 + right.M12, left.M13 + right.M13, left.M14 + right.M14,
|
||||
left.M21 + right.M21, left.M22 + right.M22, left.M23 + right.M23, left.M24 + right.M24,
|
||||
left.M31 + right.M31, left.M32 + right.M32, left.M33 + right.M33, left.M34 + right.M34,
|
||||
left.M41 + right.M41, left.M42 + right.M42, left.M43 + right.M43, left.M44 + right.M44
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the sum.</returns>
|
||||
public static Matrix4 Add(Matrix4 matrix, float scalar)
|
||||
{
|
||||
return new Matrix4(
|
||||
matrix.M11 + scalar, matrix.M12 + scalar, matrix.M13 + scalar, matrix.M14 + scalar,
|
||||
matrix.M21 + scalar, matrix.M22 + scalar, matrix.M23 + scalar, matrix.M24 + scalar,
|
||||
matrix.M31 + scalar, matrix.M32 + scalar, matrix.M33 + scalar, matrix.M34 + scalar,
|
||||
matrix.M41 + scalar, matrix.M42 + scalar, matrix.M43 + scalar, matrix.M44 + scalar
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds two matrices and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Matrix4"/> instance to hold the result.</param>
|
||||
public static void Add(Matrix4 left, Matrix4 right, ref Matrix4 result)
|
||||
{
|
||||
result.M11 = left.M11 + right.M11;
|
||||
result.M12 = left.M12 + right.M12;
|
||||
result.M13 = left.M13 + right.M13;
|
||||
result.M14 = left.M14 + right.M14;
|
||||
|
||||
result.M21 = left.M21 + right.M21;
|
||||
result.M22 = left.M22 + right.M22;
|
||||
result.M23 = left.M23 + right.M23;
|
||||
result.M24 = left.M24 + right.M24;
|
||||
|
||||
result.M31 = left.M31 + right.M31;
|
||||
result.M32 = left.M32 + right.M32;
|
||||
result.M33 = left.M33 + right.M33;
|
||||
result.M34 = left.M34 + right.M34;
|
||||
|
||||
result.M41 = left.M41 + right.M41;
|
||||
result.M42 = left.M42 + right.M42;
|
||||
result.M43 = left.M43 + right.M43;
|
||||
result.M44 = left.M44 + right.M44;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Matrix4"/> instance to hold the result.</param>
|
||||
public static void Add(Matrix4 matrix, float scalar, ref Matrix4 result)
|
||||
{
|
||||
result.M11 = matrix.M11 + scalar;
|
||||
result.M12 = matrix.M12 + scalar;
|
||||
result.M13 = matrix.M13 + scalar;
|
||||
result.M14 = matrix.M14 + scalar;
|
||||
|
||||
result.M21 = matrix.M21 + scalar;
|
||||
result.M22 = matrix.M22 + scalar;
|
||||
result.M23 = matrix.M23 + scalar;
|
||||
result.M24 = matrix.M24 + scalar;
|
||||
|
||||
result.M31 = matrix.M31 + scalar;
|
||||
result.M32 = matrix.M32 + scalar;
|
||||
result.M33 = matrix.M33 + scalar;
|
||||
result.M34 = matrix.M34 + scalar;
|
||||
|
||||
result.M41 = matrix.M41 + scalar;
|
||||
result.M42 = matrix.M42 + scalar;
|
||||
result.M43 = matrix.M43 + scalar;
|
||||
result.M44 = matrix.M44 + scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance to subtract from.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance to subtract.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the difference.</returns>
|
||||
/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
|
||||
public static Matrix4 Subtract(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return new Matrix4(
|
||||
left.M11 - right.M11, left.M12 - right.M12, left.M13 - right.M13, left.M14 - right.M14,
|
||||
left.M21 - right.M21, left.M22 - right.M22, left.M23 - right.M23, left.M24 - right.M24,
|
||||
left.M31 - right.M31, left.M32 - right.M32, left.M33 - right.M33, left.M34 - right.M34,
|
||||
left.M41 - right.M41, left.M42 - right.M42, left.M43 - right.M43, left.M44 - right.M44
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the difference.</returns>
|
||||
public static Matrix4 Subtract(Matrix4 matrix, float scalar)
|
||||
{
|
||||
return new Matrix4(
|
||||
matrix.M11 - scalar, matrix.M12 - scalar, matrix.M13 - scalar, matrix.M14 - scalar,
|
||||
matrix.M21 - scalar, matrix.M22 - scalar, matrix.M23 - scalar, matrix.M24 - scalar,
|
||||
matrix.M31 - scalar, matrix.M32 - scalar, matrix.M33 - scalar, matrix.M34 - scalar,
|
||||
matrix.M41 - scalar, matrix.M42 - scalar, matrix.M43 - scalar, matrix.M44 - scalar
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance to subtract from.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance to subtract.</param>
|
||||
/// <param name="result">A <see cref="Matrix4"/> instance to hold the result.</param>
|
||||
/// <remarks>result[x][y] = left[x][y] - right[x][y]</remarks>
|
||||
public static void Subtract(Matrix4 left, Matrix4 right, ref Matrix4 result)
|
||||
{
|
||||
result.M11 = left.M11 - right.M11;
|
||||
result.M12 = left.M12 - right.M12;
|
||||
result.M13 = left.M13 - right.M13;
|
||||
result.M14 = left.M14 - right.M14;
|
||||
|
||||
result.M21 = left.M21 - right.M21;
|
||||
result.M22 = left.M22 - right.M22;
|
||||
result.M23 = left.M23 - right.M23;
|
||||
result.M24 = left.M24 - right.M24;
|
||||
|
||||
result.M31 = left.M31 - right.M31;
|
||||
result.M32 = left.M32 - right.M32;
|
||||
result.M33 = left.M33 - right.M33;
|
||||
result.M34 = left.M34 - right.M34;
|
||||
|
||||
result.M41 = left.M41 - right.M41;
|
||||
result.M42 = left.M42 - right.M42;
|
||||
result.M43 = left.M43 - right.M43;
|
||||
result.M44 = left.M44 - right.M44;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Matrix4"/> instance to hold the result.</param>
|
||||
public static void Subtract(Matrix4 matrix, float scalar, ref Matrix4 result)
|
||||
{
|
||||
result.M11 = matrix.M11 - scalar;
|
||||
result.M12 = matrix.M12 - scalar;
|
||||
result.M13 = matrix.M13 - scalar;
|
||||
result.M14 = matrix.M14 - scalar;
|
||||
|
||||
result.M21 = matrix.M21 - scalar;
|
||||
result.M22 = matrix.M22 - scalar;
|
||||
result.M23 = matrix.M23 - scalar;
|
||||
result.M24 = matrix.M24 - scalar;
|
||||
|
||||
result.M31 = matrix.M31 - scalar;
|
||||
result.M32 = matrix.M32 - scalar;
|
||||
result.M33 = matrix.M33 - scalar;
|
||||
result.M34 = matrix.M34 - scalar;
|
||||
|
||||
result.M41 = matrix.M41 - scalar;
|
||||
result.M42 = matrix.M42 - scalar;
|
||||
result.M43 = matrix.M43 - scalar;
|
||||
result.M44 = matrix.M44 - scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the result.</returns>
|
||||
public static Matrix4 Multiply(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return new Matrix4(
|
||||
left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31 + left.M14 * right.M41,
|
||||
left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32 + left.M14 * right.M42,
|
||||
left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33 + left.M14 * right.M43,
|
||||
left.M11 * right.M14 + left.M12 * right.M24 + left.M13 * right.M34 + left.M14 * right.M44,
|
||||
|
||||
left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31 + left.M24 * right.M41,
|
||||
left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32 + left.M24 * right.M42,
|
||||
left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33 + left.M24 * right.M43,
|
||||
left.M21 * right.M14 + left.M22 * right.M24 + left.M23 * right.M34 + left.M24 * right.M44,
|
||||
|
||||
left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31 + left.M34 * right.M41,
|
||||
left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32 + left.M34 * right.M42,
|
||||
left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33 + left.M34 * right.M43,
|
||||
left.M31 * right.M14 + left.M32 * right.M24 + left.M33 * right.M34 + left.M34 * right.M44,
|
||||
|
||||
left.M41 * right.M11 + left.M42 * right.M21 + left.M43 * right.M31 + left.M44 * right.M41,
|
||||
left.M41 * right.M12 + left.M42 * right.M22 + left.M43 * right.M32 + left.M44 * right.M42,
|
||||
left.M41 * right.M13 + left.M42 * right.M23 + left.M43 * right.M33 + left.M44 * right.M43,
|
||||
left.M41 * right.M14 + left.M42 * right.M24 + left.M43 * right.M34 + left.M44 * right.M44
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices and put the result in a third matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Matrix4"/> instance to hold the result.</param>
|
||||
public static void Multiply(Matrix4 left, Matrix4 right, ref Matrix4 result)
|
||||
{
|
||||
result.M11 = left.M11 * right.M11 + left.M12 * right.M21 + left.M13 * right.M31 + left.M14 * right.M41;
|
||||
result.M12 = left.M11 * right.M12 + left.M12 * right.M22 + left.M13 * right.M32 + left.M14 * right.M42;
|
||||
result.M13 = left.M11 * right.M13 + left.M12 * right.M23 + left.M13 * right.M33 + left.M14 * right.M43;
|
||||
result.M14 = left.M11 * right.M14 + left.M12 * right.M24 + left.M13 * right.M34 + left.M14 * right.M44;
|
||||
|
||||
result.M21 = left.M21 * right.M11 + left.M22 * right.M21 + left.M23 * right.M31 + left.M24 * right.M41;
|
||||
result.M22 = left.M21 * right.M12 + left.M22 * right.M22 + left.M23 * right.M32 + left.M24 * right.M42;
|
||||
result.M23 = left.M21 * right.M13 + left.M22 * right.M23 + left.M23 * right.M33 + left.M24 * right.M43;
|
||||
result.M24 = left.M21 * right.M14 + left.M22 * right.M24 + left.M23 * right.M34 + left.M24 * right.M44;
|
||||
|
||||
result.M31 = left.M31 * right.M11 + left.M32 * right.M21 + left.M33 * right.M31 + left.M34 * right.M41;
|
||||
result.M32 = left.M31 * right.M12 + left.M32 * right.M22 + left.M33 * right.M32 + left.M34 * right.M42;
|
||||
result.M33 = left.M31 * right.M13 + left.M32 * right.M23 + left.M33 * right.M33 + left.M34 * right.M43;
|
||||
result.M34 = left.M31 * right.M14 + left.M32 * right.M24 + left.M33 * right.M34 + left.M34 * right.M44;
|
||||
|
||||
result.M41 = left.M41 * right.M11 + left.M42 * right.M21 + left.M43 * right.M31 + left.M44 * right.M41;
|
||||
result.M42 = left.M41 * right.M12 + left.M42 * right.M22 + left.M43 * right.M32 + left.M44 * right.M42;
|
||||
result.M43 = left.M41 * right.M13 + left.M42 * right.M23 + left.M43 * right.M33 + left.M44 * right.M43;
|
||||
result.M44 = left.M41 * right.M14 + left.M42 * right.M24 + left.M43 * right.M34 + left.M44 * right.M44;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector4"/> instance containing the result.</returns>
|
||||
public static Vector4 Transform(Matrix4 matrix, Vector4 vector)
|
||||
{
|
||||
return new Vector4(
|
||||
(matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + (matrix.M14 * vector.W),
|
||||
(matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + (matrix.M24 * vector.W),
|
||||
(matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + (matrix.M34 * vector.W),
|
||||
(matrix.M41 * vector.X) + (matrix.M42 * vector.Y) + (matrix.M43 * vector.Z) + (matrix.M44 * vector.W));
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix and put the result in a vector.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector4"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Vector4"/> instance to hold the result.</param>
|
||||
public static void Transform(Matrix4 matrix, Vector4 vector, ref Vector4 result)
|
||||
{
|
||||
result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + (matrix.M14 * vector.W);
|
||||
result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + (matrix.M24 * vector.W);
|
||||
result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + (matrix.M34 * vector.W);
|
||||
result.W = (matrix.M41 * vector.X) + (matrix.M42 * vector.Y) + (matrix.M43 * vector.Z) + (matrix.M44 * vector.W);
|
||||
}
|
||||
/// <summary>
|
||||
/// Transposes a matrix.
|
||||
/// </summary>
|
||||
/// <param name="m">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the transposed matrix.</returns>
|
||||
public static Matrix4 Transpose(Matrix4 m)
|
||||
{
|
||||
Matrix4 t = new Matrix4(m);
|
||||
t.Transpose();
|
||||
return t;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region System.Object overrides
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return
|
||||
_m11.GetHashCode() ^ _m12.GetHashCode() ^ _m13.GetHashCode() ^ _m14.GetHashCode() ^
|
||||
_m21.GetHashCode() ^ _m22.GetHashCode() ^ _m23.GetHashCode() ^ _m24.GetHashCode() ^
|
||||
_m31.GetHashCode() ^ _m32.GetHashCode() ^ _m33.GetHashCode() ^ _m34.GetHashCode() ^
|
||||
_m41.GetHashCode() ^ _m42.GetHashCode() ^ _m43.GetHashCode() ^ _m44.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="obj"/> is a <see cref="Matrix4"/> and has the same values as this instance; otherwise, <see langword="false"/>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Matrix4)
|
||||
{
|
||||
Matrix4 m = (Matrix4)obj;
|
||||
return
|
||||
(_m11 == m.M11) && (_m12 == m.M12) && (_m13 == m.M13) && (_m14 == m.M14) &&
|
||||
(_m21 == m.M21) && (_m22 == m.M22) && (_m23 == m.M23) && (_m24 == m.M24) &&
|
||||
(_m31 == m.M31) && (_m32 == m.M32) && (_m33 == m.M33) && (_m34 == m.M34) &&
|
||||
(_m41 == m.M41) && (_m42 == m.M42) && (_m43 == m.M43) && (_m44 == m.M44);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("4x4[{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}]",
|
||||
_m11, _m12, _m13, _m14, _m21, _m22, _m23, _m24, _m31, _m32, _m33, _m34, _m41, _m42, _m43, _m44);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Calculates the determinant value of the matrix.
|
||||
/// </summary>
|
||||
/// <returns>The determinant value of the matrix.</returns>
|
||||
public float GetDeterminant()
|
||||
{
|
||||
// float det = 0.0f;
|
||||
// for (int col = 0; col < 4; col++)
|
||||
// {
|
||||
// if ((col % 2) == 0)
|
||||
// det += this[0, col] * Minor(0, col).Determinant();
|
||||
// else
|
||||
// det -= this[0, col] * Minor(0, col).Determinant();
|
||||
// }
|
||||
// return det;
|
||||
return
|
||||
_m14 * _m23 * _m32 * _m41 - _m13 * _m24 * _m32 * _m41 - _m14 * _m22 * _m33 * _m41 + _m12 * _m24 * _m33 * _m41 +
|
||||
_m13 * _m22 * _m34 * _m41 - _m12 * _m23 * _m34 * _m41 - _m14 * _m23 * _m31 * _m42 + _m13 * _m24 * _m31 * _m42 +
|
||||
_m14 * _m21 * _m33 * _m42 - _m11 * _m24 * _m33 * _m42 - _m13 * _m21 * _m34 * _m42 + _m11 * _m23 * _m34 * _m42 +
|
||||
_m14 * _m22 * _m31 * _m43 - _m12 * _m24 * _m31 * _m43 - _m14 * _m21 * _m32 * _m43 + _m11 * _m24 * _m32 * _m43 +
|
||||
_m12 * _m21 * _m34 * _m43 - _m11 * _m22 * _m34 * _m43 - _m13 * _m22 * _m31 * _m44 + _m12 * _m23 * _m31 * _m44 +
|
||||
_m13 * _m21 * _m32 * _m44 - _m11 * _m23 * _m32 * _m44 - _m12 * _m21 * _m33 * _m44 + _m11 * _m22 * _m33 * _m44;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transposes this matrix.
|
||||
/// </summary>
|
||||
public void Transpose()
|
||||
{
|
||||
MathFunctions.Swap<float>(ref _m12, ref _m21);
|
||||
MathFunctions.Swap<float>(ref _m13, ref _m31);
|
||||
MathFunctions.Swap<float>(ref _m14, ref _m41);
|
||||
MathFunctions.Swap<float>(ref _m23, ref _m32);
|
||||
MathFunctions.Swap<float>(ref _m24, ref _m42);
|
||||
MathFunctions.Swap<float>(ref _m34, ref _m43);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Comparison Operators
|
||||
/// <summary>
|
||||
/// Tests whether two specified matrices are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two matrices are equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator ==(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return ValueType.Equals(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two specified matrices are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two matrices are not equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator !=(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return !ValueType.Equals(left, right);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Binary Operators
|
||||
/// <summary>
|
||||
/// Adds two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the sum.</returns>
|
||||
public static Matrix4 operator +(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return Matrix4.Add(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the sum.</returns>
|
||||
public static Matrix4 operator +(Matrix4 matrix, float scalar)
|
||||
{
|
||||
return Matrix4.Add(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the sum.</returns>
|
||||
public static Matrix4 operator +(float scalar, Matrix4 matrix)
|
||||
{
|
||||
return Matrix4.Add(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a matrix from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the difference.</returns>
|
||||
public static Matrix4 operator -(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return Matrix4.Subtract(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the difference.</returns>
|
||||
public static Matrix4 operator -(Matrix4 matrix, float scalar)
|
||||
{
|
||||
return Matrix4.Subtract(matrix, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies two matrices.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the result.</returns>
|
||||
public static Matrix4 operator *(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return Matrix4.Multiply(left, right); ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">A <see cref="Matrix4"/> instance.</param>
|
||||
/// <param name="vector">A <see cref="Vector4"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector4"/> instance containing the result.</returns>
|
||||
public static Vector4 operator *(Matrix4 matrix, Vector4 vector)
|
||||
{
|
||||
Vector4 result = new Vector4();
|
||||
for (int r = 0; r < 4; ++r)
|
||||
{
|
||||
for (int c = 0; c < 4; ++c)
|
||||
{
|
||||
result[r] += matrix[r, c] * vector[c];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Indexing Operators
|
||||
/// <summary>
|
||||
/// Indexer allowing to access the matrix elements by an index
|
||||
/// where index = 2*row + column.
|
||||
/// </summary>
|
||||
public unsafe float this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= 16)
|
||||
throw new IndexOutOfRangeException("Invalid matrix index!");
|
||||
|
||||
fixed (float* f = &_m11)
|
||||
{
|
||||
return *(f + index);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= 16)
|
||||
throw new IndexOutOfRangeException("Invalid matrix index!");
|
||||
|
||||
fixed (float* f = &_m11)
|
||||
{
|
||||
*(f + index) = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Indexer allowing to access the matrix elements by row and column.
|
||||
/// </summary>
|
||||
public float this[int row, int column]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this[(row) * 4 + (column)];
|
||||
}
|
||||
set
|
||||
{
|
||||
this[(row) * 4 + (column)] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2003-2004 Eran Kampf eran@ekampf.com http://www.ekampf.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// An enumeration representing the sides of the plane.
|
||||
/// </summary>
|
||||
public enum PlaneSide
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the plane itself.
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// Represents the positive halfspace of the plane (the side where the normal points to).
|
||||
/// </summary>
|
||||
Positive,
|
||||
/// <summary>
|
||||
/// Represents the negative halfspace of the plane
|
||||
/// </summary>
|
||||
Negative
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a plane in 3D space.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The plane is described by a normal and a constant (N,D) which
|
||||
/// denotes that the plane is consisting of points Q that
|
||||
/// satisfies (N dot Q)+D = 0.
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public struct Plane : ISerializable, ICloneable
|
||||
{
|
||||
#region Private Fields
|
||||
private Vector3 _normal;
|
||||
private float _const;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plane"/> class using given normal and constant values.
|
||||
/// </summary>
|
||||
/// <param name="normal">The plane's normal vector.</param>
|
||||
/// <param name="constant">The plane's constant value.</param>
|
||||
public Plane(Vector3 normal, float constant)
|
||||
{
|
||||
_normal = normal;
|
||||
_const = constant;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plane"/> class using given normal and a point.
|
||||
/// </summary>
|
||||
/// <param name="normal">The plane's normal vector.</param>
|
||||
/// <param name="point">A point on the plane in 3D space.</param>
|
||||
public Plane(Vector3 normal, Vector3 point)
|
||||
{
|
||||
_normal = normal;
|
||||
_const = Vector3.DotProduct(normal, point);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plane"/> class using 3 given points.
|
||||
/// </summary>
|
||||
/// <param name="p0">A point on the plane in 3D space.</param>
|
||||
/// <param name="p1">A point on the plane in 3D space.</param>
|
||||
/// <param name="p2">A point on the plane in 3D space.</param>
|
||||
public Plane(Vector3 p0, Vector3 p1, Vector3 p2)
|
||||
{
|
||||
_normal = Vector3.CrossProduct(p2 - p1, p0 - p1);
|
||||
_normal.Normalize();
|
||||
_const = Vector3.DotProduct(_normal, p0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plane"/> class using given a plane to assign values from.
|
||||
/// </summary>
|
||||
/// <param name="p">A 3D plane to assign values from.</param>
|
||||
public Plane(Plane p)
|
||||
{
|
||||
_normal = p.Normal;
|
||||
_const = p.Constant;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plane"/> class with serialized data.
|
||||
/// </summary>
|
||||
/// <param name="info">The object that holds the serialized object data.</param>
|
||||
/// <param name="context">The contextual information about the source or destination.</param>
|
||||
private Plane(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
_normal = (Vector3)info.GetValue("Normal", typeof(Vector3));
|
||||
_const = info.GetSingle("Constant");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// Plane on the X axis.
|
||||
/// </summary>
|
||||
public static readonly Plane XPlane = new Plane(Vector3.XAxis, Vector3.Zero);
|
||||
/// <summary>
|
||||
/// Plane on the Y axis.
|
||||
/// </summary>
|
||||
public static readonly Plane YPlane = new Plane(Vector3.YAxis, Vector3.Zero);
|
||||
/// <summary>
|
||||
/// Plane on the Z axis.
|
||||
/// </summary>
|
||||
public static readonly Plane ZPlane = new Plane(Vector3.ZAxis, Vector3.Zero);
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the plane's normal vector.
|
||||
/// </summary>
|
||||
public Vector3 Normal
|
||||
{
|
||||
get { return _normal; }
|
||||
set { _normal = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the plane's constant value.
|
||||
/// </summary>
|
||||
public float Constant
|
||||
{
|
||||
get { return _const; }
|
||||
set { _const = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Plane"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Plane"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new Plane(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Plane"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Plane"/> object this method creates.</returns>
|
||||
public Plane Clone()
|
||||
{
|
||||
return new Plane(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ISerializable Members
|
||||
/// <summary>
|
||||
/// Populates a <see cref="SerializationInfo"/> with the data needed to serialize the target object.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="SerializationInfo"/> to populate with data. </param>
|
||||
/// <param name="context">The destination (see <see cref="StreamingContext"/>) for this serialization.</param>
|
||||
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("Normal", _normal, typeof(Vector3));
|
||||
info.AddValue("Constant", _const);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Flip the plane.
|
||||
/// </summary>
|
||||
public void Flip()
|
||||
{
|
||||
_normal = -_normal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new flipped plane (-normal, constant).
|
||||
/// </summary>
|
||||
/// <returns>A new <see cref="Plane"/> instance.</returns>
|
||||
public Plane GetFlipped()
|
||||
{
|
||||
return new Plane(-_normal, _const);
|
||||
}
|
||||
/// <summary>
|
||||
/// Get the shortest distance from a 3D vector to the plane.
|
||||
/// </summary>
|
||||
/// <param name="p">A <see cref="Vector3"/> instance.</param>
|
||||
/// <returns>A float representing the shortest distance from the given vector to the plane.</returns>
|
||||
public float GetDistanceToPlane(Vector3 p)
|
||||
{
|
||||
return Vector3.DotProduct(p, this.Normal) - this.Constant;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _normal.GetHashCode() ^ _const.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns>True if <paramref name="obj"/> is a <see cref="Vector2D"/> and has the same values as this instance; otherwise, False.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Plane)
|
||||
{
|
||||
Plane p = (Plane)obj;
|
||||
return (_normal == p.Normal) && (_const == p.Constant);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Plane[n={0}, c={1}]", _normal.ToString(), _const.ToString());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,815 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2003-2004 Eran Kampf eran@ekampf.com http://www.ekampf.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a double-precision floating-point quaternion.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// A quaternion can be thought of as a 4-Dimentional vector of form:
|
||||
/// q = [w, x, y, z] = w + xi + yj +zk.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// A Quaternion is often written as q = s + V where S represents
|
||||
/// the scalar part (w component) and V is a 3D vector representing
|
||||
/// the imaginery coefficients (x,y,z components).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Check out http://mathworld.wolfram.com/Quaternion.html for further details.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Quaternion : ICloneable
|
||||
{
|
||||
#region Private Fields
|
||||
private float _w;
|
||||
private float _x;
|
||||
private float _y;
|
||||
private float _z;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Quaternion"/> class with the specified coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x">The quaternions's X coordinate.</param>
|
||||
/// <param name="y">The quaternions's Y coordinate.</param>
|
||||
/// <param name="z">The quaternions's Z coordinate.</param>
|
||||
/// /// <param name="w">The quaternions's W coordinate.</param>
|
||||
public Quaternion(float x, float y, float z, float w)
|
||||
{
|
||||
_w = w;
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Quaternion"/> class using coordinates from a given <see cref="Quaternion"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance to copy the coordinates from.</param>
|
||||
public Quaternion(Quaternion quaternion)
|
||||
{
|
||||
_x = quaternion.X;
|
||||
_y = quaternion.Y;
|
||||
_z = quaternion.Z;
|
||||
_w = quaternion.W;
|
||||
}
|
||||
public Quaternion(Matrix3 rot) : this(Zero)
|
||||
{
|
||||
int[] plus1mod3 = { 1, 2, 0 };
|
||||
|
||||
// Find the index of the largest diagonal component
|
||||
// These ? operations hopefully compile to conditional
|
||||
// move instructions instead of branches.
|
||||
int i = (rot[1, 1] > rot[0, 0]) ? 2 : 1;
|
||||
i = (rot[2, 2] > rot[i, i]) ? 2 : i;
|
||||
|
||||
// Find the indices of the other elements
|
||||
int j = plus1mod3[i];
|
||||
int k = plus1mod3[j];
|
||||
|
||||
// If we attempted to pre-normalize and trusted the matrix to be
|
||||
// perfectly orthonormal, the result would be:
|
||||
//
|
||||
// double c = sqrt((rot[i][i] - (rot[j][j] + rot[k][k])) + 1.0)
|
||||
// v[i] = -c * 0.5
|
||||
// v[j] = -(rot[i][j] + rot[j][i]) * 0.5 / c
|
||||
// v[k] = -(rot[i][k] + rot[k][i]) * 0.5 / c
|
||||
// w = (rot[j][k] - rot[k][j]) * 0.5 / c
|
||||
//
|
||||
// Since we're going to pay the sqrt anyway, we perform a post normalization, which also
|
||||
// fixes any poorly normalized input. Multiply all elements by 2*c in the above, giving:
|
||||
|
||||
// nc2 = -c^2
|
||||
double nc2 = ((rot[j, j] + rot[k, k]) - rot[i, i]) - 1.0;
|
||||
this[i] = (float)nc2;
|
||||
W = (rot[j, k] - rot[k, j]);
|
||||
this[j] = -(rot[i, j] + rot[j, i]);
|
||||
this[k] = -(rot[i, k] + rot[k, i]);
|
||||
|
||||
// We now have the correct result with the wrong magnitude, so normalize it:
|
||||
float s = (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W);
|
||||
if (s > 0.00001f)
|
||||
{
|
||||
s = 1.0f / s;
|
||||
X *= s;
|
||||
Y *= s;
|
||||
Z *= s;
|
||||
W *= s;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The quaternion is nearly zero. Make it 0 0 0 1
|
||||
X = 0.0f;
|
||||
Y = 0.0f;
|
||||
Z = 0.0f;
|
||||
W = 1.0f;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// Double-precision floating point zero quaternion.
|
||||
/// </summary>
|
||||
public static readonly Quaternion Zero = new Quaternion(0, 0, 0, 0);
|
||||
/// <summary>
|
||||
/// Double-precision floating point identity quaternion.
|
||||
/// </summary>
|
||||
public static readonly Quaternion Identity = new Quaternion(0, 0, 0, 1);
|
||||
/// <summary>
|
||||
/// Double-precision floating point X-Axis quaternion.
|
||||
/// </summary>
|
||||
public static readonly Quaternion XAxis = new Quaternion(1, 0, 0, 0);
|
||||
/// <summary>
|
||||
/// Double-precision floating point Y-Axis quaternion.
|
||||
/// </summary>
|
||||
public static readonly Quaternion YAxis = new Quaternion(0, 1, 0, 0);
|
||||
/// <summary>
|
||||
/// Double-precision floating point Z-Axis quaternion.
|
||||
/// </summary>
|
||||
public static readonly Quaternion ZAxis = new Quaternion(0, 0, 1, 0);
|
||||
/// <summary>
|
||||
/// Double-precision floating point W-Axis quaternion.
|
||||
/// </summary>
|
||||
public static readonly Quaternion WAxis = new Quaternion(0, 0, 0, 1);
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summery>
|
||||
/// Gets or sets the x-coordinate of this quaternion.
|
||||
/// </summery>
|
||||
/// <value>The x-coordinate of this quaternion.</value>
|
||||
public float X
|
||||
{
|
||||
get { return _x; }
|
||||
set { _x = value; }
|
||||
}
|
||||
/// <summery>
|
||||
/// Gets or sets the y-coordinate of this quaternion.
|
||||
/// </summery>
|
||||
/// <value>The y-coordinate of this quaternion.</value>
|
||||
public float Y
|
||||
{
|
||||
get { return _y; }
|
||||
set { _y = value; }
|
||||
}
|
||||
/// <summery>
|
||||
/// Gets or sets the z-coordinate of this quaternion.
|
||||
/// </summery>
|
||||
/// <value>The z-coordinate of this quaternion.</value>
|
||||
public float Z
|
||||
{
|
||||
get { return _z; }
|
||||
set { _z = value; }
|
||||
}
|
||||
/// <summery>
|
||||
/// Gets or sets the w-coordinate of this quaternion.
|
||||
/// </summery>
|
||||
/// <value>The w-coordinate of this quaternion.</value>
|
||||
public float W
|
||||
{
|
||||
get { return _w; }
|
||||
set { _w = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the the modulus of the quaternion.
|
||||
/// </summary>
|
||||
/// <value>A double-precision floating-point number.</value>
|
||||
public float Modulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (float)System.Math.Sqrt(_w * _w + _x * _x + _y * _y + _z * _z);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the the squared modulus of the quaternion.
|
||||
/// </summary>
|
||||
/// <value>A double-precision floating-point number.</value>
|
||||
public float ModulusSquared
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_w * _w + _x * _x + _y * _y + _z * _z);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the conjugate of the quaternion.
|
||||
/// </summary>
|
||||
/// <value>A <see cref="Quaternion"/> instance.</value>
|
||||
public Quaternion Conjugate
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Quaternion(-_x, -_y, -_z, _w);
|
||||
}
|
||||
set
|
||||
{
|
||||
this = value.Conjugate;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Quaternion"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Quaternion"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new Quaternion(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Quaternion"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Quaternion"/> object this method creates.</returns>
|
||||
public Quaternion Clone()
|
||||
{
|
||||
return new Quaternion(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Parse Methods
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Quaternion"/> equivalent.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Quaternion"/></param>
|
||||
/// <returns>A <see cref="Quaternion"/> that represents the vector specified by the <paramref name="s"/> parameter.</returns>
|
||||
public static Quaternion Parse(string value)
|
||||
{
|
||||
Regex r = new Regex(@"\((?<w>.*),(?<x>.*),(?<y>.*),(?<z>.*)\)", RegexOptions.None);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
return new Quaternion(
|
||||
float.Parse(m.Result("${x}")),
|
||||
float.Parse(m.Result("${y}")),
|
||||
float.Parse(m.Result("${z}")),
|
||||
float.Parse(m.Result("${w}"))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsuccessful Match.");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Quaternion"/> equivalent.
|
||||
/// A return value indicates whether the conversion succeeded or failed.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Quaternion"/>.</param>
|
||||
/// <param name="result">
|
||||
/// When this method returns, if the conversion succeeded,
|
||||
/// contains a <see cref="Quaternion"/> representing the vector specified by <paramref name="value"/>.
|
||||
/// </param>
|
||||
/// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool TryParse(string value, out Quaternion result)
|
||||
{
|
||||
Regex r = new Regex(@"\((?<x>.*),(?<y>.*),(?<z>.*),(?<w>.*)\)", RegexOptions.None);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
result = new Quaternion(
|
||||
float.Parse(m.Result("${x}")),
|
||||
float.Parse(m.Result("${y}")),
|
||||
float.Parse(m.Result("${z}")),
|
||||
float.Parse(m.Result("${w}"))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result = Quaternion.Zero;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Quaternion Arithmetics
|
||||
/// <summary>
|
||||
/// Adds two quaternions.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>A new <see cref="Quaternion"/> instance containing the sum.</returns>
|
||||
public static Quaternion Add(Quaternion left, Quaternion right)
|
||||
{
|
||||
return new Quaternion(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds two quaternions and put the result in the third quaternion.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Quaternion"/> instance to hold the result.</param>
|
||||
public static void Add(Quaternion left, Quaternion right, ref Quaternion result)
|
||||
{
|
||||
result.X = left.X + right.X;
|
||||
result.Y = left.Y + right.Y;
|
||||
result.Z = left.Z + right.Z;
|
||||
result.W = left.W + right.W;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts a quaternion from a quaternion.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>A new <see cref="Quaternion"/> instance containing the difference.</returns>
|
||||
public static Quaternion Subtract(Quaternion left, Quaternion right)
|
||||
{
|
||||
return new Quaternion(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a quaternion from a quaternion and puts the result into a third quaternion.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Quaternion"/> instance to hold the result.</param>
|
||||
public static void Subtract(Quaternion left, Quaternion right, ref Quaternion result)
|
||||
{
|
||||
result.X = left.X - right.X;
|
||||
result.Y = left.Y - right.Y;
|
||||
result.Z = left.Z - right.Z;
|
||||
result.W = left.W - right.W;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies quaternion <paramref name="a"/> by quaternion <paramref name="b"/>.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>A new <see cref="Quaternion"/> containing the result.</returns>
|
||||
public static Quaternion Multiply(Quaternion left, Quaternion right)
|
||||
{
|
||||
Quaternion result = new Quaternion();
|
||||
result.X = left.W * right.X + left.X * right.W + left.Y * right.Z - left.Z * right.Y;
|
||||
result.Y = left.W * right.Y + left.Y * right.W + left.Z * right.X - left.X * right.Z;
|
||||
result.Z = left.W * right.Z + left.Z * right.W + left.X * right.Y - left.Y * right.X;
|
||||
result.W = left.W * right.W - left.X * right.X - left.Y * right.Y - left.Z * right.Z;
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies quaternion <paramref name="a"/> by quaternion <paramref name="b"/> and put the result in a third quaternion.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Quaternion"/> instance to hold the result.</param>
|
||||
public static void Multiply(Quaternion left, Quaternion right, ref Quaternion result)
|
||||
{
|
||||
result.X = left.W * right.X + left.X * right.W + left.Y * right.Z - left.Z * right.Y;
|
||||
result.Y = left.W * right.Y + left.Y * right.W + left.Z * right.X - left.X * right.Z;
|
||||
result.Z = left.W * right.Z + left.Z * right.W + left.X * right.Y - left.Y * right.X;
|
||||
result.W = left.W * right.W - left.X * right.X - left.Y * right.Y - left.Z * right.Z;
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a quaternion by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <returns>A <see cref="Quaternion"/> instance to hold the result.</returns>
|
||||
public static Quaternion Multiply(Quaternion quaternion, float scalar)
|
||||
{
|
||||
Quaternion result = new Quaternion(quaternion);
|
||||
result.X *= scalar;
|
||||
result.Y *= scalar;
|
||||
result.Z *= scalar;
|
||||
result.W *= scalar;
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a quaternion by a scalar and put the result in a third quaternion.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <param name="result">A <see cref="Quaternion"/> instance to hold the result.</param>
|
||||
public static void Multiply(Quaternion quaternion, float scalar, ref Quaternion result)
|
||||
{
|
||||
result.X = quaternion.X * scalar;
|
||||
result.Y = quaternion.Y * scalar;
|
||||
result.Z = quaternion.Z * scalar;
|
||||
result.W = quaternion.W * scalar;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Divides a quaternion by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <returns>A <see cref="Quaternion"/> instance to hold the result.</returns>
|
||||
public static Quaternion Divide(Quaternion quaternion, float scalar)
|
||||
{
|
||||
if (scalar == 0)
|
||||
{
|
||||
throw new DivideByZeroException("Dividing quaternion by zero");
|
||||
}
|
||||
|
||||
Quaternion result = new Quaternion(quaternion);
|
||||
result.X /= scalar;
|
||||
result.Y /= scalar;
|
||||
result.Z /= scalar;
|
||||
result.W /= scalar;
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a quaternion by a scalar and put the result in a third quaternion.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <param name="result">A <see cref="Quaternion"/> instance to hold the result.</param>
|
||||
public static void Divide(Quaternion quaternion, float scalar, ref Quaternion result)
|
||||
{
|
||||
if (scalar == 0)
|
||||
{
|
||||
throw new DivideByZeroException("Dividing quaternion by zero");
|
||||
}
|
||||
|
||||
result.X = quaternion.X / scalar;
|
||||
result.Y = quaternion.Y / scalar;
|
||||
result.Z = quaternion.Z / scalar;
|
||||
result.W = quaternion.W / scalar;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the dot product of two quaternions.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>The dot product value.</returns>
|
||||
public static double DotProduct(Quaternion left, Quaternion right)
|
||||
{
|
||||
return left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool isUnit(double tolerance = 1e-5)
|
||||
{
|
||||
return Math.Abs(dot(this) - 1.0f) < tolerance;
|
||||
}
|
||||
|
||||
public Quaternion ToUnit()
|
||||
{
|
||||
Quaternion copyOfThis = this;
|
||||
copyOfThis *= rsq(dot(this));
|
||||
return copyOfThis;
|
||||
}
|
||||
|
||||
float dot(Quaternion other)
|
||||
{
|
||||
return (float)((X * other.X) + (Y * other.Y) + (Z * other.Z) + (W * other.W));
|
||||
}
|
||||
|
||||
float rsq(float x)
|
||||
{
|
||||
return 1.0f / (float)Math.Sqrt(x);
|
||||
}
|
||||
|
||||
#region Public Static Complex Special Functions
|
||||
/// <summary>
|
||||
/// Calculates the logarithm of a given quaternion.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>The quaternion's logarithm.</returns>
|
||||
public static Quaternion Log(Quaternion quaternion)
|
||||
{
|
||||
Quaternion result = new Quaternion(0, 0, 0, 0);
|
||||
|
||||
if (Math.Abs(quaternion.W) < 1.0)
|
||||
{
|
||||
float angle = (float)System.Math.Acos(quaternion.W);
|
||||
float sin = (float)System.Math.Sin(angle);
|
||||
|
||||
if (Math.Abs(sin) >= 0)
|
||||
{
|
||||
float coeff = angle / sin;
|
||||
result.X = coeff * quaternion.X;
|
||||
result.Y = coeff * quaternion.Y;
|
||||
result.Z = coeff * quaternion.Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.X = quaternion.X;
|
||||
result.Y = quaternion.Y;
|
||||
result.Z = quaternion.Z;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Calculates the exponent of a quaternion.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>The quaternion's exponent.</returns>
|
||||
public Quaternion Exp(Quaternion quaternion)
|
||||
{
|
||||
Quaternion result = new Quaternion(0, 0, 0, 0);
|
||||
|
||||
float angle = (float)System.Math.Sqrt(quaternion.X * quaternion.X + quaternion.Y * quaternion.Y + quaternion.Z * quaternion.Z);
|
||||
float sin = (float)System.Math.Sin(angle);
|
||||
|
||||
if (Math.Abs(sin) > 0)
|
||||
{
|
||||
float coeff = angle / sin;
|
||||
result.X = coeff * quaternion.X;
|
||||
result.Y = coeff * quaternion.Y;
|
||||
result.Z = coeff * quaternion.Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.X = quaternion.X;
|
||||
result.Y = quaternion.Y;
|
||||
result.Z = quaternion.Z;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Inverts the quaternion.
|
||||
/// </summary>
|
||||
public void Inverse()
|
||||
{
|
||||
float norm = ModulusSquared;
|
||||
if (norm > 0)
|
||||
{
|
||||
float invNorm = 1.0f / norm;
|
||||
_w *= invNorm;
|
||||
_x *= -invNorm;
|
||||
_y *= -invNorm;
|
||||
_z *= -invNorm;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Quaternion " + ToString() + " is not invertable");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Normelizes the quaternion.
|
||||
/// </summary>
|
||||
public void Normalize()
|
||||
{
|
||||
float norm = Modulus;
|
||||
if (norm == 0)
|
||||
{
|
||||
throw new DivideByZeroException("Trying to normalize a quaternion with modulus of zero.");
|
||||
}
|
||||
|
||||
_w /= norm;
|
||||
_x /= norm;
|
||||
_y /= norm;
|
||||
_z /= norm;
|
||||
}
|
||||
/// <summary>
|
||||
/// Clamps quaternion values to zero using a given tolerance value.
|
||||
/// </summary>
|
||||
/// <param name="tolerance">The tolerance to use.</param>
|
||||
/// <remarks>
|
||||
/// The quaternion values that are close to zero within the given tolerance are set to zero.
|
||||
/// </remarks>
|
||||
public void ClampZero(float tolerance)
|
||||
{
|
||||
_x = MathFunctions.Clamp(_x, 0, tolerance);
|
||||
_y = MathFunctions.Clamp(_y, 0, tolerance);
|
||||
_z = MathFunctions.Clamp(_z, 0, tolerance);
|
||||
_w = MathFunctions.Clamp(_w, 0, tolerance);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clamps quaternion values to zero using the default tolerance value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The quaternion values that are close to zero within the given tolerance are set to zero.
|
||||
/// The tolerance value used is <see cref="MathFunctions.EpsilonD"/>
|
||||
/// </remarks>
|
||||
public void ClampZero()
|
||||
{
|
||||
_x = MathFunctions.Clamp(_x, 0);
|
||||
_y = MathFunctions.Clamp(_y, 0);
|
||||
_z = MathFunctions.Clamp(_z, 0);
|
||||
_w = MathFunctions.Clamp(_w, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region System.Object Overrides
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _w.GetHashCode() ^ _x.GetHashCode() ^ _y.GetHashCode() ^ _z.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="obj"/> is a <see cref="Quaternion"/> and has the same values as this instance; otherwise, <see langword="false"/>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Quaternion)
|
||||
{
|
||||
Quaternion quaternion = (Quaternion)obj;
|
||||
return (_w == quaternion.W) && (_x == quaternion.X) && (_y == quaternion.Y) && (_z == quaternion.Z);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1}, {2}, {3})", _w, _x, _y, _z);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Comparison Operators
|
||||
/// <summary>
|
||||
/// Tests whether two specified quaternions are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The left-hand quaternion.</param>
|
||||
/// <param name="right">The right-hand quaternion.</param>
|
||||
/// <returns><see langword="true"/> if the two quaternions are equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator ==(Quaternion left, Quaternion right)
|
||||
{
|
||||
return ValueType.Equals(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two specified quaternions are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The left-hand quaternion.</param>
|
||||
/// <param name="right">The right-hand quaternion.</param>
|
||||
/// <returns><see langword="true"/> if the two quaternions are not equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator !=(Quaternion left, Quaternion right)
|
||||
{
|
||||
return !ValueType.Equals(left, right);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Binary Operators
|
||||
/// <summary>
|
||||
/// Adds two quaternions.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>A new <see cref="Quaternion"/> instance containing the sum.</returns>
|
||||
public static Quaternion operator +(Quaternion left, Quaternion right)
|
||||
{
|
||||
return Quaternion.Add(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a quaternion from a quaternion.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>A new <see cref="Quaternion"/> instance containing the difference.</returns>
|
||||
public static Quaternion operator -(Quaternion left, Quaternion right)
|
||||
{
|
||||
return Quaternion.Subtract(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies quaternion <paramref name="a"/> by quaternion <paramref name="b"/>.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>A new <see cref="Quaternion"/> containing the result.</returns>
|
||||
public static Quaternion operator *(Quaternion left, Quaternion right)
|
||||
{
|
||||
return Quaternion.Multiply(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a quaternion by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <returns>A <see cref="Quaternion"/> instance to hold the result.</returns>
|
||||
public static Quaternion operator *(Quaternion quaternion, float scalar)
|
||||
{
|
||||
return Quaternion.Multiply(quaternion, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a quaternion by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <returns>A <see cref="Quaternion"/> instance to hold the result.</returns>
|
||||
public static Quaternion operator *(float scalar, Quaternion quaternion)
|
||||
{
|
||||
return Quaternion.Multiply(quaternion, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a quaternion by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <returns>A <see cref="Quaternion"/> instance to hold the result.</returns>
|
||||
public static Quaternion operator /(Quaternion quaternion, float scalar)
|
||||
{
|
||||
return Quaternion.Divide(quaternion, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a scalar by a quaternion.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <param name="scalar">A scalar.</param>
|
||||
/// <returns>A <see cref="Quaternion"/> instance to hold the result.</returns>
|
||||
public static Quaternion operator /(float scalar, Quaternion quaternion)
|
||||
{
|
||||
return Quaternion.Multiply(quaternion, (1.0f / scalar));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Array Indexing Operator
|
||||
/// <summary>
|
||||
/// Indexer ( [w, x, y, z] ).
|
||||
/// </summary>
|
||||
public float this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
return _x;
|
||||
case 1:
|
||||
return _y;
|
||||
case 2:
|
||||
return _z;
|
||||
case 3:
|
||||
return _w;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
_x = value;
|
||||
break;
|
||||
case 1:
|
||||
_y = value;
|
||||
break;
|
||||
case 2:
|
||||
_z = value;
|
||||
break;
|
||||
case 3:
|
||||
_w = value;
|
||||
break;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Conversion Operators
|
||||
/// <summary>
|
||||
/// Converts the quaternion to an array of double-precision floating point numbers.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">A <see cref="Quaternion"/> instance.</param>
|
||||
/// <returns>An array of double-precision floating point numbers.</returns>
|
||||
/// <remarks>The array is [w, x, y, z].</remarks>
|
||||
public static explicit operator double[] (Quaternion quaternion)
|
||||
{
|
||||
double[] doubles = new double[4];
|
||||
doubles[1] = quaternion.X;
|
||||
doubles[2] = quaternion.Y;
|
||||
doubles[3] = quaternion.Z;
|
||||
doubles[0] = quaternion.W;
|
||||
return doubles;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2003-2004 Eran Kampf eran@ekampf.com http://www.ekampf.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.ComponentModel;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ray in 3D space.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A ray is R(t) = Origin + t * Direction where t>=0. The Direction isnt necessarily of unit length.
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
[TypeConverter(typeof(RayConverter))]
|
||||
public struct Ray : ICloneable
|
||||
{
|
||||
#region Private Fields
|
||||
private Vector3 _origin;
|
||||
private Vector3 _direction;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Ray"/> class using given origin and direction vectors.
|
||||
/// </summary>
|
||||
/// <param name="origin">Ray's origin point.</param>
|
||||
/// <param name="direction">Ray's direction vector.</param>
|
||||
public Ray(Vector3 origin, Vector3 direction)
|
||||
{
|
||||
_origin = origin;
|
||||
_direction = direction;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Ray"/> class using given ray.
|
||||
/// </summary>
|
||||
/// <param name="ray">A <see cref="Ray"/> instance to assign values from.</param>
|
||||
public Ray(Ray ray)
|
||||
{
|
||||
_origin = ray.Origin;
|
||||
_direction = ray.Direction;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the ray's origin.
|
||||
/// </summary>
|
||||
public Vector3 Origin
|
||||
{
|
||||
get { return _origin; }
|
||||
set { _origin = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the ray's direction vector.
|
||||
/// </summary>
|
||||
public Vector3 Direction
|
||||
{
|
||||
get { return _direction; }
|
||||
set { _direction = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Ray"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Ray"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new Ray(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Ray"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Ray"/> object this method creates.</returns>
|
||||
public Ray Clone()
|
||||
{
|
||||
return new Ray(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Parse Methods
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Ray"/> equivalent.
|
||||
/// </summary>
|
||||
/// <param name="s">A string representation of a <see cref="Ray"/></param>
|
||||
/// <returns>A <see cref="Ray"/> that represents the vector specified by the <paramref name="s"/> parameter.</returns>
|
||||
public static Ray Parse(string s)
|
||||
{
|
||||
Regex r = new Regex(@"\((?<origin>\([^\)]*\)), (?<direction>\([^\)]*\))\)", RegexOptions.None);
|
||||
Match m = r.Match(s);
|
||||
if (m.Success)
|
||||
{
|
||||
return new Ray(
|
||||
Vector3.Parse(m.Result("${origin}")),
|
||||
Vector3.Parse(m.Result("${direction}"))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsuccessful Match.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Gets a point on the ray.
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public Vector3 GetPointOnRay(float t)
|
||||
{
|
||||
return (Origin + Direction * t);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
/// <summary>
|
||||
/// Get the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>Returns the hash code for this vector instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _origin.GetHashCode() ^ _direction.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="obj"/> is a <see cref="Vector3"/> and has the same values as this instance; otherwise, <see langword="false"/>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Ray)
|
||||
{
|
||||
Ray r = (Ray)obj;
|
||||
return ((_origin == r.Origin) && (_direction == r.Direction));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1})", _origin, _direction);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Comparison Operators
|
||||
/// <summary>
|
||||
/// Tests whether two specified rays are equal.
|
||||
/// </summary>
|
||||
/// <param name="a">The first of two rays to compare.</param>
|
||||
/// <param name="b">The second of two rays to compare.</param>
|
||||
/// <returns><see langword="true"/> if the two rays are equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator ==(Ray a, Ray b)
|
||||
{
|
||||
return ValueType.Equals(a, b);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two specified rays are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a">The first of two rays to compare.</param>
|
||||
/// <param name="b">The second of two rays to compare.</param>
|
||||
/// <returns><see langword="true"/> if the two rays are not equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator !=(Ray a, Ray b)
|
||||
{
|
||||
return !ValueType.Equals(a, b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public float intersectionTime(AxisAlignedBox box)
|
||||
{
|
||||
Vector3 dummy = Vector3.Zero;
|
||||
bool inside;
|
||||
float time = CollisionDetection.collisionTimeForMovingPointFixedAABox(_origin, _direction, box, ref dummy, out inside);
|
||||
|
||||
if (float.IsInfinity(time) && inside)
|
||||
return 0.0f;
|
||||
else
|
||||
return time;
|
||||
}
|
||||
|
||||
public Vector3 invDirection()
|
||||
{
|
||||
return Vector3.Divide(Vector3.One, Direction);
|
||||
}
|
||||
}
|
||||
|
||||
#region RayConverter class
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Ray"/> to and from string representation.
|
||||
/// </summary>
|
||||
public class RayConverter : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="sourceType">A <see cref="Type"/> that represents the type you want to convert from.</param>
|
||||
/// <returns><b>true</b> if this converter can perform the conversion; otherwise, <b>false</b>.</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
if (sourceType == typeof(string))
|
||||
return true;
|
||||
|
||||
return base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether this converter can convert the object to the specified type, using the specified context.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="destinationType">A <see cref="Type"/> that represents the type you want to convert to.</param>
|
||||
/// <returns><b>true</b> if this converter can perform the conversion; otherwise, <b>false</b>.</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return true;
|
||||
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the given value object to the specified type, using the specified context and culture information.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="culture">A <see cref="System.Globalization.CultureInfo"/> object. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed.</param>
|
||||
/// <param name="value">The <see cref="Object"/> to convert.</param>
|
||||
/// <param name="destinationType">The Type to convert the <paramref name="value"/> parameter to.</param>
|
||||
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if ((destinationType == typeof(string)) && (value is Ray))
|
||||
{
|
||||
Ray r = (Ray)value;
|
||||
return r.ToString();
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the given object to the type of this converter, using the specified context and culture information.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="culture">The <see cref="System.Globalization.CultureInfo"/> to use as the current culture. </param>
|
||||
/// <param name="value">The <see cref="Object"/> to convert.</param>
|
||||
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
|
||||
/// <exception cref="ParseException">Failed parsing from string.</exception>
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
|
||||
{
|
||||
if (value.GetType() == typeof(string))
|
||||
{
|
||||
return Ray.Parse((string)value);
|
||||
}
|
||||
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,948 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
* Copyright (C) 2003-2004 Eran Kampf eran@ekampf.com http://www.ekampf.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.GameMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents 2-Dimentional vector of single-precision floating point numbers.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[TypeConverter(typeof(Vector2FConverter))]
|
||||
public struct Vector2 : ICloneable
|
||||
{
|
||||
#region Private fields
|
||||
private float _x;
|
||||
private float _y;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Vector2"/> class with the specified coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x">The vector's X coordinate.</param>
|
||||
/// <param name="y">The vector's Y coordinate.</param>
|
||||
public Vector2(float x, float y)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Vector2"/> class with the specified coordinates.
|
||||
/// </summary>
|
||||
/// <param name="coordinates">An array containing the coordinate parameters.</param>
|
||||
public Vector2(float[] coordinates)
|
||||
{
|
||||
Debug.Assert(coordinates != null);
|
||||
Debug.Assert(coordinates.Length >= 2);
|
||||
|
||||
_x = coordinates[0];
|
||||
_y = coordinates[1];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Vector2"/> class with the specified coordinates.
|
||||
/// </summary>
|
||||
/// <param name="coordinates">An array containing the coordinate parameters.</param>
|
||||
public Vector2(List<float> coordinates)
|
||||
{
|
||||
Debug.Assert(coordinates != null);
|
||||
Debug.Assert(coordinates.Count >= 2);
|
||||
|
||||
_x = coordinates[0];
|
||||
_y = coordinates[1];
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Vector2"/> class using coordinates from a given <see cref="Vector2"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> to get the coordinates from.</param>
|
||||
public Vector2(Vector2 vector)
|
||||
{
|
||||
_x = vector.X;
|
||||
_y = vector.Y;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// 4-Dimentional single-precision floating point zero vector.
|
||||
/// </summary>
|
||||
public static readonly Vector2 Zero = new Vector2(0.0f, 0.0f);
|
||||
/// <summary>
|
||||
/// 4-Dimentional single-precision floating point X-Axis vector.
|
||||
/// </summary>
|
||||
public static readonly Vector2 XAxis = new Vector2(1.0f, 0.0f);
|
||||
/// <summary>
|
||||
/// 4-Dimentional single-precision floating point Y-Axis vector.
|
||||
/// </summary>
|
||||
public static readonly Vector2 YAxis = new Vector2(0.0f, 1.0f);
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
/// <summary>
|
||||
/// Gets or sets the x-coordinate of this vector.
|
||||
/// </summary>
|
||||
/// <value>The x-coordinate of this vector.</value>
|
||||
public float X
|
||||
{
|
||||
get { return _x; }
|
||||
set { _x = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the y-coordinate of this vector.
|
||||
/// </summary>
|
||||
/// <value>The y-coordinate of this vector.</value>
|
||||
public float Y
|
||||
{
|
||||
get { return _y; }
|
||||
set { _y = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Vector2"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Vector2"/> object this method creates, cast as an object.</returns>
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return new Vector2(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an exact copy of this <see cref="Vector2"/> object.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Vector2"/> object this method creates.</returns>
|
||||
public Vector2 Clone()
|
||||
{
|
||||
return new Vector2(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Parse Methods
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Vector2"/> equivalent.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Vector2"/>.</param>
|
||||
/// <returns>A <see cref="Vector2"/> that represents the vector specified by the <paramref name="value"/> parameter.</returns>
|
||||
public static Vector2 Parse(string value)
|
||||
{
|
||||
Regex r = new Regex(@"\((?<x>.*),(?<y>.*)\)", RegexOptions.Singleline);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
return new Vector2(
|
||||
float.Parse(m.Result("${x}")),
|
||||
float.Parse(m.Result("${y}"))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsuccessful Match.");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the specified string to its <see cref="Vector2"/> equivalent.
|
||||
/// A return value indicates whether the conversion succeeded or failed.
|
||||
/// </summary>
|
||||
/// <param name="value">A string representation of a <see cref="Vector2"/>.</param>
|
||||
/// <param name="result">
|
||||
/// When this method returns, if the conversion succeeded,
|
||||
/// contains a <see cref="Vector2"/> representing the vector specified by <paramref name="value"/>.
|
||||
/// </param>
|
||||
/// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool TryParse(string value, out Vector2 result)
|
||||
{
|
||||
Regex r = new Regex(@"\((?<x>.*),(?<y>.*)\)", RegexOptions.Singleline);
|
||||
Match m = r.Match(value);
|
||||
if (m.Success)
|
||||
{
|
||||
result = new Vector2(
|
||||
float.Parse(m.Result("${x}")),
|
||||
float.Parse(m.Result("${y}"))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result = Vector2.Zero;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Static Vector Arithmetics
|
||||
/// <summary>
|
||||
/// Adds two vectors.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the sum.</returns>
|
||||
public static Vector2 Add(Vector2 left, Vector2 right)
|
||||
{
|
||||
return new Vector2(left.X + right.X, left.Y + right.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a vector and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the sum.</returns>
|
||||
public static Vector2 Add(Vector2 vector, float scalar)
|
||||
{
|
||||
return new Vector2(vector.X + scalar, vector.Y + scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds two vectors and put the result in the third vector.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
public static void Add(Vector2 left, Vector2 right, ref Vector2 result)
|
||||
{
|
||||
result.X = left.X + right.X;
|
||||
result.Y = left.Y + right.Y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a vector and a scalar and put the result into another vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
public static void Add(Vector2 vector, float scalar, ref Vector2 result)
|
||||
{
|
||||
result.X = vector.X + scalar;
|
||||
result.Y = vector.Y + scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a vector from a vector.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the difference.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = left[i] - right[i].
|
||||
/// </remarks>
|
||||
public static Vector2 Subtract(Vector2 left, Vector2 right)
|
||||
{
|
||||
return new Vector2(left.X - right.X, left.Y - right.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the difference.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = vector[i] - scalar
|
||||
/// </remarks>
|
||||
public static Vector2 Subtract(Vector2 vector, float scalar)
|
||||
{
|
||||
return new Vector2(vector.X - scalar, vector.Y - scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a vector from a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the difference.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = scalar - vector[i]
|
||||
/// </remarks>
|
||||
public static Vector2 Subtract(float scalar, Vector2 vector)
|
||||
{
|
||||
return new Vector2(scalar - vector.X, scalar - vector.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a vector from a second vector and puts the result into a third vector.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
/// <remarks>
|
||||
/// result[i] = left[i] - right[i].
|
||||
/// </remarks>
|
||||
public static void Subtract(Vector2 left, Vector2 right, ref Vector2 result)
|
||||
{
|
||||
result.X = left.X - right.X;
|
||||
result.Y = left.Y - right.Y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a vector from a scalar and put the result into another vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
/// <remarks>
|
||||
/// result[i] = vector[i] - scalar
|
||||
/// </remarks>
|
||||
public static void Subtract(Vector2 vector, float scalar, ref Vector2 result)
|
||||
{
|
||||
result.X = vector.X - scalar;
|
||||
result.Y = vector.Y - scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a vector and put the result into another vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
/// <remarks>
|
||||
/// result[i] = scalar - vector[i]
|
||||
/// </remarks>
|
||||
public static void Subtract(float scalar, Vector2 vector, ref Vector2 result)
|
||||
{
|
||||
result.X = scalar - vector.X;
|
||||
result.Y = scalar - vector.Y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a vector by another vector.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the quotient.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = left[i] / right[i].
|
||||
/// </remarks>
|
||||
public static Vector2 Divide(Vector2 left, Vector2 right)
|
||||
{
|
||||
return new Vector2(left.X / right.X, left.Y / right.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a vector by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A scalar</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the quotient.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = vector[i] / scalar;
|
||||
/// </remarks>
|
||||
public static Vector2 Divide(Vector2 vector, float scalar)
|
||||
{
|
||||
return new Vector2(vector.X / scalar, vector.Y / scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a scalar by a vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A scalar</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the quotient.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = scalar / vector[i]
|
||||
/// </remarks>
|
||||
public static Vector2 Divide(float scalar, Vector2 vector)
|
||||
{
|
||||
return new Vector2(scalar / vector.X, scalar / vector.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a vector by another vector.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
/// <remarks>
|
||||
/// result[i] = left[i] / right[i]
|
||||
/// </remarks>
|
||||
public static void Divide(Vector2 left, Vector2 right, ref Vector2 result)
|
||||
{
|
||||
result.X = left.X / right.X;
|
||||
result.Y = left.Y / right.Y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a vector by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A scalar</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
/// <remarks>
|
||||
/// result[i] = vector[i] / scalar
|
||||
/// </remarks>
|
||||
public static void Divide(Vector2 vector, float scalar, ref Vector2 result)
|
||||
{
|
||||
result.X = vector.X / scalar;
|
||||
result.Y = vector.Y / scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a scalar by a vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A scalar</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
/// <remarks>
|
||||
/// result[i] = scalar / vector[i]
|
||||
/// </remarks>
|
||||
public static void Divide(float scalar, Vector2 vector, ref Vector2 result)
|
||||
{
|
||||
result.X = scalar / vector.X;
|
||||
result.Y = scalar / vector.Y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a vector by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the result.</returns>
|
||||
public static Vector2 Multiply(Vector2 vector, float scalar)
|
||||
{
|
||||
return new Vector2(vector.X * scalar, vector.Y * scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a vector by a scalar and put the result in another vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <param name="result">A <see cref="Vector2"/> instance to hold the result.</param>
|
||||
public static void Multiply(Vector2 vector, float scalar, ref Vector2 result)
|
||||
{
|
||||
result.X = vector.X * scalar;
|
||||
result.Y = vector.Y * scalar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Calculates the dot product of two vectors.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>The dot product value.</returns>
|
||||
public static float DotProduct(Vector2 left, Vector2 right)
|
||||
{
|
||||
return (left.X * right.X) + (left.Y * right.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Calculates the Kross product of two vectors.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>The Kross product value.</returns>
|
||||
/// <remarks>
|
||||
/// <p>
|
||||
/// The Kross product is defined as:
|
||||
/// Kross(u,v) = u.X*v.Y - u.Y*v.X.
|
||||
/// </p>
|
||||
/// <p>
|
||||
/// The operation is related to the cross product in 3D given by (x0, y0, 0) X (x1, y1, 0) = (0, 0, Kross((x0, y0), (x1, y1))).
|
||||
/// The operation has the property that Kross(u, v) = -Kross(v, u).
|
||||
/// </p>
|
||||
/// </remarks>
|
||||
public static float KrossProduct(Vector2 left, Vector2 right)
|
||||
{
|
||||
return (left.X * right.Y) - (left.Y * right.X);
|
||||
}
|
||||
/// <summary>
|
||||
/// Negates a vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the negated values.</returns>
|
||||
public static Vector2 Negate(Vector2 vector)
|
||||
{
|
||||
return new Vector2(-vector.X, -vector.Y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two vectors are approximately equal using default tolerance value.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool ApproxEqual(Vector2 left, Vector2 right)
|
||||
{
|
||||
return ApproxEqual(left, right, MathFunctions.Epsilon);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two vectors are approximately equal given a tolerance value.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="tolerance">The tolerance value used to test approximate equality.</param>
|
||||
/// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool ApproxEqual(Vector2 left, Vector2 right, float tolerance)
|
||||
{
|
||||
return
|
||||
(
|
||||
(System.Math.Abs(left.X - right.X) <= tolerance) &&
|
||||
(System.Math.Abs(left.Y - right.Y) <= tolerance)
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Scale the vector so that its length is 1.
|
||||
/// </summary>
|
||||
public void Normalize()
|
||||
{
|
||||
float length = GetLength();
|
||||
if (length == 0)
|
||||
{
|
||||
throw new DivideByZeroException("Trying to normalize a vector with length of zero.");
|
||||
}
|
||||
|
||||
_x /= length;
|
||||
_y /= length;
|
||||
}
|
||||
/// <summary>
|
||||
/// Calculates the length of the vector.
|
||||
/// </summary>
|
||||
/// <returns>Returns the length of the vector. (Sqrt(X*X + Y*Y))</returns>
|
||||
public float GetLength()
|
||||
{
|
||||
return (float)System.Math.Sqrt(_x * _x + _y * _y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Calculates the squared length of the vector.
|
||||
/// </summary>
|
||||
/// <returns>Returns the squared length of the vector. (X*X + Y*Y)</returns>
|
||||
public float GetLengthSquared()
|
||||
{
|
||||
return (_x * _x + _y * _y);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clamps vector values to zero using a given tolerance value.
|
||||
/// </summary>
|
||||
/// <param name="tolerance">The tolerance to use.</param>
|
||||
/// <remarks>
|
||||
/// The vector values that are close to zero within the given tolerance are set to zero.
|
||||
/// </remarks>
|
||||
public void ClampZero(float tolerance)
|
||||
{
|
||||
_x = MathFunctions.Clamp(_x, 0, tolerance);
|
||||
_y = MathFunctions.Clamp(_y, 0, tolerance);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clamps vector values to zero using the default tolerance value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The vector values that are close to zero within the given tolerance are set to zero.
|
||||
/// The tolerance value used is <see cref="MathFunctions.EpsilonD"/>
|
||||
/// </remarks>
|
||||
public void ClampZero()
|
||||
{
|
||||
_x = MathFunctions.Clamp(_x, 0);
|
||||
_y = MathFunctions.Clamp(_y, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region System.Object Overrides
|
||||
/// <summary>
|
||||
/// Returns the hashcode for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _x.GetHashCode() ^ _y.GetHashCode();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this instance is equal to
|
||||
/// the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare to this instance.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="obj"/> is a <see cref="Vector2"/> and has the same values as this instance; otherwise, <see langword="false"/>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Vector2)
|
||||
{
|
||||
Vector2 v = (Vector2)obj;
|
||||
return (_x == v.X) && (_y == v.Y);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1})", _x, _y);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Comparison Operators
|
||||
/// <summary>
|
||||
/// Tests whether two specified vectors are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two vectors are equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator ==(Vector2 left, Vector2 right)
|
||||
{
|
||||
return ValueType.Equals(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests whether two specified vectors are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the two vectors are not equal; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator !=(Vector2 left, Vector2 right)
|
||||
{
|
||||
return !ValueType.Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests if a vector's components are greater than another vector's components.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the left-hand vector's components are greater than the right-hand vector's component; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator >(Vector2 left, Vector2 right)
|
||||
{
|
||||
return (
|
||||
(left._x > right._x) &&
|
||||
(left._y > right._y));
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests if a vector's components are smaller than another vector's components.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the left-hand vector's components are smaller than the right-hand vector's component; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator <(Vector2 left, Vector2 right)
|
||||
{
|
||||
return (
|
||||
(left._x < right._x) &&
|
||||
(left._y < right._y));
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests if a vector's components are greater or equal than another vector's components.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the left-hand vector's components are greater or equal than the right-hand vector's component; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator >=(Vector2 left, Vector2 right)
|
||||
{
|
||||
return (
|
||||
(left._x >= right._x) &&
|
||||
(left._y >= right._y));
|
||||
}
|
||||
/// <summary>
|
||||
/// Tests if a vector's components are smaller or equal than another vector's components.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns><see langword="true"/> if the left-hand vector's components are smaller or equal than the right-hand vector's component; otherwise, <see langword="false"/>.</returns>
|
||||
public static bool operator <=(Vector2 left, Vector2 right)
|
||||
{
|
||||
return (
|
||||
(left._x <= right._x) &&
|
||||
(left._y <= right._y));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Unary Operators
|
||||
/// <summary>
|
||||
/// Negates the values of the given vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the negated values.</returns>
|
||||
public static Vector2 operator -(Vector2 vector)
|
||||
{
|
||||
return Vector2.Negate(vector);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Binary Operators
|
||||
/// <summary>
|
||||
/// Adds two vectors.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the sum.</returns>
|
||||
public static Vector2 operator +(Vector2 left, Vector2 right)
|
||||
{
|
||||
return Vector2.Add(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a vector and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the sum.</returns>
|
||||
public static Vector2 operator +(Vector2 vector, float scalar)
|
||||
{
|
||||
return Vector2.Add(vector, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a vector and a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the sum.</returns>
|
||||
public static Vector2 operator +(float scalar, Vector2 vector)
|
||||
{
|
||||
return Vector2.Add(vector, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a vector from a vector.
|
||||
/// </summary>
|
||||
/// <param name="left">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="right">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the difference.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = left[i] - right[i].
|
||||
/// </remarks>
|
||||
public static Vector2 operator -(Vector2 left, Vector2 right)
|
||||
{
|
||||
return Vector2.Subtract(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the difference.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = vector[i] - scalar
|
||||
/// </remarks>
|
||||
public static Vector2 operator -(Vector2 vector, float scalar)
|
||||
{
|
||||
return Vector2.Subtract(vector, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a vector from a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> instance containing the difference.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = scalar - vector[i]
|
||||
/// </remarks>
|
||||
public static Vector2 operator -(float scalar, Vector2 vector)
|
||||
{
|
||||
return Vector2.Subtract(scalar, vector);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a vector by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the result.</returns>
|
||||
public static Vector2 operator *(Vector2 vector, float scalar)
|
||||
{
|
||||
return Vector2.Multiply(vector, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Multiplies a vector by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A single-precision floating-point number.</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the result.</returns>
|
||||
public static Vector2 operator *(float scalar, Vector2 vector)
|
||||
{
|
||||
return Vector2.Multiply(vector, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a vector by a scalar.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A scalar</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the quotient.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = vector[i] / scalar;
|
||||
/// </remarks>
|
||||
public static Vector2 operator /(Vector2 vector, float scalar)
|
||||
{
|
||||
return Vector2.Divide(vector, scalar);
|
||||
}
|
||||
/// <summary>
|
||||
/// Divides a scalar by a vector.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <param name="scalar">A scalar</param>
|
||||
/// <returns>A new <see cref="Vector2"/> containing the quotient.</returns>
|
||||
/// <remarks>
|
||||
/// result[i] = scalar / vector[i]
|
||||
/// </remarks>
|
||||
public static Vector2 operator /(float scalar, Vector2 vector)
|
||||
{
|
||||
return Vector2.Divide(scalar, vector);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Array Indexing Operator
|
||||
/// <summary>
|
||||
/// Indexer ( [x, y] ).
|
||||
/// </summary>
|
||||
public float this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
return _x;
|
||||
case 1:
|
||||
return _y;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
_x = value;
|
||||
break;
|
||||
case 1:
|
||||
_y = value;
|
||||
break;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Conversion Operators
|
||||
/// <summary>
|
||||
/// Converts the vector to an array of single-precision floating point values.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>An array of single-precision floating point values.</returns>
|
||||
public static explicit operator float[] (Vector2 vector)
|
||||
{
|
||||
float[] array = new float[2];
|
||||
array[0] = vector.X;
|
||||
array[1] = vector.Y;
|
||||
return array;
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the vector to a <see cref="System.Collections.Generic.List"/> of single-precision floating point values.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A <see cref="System.Collections.Generic.List"/> of single-precision floating point values.</returns>
|
||||
public static explicit operator List<float>(Vector2 vector)
|
||||
{
|
||||
List<float> list = new List<float>();
|
||||
list.Add(vector.X);
|
||||
list.Add(vector.Y);
|
||||
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the vector to a <see cref="System.Collections.Generic.LinkedList"/> of single-precision floating point values.
|
||||
/// </summary>
|
||||
/// <param name="vector">A <see cref="Vector2"/> instance.</param>
|
||||
/// <returns>A <see cref="System.Collections.Generic.LinkedList"/> of single-precision floating point values.</returns>
|
||||
public static explicit operator LinkedList<float>(Vector2 vector)
|
||||
{
|
||||
LinkedList<float> list = new LinkedList<float>();
|
||||
list.AddLast(vector.X);
|
||||
list.AddLast(vector.Y);
|
||||
|
||||
return list;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Vector2FConverter class
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Vector2"/> to and from string representation.
|
||||
/// </summary>
|
||||
public class Vector2FConverter : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="sourceType">A <see cref="Type"/> that represents the type you want to convert from.</param>
|
||||
/// <returns><b>true</b> if this converter can perform the conversion; otherwise, <b>false</b>.</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
if (sourceType == typeof(string))
|
||||
return true;
|
||||
|
||||
return base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether this converter can convert the object to the specified type, using the specified context.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="destinationType">A <see cref="Type"/> that represents the type you want to convert to.</param>
|
||||
/// <returns><b>true</b> if this converter can perform the conversion; otherwise, <b>false</b>.</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return true;
|
||||
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the given value object to the specified type, using the specified context and culture information.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="culture">A <see cref="System.Globalization.CultureInfo"/> object. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed.</param>
|
||||
/// <param name="value">The <see cref="Object"/> to convert.</param>
|
||||
/// <param name="destinationType">The Type to convert the <paramref name="value"/> parameter to.</param>
|
||||
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if ((destinationType == typeof(string)) && (value is Vector2))
|
||||
{
|
||||
Vector2 v = (Vector2)value;
|
||||
return v.ToString();
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the given object to the type of this converter, using the specified context and culture information.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <param name="culture">The <see cref="System.Globalization.CultureInfo"/> to use as the current culture. </param>
|
||||
/// <param name="value">The <see cref="Object"/> to convert.</param>
|
||||
/// <returns>An <see cref="Object"/> that represents the converted value.</returns>
|
||||
/// <exception cref="ParseException">Failed parsing from string.</exception>
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
|
||||
{
|
||||
if (value.GetType() == typeof(string))
|
||||
{
|
||||
return Vector2.Parse((string)value);
|
||||
}
|
||||
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be picked from a list.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
|
||||
/// <returns><b>true</b> if <see cref="GetStandardValues"/> should be called to find a common set of values the object supports; otherwise, <b>false</b>.</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values for the data type this type converter is designed for when provided with a format context.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be a null reference.</param>
|
||||
/// <returns>A <see cref="TypeConverter.StandardValuesCollection"/> that holds a standard set of valid values, or a null reference (Nothing in Visual Basic) if the data type does not support a standard set of values.</returns>
|
||||
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
StandardValuesCollection svc =
|
||||
new StandardValuesCollection(new object[3] { Vector2.Zero, Vector2.XAxis, Vector2.YAxis });
|
||||
|
||||
return svc;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,480 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 Framework.GameMath;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Framework.IO
|
||||
{
|
||||
public class ByteBuffer : IDisposable
|
||||
{
|
||||
public ByteBuffer()
|
||||
{
|
||||
writeStream = new BinaryWriter(new MemoryStream());
|
||||
}
|
||||
|
||||
public ByteBuffer(byte[] data)
|
||||
{
|
||||
readStream = new BinaryReader(new MemoryStream(data));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (writeStream != null)
|
||||
writeStream.Dispose();
|
||||
|
||||
if (readStream != null)
|
||||
readStream.Dispose();
|
||||
}
|
||||
|
||||
#region Read Methods
|
||||
public sbyte ReadInt8()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadSByte();
|
||||
}
|
||||
|
||||
public short ReadInt16()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadInt16();
|
||||
}
|
||||
|
||||
public int ReadInt32()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadInt32();
|
||||
}
|
||||
|
||||
public long ReadInt64()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadInt64();
|
||||
}
|
||||
|
||||
public byte ReadUInt8()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadByte();
|
||||
}
|
||||
|
||||
public ushort ReadUInt16()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadUInt16();
|
||||
}
|
||||
|
||||
public uint ReadUInt32()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadUInt32();
|
||||
}
|
||||
|
||||
public ulong ReadUInt64()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadUInt64();
|
||||
}
|
||||
|
||||
public float ReadFloat()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadSingle();
|
||||
}
|
||||
|
||||
public double ReadDouble()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadDouble();
|
||||
}
|
||||
|
||||
public string ReadCString()
|
||||
{
|
||||
ResetBitPos();
|
||||
StringBuilder tmpString = new StringBuilder();
|
||||
char tmpChar = readStream.ReadChar();
|
||||
char tmpEndChar = Convert.ToChar(Encoding.UTF8.GetString(new byte[] { 0 }));
|
||||
|
||||
while (tmpChar != tmpEndChar)
|
||||
{
|
||||
tmpString.Append(tmpChar);
|
||||
tmpChar = readStream.ReadChar();
|
||||
}
|
||||
|
||||
return tmpString.ToString();
|
||||
}
|
||||
|
||||
public string ReadString(uint length)
|
||||
{
|
||||
if (length == 0)
|
||||
return "";
|
||||
|
||||
ResetBitPos();
|
||||
return Encoding.UTF8.GetString(ReadBytes(length));
|
||||
}
|
||||
|
||||
public bool ReadBool()
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadBoolean();
|
||||
}
|
||||
|
||||
public byte[] ReadBytes(uint count)
|
||||
{
|
||||
ResetBitPos();
|
||||
return readStream.ReadBytes((int)count);
|
||||
}
|
||||
|
||||
public void Skip(int count)
|
||||
{
|
||||
ResetBitPos();
|
||||
readStream.BaseStream.Position += count;
|
||||
}
|
||||
|
||||
public uint ReadPackedTime()
|
||||
{
|
||||
uint packedDate = ReadUInt32();
|
||||
var time = new DateTime((int)((packedDate >> 24) & 0x1F) + 2000, (int)((packedDate >> 20) & 0xF) + 1, (int)((packedDate >> 14) & 0x3F) + 1, (int)(packedDate >> 6) & 0x1F, (int)(packedDate & 0x3F), 0);
|
||||
return (uint)Time.DateTimeToUnixTime(time);
|
||||
}
|
||||
|
||||
public Vector3 ReadVector3()
|
||||
{
|
||||
return new Vector3(ReadFloat(), ReadFloat(), ReadFloat());
|
||||
}
|
||||
|
||||
//BitPacking
|
||||
public byte ReadBit()
|
||||
{
|
||||
if (BitPosition == 8)
|
||||
{
|
||||
BitValue = ReadUInt8();
|
||||
BitPosition = 0;
|
||||
}
|
||||
|
||||
int returnValue = BitValue;
|
||||
BitValue = (byte)(2 * returnValue);
|
||||
++BitPosition;
|
||||
|
||||
return (byte)(returnValue >> 7);
|
||||
}
|
||||
|
||||
public bool HasBit()
|
||||
{
|
||||
if (BitPosition == 8)
|
||||
{
|
||||
BitValue = ReadUInt8();
|
||||
BitPosition = 0;
|
||||
}
|
||||
|
||||
int returnValue = BitValue;
|
||||
BitValue = (byte)(2 * returnValue);
|
||||
++BitPosition;
|
||||
|
||||
return Convert.ToBoolean(returnValue >> 7);
|
||||
}
|
||||
|
||||
public T ReadBits<T>(int bitCount)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
for (var i = bitCount - 1; i >= 0; --i)
|
||||
if (HasBit())
|
||||
value |= (1 << i);
|
||||
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Write Methods
|
||||
public void WriteInt8<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToSByte(data));
|
||||
}
|
||||
|
||||
public void WriteInt16<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToInt16(data));
|
||||
}
|
||||
|
||||
public void WriteInt32<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToInt32(data));
|
||||
}
|
||||
|
||||
public void WriteInt64<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToInt64(data));
|
||||
}
|
||||
|
||||
public void WriteUInt8<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToByte(data));
|
||||
}
|
||||
|
||||
public void WriteUInt16<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToUInt16(data));
|
||||
}
|
||||
|
||||
public void WriteUInt32<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToUInt32(data));
|
||||
}
|
||||
|
||||
public void WriteUInt64<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToUInt64(data));
|
||||
}
|
||||
|
||||
public void WriteFloat<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToSingle(data));
|
||||
}
|
||||
|
||||
public void WriteDouble<T>(T data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(Convert.ToDouble(data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a string to the packet with a null terminated (0)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void WriteCString(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
WriteUInt8(0);
|
||||
return;
|
||||
}
|
||||
|
||||
WriteString(str);
|
||||
WriteUInt8(0);
|
||||
}
|
||||
|
||||
public void WriteString(string str)
|
||||
{
|
||||
byte[] sBytes = Encoding.UTF8.GetBytes(str);
|
||||
WriteBytes(sBytes);
|
||||
}
|
||||
|
||||
public void WriteBytes(byte[] data)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void WriteBytes(byte[] data, uint count)
|
||||
{
|
||||
FlushBits();
|
||||
writeStream.Write(data, 0, (int)count);
|
||||
}
|
||||
|
||||
public void WriteBytes(ByteBuffer buffer)
|
||||
{
|
||||
WriteBytes(buffer.GetData());
|
||||
}
|
||||
|
||||
public void Replace<T>(int pos, T value)
|
||||
{
|
||||
int retpos = (int)writeStream.BaseStream.Position;
|
||||
|
||||
writeStream.Seek(pos, SeekOrigin.Begin);
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "Byte":
|
||||
WriteUInt8(Convert.ToByte(value));
|
||||
break;
|
||||
case "SByte":
|
||||
WriteInt8(Convert.ToSByte(value));
|
||||
break;
|
||||
case "Float":
|
||||
WriteFloat(Convert.ToSingle(value));
|
||||
break;
|
||||
case "Int16":
|
||||
WriteInt16(Convert.ToInt16(value));
|
||||
break;
|
||||
case "UInt16":
|
||||
WriteUInt16(Convert.ToUInt16(value));
|
||||
break;
|
||||
case "Int32":
|
||||
WriteInt32(Convert.ToInt32(value));
|
||||
break;
|
||||
case "UInt32":
|
||||
WriteUInt32(Convert.ToUInt32(value));
|
||||
break;
|
||||
case "Int64":
|
||||
WriteInt64(Convert.ToInt64(value));
|
||||
break;
|
||||
case "UInt64":
|
||||
WriteUInt64(Convert.ToUInt64(value));
|
||||
break;
|
||||
}
|
||||
writeStream.Seek(retpos, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public void WriteVector3(Vector3 pos)
|
||||
{
|
||||
WriteFloat(pos.X);
|
||||
WriteFloat(pos.Y);
|
||||
WriteFloat(pos.Z);
|
||||
}
|
||||
|
||||
public void WriteVector2(Vector2 pos)
|
||||
{
|
||||
WriteFloat(pos.X);
|
||||
WriteFloat(pos.Y);
|
||||
}
|
||||
|
||||
public void WritePackXYZ(Vector3 pos)
|
||||
{
|
||||
uint packed = 0;
|
||||
packed |= ((uint)(pos.X / 0.25f) & 0x7FF);
|
||||
packed |= ((uint)(pos.Y / 0.25f) & 0x7FF) << 11;
|
||||
packed |= ((uint)(pos.Z / 0.25f) & 0x3FF) << 22;
|
||||
WriteUInt32(packed);
|
||||
}
|
||||
|
||||
public bool WriteBit(object bit)
|
||||
{
|
||||
--BitPosition;
|
||||
|
||||
if (Convert.ToBoolean(bit))
|
||||
BitValue |= (byte)(1 << BitPosition);
|
||||
|
||||
if (BitPosition == 0)
|
||||
{
|
||||
writeStream.Write(BitValue);
|
||||
|
||||
BitPosition = 8;
|
||||
BitValue = 0;
|
||||
}
|
||||
return Convert.ToBoolean(bit);
|
||||
}
|
||||
|
||||
public void WriteBits(object bit, int count)
|
||||
{
|
||||
for (int i = count - 1; i >= 0; --i)
|
||||
WriteBit((Convert.ToInt32(bit) >> i) & 1);
|
||||
}
|
||||
|
||||
public void WritePackedTime(long time)
|
||||
{
|
||||
var now = Time.UnixTimeToDateTime(time);
|
||||
WriteUInt32(Convert.ToUInt32((now.Year - 2000) << 24 | (now.Month - 1) << 20 | (now.Day - 1) << 14 | (int)now.DayOfWeek << 11 | now.Hour << 6 | now.Minute));
|
||||
}
|
||||
|
||||
public void WritePackedTime()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
WriteUInt32(Convert.ToUInt32((now.Year - 2000) << 24 | (now.Month - 1) << 20 | (now.Day - 1) << 14 | (int)now.DayOfWeek << 11 | now.Hour << 6 | now.Minute));
|
||||
}
|
||||
#endregion
|
||||
|
||||
public int GetPosition()
|
||||
{
|
||||
long pos = 0;
|
||||
if (writeStream != null)
|
||||
pos = writeStream.BaseStream.Position;
|
||||
else if (readStream != null)
|
||||
pos = readStream.BaseStream.Position;
|
||||
|
||||
return (int)pos;
|
||||
}
|
||||
|
||||
public void SetPosition(long pos)
|
||||
{
|
||||
if (writeStream != null)
|
||||
writeStream.BaseStream.Position = pos;
|
||||
else if (readStream != null)
|
||||
readStream.BaseStream.Position = pos;
|
||||
}
|
||||
|
||||
public void FlushBits()
|
||||
{
|
||||
if (BitPosition == 8)
|
||||
return;
|
||||
|
||||
writeStream.Write(BitValue);
|
||||
BitValue = 0;
|
||||
BitPosition = 8;
|
||||
}
|
||||
|
||||
public void ResetBitPos()
|
||||
{
|
||||
if (BitPosition > 7)
|
||||
return;
|
||||
|
||||
BitPosition = 8;
|
||||
BitValue = 0;
|
||||
}
|
||||
|
||||
public byte[] GetData()
|
||||
{
|
||||
long pos;
|
||||
Stream stream = GetCurrentStream();
|
||||
|
||||
var data = new byte[stream.Length];
|
||||
|
||||
pos = stream.Position;
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
data[i] = (byte)stream.ReadByte();
|
||||
|
||||
stream.Seek(pos, SeekOrigin.Begin);
|
||||
return data;
|
||||
}
|
||||
|
||||
public uint GetSize()
|
||||
{
|
||||
return (uint)GetCurrentStream().Length;
|
||||
}
|
||||
|
||||
public Stream GetCurrentStream()
|
||||
{
|
||||
if (writeStream != null)
|
||||
return writeStream.BaseStream;
|
||||
else
|
||||
return readStream.BaseStream;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
BitPosition = 8;
|
||||
BitValue = 0;
|
||||
writeStream = new BinaryWriter(new MemoryStream());
|
||||
}
|
||||
|
||||
byte BitPosition = 8;
|
||||
byte BitValue;
|
||||
BinaryWriter writeStream;
|
||||
BinaryReader readStream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Framework.IO
|
||||
{
|
||||
public sealed class StringArguments
|
||||
{
|
||||
public StringArguments(string args)
|
||||
{
|
||||
if (!args.IsEmpty())
|
||||
activestring = args.TrimStart(' ');
|
||||
activeposition = -1;
|
||||
}
|
||||
|
||||
public bool Empty()
|
||||
{
|
||||
return activestring.IsEmpty();
|
||||
}
|
||||
|
||||
public void MoveToNextChar(char c)
|
||||
{
|
||||
for (var i = activeposition; i < activestring.Length; ++i)
|
||||
if (activestring[i] == c)
|
||||
break;
|
||||
}
|
||||
|
||||
public string NextString(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return "";
|
||||
|
||||
Contract.Assume(Current != null);
|
||||
return Current;
|
||||
}
|
||||
|
||||
public bool NextBoolean(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return false;
|
||||
|
||||
bool value;
|
||||
if (bool.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public char NextChar(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(char);
|
||||
|
||||
char value;
|
||||
if (char.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(char);
|
||||
}
|
||||
|
||||
public byte NextByte(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(byte);
|
||||
|
||||
byte value;
|
||||
if (byte.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(byte);
|
||||
}
|
||||
|
||||
public sbyte NextSByte(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(sbyte);
|
||||
|
||||
sbyte value;
|
||||
if (sbyte.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(sbyte);
|
||||
}
|
||||
|
||||
public ushort NextUInt16(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(ushort);
|
||||
|
||||
ushort value;
|
||||
if (ushort.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(ushort);
|
||||
}
|
||||
|
||||
public short NextInt16(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(short);
|
||||
|
||||
short value;
|
||||
if (short.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(short);
|
||||
}
|
||||
|
||||
public uint NextUInt32(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(uint);
|
||||
|
||||
uint value;
|
||||
if (uint.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(uint);
|
||||
}
|
||||
|
||||
public int NextInt32(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(int);
|
||||
|
||||
int value;
|
||||
if (int.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(int);
|
||||
}
|
||||
|
||||
public ulong NextUInt64(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(ulong);
|
||||
|
||||
ulong value;
|
||||
if (ulong.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(ulong);
|
||||
}
|
||||
|
||||
public long NextInt64(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(long);
|
||||
|
||||
long value;
|
||||
if (long.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(long);
|
||||
}
|
||||
|
||||
public float NextSingle(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(float);
|
||||
|
||||
float value;
|
||||
if (float.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(float);
|
||||
}
|
||||
|
||||
public double NextDouble(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(double);
|
||||
|
||||
double value;
|
||||
if (double.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(double);
|
||||
}
|
||||
|
||||
public decimal NextDecimal(string delimiters = " ")
|
||||
{
|
||||
if (!MoveNext(delimiters))
|
||||
return default(decimal);
|
||||
|
||||
decimal value;
|
||||
if (decimal.TryParse(Current, out value))
|
||||
return value;
|
||||
|
||||
return default(decimal);
|
||||
}
|
||||
|
||||
public void AlignToNextChar()
|
||||
{
|
||||
while (activeposition < activestring.Length && activestring[activeposition] != ' ')
|
||||
activeposition++;
|
||||
}
|
||||
|
||||
public char this[int index]
|
||||
{
|
||||
get { return activestring[index]; }
|
||||
}
|
||||
|
||||
public string GetString()
|
||||
{
|
||||
return activestring;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
activeposition = -1;
|
||||
Current = null;
|
||||
}
|
||||
|
||||
bool MoveNext(string delimiters)
|
||||
{
|
||||
//the stringtotokenize was never set:
|
||||
if (activestring == null)
|
||||
return false;
|
||||
|
||||
//all tokens have already been extracted:
|
||||
if (activeposition == activestring.Length)
|
||||
return false;
|
||||
|
||||
//bypass delimiters:
|
||||
activeposition++;
|
||||
while (activeposition < activestring.Length && delimiters.IndexOf(activestring[activeposition]) > -1)
|
||||
{
|
||||
activeposition++;
|
||||
}
|
||||
|
||||
//only delimiters were left, so return null:
|
||||
if (activeposition == activestring.Length)
|
||||
return false;
|
||||
|
||||
//get starting position of string to return:
|
||||
int startingposition = activeposition;
|
||||
|
||||
//read until next delimiter:
|
||||
do
|
||||
{
|
||||
activeposition++;
|
||||
} while (activeposition < activestring.Length && delimiters.IndexOf(activestring[activeposition]) == -1);
|
||||
|
||||
Current = activestring.Substring(startingposition, activeposition - startingposition);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Match(string pattern, out Match m)
|
||||
{
|
||||
Regex r = new Regex(pattern);
|
||||
m = r.Match(activestring);
|
||||
return m.Success;
|
||||
}
|
||||
|
||||
private string activestring;
|
||||
private int activeposition;
|
||||
private string Current;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// adler32.cs -- compute the Adler-32 checksum of a data stream
|
||||
// Copyright (C) 1995-2007 Mark Adler
|
||||
// Copyright (C) 2007-2011 by the Authors
|
||||
// For conditions of distribution and use, see copyright notice in License.txt
|
||||
|
||||
|
||||
namespace Framework.IO
|
||||
{
|
||||
public static partial class ZLib
|
||||
{
|
||||
private const uint BASE=65521; // largest prime smaller than 65536
|
||||
private const uint NMAX=5552; // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
|
||||
|
||||
// =========================================================================
|
||||
|
||||
// Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum.
|
||||
// If buf is NULL, this function returns the required initial value for the checksum.
|
||||
// An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster.
|
||||
//
|
||||
// Usage example:
|
||||
// uint adler=adler32(0, null, 0);
|
||||
// while(read_buffer(buffer, length)!=EOF)
|
||||
// {
|
||||
// adler=adler32(adler, buffer, length);
|
||||
// }
|
||||
// if(adler!=original_adler) error();
|
||||
|
||||
public static uint adler32(uint adler, byte[] buf, uint len)
|
||||
{
|
||||
return adler32(adler, buf, 0, len);
|
||||
}
|
||||
|
||||
public static uint adler32(uint adler, byte[] buf, uint ind, uint len)
|
||||
{
|
||||
// initial Adler-32 value (deferred check for len==1 speed)
|
||||
if(buf==null) return 1;
|
||||
|
||||
// split Adler-32 into component sums
|
||||
uint sum2=(adler>>16)&0xffff;
|
||||
adler&=0xffff;
|
||||
|
||||
//uint ind=0; // index in buf
|
||||
|
||||
// in case user likes doing a byte at a time, keep it fast
|
||||
if(len==1)
|
||||
{
|
||||
adler+=buf[ind];
|
||||
if(adler>=BASE) adler-=BASE;
|
||||
sum2+=adler;
|
||||
if(sum2>=BASE) sum2-=BASE;
|
||||
return adler|(sum2<<16);
|
||||
}
|
||||
|
||||
// in case short lengths are provided, keep it somewhat fast
|
||||
if(len<16)
|
||||
{
|
||||
while(len--!=0)
|
||||
{
|
||||
adler+=buf[ind++];
|
||||
sum2+=adler;
|
||||
}
|
||||
if(adler>=BASE) adler-=BASE;
|
||||
sum2%=BASE; // only added so many BASE's
|
||||
return adler|(sum2<<16);
|
||||
}
|
||||
|
||||
// do length NMAX blocks -- requires just one modulo operation
|
||||
while(len>=NMAX)
|
||||
{
|
||||
len-=NMAX;
|
||||
uint n=NMAX/16; // NMAX is divisible by 16
|
||||
do
|
||||
{
|
||||
// 16 sums unrolled
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
} while(--n!=0);
|
||||
|
||||
adler%=BASE;
|
||||
sum2%=BASE;
|
||||
}
|
||||
|
||||
// do remaining bytes (less than NMAX, still just one modulo)
|
||||
if(len!=0)
|
||||
{ // avoid modulos if none remaining
|
||||
while(len>=16)
|
||||
{
|
||||
len-=16;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
adler+=buf[ind++]; sum2+=adler;
|
||||
}
|
||||
|
||||
while(len--!=0)
|
||||
{
|
||||
adler+=buf[ind++];
|
||||
sum2+=adler;
|
||||
}
|
||||
|
||||
adler%=BASE;
|
||||
sum2%=BASE;
|
||||
}
|
||||
|
||||
// return recombined sums
|
||||
return adler|(sum2<<16);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
||||
// Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
|
||||
// and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
|
||||
// each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
|
||||
// seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
|
||||
|
||||
public static uint adler32_combine_(uint adler1, uint adler2, uint len2)
|
||||
{ // the derivation of this formula is left as an exercise for the reader
|
||||
uint rem=len2%BASE;
|
||||
uint sum1=adler1&0xffff;
|
||||
uint sum2=(rem*sum1)%BASE;
|
||||
sum1+=(adler2&0xffff)+BASE-1;
|
||||
sum2+=((adler1>>16)&0xffff)+((adler2>>16)&0xffff)+BASE-rem;
|
||||
if(sum1>=BASE) sum1-=BASE;
|
||||
if(sum1>=BASE) sum1-=BASE;
|
||||
if(sum2>=(BASE<<1)) sum2-=(BASE<<1);
|
||||
if(sum2>=BASE) sum2-=BASE;
|
||||
return sum1|(sum2<<16);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
public static uint adler32_combine(uint adler1, uint adler2, uint len2)
|
||||
{
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
||||
public static uint adler32_combine64(uint adler1, uint adler2, uint len2)
|
||||
{
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user