mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/DataStores: Optimized item toy check by using a better container for this
This commit is contained in:
@@ -489,7 +489,7 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale)
|
||||
sTransportMgr->AddPathRotationToTransport(rot->TransportID, rot->TimeIndex, rot);
|
||||
|
||||
for (ToyEntry const* toy : sToyStore)
|
||||
_toys.push_back(toy->ItemID);
|
||||
_toys.insert(toy->ItemID);
|
||||
|
||||
for (HeirloomEntry const* heirloom : sHeirloomStore)
|
||||
_heirlooms[heirloom->ItemID] = heirloom;
|
||||
@@ -638,6 +638,15 @@ uint32 DB2Manager::GetHeirloomItemLevel(uint32 curveId, uint32 level) const
|
||||
return uint32(previousItr->second->Y); // Lowest scaling point
|
||||
}
|
||||
|
||||
HeirloomEntry const* DB2Manager::GetHeirloomByItemId(uint32 itemId) const
|
||||
{
|
||||
auto itr = _heirlooms.find(itemId);
|
||||
if (itr != _heirlooms.end())
|
||||
return itr->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DB2Manager::ItemBonusList const* DB2Manager::GetItemBonusList(uint32 bonusListId) const
|
||||
{
|
||||
auto itr = _itemBonusLists.find(bonusListId);
|
||||
@@ -826,6 +835,11 @@ std::vector<SpellPowerEntry const*> DB2Manager::GetSpellPowers(uint32 spellId, D
|
||||
return powers;
|
||||
}
|
||||
|
||||
bool DB2Manager::IsToyItem(uint32 toy) const
|
||||
{
|
||||
return _toys.count(toy) > 0;
|
||||
}
|
||||
|
||||
bool DB2Manager::ChrClassesXPowerTypesEntryComparator::Compare(ChrClassesXPowerTypesEntry const* left, ChrClassesXPowerTypesEntry const* right)
|
||||
{
|
||||
if (left->ClassID != right->ClassID)
|
||||
@@ -846,17 +860,3 @@ bool DB2Manager::MountTypeXCapabilityEntryComparator::Compare(MountTypeXCapabili
|
||||
return left->OrderIndex < right->OrderIndex;
|
||||
return left->ID < right->ID;
|
||||
}
|
||||
|
||||
bool DB2Manager::GetToyItemIdMatch(uint32 toy) const
|
||||
{
|
||||
return std::find(_toys.begin(), _toys.end(), toy) != _toys.end();
|
||||
}
|
||||
|
||||
HeirloomEntry const* DB2Manager::GetHeirloomByItemId(uint32 itemId) const
|
||||
{
|
||||
auto itr = _heirlooms.find(itemId);
|
||||
if (itr != _heirlooms.end())
|
||||
return itr->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ public:
|
||||
typedef std::unordered_map<uint32, CharStartOutfitEntry const*> CharStartOutfitContainer;
|
||||
typedef std::set<GlyphSlotEntry const*, GlyphSlotEntryComparator> GlyphSlotContainer;
|
||||
typedef std::map<uint32 /*curveID*/, std::map<uint32/*index*/, CurvePointEntry const*, std::greater<uint32>>> HeirloomCurvesContainer;
|
||||
typedef std::unordered_map<uint32, HeirloomEntry const*> HeirloomItemsContainer;
|
||||
typedef std::vector<ItemBonusEntry const*> ItemBonusList;
|
||||
typedef std::unordered_map<uint32 /*bonusListId*/, ItemBonusList> ItemBonusListContainer;
|
||||
typedef std::unordered_multimap<uint32 /*itemId*/, uint32 /*bonusTreeId*/> ItemToBonusTreeContainer;
|
||||
@@ -159,8 +160,7 @@ public:
|
||||
typedef std::unordered_map<uint32, std::vector<SpecializationSpellsEntry const*>> SpecializationSpellsContainer;
|
||||
typedef std::unordered_map<uint32, std::vector<SpellPowerEntry const*>> SpellPowerContainer;
|
||||
typedef std::unordered_map<uint32, std::unordered_map<uint32, std::vector<SpellPowerEntry const*>>> SpellPowerDifficultyContainer;
|
||||
typedef std::vector<uint32> ToyItemIdsContainer;
|
||||
typedef std::unordered_map<uint32, HeirloomEntry const*> HeirloomItemsContainer;
|
||||
typedef std::unordered_set<uint32> ToyItemIdsContainer;
|
||||
|
||||
static DB2Manager& Instance()
|
||||
{
|
||||
@@ -181,6 +181,7 @@ public:
|
||||
uint32 GetPowerIndexByClass(uint32 powerType, uint32 classId) const;
|
||||
GlyphSlotContainer const& GetGlyphSlots() const { return _glyphSlots; }
|
||||
uint32 GetHeirloomItemLevel(uint32 curveId, uint32 level) const;
|
||||
HeirloomEntry const* GetHeirloomByItemId(uint32 itemId) const;
|
||||
ItemBonusList const* GetItemBonusList(uint32 bonusListId) const;
|
||||
std::set<uint32> GetItemBonusTree(uint32 itemId, uint32 itemBonusTreeMod) const;
|
||||
uint32 GetItemDisplayId(uint32 itemId, uint32 appearanceModId) const;
|
||||
@@ -195,8 +196,7 @@ public:
|
||||
std::set<uint32> GetPhasesForGroup(uint32 group) const;
|
||||
std::vector<SpecializationSpellsEntry const*> const* GetSpecializationSpells(uint32 specId) const;
|
||||
std::vector<SpellPowerEntry const*> GetSpellPowers(uint32 spellId, Difficulty difficulty = DIFFICULTY_NONE, bool* hasDifficultyPowers = nullptr) const;
|
||||
bool GetToyItemIdMatch(uint32 toy) const;
|
||||
HeirloomEntry const* GetHeirloomByItemId(uint32 itemId) const;
|
||||
bool IsToyItem(uint32 toy) const;
|
||||
|
||||
private:
|
||||
StorageMap _stores;
|
||||
@@ -206,6 +206,7 @@ private:
|
||||
CharStartOutfitContainer _charStartOutfits;
|
||||
uint32 _powersByClass[MAX_CLASSES][MAX_POWERS];
|
||||
GlyphSlotContainer _glyphSlots;
|
||||
HeirloomItemsContainer _heirlooms;
|
||||
HeirloomCurvesContainer _heirloomCurvePoints;
|
||||
ItemBonusListContainer _itemBonusLists;
|
||||
ItemBonusTreeContainer _itemBonusTrees;
|
||||
@@ -222,7 +223,6 @@ private:
|
||||
SpellPowerContainer _spellPowers;
|
||||
SpellPowerDifficultyContainer _spellPowerDifficulties;
|
||||
ToyItemIdsContainer _toys;
|
||||
HeirloomItemsContainer _heirlooms;
|
||||
};
|
||||
|
||||
#define sDB2Manager DB2Manager::Instance()
|
||||
|
||||
@@ -31,7 +31,7 @@ void WorldSession::HandleAddToy(WorldPackets::Toy::AddToy& packet)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sDB2Manager.GetToyItemIdMatch(item->GetEntry()))
|
||||
if (!sDB2Manager.IsToyItem(item->GetEntry()))
|
||||
return;
|
||||
|
||||
InventoryResult msg = _player->CanUseItem(item);
|
||||
|
||||
Reference in New Issue
Block a user