Updated to 8.2.0.31429 (scripts disabled atm, they still need updated)

Code Port from TrinityCore https://github.com/TrinityCore/TrinityCore
Casc from WoW-Tools https://github.com/WoW-Tools/CASCExplorer
This commit is contained in:
hondacrx
2019-08-14 11:20:42 -04:00
parent e4d500f4b5
commit 125e3b3ac7
232 changed files with 12268 additions and 14670 deletions
+60 -17
View File
@@ -17,6 +17,7 @@
using Framework.Constants;
using Framework.Database;
using Game.Network;
namespace Game.Entities
{
@@ -27,8 +28,7 @@ namespace Game.Entities
objectTypeMask |= TypeMask.Container;
objectTypeId = TypeId.Container;
valuesCount = (int)ContainerFields.End;
_dynamicValuesCount = (int)ItemDynamicFields.End;
m_containerData = new ContainerData();
}
public override void Dispose()
@@ -86,20 +86,20 @@ namespace Game.Entities
if (owner)
{
SetGuidValue(ItemFields.Owner, owner.GetGUID());
SetGuidValue(ItemFields.Contained, owner.GetGUID());
SetOwnerGUID(owner.GetGUID());
SetContainedIn(owner.GetGUID());
}
SetUInt32Value(ItemFields.MaxDurability, itemProto.MaxDurability);
SetUInt32Value(ItemFields.Durability, itemProto.MaxDurability);
SetUInt32Value(ItemFields.StackCount, 1);
SetUpdateFieldValue(m_values.ModifyValue(m_itemData).ModifyValue(m_itemData.MaxDurability), itemProto.MaxDurability);
SetDurability(itemProto.MaxDurability);
SetCount(1);
// Setting the number of Slots the Container has
SetUInt32Value(ContainerFields.NumSlots, itemProto.GetContainerSlots());
SetBagSize(itemProto.GetContainerSlots());
// Cleaning 20 slots
for (byte i = 0; i < ItemConst.MaxBagSize; ++i)
SetGuidValue(ContainerFields.Slot1 + (i * 4), ObjectGuid.Empty);
SetSlot(i, ObjectGuid.Empty);
m_bagslot = new Item[ItemConst.MaxBagSize];
return true;
@@ -111,11 +111,11 @@ namespace Game.Entities
return false;
ItemTemplate itemProto = GetTemplate(); // checked in Item.LoadFromDB
SetUInt32Value(ContainerFields.NumSlots, itemProto.GetContainerSlots());
SetBagSize(itemProto.GetContainerSlots());
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (byte i = 0; i < ItemConst.MaxBagSize; ++i)
{
SetGuidValue(ContainerFields.Slot1 + (i * 4), ObjectGuid.Empty);
SetSlot(i, ObjectGuid.Empty);
m_bagslot[i] = null;
}
return true;
@@ -144,9 +144,9 @@ namespace Game.Entities
{
if (m_bagslot[slot] != null)
m_bagslot[slot].SetContainer(null);
m_bagslot[slot] = null;
SetGuidValue(ContainerFields.Slot1 + (slot * 4), ObjectGuid.Empty);
SetSlot(slot, ObjectGuid.Empty);
}
public void StoreItem(byte slot, Item pItem, bool update)
@@ -154,9 +154,9 @@ namespace Game.Entities
if (pItem != null && pItem.GetGUID() != GetGUID())
{
m_bagslot[slot] = pItem;
SetGuidValue(ContainerFields.Slot1 + (slot * 4), pItem.GetGUID());
pItem.SetGuidValue(ItemFields.Contained, GetGUID());
pItem.SetGuidValue(ItemFields.Owner, GetOwnerGUID());
SetSlot(slot, pItem.GetGUID());
pItem.SetContainedIn(GetGUID());
pItem.SetOwnerGUID(GetOwnerGUID());
pItem.SetContainer(this);
pItem.SetSlot(slot);
}
@@ -171,6 +171,45 @@ namespace Game.Entities
m_bagslot[i].BuildCreateUpdateBlockForPlayer(data, target);
}
public override void BuildValuesCreate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt8((byte)flags);
m_objectData.WriteCreate(buffer, flags, this, target);
m_itemData.WriteCreate(buffer, flags, this, target);
m_containerData.WriteCreate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void BuildValuesUpdate(WorldPacket data, Player target)
{
UpdateFieldFlag flags = GetUpdateFieldFlagsFor(target);
WorldPacket buffer = new WorldPacket();
buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
if (m_values.HasChanged(TypeId.Object))
m_objectData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.Item))
m_itemData.WriteUpdate(buffer, flags, this, target);
if (m_values.HasChanged(TypeId.Container))
m_containerData.WriteUpdate(buffer, flags, this, target);
data.WriteUInt32(buffer.GetSize());
data.WriteBytes(buffer);
}
public override void ClearUpdateMask(bool remove)
{
m_values.ClearChangesMask(m_containerData);
base.ClearUpdateMask(remove);
}
public bool IsEmpty()
{
for (var i = 0; i < GetBagSize(); ++i)
@@ -243,13 +282,17 @@ namespace Game.Entities
return null;
}
public uint GetBagSize() { return GetUInt32Value(ContainerFields.NumSlots); }
public uint GetBagSize() { return m_containerData.NumSlots; }
void SetBagSize(uint numSlots) { SetUpdateFieldValue(m_values.ModifyValue(m_containerData).ModifyValue(m_containerData.NumSlots), numSlots); }
void SetSlot(int slot, ObjectGuid guid) { SetUpdateFieldValue(ref m_values.ModifyValue(m_containerData).ModifyValue(m_containerData.Slots, slot), guid); }
public static Item NewItemOrBag(ItemTemplate proto)
{
return (proto.GetInventoryType() == InventoryType.Bag) ? new Bag() : new Item();
}
ContainerData m_containerData;
Item[] m_bagslot = new Item[36];
}
}