Core/Loot: Allocate Loot separately from objects

Port From (https://github.com/TrinityCore/TrinityCore/commit/7957e2d380e08fa831765f610c0e29d2f3e11a04)
This commit is contained in:
hondacrx
2022-09-02 14:14:04 -04:00
parent 0e4832809c
commit 7bba4bdd79
15 changed files with 160 additions and 126 deletions
+4 -4
View File
@@ -43,8 +43,6 @@ namespace Game.Entities
uState = ItemUpdateState.New;
uQueuePos = -1;
m_lastPlayedTimeUpdate = GameTime.GetGameTime();
loot = new Loot();
}
public virtual bool Create(ulong guidlow, uint itemId, ItemContext context, Player owner)
@@ -386,7 +384,7 @@ namespace Game.Entities
}
// Delete the items if this is a container
if (!loot.IsLooted())
if (loot != null && !loot.IsLooted())
Global.LootItemStorage.RemoveStoredLootForContainer(GetGUID().GetCounter());
Dispose();
@@ -689,7 +687,7 @@ namespace Game.Entities
DeleteFromDB(trans, GetGUID().GetCounter());
// Delete the items if this is a container
if (!loot.IsLooted())
if (loot != null && !loot.IsLooted())
Global.LootItemStorage.RemoveStoredLootForContainer(GetGUID().GetCounter());
}
@@ -2667,6 +2665,8 @@ namespace Game.Entities
public void SetChildItem(ObjectGuid childItem) { m_childItem = childItem; }
public ItemEffectRecord[] GetEffects() { return _bonusData.Effects[0.._bonusData.EffectCount]; }
public override Loot GetLootForPlayer(Player player) { return loot; }
//Static
public static bool ItemCanGoIntoBag(ItemTemplate pProto, ItemTemplate pBagProto)