Updated DB2 structs

This commit is contained in:
hondacrx
2018-02-26 13:13:54 -05:00
parent 0a3dfaba37
commit 82dca6de94
61 changed files with 2639 additions and 2517 deletions
@@ -157,6 +157,7 @@ namespace Framework.Constants
//CRITERIA_ADDITIONAL_CONDITION_UNK86 = 86, // Some external event id
//CRITERIA_ADDITIONAL_CONDITION_UNK87 = 87, // Achievement id
BattlePetSpecies = 91,
Expansion = 92,
GarrisonFollowerEntry = 144,
GarrisonFollowerQuality = 145,
GarrisonFollowerLevel = 146,
@@ -403,7 +404,7 @@ namespace Framework.Constants
GainParagonReputation = 206,
EarnHonorXp = 207,
RelicTalentUnlocked = 211,
TotalTypes = 212
TotalTypes = 213
}
public enum CriteriaDataType
+2 -2
View File
@@ -849,7 +849,7 @@ namespace Framework.Constants
FlyWarriorChargeEnd = 821
}
public enum AreaFlags
public enum AreaFlags : int
{
Snow = 0x01, // Snow (Only Dun Morogh, Naxxramas, Razorfen Downs And Winterspring)
Unk1 = 0x02, // Razorfen Downs, Naxxramas And Acherus: The Ebon Hold (3.3.5a)
@@ -1232,7 +1232,7 @@ namespace Framework.Constants
Prime = 2
}
public enum ItemSetFlags
public enum ItemSetFlags : byte
{
LegacyInactive = 0x01,
}
+2 -1
View File
@@ -343,7 +343,8 @@ namespace Framework.Constants
ItemLevelCanIncrease = 14, // Displays a + next to item level indicating it can warforge
RandomEnchantment = 15, // Responsible for showing "<Random additional stats>" or "+%d Rank Random Minor Trait" in the tooltip before item is obtained
Bounding = 16,
RelicType = 17
RelicType = 17,
OverrideRequiredLevel = 18
}
public enum ItemEnchantmentType : byte
+1 -1
View File
@@ -131,7 +131,7 @@ namespace Framework.Constants
// uses this category
}
public enum SummonType
public enum SummonType: byte
{
None = 0,
Pet = 1,
+1 -1
View File
@@ -44,7 +44,7 @@ namespace Framework.Constants
public const uint infinityCooldownDelayCheck = Time.Month / 2;
public const int MaxPlayerSummonDelay = 2 * Time.Minute;
public const int TaxiMaskSize = 253;
public const int TaxiMaskSize = 258;
// corpse reclaim times
public const int DeathExpireStep = (5 * Time.Minute);
+9 -4
View File
@@ -505,14 +505,19 @@ namespace Framework.Constants
PandarenNeutral = 24,
PandarenAlliance = 25,
PandarenHorde = 26,
Max = 27,
Nightborne = 27,
HighmountainTauren = 28,
VoidElf = 29,
LightforgedDraenei = 30,
Max = 31,
RaceMaskAllPlayable = ((1 << (Human - 1)) | (1 << (Orc - 1)) | (1 << (Dwarf - 1)) | (1 << (NightElf - 1)) | (1 << (Undead - 1))
| (1 << (Tauren - 1)) | (1 << (Gnome - 1)) | (1 << (Troll - 1)) | (1 << (BloodElf - 1)) | (1 << (Draenei - 1))
| (1 << (Goblin - 1)) | (1 << (Worgen - 1)) | (1 << (PandarenNeutral - 1)) | (1 << (PandarenAlliance - 1)) | (1 << (PandarenHorde - 1))),
| (1 << (Goblin - 1)) | (1 << (Worgen - 1)) | (1 << (PandarenNeutral - 1)) | (1 << (PandarenAlliance - 1)) | (1 << (PandarenHorde - 1))
| (1 << (Nightborne - 1)) | (1 << (HighmountainTauren - 1)) | (1 << (VoidElf - 1)) | (1 << (LightforgedDraenei - 1))),
RaceMaskAlliance = ((1 << (Human - 1)) | (1 << (Dwarf - 1)) | (1 << (NightElf - 1)) |
(1 << (Gnome - 1)) | (1 << (Draenei - 1)) | (1 << (Worgen - 1)) | (1 << (PandarenAlliance - 1))),
RaceMaskAlliance = ((1 << (Human - 1)) | (1 << (Dwarf - 1)) | (1 << (NightElf - 1)) | (1 << (Gnome - 1))
| (1 << (Draenei - 1)) | (1 << (Worgen - 1)) | (1 << (PandarenAlliance - 1)) | (1 << (VoidElf - 1)) | (1<<(LightforgedDraenei - 1))),
RaceMaskHorde = RaceMaskAllPlayable & ~RaceMaskAlliance
}
File diff suppressed because it is too large Load Diff
+94
View File
@@ -0,0 +1,94 @@
/*
* Copyright (C) 2012-2018 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.Text;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Framework.IO
{
public static class FastStruct<T> where T : struct
{
private delegate T LoadFromByteRefDelegate(ref byte source);
private delegate void CopyMemoryDelegate(ref T dest, ref byte src, int count);
private readonly static LoadFromByteRefDelegate LoadFromByteRef = BuildLoadFromByteRefMethod();
private readonly static CopyMemoryDelegate CopyMemory = BuildCopyMemoryMethod();
public static readonly int Size = Marshal.SizeOf<T>();
private static LoadFromByteRefDelegate BuildLoadFromByteRefMethod()
{
var methodLoadFromByteRef = new DynamicMethod("LoadFromByteRef<" + typeof(T).FullName + ">",
typeof(T), new[] { typeof(byte).MakeByRefType() }, typeof(FastStruct<T>));
ILGenerator generator = methodLoadFromByteRef.GetILGenerator();
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Ldobj, typeof(T));
generator.Emit(OpCodes.Ret);
return (LoadFromByteRefDelegate)methodLoadFromByteRef.CreateDelegate(typeof(LoadFromByteRefDelegate));
}
private static CopyMemoryDelegate BuildCopyMemoryMethod()
{
var methodCopyMemory = new DynamicMethod("CopyMemory<" + typeof(T).FullName + ">",
typeof(void), new[] { typeof(T).MakeByRefType(), typeof(byte).MakeByRefType(), typeof(int) }, typeof(FastStruct<T>));
ILGenerator generator = methodCopyMemory.GetILGenerator();
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Ldarg_1);
generator.Emit(OpCodes.Ldarg_2);
generator.Emit(OpCodes.Cpblk);
generator.Emit(OpCodes.Ret);
return (CopyMemoryDelegate)methodCopyMemory.CreateDelegate(typeof(CopyMemoryDelegate));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T ArrayToStructure(byte[] src)
{
return LoadFromByteRef(ref src[0]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T ArrayToStructure(byte[] src, int offset)
{
return LoadFromByteRef(ref src[offset]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T ArrayToStructure(ref byte src)
{
return LoadFromByteRef(ref src);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] ReadArray(byte[] source)
{
T[] buffer = new T[source.Length / Size];
if (source.Length > 0)
CopyMemory(ref buffer[0], ref source[0], source.Length);
return buffer;
}
}
}
+92 -20
View File
@@ -25,6 +25,7 @@ using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using Framework.IO;
namespace System
{
@@ -201,26 +202,6 @@ namespace System
return (Action<object, object>)setterMethod.CreateDelegate(typeof(Action<object, object>));
}
public static Func<T, object> GetGetter<T>(this FieldInfo fieldInfo)
{
var paramExpression = Expression.Parameter(typeof(T));
var propertyExpression = Expression.Field(paramExpression, fieldInfo);
var convertExpression = Expression.TypeAs(propertyExpression, typeof(object));
return Expression.Lambda<Func<T, object>>(convertExpression, paramExpression).Compile();
}
public static Action<T, object> GetSetter<T>(this FieldInfo fieldInfo)
{
var paramExpression = Expression.Parameter(typeof(T));
var propertyExpression = Expression.Field(paramExpression, fieldInfo);
var valueExpression = Expression.Parameter(typeof(object));
var convertExpression = Expression.Convert(valueExpression, fieldInfo.FieldType);
var assignExpression = Expression.Assign(propertyExpression, convertExpression);
return Expression.Lambda<Action<T, object>>(assignExpression, paramExpression, valueExpression).Compile();
}
public static uint[] SerializeObject<T>(this T obj)
{
//if (obj.GetType()<StructLayoutAttribute>() == null)
@@ -370,6 +351,97 @@ namespace System
return data;
}
public static T[] ReadArray<T>(this BinaryReader reader, int size) where T : struct
{
int numBytes = FastStruct<T>.Size * size;
byte[] result = reader.ReadBytes(numBytes);
return FastStruct<T>.ReadArray(result);
}
public static T Read<T>(this BinaryReader reader) where T : struct
{
byte[] result = reader.ReadBytes(FastStruct<T>.Size);
return FastStruct<T>.ArrayToStructure(result);
}
public static T Read<T>(this BinaryReader reader, int byteCount) where T : struct
{
byte[] result = reader.ReadBytes(byteCount == 0 ? FastStruct<T>.Size : byteCount);
return FastStruct<T>.ArrayToStructure(result);
}
public static int ReadInt32(this BinaryReader br, int byteCount = 0)
{
if (byteCount == 0)
return br.ReadInt32();
if (byteCount != 4)
{
}
byte[] b = new byte[sizeof(int)];
for (int i = 0; i < byteCount; i++)
b[i] = br.ReadByte();
return BitConverter.ToInt32(b, 0);
}
public static uint ReadUInt32(this BinaryReader br, int byteCount = 0)
{
if (byteCount == 0)
return br.ReadUInt32();
if (byteCount != 4)
{
}
byte[] b = new byte[sizeof(uint)];
for (int i = 0; i < byteCount; i++)
b[i] = br.ReadByte();
return BitConverter.ToUInt32(b, 0);
}
public static long ReadInt64(this BinaryReader br, int byteCount = 0)
{
if (byteCount == 0)
return br.ReadInt64();
if (byteCount != 8)
{
}
byte[] b = new byte[sizeof(long)];
for (int i = 0; i < byteCount; i++)
b[i] = br.ReadByte();
return BitConverter.ToInt64(b, 0);
}
public static ulong ReadUInt64(this BinaryReader br, int byteCount = 0)
{
if (byteCount == 0)
return br.ReadUInt64();
if (byteCount != 8)
{
}
byte[] b = new byte[sizeof(ulong)];
for (int i = 0; i < byteCount; i++)
b[i] = br.ReadByte();
return BitConverter.ToUInt64(b, 0);
}
#endregion
}
}