Core/ObjectMgr: Refactor sItemStorage
This commit is contained in:
@@ -248,7 +248,7 @@ bool LootStoreItem::Roll(bool rate) const
|
||||
if (mincountOrRef < 0) // reference case
|
||||
return roll_chance_f(chance* (rate ? sWorld->getRate(RATE_DROP_ITEM_REFERENCED) : 1.0f));
|
||||
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid);
|
||||
ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(itemid);
|
||||
|
||||
float qualityModifier = pProto && rate ? sWorld->getRate(qualityToRate[pProto->Quality]) : 1.0f;
|
||||
|
||||
@@ -272,7 +272,7 @@ bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const
|
||||
|
||||
if (mincountOrRef > 0) // item (quest or non-quest) entry, maybe grouped
|
||||
{
|
||||
ItemPrototype const *proto = ObjectMgr::GetItemPrototype(itemid);
|
||||
ItemTemplate const *proto = sObjectMgr->GetItemTemplate(itemid);
|
||||
if (!proto)
|
||||
{
|
||||
sLog->outErrorDb("Table '%s' entry %d item %d: item entry not listed in `item_template` - skipped", store.GetName(), entry, itemid);
|
||||
@@ -322,7 +322,7 @@ LootItem::LootItem(LootStoreItem const& li)
|
||||
itemid = li.itemid;
|
||||
conditions = li.conditions;
|
||||
|
||||
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemid);
|
||||
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemid);
|
||||
freeforall = proto && (proto->Flags & ITEM_PROTO_FLAG_PARTY_LOOT);
|
||||
|
||||
needs_quest = li.needs_quest;
|
||||
@@ -343,7 +343,7 @@ bool LootItem::AllowedForPlayer(Player const * player) const
|
||||
if (!sConditionMgr->IsPlayerMeetToConditions(const_cast<Player*>(player), conditions))
|
||||
return false;
|
||||
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid);
|
||||
ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(itemid);
|
||||
if (!pProto)
|
||||
return false;
|
||||
|
||||
@@ -400,7 +400,7 @@ void Loot::AddItem(LootStoreItem const & item)
|
||||
// non-ffa conditionals are counted in FillNonQuestNonFFAConditionalLoot()
|
||||
if (item.conditions.empty())
|
||||
{
|
||||
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item.itemid);
|
||||
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item.itemid);
|
||||
if (!proto || (proto->Flags & ITEM_PROTO_FLAG_PARTY_LOOT) == 0)
|
||||
++unlootedCount;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
|
||||
|
||||
for (uint8 i = 0; i < items.size(); ++i)
|
||||
{
|
||||
if (ItemPrototype const *proto = sItemStorage.LookupEntry<ItemPrototype>(items[i].itemid))
|
||||
if (ItemTemplate const *proto = sObjectMgr->GetItemTemplate(items[i].itemid))
|
||||
if (proto->Quality < uint32(pGroup->GetLootThreshold()))
|
||||
items[i].is_underthreshold = true;
|
||||
}
|
||||
@@ -484,7 +484,7 @@ void Loot::FillNotNormalLootFor(Player* pl, bool presentAtLooting)
|
||||
item = &quest_items[i-itemsSize];
|
||||
|
||||
if (!item->is_looted && item->freeforall && item->AllowedForPlayer(pl))
|
||||
if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item->itemid))
|
||||
if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item->itemid))
|
||||
if (proto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
|
||||
pl->StoreLootItem(i, this);
|
||||
}
|
||||
@@ -790,7 +790,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootItem const& li)
|
||||
{
|
||||
b << uint32(li.itemid);
|
||||
b << uint32(li.count); // nr of items of this type
|
||||
b << uint32(ObjectMgr::GetItemPrototype(li.itemid)->DisplayInfoID);
|
||||
b << uint32(sObjectMgr->GetItemTemplate(li.itemid)->DisplayInfoID);
|
||||
b << uint32(li.randomSuffix);
|
||||
b << uint32(li.randomPropertyId);
|
||||
//b << uint8(0); // slot type - will send after this function call
|
||||
@@ -1085,7 +1085,7 @@ void LootTemplate::LootGroup::Process(Loot& loot, uint16 lootMode) const
|
||||
if (item != NULL && item->lootmode & lootMode) // only add this item if roll succeeds and the mode matches
|
||||
{
|
||||
bool duplicate = false;
|
||||
if (ItemPrototype const *_proto = sItemStorage.LookupEntry<ItemPrototype>(item->itemid))
|
||||
if (ItemTemplate const *_proto = sObjectMgr->GetItemTemplate(item->itemid))
|
||||
{
|
||||
uint8 _item_counter = 0;
|
||||
for (LootItemList::const_iterator _item = loot.items.begin(); _item != loot.items.end(); ++_item)
|
||||
@@ -1226,7 +1226,7 @@ void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId
|
||||
if (!i->Roll(rate))
|
||||
continue; // Bad luck for the entry
|
||||
|
||||
if (ItemPrototype const *_proto = sItemStorage.LookupEntry<ItemPrototype>(i->itemid))
|
||||
if (ItemTemplate const *_proto = sObjectMgr->GetItemTemplate(i->itemid))
|
||||
{
|
||||
uint8 _item_counter = 0;
|
||||
LootItemList::const_iterator _item = loot.items.begin();
|
||||
@@ -1458,27 +1458,26 @@ void LoadLootTemplates_Disenchant()
|
||||
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
LootIdSet ids_set, ids_setUsed;
|
||||
uint32 count = LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set);
|
||||
LootIdSet lootIdSet, loodIdSetUsed;
|
||||
uint32 count = LootTemplates_Disenchant.LoadAndCollectLootIds(lootIdSet);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
||||
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
||||
{
|
||||
if (ItemPrototype const *proto = sItemStorage.LookupEntry<ItemPrototype>(i))
|
||||
if (uint32 lootid = itr->second.DisenchantID)
|
||||
{
|
||||
if (uint32 lootid = proto->DisenchantID)
|
||||
{
|
||||
if (ids_set.find(lootid) == ids_set.end())
|
||||
LootTemplates_Disenchant.ReportNotExistedId(lootid);
|
||||
else
|
||||
ids_setUsed.insert(lootid);
|
||||
}
|
||||
if (lootIdSet.find(lootid) == lootIdSet.end())
|
||||
LootTemplates_Disenchant.ReportNotExistedId(lootid);
|
||||
else
|
||||
loodIdSetUsed.insert(lootid);
|
||||
}
|
||||
}
|
||||
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
|
||||
ids_set.erase(*itr);
|
||||
|
||||
for (LootIdSet::const_iterator itr = loodIdSetUsed.begin(); itr != loodIdSetUsed.end(); ++itr)
|
||||
lootIdSet.erase(*itr);
|
||||
|
||||
// output error for any still listed (not referenced from appropriate table) ids
|
||||
LootTemplates_Disenchant.ReportUnusedIds(ids_set);
|
||||
LootTemplates_Disenchant.ReportUnusedIds(lootIdSet);
|
||||
|
||||
if(count)
|
||||
sLog->outString(">> Loaded %u disenchanting loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -1560,10 +1559,10 @@ void LoadLootTemplates_Item()
|
||||
uint32 count = LootTemplates_Item.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
if (ItemPrototype const *proto = sItemStorage.LookupEntry<ItemPrototype>(i))
|
||||
if (ids_set.find(proto->ItemId) != ids_set.end() && proto->Flags & ITEM_PROTO_FLAG_OPENABLE)
|
||||
ids_set.erase(proto->ItemId);
|
||||
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
||||
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
||||
if (ids_set.find(itr->second.ItemId) != ids_set.end() && itr->second.Flags & ITEM_PROTO_FLAG_OPENABLE)
|
||||
ids_set.erase(itr->second.ItemId);
|
||||
|
||||
// output error for any still listed (not referenced from appropriate table) ids
|
||||
LootTemplates_Item.ReportUnusedIds(ids_set);
|
||||
@@ -1586,17 +1585,14 @@ void LoadLootTemplates_Milling()
|
||||
uint32 count = LootTemplates_Milling.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
||||
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
||||
{
|
||||
ItemPrototype const *proto = sItemStorage.LookupEntry<ItemPrototype>(i);
|
||||
if (!proto)
|
||||
if (!(itr->second.Flags & ITEM_PROTO_FLAG_MILLABLE))
|
||||
continue;
|
||||
|
||||
if (!(proto->Flags & ITEM_PROTO_FLAG_MILLABLE))
|
||||
continue;
|
||||
|
||||
if (ids_set.find(proto->ItemId) != ids_set.end())
|
||||
ids_set.erase(proto->ItemId);
|
||||
if (ids_set.find(itr->second.ItemId) != ids_set.end())
|
||||
ids_set.erase(itr->second.ItemId);
|
||||
}
|
||||
|
||||
// output error for any still listed (not referenced from appropriate table) ids
|
||||
@@ -1657,17 +1653,14 @@ void LoadLootTemplates_Prospecting()
|
||||
uint32 count = LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set);
|
||||
|
||||
// remove real entries and check existence loot
|
||||
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
|
||||
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
||||
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
||||
{
|
||||
ItemPrototype const *proto = sItemStorage.LookupEntry<ItemPrototype>(i);
|
||||
if (!proto)
|
||||
if (!(itr->second.Flags & ITEM_PROTO_FLAG_PROSPECTABLE))
|
||||
continue;
|
||||
|
||||
if (!(proto->Flags & ITEM_PROTO_FLAG_PROSPECTABLE))
|
||||
continue;
|
||||
|
||||
if (ids_set.find(proto->ItemId) != ids_set.end())
|
||||
ids_set.erase(proto->ItemId);
|
||||
if (ids_set.find(itr->second.ItemId) != ids_set.end())
|
||||
ids_set.erase(itr->second.ItemId);
|
||||
}
|
||||
|
||||
// output error for any still listed (not referenced from appropriate table) ids
|
||||
|
||||
Reference in New Issue
Block a user