Core/Items: Add location filters to Player.GetItemByEntry
Port From (https://github.com/TrinityCore/TrinityCore/commit/96575e33bb6992e6906e02427f20c58af674bdaa)
This commit is contained in:
@@ -740,10 +740,21 @@ namespace Framework.Constants
|
|||||||
FailedRestArea = 8
|
FailedRestArea = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TutorialsFlag
|
public enum TutorialsFlag
|
||||||
{
|
{
|
||||||
None = 0x00,
|
None = 0x00,
|
||||||
Changed = 0x01,
|
Changed = 0x01,
|
||||||
LoadedFromDB = 0x02
|
LoadedFromDB = 0x02
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ItemSearchLocation
|
||||||
|
{
|
||||||
|
InEquipment = 0x01,
|
||||||
|
InInventory = 0x02,
|
||||||
|
InBank = 0x04,
|
||||||
|
InReagentBank = 0x08,
|
||||||
|
|
||||||
|
Default = InEquipment | InInventory,
|
||||||
|
Everywhere = InEquipment | InInventory | InBank | InReagentBank
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2293,7 +2293,7 @@ namespace Game.Achievements
|
|||||||
}
|
}
|
||||||
case CriteriaAdditionalCondition.AzeriteItemLevel: // 235
|
case CriteriaAdditionalCondition.AzeriteItemLevel: // 235
|
||||||
{
|
{
|
||||||
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (!heartOfAzeroth || heartOfAzeroth.ToAzeriteItem().GetLevel() < reqValue)
|
if (!heartOfAzeroth || heartOfAzeroth.ToAzeriteItem().GetLevel() < reqValue)
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
@@ -2346,7 +2346,7 @@ namespace Game.Achievements
|
|||||||
break;
|
break;
|
||||||
case CriteriaAdditionalCondition.UnlockedAzeriteEssenceRankLower: // 259
|
case CriteriaAdditionalCondition.UnlockedAzeriteEssenceRankLower: // 259
|
||||||
{
|
{
|
||||||
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth != null)
|
if (heartOfAzeroth != null)
|
||||||
{
|
{
|
||||||
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
||||||
@@ -2361,7 +2361,7 @@ namespace Game.Achievements
|
|||||||
}
|
}
|
||||||
case CriteriaAdditionalCondition.UnlockedAzeriteEssenceRankEqual: // 260
|
case CriteriaAdditionalCondition.UnlockedAzeriteEssenceRankEqual: // 260
|
||||||
{
|
{
|
||||||
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth != null)
|
if (heartOfAzeroth != null)
|
||||||
{
|
{
|
||||||
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
||||||
@@ -2376,7 +2376,7 @@ namespace Game.Achievements
|
|||||||
}
|
}
|
||||||
case CriteriaAdditionalCondition.UnlockedAzeriteEssenceRankGreater: // 261
|
case CriteriaAdditionalCondition.UnlockedAzeriteEssenceRankGreater: // 261
|
||||||
{
|
{
|
||||||
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth != null)
|
if (heartOfAzeroth != null)
|
||||||
{
|
{
|
||||||
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
||||||
@@ -2406,7 +2406,7 @@ namespace Game.Achievements
|
|||||||
break;
|
break;
|
||||||
case CriteriaAdditionalCondition.SelectedAzeriteEssenceRankLower: // 266
|
case CriteriaAdditionalCondition.SelectedAzeriteEssenceRankLower: // 266
|
||||||
{
|
{
|
||||||
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth != null)
|
if (heartOfAzeroth != null)
|
||||||
{
|
{
|
||||||
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
||||||
@@ -2425,7 +2425,7 @@ namespace Game.Achievements
|
|||||||
}
|
}
|
||||||
case CriteriaAdditionalCondition.SelectedAzeriteEssenceRankGreater: // 267
|
case CriteriaAdditionalCondition.SelectedAzeriteEssenceRankGreater: // 267
|
||||||
{
|
{
|
||||||
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = referencePlayer.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth != null)
|
if (heartOfAzeroth != null)
|
||||||
{
|
{
|
||||||
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
||||||
|
|||||||
@@ -1912,7 +1912,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
case 2: // Heart Forge
|
case 2: // Heart Forge
|
||||||
{
|
{
|
||||||
Item item = player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item item = player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -2858,47 +2858,89 @@ namespace Game.Entities
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public Item GetItemByEntry(uint entry)
|
public Item GetItemByEntry(uint entry, ItemSearchLocation where = ItemSearchLocation.Default)
|
||||||
{
|
{
|
||||||
// in inventory
|
if (where.HasAnyFlag(ItemSearchLocation.InEquipment))
|
||||||
int inventoryEnd = InventorySlots.ItemStart + GetInventorySlotCount();
|
|
||||||
for (byte i = InventorySlots.ItemStart; i < inventoryEnd; ++i)
|
|
||||||
{
|
{
|
||||||
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
for (byte i = EquipmentSlot.Start; i < InventorySlots.BagEnd; ++i)
|
||||||
if (pItem != null)
|
{
|
||||||
if (pItem.GetEntry() == entry)
|
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
||||||
return pItem;
|
if (pItem != null)
|
||||||
|
if (pItem.GetEntry() == entry)
|
||||||
|
return pItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (byte i = InventorySlots.BagStart; i < InventorySlots.BagEnd; ++i)
|
if (where.HasAnyFlag(ItemSearchLocation.InInventory))
|
||||||
{
|
{
|
||||||
Bag pBag = GetBagByPos(i);
|
int inventoryEnd = InventorySlots.ItemStart + GetInventorySlotCount();
|
||||||
if (pBag != null)
|
for (byte i = InventorySlots.ItemStart; i < inventoryEnd; ++i)
|
||||||
for (byte j = 0; j < pBag.GetBagSize(); ++j)
|
{
|
||||||
{
|
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
||||||
Item pItem = pBag.GetItemByPos(j);
|
if (pItem != null)
|
||||||
if (pItem != null)
|
if (pItem.GetEntry() == entry)
|
||||||
|
return pItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (byte i = InventorySlots.BagStart; i < InventorySlots.BagEnd; ++i)
|
||||||
|
{
|
||||||
|
Bag pBag = GetBagByPos(i);
|
||||||
|
if (pBag != null)
|
||||||
|
for (byte j = 0; j < pBag.GetBagSize(); ++j)
|
||||||
{
|
{
|
||||||
if (pItem.GetEntry() == entry)
|
Item pItem = pBag.GetItemByPos(j);
|
||||||
return pItem;
|
if (pItem != null)
|
||||||
|
{
|
||||||
|
if (pItem.GetEntry() == entry)
|
||||||
|
return pItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (byte i = InventorySlots.ChildEquipmentStart; i < InventorySlots.ChildEquipmentEnd; ++i)
|
||||||
|
{
|
||||||
|
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
||||||
|
if (pItem)
|
||||||
|
if (pItem.GetEntry() == entry)
|
||||||
|
return pItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (where.HasAnyFlag(ItemSearchLocation.InBank))
|
||||||
|
{
|
||||||
|
for (byte i = InventorySlots.BankItemStart; i < InventorySlots.BankItemEnd; ++i)
|
||||||
|
{
|
||||||
|
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
||||||
|
if (pItem != null)
|
||||||
|
if (pItem.GetEntry() == entry)
|
||||||
|
return pItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (byte i = InventorySlots.BankBagStart; i < InventorySlots.BankBagEnd; ++i)
|
||||||
|
{
|
||||||
|
Bag pBag = GetBagByPos(i);
|
||||||
|
if (pBag != null)
|
||||||
|
{
|
||||||
|
for (byte j = 0; j < pBag.GetBagSize(); ++j)
|
||||||
|
{
|
||||||
|
Item pItem = pBag.GetItemByPos(j);
|
||||||
|
if (pItem != null)
|
||||||
|
if (pItem.GetEntry() == entry)
|
||||||
|
return pItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (byte i = EquipmentSlot.Start; i < InventorySlots.BagEnd; ++i)
|
if (where.HasAnyFlag(ItemSearchLocation.InReagentBank))
|
||||||
{
|
{
|
||||||
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
for (byte i = InventorySlots.ReagentStart; i < InventorySlots.ReagentEnd; ++i)
|
||||||
if (pItem != null)
|
{
|
||||||
if (pItem.GetEntry() == entry)
|
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
||||||
return pItem;
|
if (pItem != null)
|
||||||
}
|
if (pItem.GetEntry() == entry)
|
||||||
|
return pItem;
|
||||||
for (byte i = InventorySlots.ChildEquipmentStart; i < InventorySlots.ChildEquipmentEnd; ++i)
|
}
|
||||||
{
|
|
||||||
Item pItem = GetItemByPos(InventorySlots.Bag0, i);
|
|
||||||
if (pItem)
|
|
||||||
if (pItem.GetEntry() == entry)
|
|
||||||
return pItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ namespace Game.Entities
|
|||||||
activeGlyphs.IsFullUpdate = true;
|
activeGlyphs.IsFullUpdate = true;
|
||||||
SendPacket(activeGlyphs);
|
SendPacket(activeGlyphs);
|
||||||
|
|
||||||
Item item = GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item item = GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
AzeriteItem azeriteItem = item.ToAzeriteItem();
|
||||||
|
|||||||
@@ -1248,7 +1248,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
Item heartOfAzeroth = GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth != null)
|
if (heartOfAzeroth != null)
|
||||||
heartOfAzeroth.ToAzeriteItem().GiveXP((ulong)count);
|
heartOfAzeroth.ToAzeriteItem().GiveXP((ulong)count);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Game
|
|||||||
if (!AzeriteItem.FindHeartForge(_player))
|
if (!AzeriteItem.FindHeartForge(_player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Item item = _player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item item = _player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -65,8 +65,8 @@ namespace Game
|
|||||||
AzeriteEssenceSelectionResult activateEssenceResult = new AzeriteEssenceSelectionResult();
|
AzeriteEssenceSelectionResult activateEssenceResult = new AzeriteEssenceSelectionResult();
|
||||||
activateEssenceResult.AzeriteEssenceID = azeriteEssenceActivateEssence.AzeriteEssenceID;
|
activateEssenceResult.AzeriteEssenceID = azeriteEssenceActivateEssence.AzeriteEssenceID;
|
||||||
|
|
||||||
Item item = _player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item item = _player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.InEquipment);
|
||||||
if (!item || !item.IsEquipped())
|
if (item == null)
|
||||||
{
|
{
|
||||||
activateEssenceResult.Reason = AzeriteEssenceActivateResult.NotEquipped;
|
activateEssenceResult.Reason = AzeriteEssenceActivateResult.NotEquipped;
|
||||||
activateEssenceResult.Slot = azeriteEssenceActivateEssence.Slot;
|
activateEssenceResult.Slot = azeriteEssenceActivateEssence.Slot;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Game
|
|||||||
inspectResult.GuildData.Set(guildData);
|
inspectResult.GuildData.Set(guildData);
|
||||||
}
|
}
|
||||||
|
|
||||||
Item heartOfAzeroth = player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = player.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth != null)
|
if (heartOfAzeroth != null)
|
||||||
{
|
{
|
||||||
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
AzeriteItem azeriteItem = heartOfAzeroth.ToAzeriteItem();
|
||||||
|
|||||||
@@ -5760,7 +5760,7 @@ namespace Game.Spells
|
|||||||
if (!playerTarget)
|
if (!playerTarget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Item heartOfAzeroth = playerTarget.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth);
|
Item heartOfAzeroth = playerTarget.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
|
||||||
if (heartOfAzeroth == null)
|
if (heartOfAzeroth == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user