diff options
49 files changed, 786 insertions, 640 deletions
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 4423c540a33..d490b95d08d 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -365,7 +365,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un } case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_EQUIPED_ITEM: { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(miscvalue1); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(miscvalue1); if (!pProto) return false; return pProto->ItemLevel >= equipped_item.item_level && pProto->Quality >= equipped_item.item_quality; @@ -1252,7 +1252,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (miscValue2 != achievementCriteria->roll_greed_on_loot.rollValue) continue; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(miscValue1); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(miscValue1); if (!pProto) continue; @@ -1380,7 +1380,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case if (!miscValue1) continue; - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(miscValue1); + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(miscValue1); if (!proto || proto->Quality < ITEM_QUALITY_EPIC) continue; SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE); @@ -2426,7 +2426,7 @@ void AchievementGlobalMgr::LoadRewards() if (reward.itemId) { - if (!ObjectMgr::GetItemPrototype(reward.itemId)) + if (!sObjectMgr->GetItemTemplate(reward.itemId)) { sLog->outErrorDb("Table `achievement_reward` (Entry: %u) has invalid item id %u, reward mail will not contain item.", entry, reward.itemId); reward.itemId = 0; diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index fa8381e1ae2..8a13201c62a 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -67,7 +67,7 @@ AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(uint32 factionTemplateId) uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem, uint32 count) { - uint32 MSV = pItem->GetProto()->SellPrice; + uint32 MSV = pItem->GetTemplate()->SellPrice; if (MSV <= 0) return AH_MINIMUM_DEPOSIT; @@ -128,7 +128,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction, SQLTransaction& uint32 owner_accid = sObjectMgr->GetPlayerAccountIdByGUID(auction->owner); sLog->outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", - bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid); + bidder_name.c_str(),bidder_accId,pItem->GetTemplate()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid); } } @@ -329,7 +329,7 @@ void AuctionHouseMgr::LoadAuctionItems() uint32 item_guid = fields[11].GetUInt32(); uint32 item_template = fields[12].GetUInt32(); - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template); + ItemTemplate const *proto = sObjectMgr->GetItemTemplate(item_template); if (!proto) { sLog->outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template); @@ -572,7 +572,7 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player if (!item) continue; - ItemPrototype const *proto = item->GetProto(); + ItemTemplate const *proto = item->GetTemplate(); if (itemClass != 0xffffffff && proto->Class != itemClass) continue; @@ -771,4 +771,4 @@ bool AuctionEntry::LoadFromDB(Field* fields) return false; } return true; -}
\ No newline at end of file +} diff --git a/src/server/game/Chat/ChatLink.cpp b/src/server/game/Chat/ChatLink.cpp index 9a7afd216d8..bb0c0889a44 100644 --- a/src/server/game/Chat/ChatLink.cpp +++ b/src/server/game/Chat/ChatLink.cpp @@ -111,7 +111,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss) return false; } // Validate item - _item = ObjectMgr::GetItemPrototype(itemEntry); + _item = sObjectMgr->GetItemTemplate(itemEntry); if (!_item) { sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry); diff --git a/src/server/game/Chat/ChatLink.h b/src/server/game/Chat/ChatLink.h index 53ac98d6354..8ee9171f744 100644 --- a/src/server/game/Chat/ChatLink.h +++ b/src/server/game/Chat/ChatLink.h @@ -23,7 +23,7 @@ #include <list> struct ItemLocale; -struct ItemPrototype; +struct ItemTemplate; struct ItemRandomSuffixEntry; struct ItemRandomPropertiesEntry; struct SpellEntry; @@ -62,7 +62,7 @@ public: protected: std::string FormatName(uint8 index, ItemLocale const* locale, char* const* suffixStrings) const; - ItemPrototype const* _item; + ItemTemplate const* _item; int32 _data[8]; ItemRandomSuffixEntry const* _suffix; ItemRandomPropertiesEntry const* _property; @@ -166,4 +166,4 @@ private: }; -#endif // TRINITYCORE_CHATLINK_H
\ No newline at end of file +#endif // TRINITYCORE_CHATLINK_H diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index d657781499f..abc8cfe7185 100755 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -261,7 +261,7 @@ bool ChatHandler::HandleAddItemCommand(const char *args) sLog->outDetail(GetTrinityString(LANG_ADDITEM), itemId, count); - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemId); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(itemId); if (!pProto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); @@ -333,48 +333,45 @@ bool ChatHandler::HandleAddItemSetCommand(const char *args) return false; } - Player* pl = m_session->GetPlayer(); - Player* plTarget = getSelectedPlayer(); - if (!plTarget) - plTarget = pl; + Player* player = m_session->GetPlayer(); + Player* playerTarget = getSelectedPlayer(); + if (!playerTarget) + playerTarget = player; sLog->outDetail(GetTrinityString(LANG_ADDITEMSET), itemsetId); bool found = false; - for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) + ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); + for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr) { - ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); - if (!pProto) - continue; - - if (pProto->ItemSet == itemsetId) + if (itr->second.ItemSet == itemsetId) { found = true; ItemPosCountVec dest; - uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1); + uint8 msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itr->second.ItemId, 1); if (msg == EQUIP_ERR_OK) { - Item* item = plTarget->StoreNewItem(dest, pProto->ItemId, true); + Item* item = playerTarget->StoreNewItem(dest, itr->second.ItemId, true); // remove binding (let GM give it to another player later) - if (pl == plTarget) + if (player == playerTarget) item->SetBinding(false); - pl->SendNewItem(item,1,false,true); - if (pl != plTarget) - plTarget->SendNewItem(item,1,true,false); + player->SendNewItem(item, 1, false, true); + if (player != playerTarget) + playerTarget->SendNewItem(item, 1, true, false); } else { - pl->SendEquipError(msg, NULL, NULL, pProto->ItemId); - PSendSysMessage(LANG_ITEM_CANNOT_CREATE, pProto->ItemId, 1); + player->SendEquipError(msg, NULL, NULL, itr->second.ItemId); + PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itr->second.ItemId, 1); } } } if (!found) { - PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); + PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemsetId); SetSentErrorMessage(true); return false; @@ -400,7 +397,7 @@ bool ChatHandler::HandleListItemCommand(const char *args) return false; } - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_id); + ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_id); if (!itemProto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); @@ -759,17 +756,14 @@ bool ChatHandler::HandleLookupItemCommand(const char *args) uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // Search in `item_template` - for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) + ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); + for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr) { - ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype >(id); - if (!pProto) - continue; - int loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) { uint8 uloc_idx = uint8(loc_idx); - if (ItemLocale const *il = sObjectMgr->GetItemLocale(pProto->ItemId)) + if (ItemLocale const *il = sObjectMgr->GetItemLocale(itr->second.ItemId)) { if (il->Name.size() > uloc_idx && !il->Name[uloc_idx].empty()) { @@ -784,9 +778,9 @@ bool ChatHandler::HandleLookupItemCommand(const char *args) } if (m_session) - PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); + PSendSysMessage(LANG_ITEM_LIST_CHAT, itr->second.ItemId, itr->second.ItemId, name.c_str()); else - PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); + PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str()); if (!found) found = true; @@ -797,7 +791,7 @@ bool ChatHandler::HandleLookupItemCommand(const char *args) } } - std::string name = pProto->Name1; + std::string name = itr->second.Name1; if (name.empty()) continue; @@ -810,9 +804,9 @@ bool ChatHandler::HandleLookupItemCommand(const char *args) } if (m_session) - PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); + PSendSysMessage(LANG_ITEM_LIST_CHAT, itr->second.ItemId, itr->second.ItemId, name.c_str()); else - PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); + PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str()); if (!found) found = true; @@ -4265,7 +4259,7 @@ bool ChatHandler::HandleSendItemsCommand(const char *args) if (!item_id) return false; - ItemPrototype const* item_proto = ObjectMgr::GetItemPrototype(item_id); + ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(item_id); if (!item_proto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 16fb2e23f18..398b9eb3211 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -651,7 +651,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Creature.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -668,7 +668,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Disenchant.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -685,7 +685,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Fishing.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -702,7 +702,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Gameobject.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -719,7 +719,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Item.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -736,7 +736,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Mail.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -753,7 +753,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Milling.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -770,7 +770,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Pickpocketing.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -787,7 +787,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Prospecting.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -804,7 +804,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Reference.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -821,7 +821,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Skinning.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -838,7 +838,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) } LootTemplate* loot = LootTemplates_Spell.GetLootForConditionFill(cond->mSourceGroup); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(cond->mSourceEntry); + ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto && !loot->isReference(cond->mSourceEntry)) { sLog->outErrorDb("SourceType %u, SourceEntry %u in `condition` table, does not exist in `item_template`, ignoring.", cond->mSourceType, cond->mSourceEntry); @@ -933,7 +933,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) return false; } - ItemPrototype const *pItemProto = ObjectMgr::GetItemPrototype(cond->mSourceEntry); + ItemTemplate const *pItemProto = sObjectMgr->GetItemTemplate(cond->mSourceEntry); if (!pItemProto) { sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `item_tamplate`, ignoring.", cond->mSourceEntry); @@ -1049,7 +1049,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) } case CONDITION_ITEM: { - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(cond->mConditionValue1); + ItemTemplate const *proto = sObjectMgr->GetItemTemplate(cond->mConditionValue1); if (!proto) { sLog->outErrorDb("Item condition has non existing item (%u), skipped", cond->mConditionValue1); @@ -1065,7 +1065,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) } case CONDITION_ITEM_EQUIPPED: { - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(cond->mConditionValue1); + ItemTemplate const *proto = sObjectMgr->GetItemTemplate(cond->mConditionValue1); if (!proto) { sLog->outErrorDb("ItemEquipped condition has non existing item (%u), skipped", cond->mConditionValue1); @@ -1332,7 +1332,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) } case CONDITION_NOITEM: { - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(cond->mConditionValue1); + ItemTemplate const *proto = sObjectMgr->GetItemTemplate(cond->mConditionValue1); if (!proto) { sLog->outErrorDb("NoItem condition has non existing item (%u), skipped", cond->mConditionValue1); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 3ff02511f29..a8ed317f7d5 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2322,7 +2322,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) { - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); + ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item); uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount) @@ -2361,7 +2361,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) { - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); + ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item); uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index d25ddd24930..9dc3b00791a 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -332,7 +332,7 @@ struct VendorItem uint32 ExtendedCost; //helpers - bool IsGoldRequired(ItemPrototype const* pProto) const { return pProto->Flags2 & ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD || !ExtendedCost; } + bool IsGoldRequired(ItemTemplate const* pProto) const { return pProto->Flags2 & ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD || !ExtendedCost; } }; typedef std::vector<VendorItem*> VendorItemList; diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 812d6fae268..e39b8f90dff 100755 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -365,7 +365,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const *pQuest, uint64 npcGUID, } else { - ItemPrototype const* IProto; + ItemTemplate const* IProto; data << uint32(pQuest->GetRewChoiceItemsCount()); for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i) @@ -376,7 +376,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const *pQuest, uint64 npcGUID, data << uint32(pQuest->RewChoiceItemId[i]); data << uint32(pQuest->RewChoiceItemCount[i]); - IProto = ObjectMgr::GetItemPrototype(pQuest->RewChoiceItemId[i]); + IProto = sObjectMgr->GetItemTemplate(pQuest->RewChoiceItemId[i]); if (IProto) data << uint32(IProto->DisplayInfoID); @@ -394,7 +394,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const *pQuest, uint64 npcGUID, data << uint32(pQuest->RewItemId[i]); data << uint32(pQuest->RewItemCount[i]); - IProto = ObjectMgr::GetItemPrototype(pQuest->RewItemId[i]); + IProto = sObjectMgr->GetItemTemplate(pQuest->RewItemId[i]); if (IProto) data << uint32(IProto->DisplayInfoID); @@ -617,12 +617,12 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, uint64 npcGUID, data << uint32(pQuest->OfferRewardEmote[i]); } - ItemPrototype const *pItem; + ItemTemplate const *pItem; data << uint32(pQuest->GetRewChoiceItemsCount()); for (uint32 i=0; i < pQuest->GetRewChoiceItemsCount(); ++i) { - pItem = ObjectMgr::GetItemPrototype(pQuest->RewChoiceItemId[i]); + pItem = sObjectMgr->GetItemTemplate(pQuest->RewChoiceItemId[i]); data << uint32(pQuest->RewChoiceItemId[i]); data << uint32(pQuest->RewChoiceItemCount[i]); @@ -636,7 +636,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, uint64 npcGUID, data << uint32(pQuest->GetRewItemsCount()); for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i) { - pItem = ObjectMgr::GetItemPrototype(pQuest->RewItemId[i]); + pItem = sObjectMgr->GetItemTemplate(pQuest->RewItemId[i]); data << uint32(pQuest->RewItemId[i]); data << uint32(pQuest->RewItemCount[i]); @@ -723,13 +723,13 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, uint64 npcGUID, data << uint32(pQuest->GetRewOrReqMoney() < 0 ? -pQuest->GetRewOrReqMoney() : 0); data << uint32(pQuest->GetReqItemsCount()); - ItemPrototype const *pItem; + ItemTemplate const *pItem; for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { if (!pQuest->ReqItemId[i]) continue; - pItem = ObjectMgr::GetItemPrototype(pQuest->ReqItemId[i]); + pItem = sObjectMgr->GetItemTemplate(pQuest->ReqItemId[i]); data << uint32(pQuest->ReqItemId[i]); data << uint32(pQuest->ReqItemCount[i]); diff --git a/src/server/game/Entities/Item/Container/Bag.cpp b/src/server/game/Entities/Item/Container/Bag.cpp index 865b94d6d44..4d2ebf1b466 100755 --- a/src/server/game/Entities/Item/Container/Bag.cpp +++ b/src/server/game/Entities/Item/Container/Bag.cpp @@ -70,7 +70,7 @@ void Bag::RemoveFromWorld() bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) { - ItemPrototype const * itemProto = ObjectMgr::GetItemPrototype(itemid); + ItemTemplate const * itemProto = sObjectMgr->GetItemTemplate(itemid); if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE) return false; @@ -110,7 +110,7 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry if (!Item::LoadFromDB(guid, owner_guid, fields, entry)) return false; - ItemPrototype const* itemProto = GetProto(); // checked in Item::LoadFromDB + ItemTemplate const* itemProto = GetTemplate(); // checked in Item::LoadFromDB SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots); // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`) for (uint8 i = 0; i < MAX_BAG_SIZE; ++i) @@ -198,12 +198,12 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const count += pItem->GetCount(); } - if (eItem && eItem->GetProto()->GemProperties) + if (eItem && eItem->GetTemplate()->GemProperties) { for (uint32 i=0; i < GetBagSize(); ++i) { pItem = m_bagslot[i]; - if (pItem && pItem != eItem && pItem->GetProto()->Socket[0].Color) + if (pItem && pItem != eItem && pItem->GetTemplate()->Socket[0].Color) count += pItem->GetGemCountWithID(item); } } @@ -217,7 +217,7 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem) for (uint32 i = 0; i < GetBagSize(); ++i) if (Item *pItem = m_bagslot[i]) if (pItem != skipItem) - if (ItemPrototype const *pProto = pItem->GetProto()) + if (ItemTemplate const *pProto = pItem->GetTemplate()) if (pProto->ItemLimitCategory == limitCategory) count += m_bagslot[i]->GetCount(); diff --git a/src/server/game/Entities/Item/Container/Bag.h b/src/server/game/Entities/Item/Container/Bag.h index 958e54e118d..c8421346082 100755 --- a/src/server/game/Entities/Item/Container/Bag.h +++ b/src/server/game/Entities/Item/Container/Bag.h @@ -66,7 +66,7 @@ class Bag : public Item Item* m_bagslot[MAX_BAG_SIZE]; }; -inline Item* NewItemOrBag(ItemPrototype const * proto) +inline Item* NewItemOrBag(ItemTemplate const * proto) { return (proto->InventoryType == INVTYPE_BAG) ? new Bag : new Item; } diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index a6b5b505c9d..024a423164c 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -28,7 +28,7 @@ void AddItemsSetItem(Player* player,Item* item) { - ItemPrototype const* proto = item->GetProto(); + ItemTemplate const* proto = item->GetTemplate(); uint32 setid = proto->ItemSet; ItemSetEntry const* set = sItemSetStore.LookupEntry(setid); @@ -109,7 +109,7 @@ void AddItemsSetItem(Player* player,Item* item) } } -void RemoveItemsSetItem(Player*player,ItemPrototype const *proto) +void RemoveItemsSetItem(Player*player,ItemTemplate const *proto) { uint32 setid = proto->ItemSet; @@ -167,7 +167,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto) } } -bool ItemCanGoIntoBag(ItemPrototype const *pProto, ItemPrototype const *pBagProto) +bool ItemCanGoIntoBag(ItemTemplate const *pProto, ItemTemplate const *pBagProto) { if (!pProto || !pBagProto) return false; @@ -263,7 +263,7 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0); SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0); - ItemPrototype const *itemProto = ObjectMgr::GetItemPrototype(itemid); + ItemTemplate const *itemProto = sObjectMgr->GetItemTemplate(itemid); if (!itemProto) return false; @@ -297,7 +297,7 @@ void Item::UpdateDuration(Player* owner, uint32 diff) if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff) { - sScriptMgr->OnItemExpire(owner, GetProto()); + sScriptMgr->OnItemExpire(owner, GetTemplate()); owner->DestroyItem(GetBagSlot(), GetSlot(), true); return; } @@ -390,7 +390,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr SetEntry(entry); SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); - ItemPrototype const* proto = GetProto(); + ItemTemplate const* proto = GetTemplate(); if (!proto) return false; @@ -484,9 +484,9 @@ void Item::DeleteFromInventoryDB(SQLTransaction& trans) DeleteFromInventoryDB(trans, GetGUIDLow()); } -ItemPrototype const *Item::GetProto() const +ItemTemplate const *Item::GetTemplate() const { - return ObjectMgr::GetItemPrototype(GetEntry()); + return sObjectMgr->GetItemTemplate(GetEntry()); } Player* Item::GetOwner()const @@ -510,7 +510,7 @@ uint32 Item::GetSkill() 0,SKILL_CLOTH,SKILL_LEATHER,SKILL_MAIL,SKILL_PLATE_MAIL,0,SKILL_SHIELD,0,0,0,0 }; - ItemPrototype const* proto = GetProto(); + ItemTemplate const* proto = GetTemplate(); switch (proto->Class) { @@ -533,7 +533,7 @@ uint32 Item::GetSkill() uint32 Item::GetSpell() { - ItemPrototype const* proto = GetProto(); + ItemTemplate const* proto = GetTemplate(); switch (proto->Class) { @@ -573,7 +573,7 @@ uint32 Item::GetSpell() int32 Item::GenerateItemRandomPropertyId(uint32 item_id) { - ItemPrototype const *itemProto = sItemStorage.LookupEntry<ItemPrototype>(item_id); + ItemTemplate const *itemProto = sObjectMgr->GetItemTemplate(item_id); if (!itemProto) return 0; @@ -804,7 +804,7 @@ bool Item::IsBoundByEnchant() const return false; } -uint8 Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const +uint8 Item::CanBeMergedPartlyWith(ItemTemplate const* proto) const { // not allow merge looting currently items if (m_lootGenerated) @@ -823,7 +823,7 @@ uint8 Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const { - ItemPrototype const* proto = GetProto(); + ItemTemplate const* proto = GetTemplate(); if (spellInfo->EquippedItemClass != -1) // -1 == any item class { @@ -859,7 +859,7 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const bool Item::IsTargetValidForItemUse(Unit* pUnitTarget) { - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET, GetProto()->ItemId); + ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET, GetTemplate()->ItemId); if (conditions.empty()) return true; @@ -921,7 +921,7 @@ bool Item::GemsFitSockets() const bool fits = true; for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot) { - uint8 SocketColor = GetProto()->Socket[enchant_slot-SOCK_ENCHANTMENT_SLOT].Color; + uint8 SocketColor = GetTemplate()->Socket[enchant_slot-SOCK_ENCHANTMENT_SLOT].Color; uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) @@ -942,7 +942,7 @@ bool Item::GemsFitSockets() const uint32 gemid = enchantEntry->GemID; if (gemid) { - ItemPrototype const* gemProto = sItemStorage.LookupEntry<ItemPrototype>(gemid); + ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(gemid); if (gemProto) { GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties); @@ -988,7 +988,7 @@ uint8 Item::GetGemCountWithLimitCategory(uint32 limitCategory) const if (!enchantEntry) continue; - ItemPrototype const* gemProto = ObjectMgr::GetItemPrototype(enchantEntry->GemID); + ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(enchantEntry->GemID); if (!gemProto) continue; @@ -1000,7 +1000,7 @@ uint8 Item::GetGemCountWithLimitCategory(uint32 limitCategory) const bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const { - ItemPrototype const* proto = GetProto(); + ItemTemplate const* proto = GetTemplate(); return proto && ((proto->Map && proto->Map != cur_mapId) || (proto->Area && proto->Area != cur_zoneId)); } @@ -1023,7 +1023,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player) if (count < 1) return NULL; //don't create item at zero count - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item); if (pProto) { if (count > pProto->GetMaxStackSize()) diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index df0769db710..93947e74428 100755 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -221,7 +221,7 @@ struct ItemRequiredTarget bool IsFitToRequirements(Unit* pUnitTarget) const; }; -bool ItemCanGoIntoBag(ItemPrototype const *proto, ItemPrototype const *pBagProto); +bool ItemCanGoIntoBag(ItemTemplate const *proto, ItemTemplate const *pBagProto); class Item : public Object { @@ -233,7 +233,7 @@ class Item : public Object virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner); - ItemPrototype const* GetProto() const; + ItemTemplate const* GetTemplate() const; uint64 const& GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); } void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); } @@ -241,7 +241,7 @@ class Item : public Object void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, val); } bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND); } - bool IsBoundAccountWide() const { return (GetProto()->Flags & ITEM_PROTO_FLAG_BIND_TO_ACCOUNT) != 0; } + bool IsBoundAccountWide() const { return (GetTemplate()->Flags & ITEM_PROTO_FLAG_BIND_TO_ACCOUNT) != 0; } bool IsBindedNotWith(Player const* player) const; bool IsBoundByEnchant() const; virtual void SaveToDB(SQLTransaction& trans); @@ -257,7 +257,7 @@ class Item : public Object const Bag* ToBag() const { if (IsBag()) return reinterpret_cast<const Bag*>(this); else return NULL; } bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_UNLOCKED); } - bool IsBag() const { return GetProto()->InventoryType == INVTYPE_BAG; } + bool IsBag() const { return GetTemplate()->InventoryType == INVTYPE_BAG; } bool IsNotEmptyBag() const; bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; } bool CanBeTraded(bool mail = false, bool trade = false) const; @@ -274,10 +274,10 @@ class Item : public Object uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); } void SetCount(uint32 value) { SetUInt32Value(ITEM_FIELD_STACK_COUNT, value); } - uint32 GetMaxStackCount() const { return GetProto()->GetMaxStackSize(); } + uint32 GetMaxStackCount() const { return GetTemplate()->GetMaxStackSize(); } uint8 GetGemCountWithID(uint32 GemID) const; uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const; - uint8 CanBeMergedPartlyWith(ItemPrototype const* proto) const; + uint8 CanBeMergedPartlyWith(ItemTemplate const* proto) const; uint8 GetSlot() const {return m_slot;} Bag *GetContainer() { return m_container; } @@ -331,12 +331,12 @@ class Item : public Object uState = state; } - bool hasQuest(uint32 quest_id) const { return GetProto()->StartQuest == quest_id; } + bool hasQuest(uint32 quest_id) const { return GetTemplate()->StartQuest == quest_id; } bool hasInvolvedQuest(uint32 /*quest_id*/) const { return false; } - bool IsPotion() const { return GetProto()->IsPotion(); } - bool IsWeaponVellum() const { return GetProto()->IsWeaponVellum(); } - bool IsArmorVellum() const { return GetProto()->IsArmorVellum(); } - bool IsConjuredConsumable() const { return GetProto()->IsConjuredConsumable(); } + bool IsPotion() const { return GetTemplate()->IsPotion(); } + bool IsWeaponVellum() const { return GetTemplate()->IsWeaponVellum(); } + bool IsArmorVellum() const { return GetTemplate()->IsArmorVellum(); } + bool IsConjuredConsumable() const { return GetTemplate()->IsConjuredConsumable(); } // Item Refund system void SetNotRefundable(Player *owner, bool changestate = true); @@ -357,7 +357,7 @@ class Item : public Object void BuildUpdate(UpdateDataMapType&); - uint32 GetScriptId() const { return GetProto()->ScriptId; } + uint32 GetScriptId() const { return GetTemplate()->ScriptId; } private: std::string m_text; uint8 m_slot; diff --git a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp index 72530848d7b..a07fbe368cb 100755 --- a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp +++ b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp @@ -120,7 +120,7 @@ uint32 GetItemEnchantMod(int32 entry) uint32 GenerateEnchSuffixFactor(uint32 item_id) { - ItemPrototype const *itemProto = ObjectMgr::GetItemPrototype(item_id); + ItemTemplate const *itemProto = sObjectMgr->GetItemTemplate(item_id); if (!itemProto) return 0; diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h index fef6c48fb80..2b19ae5cfe2 100755 --- a/src/server/game/Entities/Item/ItemPrototype.h +++ b/src/server/game/Entities/Item/ItemPrototype.h @@ -576,13 +576,13 @@ struct _Socket #define MAX_ITEM_PROTO_SPELLS 5 #define MAX_ITEM_PROTO_STATS 10 -struct ItemPrototype +struct ItemTemplate { uint32 ItemId; uint32 Class; // id from ItemClass.dbc uint32 SubClass; // id from ItemSubClass.dbc int32 Unk0; - char* Name1; + const char* Name1; uint32 DisplayInfoID; // id from ItemDisplayInfo.dbc uint32 Quality; uint32 Flags; @@ -622,7 +622,7 @@ struct ItemPrototype float RangedModRange; _Spell Spells[MAX_ITEM_PROTO_SPELLS]; uint32 Bonding; - char* Description; + const char* Description; uint32 PageText; uint32 LanguageID; uint32 PageMaterial; @@ -729,8 +729,12 @@ struct ItemPrototype bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; } bool IsArmorVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT; } bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_PROTO_FLAG_CONJURED); } + }; +// Benchmarked: Faster than std::map (insert/find) +typedef UNORDERED_MAP<uint32, ItemTemplate> ItemTemplateContainer; + struct ItemLocale { StringVector Name; diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 61c1542caa7..e82f06cf5d2 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -1051,7 +1051,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) return true; } -bool Pet::HaveInDiet(ItemPrototype const* item) const +bool Pet::HaveInDiet(ItemTemplate const* item) const { if (!item->FoodType) return false; diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 0b4470abec9..c52bde72b87 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -163,7 +163,7 @@ class Pet : public Guardian void GivePetXP(uint32 xp); void GivePetLevel(uint8 level); void SynchronizeLevelWithOwner(); - bool HaveInDiet(ItemPrototype const* item) const; + bool HaveInDiet(ItemTemplate const* item) const; uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel); void SetDuration(int32 dur) { m_duration = dur; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5f2ac588e9b..dc86a43a088 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1108,7 +1108,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c uint32 item_id = oEntry->ItemId[j]; // just skip, reported in ObjectMgr::LoadItemPrototypes - ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(item_id); + ItemTemplate const* iProto = sObjectMgr->GetItemTemplate(item_id); if (!iProto) continue; @@ -1960,7 +1960,7 @@ bool Player::BuildEnumData(QueryResult result, WorldPacket* data) { uint32 visualBase = slot * 2; uint32 itemId = GetUInt32ValueFromArray(equipment, visualBase); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId); + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (!proto) { *data << uint32(0); @@ -4793,7 +4793,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC uint32 item_guidlow = fields[11].GetUInt32(); uint32 item_template = fields[12].GetUInt32(); - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_template); + ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template); if (!itemProto) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); @@ -5209,8 +5209,8 @@ void Player::CreateCorpse() { if (m_items[i]) { - iDisplayID = m_items[i]->GetProto()->DisplayInfoID; - iIventoryType = m_items[i]->GetProto()->InventoryType; + iDisplayID = m_items[i]->GetTemplate()->DisplayInfoID; + iIventoryType = m_items[i]->GetTemplate()->InventoryType; _cfi = iDisplayID | (iIventoryType << 24); corpse->SetUInt32Value(CORPSE_FIELD_ITEM + i, _cfi); @@ -5375,7 +5375,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g uint32 LostDurability = maxDurability - curDurability; if (LostDurability>0) { - ItemPrototype const *ditemProto = item->GetProto(); + ItemTemplate const *ditemProto = item->GetTemplate(); DurabilityCostsEntry const *dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel); if (!dcost) @@ -5987,7 +5987,7 @@ void Player::SetRegularAttackTime() Item *tmpitem = GetWeaponForAttack(WeaponAttackType(i), true); if (tmpitem && !tmpitem->IsBroken()) { - ItemPrototype const *proto = tmpitem->GetProto(); + ItemTemplate const *proto = tmpitem->GetTemplate(); if (proto->Delay) SetAttackTime(WeaponAttackType(i), proto->Delay); } @@ -6203,7 +6203,7 @@ void Player::UpdateWeaponSkill (WeaponAttackType attType) if (!tmpitem) UpdateSkill(SKILL_UNARMED,weapon_skill_gain); - else if (tmpitem->GetProto()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) + else if (tmpitem->GetTemplate()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) UpdateSkill(tmpitem->GetSkill(),weapon_skill_gain); break; } @@ -6625,7 +6625,7 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) } break; case ACTION_BUTTON_ITEM: - if (!ObjectMgr::GetItemPrototype(action)) + if (!sObjectMgr->GetItemTemplate(action)) { sLog->outError( "Item action %u not added into button %u for player %s: item not exist", action, button, GetName() ); return false; @@ -7607,7 +7607,7 @@ void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) if (slot >= INVENTORY_SLOT_BAG_END || !item) return; - ItemPrototype const *proto = item->GetProto(); + ItemTemplate const *proto = item->GetTemplate(); if (!proto) return; @@ -7637,7 +7637,7 @@ void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "_ApplyItemMods complete."); } -void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool apply, bool only_level_scale /*= false*/) +void Player::_ApplyItemBonuses(ItemTemplate const *proto, uint8 slot, bool apply, bool only_level_scale /*= false*/) { if (slot >= INVENTORY_SLOT_BAG_END || !proto) return; @@ -7918,7 +7918,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl } -void Player::_ApplyWeaponDamage(uint8 slot, ItemPrototype const *proto, ScalingStatValuesEntry const *ssv, bool apply) +void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const *proto, ScalingStatValuesEntry const *ssv, bool apply) { WeaponAttackType attType = BASE_ATTACK; float damage = 0.0f; @@ -8060,7 +8060,7 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) if (!item) return; - ItemPrototype const *proto = item->GetProto(); + ItemTemplate const *proto = item->GetTemplate(); if (!proto) return; @@ -8160,7 +8160,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 // If usable, try to cast item spell if (Item * item = GetItemByPos(INVENTORY_SLOT_BAG_0,i)) if (!item->IsBroken() && CanUseAttackType(attType)) - if (ItemPrototype const *proto = item->GetProto()) + if (ItemTemplate const *proto = item->GetTemplate()) { // Additional check for weapons if (proto->Class == ITEM_CLASS_WEAPON) @@ -8186,7 +8186,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 } } -void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item *item, ItemPrototype const * proto) +void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item *item, ItemTemplate const * proto) { // Can do effect if any damage done to target if (procVictim & PROC_FLAG_TAKEN_DAMAGE) @@ -8309,7 +8309,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex) { - ItemPrototype const* proto = item->GetProto(); + ItemTemplate const* proto = item->GetTemplate(); // special learning case if (proto->Spells[0].SpellId == 483 || proto->Spells[0].SpellId == 55884) { @@ -8402,7 +8402,7 @@ void Player::_RemoveAllItemMods() { if (m_items[i]) { - ItemPrototype const *proto = m_items[i]->GetProto(); + ItemTemplate const *proto = m_items[i]->GetTemplate(); if (!proto) continue; @@ -8424,7 +8424,7 @@ void Player::_RemoveAllItemMods() { if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) continue; - ItemPrototype const *proto = m_items[i]->GetProto(); + ItemTemplate const *proto = m_items[i]->GetTemplate(); if (!proto) continue; @@ -8453,7 +8453,7 @@ void Player::_ApplyAllItemMods() if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) continue; - ItemPrototype const *proto = m_items[i]->GetProto(); + ItemTemplate const *proto = m_items[i]->GetTemplate(); if (!proto) continue; @@ -8472,7 +8472,7 @@ void Player::_ApplyAllItemMods() { if (m_items[i]) { - ItemPrototype const *proto = m_items[i]->GetProto(); + ItemTemplate const *proto = m_items[i]->GetTemplate(); if (!proto) continue; @@ -8500,7 +8500,7 @@ void Player::_ApplyAllLevelScaleItemMods(bool apply) if (m_items[i]->IsBroken() || !CanUseAttackType(GetAttackBySlot(i))) continue; - ItemPrototype const *proto = m_items[i]->GetProto(); + ItemTemplate const *proto = m_items[i]->GetTemplate(); if (!proto) continue; @@ -8518,7 +8518,7 @@ void Player::_ApplyAmmoBonuses() float currentAmmoDPS; - ItemPrototype const *ammo_proto = ObjectMgr::GetItemPrototype(ammo_id); + ItemTemplate const *ammo_proto = sObjectMgr->GetItemTemplate(ammo_id); if (!ammo_proto || ammo_proto->Class != ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) currentAmmoDPS = 0.0f; else @@ -8533,7 +8533,7 @@ void Player::_ApplyAmmoBonuses() UpdateDamagePhysical(RANGED_ATTACK); } -bool Player::CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const +bool Player::CheckAmmoCompatibility(const ItemTemplate *ammo_proto) const { if (!ammo_proto) return false; @@ -8543,7 +8543,7 @@ bool Player::CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const if (!weapon || weapon->IsBroken()) return false; - ItemPrototype const* weapon_proto = weapon->GetProto(); + ItemTemplate const* weapon_proto = weapon->GetTemplate(); if (!weapon_proto || weapon_proto->Class != ITEM_CLASS_WEAPON) return false; @@ -8738,7 +8738,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) switch (loot_type) { case LOOT_DISENCHANTING: - loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this,true); + loot->FillLoot(item->GetTemplate()->DisenchantID, LootTemplates_Disenchant, this,true); break; case LOOT_PROSPECTING: loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this,true); @@ -8747,7 +8747,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this,true); break; default: - loot->generateMoneyLoot(item->GetProto()->MinMoneyLoot,item->GetProto()->MaxMoneyLoot); + loot->generateMoneyLoot(item->GetTemplate()->MinMoneyLoot,item->GetTemplate()->MaxMoneyLoot); loot->FillLoot(item->GetEntry(), LootTemplates_Item, this, true, loot->gold != 0); break; } @@ -9682,7 +9682,7 @@ void Player::SetSheath(SheathState sheathed) Unit::SetSheath(sheathed); // this must visualize Sheath changing for other players... } -uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) const +uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const { uint8 playerClass = getClass(); @@ -9757,7 +9757,7 @@ uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) slots[0] = EQUIPMENT_SLOT_MAINHAND; if (Item* mhWeapon = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) { - if (ItemPrototype const* mhWeaponProto = mhWeapon->GetProto()) + if (ItemTemplate const* mhWeaponProto = mhWeapon->GetTemplate()) { if (mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) { @@ -9930,10 +9930,10 @@ uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const if (Bag* pBag = GetBagByPos(i)) count += pBag->GetItemCount(item, skipItem); - if (skipItem && skipItem->GetProto()->GemProperties) + if (skipItem && skipItem->GetTemplate()->GemProperties) for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - if (pItem != skipItem && pItem->GetProto()->Socket[0].Color) + if (pItem != skipItem && pItem->GetTemplate()->Socket[0].Color) count += pItem->GetGemCountWithID(item); if (inBankAlso) @@ -9947,10 +9947,10 @@ uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const if (Bag* pBag = GetBagByPos(i)) count += pBag->GetItemCount(item, skipItem); - if (skipItem && skipItem->GetProto()->GemProperties) + if (skipItem && skipItem->GetTemplate()->GemProperties) for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - if (pItem != skipItem && pItem->GetProto()->Socket[0].Color) + if (pItem != skipItem && pItem->GetTemplate()->Socket[0].Color) count += pItem->GetGemCountWithID(item); } @@ -9963,14 +9963,14 @@ uint32 Player::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipIte for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem != skipItem) - if (ItemPrototype const *pProto = pItem->GetProto()) + if (ItemTemplate const *pProto = pItem->GetTemplate()) if (pProto->ItemLimitCategory == limitCategory) count += pItem->GetCount(); for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem != skipItem) - if (ItemPrototype const *pProto = pItem->GetProto()) + if (ItemTemplate const *pProto = pItem->GetTemplate()) if (pProto->ItemLimitCategory == limitCategory) count += pItem->GetCount(); @@ -9981,7 +9981,7 @@ uint32 Player::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipIte for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) if (Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem != skipItem) - if (ItemPrototype const *pProto = pItem->GetProto()) + if (ItemTemplate const *pProto = pItem->GetTemplate()) if (pProto->ItemLimitCategory == limitCategory) count += pItem->GetCount(); @@ -10067,7 +10067,7 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= f item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, slot); else item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!item || item->GetProto()->Class != ITEM_CLASS_WEAPON) + if (!item || item->GetTemplate()->Class != ITEM_CLASS_WEAPON) return NULL; if (!useable) @@ -10086,7 +10086,7 @@ Item* Player::GetShield(bool useable) const item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); else item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if (!item || item->GetProto()->Class != ITEM_CLASS_ARMOR) + if (!item || item->GetTemplate()->Class != ITEM_CLASS_ARMOR) return NULL; if (!useable) @@ -10297,7 +10297,7 @@ bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_ } } - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item); if (pProto && pProto->GemProperties) { for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) @@ -10306,7 +10306,7 @@ bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_ continue; Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (pItem && pItem->GetProto()->Socket[0].Color) + if (pItem && pItem->GetTemplate()->Socket[0].Color) { tempcount += pItem->GetGemCountWithID(item); if (tempcount >= count) @@ -10330,7 +10330,7 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 if (!pItem) continue; - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); if (!pProto) continue; @@ -10354,7 +10354,7 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 uint8 Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(entry); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(entry); if (!pProto) { if (no_space_count) @@ -10412,13 +10412,13 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { pItem = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i); - if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetTemplate()->TotemCategory,TotemCategory)) return true; } for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { pItem = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i); - if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetTemplate()->TotemCategory,TotemCategory)) return true; } for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) @@ -10428,7 +10428,7 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { pItem = GetUseableItemByPos(i, j); - if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetTemplate()->TotemCategory,TotemCategory)) return true; } } @@ -10436,7 +10436,7 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const return false; } -uint8 Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool swap, Item* pSrcItem) const +uint8 Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemTemplate const *pProto, uint32& count, bool swap, Item* pSrcItem) const { Item* pItem2 = GetItemByPos(bag, slot); @@ -10472,7 +10472,7 @@ uint8 Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVe if (!pBag) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - ItemPrototype const* pBagProto = pBag->GetProto(); + ItemTemplate const* pBagProto = pBag->GetTemplate(); if (!pBagProto) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; @@ -10510,7 +10510,7 @@ uint8 Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVe return EQUIP_ERR_OK; } -uint8 Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +uint8 Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, ItemTemplate const *pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { // skip specific bag already processed in first called _CanStoreItem_InBag if (bag == skip_bag) @@ -10524,7 +10524,7 @@ uint8 Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, ItemPrototyp if (pSrcItem && pSrcItem->IsNotEmptyBag()) return EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS; - ItemPrototype const* pBagProto = pBag->GetProto(); + ItemTemplate const* pBagProto = pBag->GetTemplate(); if (!pBagProto) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; @@ -10580,7 +10580,7 @@ uint8 Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, ItemPrototyp return EQUIP_ERR_OK; } -uint8 Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +uint8 Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemTemplate const *pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { //this is never called for non-bag slots so we can do this if (pSrcItem && pSrcItem->IsNotEmptyBag()) @@ -10635,7 +10635,7 @@ uint8 Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 { sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(entry); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(entry); if (!pProto) { if (no_space_count) @@ -11133,7 +11133,7 @@ uint8 Player::CanStoreItems(Item **pItems,int count) const if (!pItem) continue; sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: CanStoreItems %i. item = %u, count = %u", k+1, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); // strange item if (!pProto) @@ -11148,7 +11148,7 @@ uint8 Player::CanStoreItems(Item **pItems,int count) const return EQUIP_ERR_DONT_OWN_THAT_ITEM; Bag *pBag; - ItemPrototype const *pBagProto; + ItemTemplate const *pBagProto; // item is 'one item only' uint8 res = CanTakeMoreSimilarItems(pItem); @@ -11200,7 +11200,7 @@ uint8 Player::CanStoreItems(Item **pItems,int count) const { if (pBag = GetBagByPos(t)) { - if (ItemCanGoIntoBag(pItem->GetProto(), pBag->GetProto())) + if (ItemCanGoIntoBag(pItem->GetTemplate(), pBag->GetTemplate())) { for (uint32 j = 0; j < pBag->GetBagSize(); j++) { @@ -11257,7 +11257,7 @@ uint8 Player::CanStoreItems(Item **pItems,int count) const { if (pBag = GetBagByPos(t)) { - pBagProto = pBag->GetProto(); + pBagProto = pBag->GetTemplate(); // not plain container check if (pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) && @@ -11296,7 +11296,7 @@ uint8 Player::CanStoreItems(Item **pItems,int count) const { if (pBag = GetBagByPos(t)) { - pBagProto = pBag->GetProto(); + pBagProto = pBag->GetTemplate(); // special bag already checked if (pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER)) @@ -11343,7 +11343,7 @@ uint8 Player::CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, boo if (pItem) { sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: CanEquipItem slot = %u, item = %u, count = %u", slot, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); if (pProto) { // item used @@ -11420,7 +11420,7 @@ uint8 Player::CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, boo { if (pBag != pItem) { - if (ItemPrototype const* pBagProto = pBag->GetProto()) + if (ItemTemplate const* pBagProto = pBag->GetTemplate()) { if (pBagProto->Class == pProto->Class && (!swap || pBag->GetSlot() != eslot)) return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH) @@ -11495,7 +11495,7 @@ uint8 Player::CanUnequipItem(uint16 pos, bool swap) const sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: CanUnequipItem slot = %u, item = %u, count = %u", pos, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); if (!pProto) return EQUIP_ERR_ITEM_NOT_FOUND; @@ -11530,7 +11530,7 @@ uint8 Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pI uint32 count = pItem->GetCount(); sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: CanBankItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); if (!pProto) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; @@ -11721,7 +11721,7 @@ uint8 Player::CanUseItem(Item *pItem, bool not_loading) const //if (isStunned()) // return EQUIP_ERR_YOU_ARE_STUNNED; - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); if (pProto) { if (pItem->IsBindedNotWith(this)) @@ -11768,7 +11768,7 @@ uint8 Player::CanUseItem(Item *pItem, bool not_loading) const return EQUIP_ERR_ITEM_NOT_FOUND; } -uint8 Player::CanUseItem(ItemPrototype const *pProto) const +uint8 Player::CanUseItem(ItemTemplate const *pProto) const { // Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player @@ -11806,7 +11806,7 @@ uint8 Player::CanUseAmmo(uint32 item) const return EQUIP_ERR_YOU_ARE_DEAD; //if (isStunned()) // return EQUIP_ERR_YOU_ARE_STUNNED; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item); if (pProto) { if (pProto->InventoryType!= INVTYPE_AMMO) @@ -11880,12 +11880,12 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update pItem->SetItemRandomProperties(randomPropertyId); pItem = StoreItem(dest, pItem, update); - const ItemPrototype *proto = pItem->GetProto(); + const ItemTemplate *proto = pItem->GetTemplate(); for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger CastSpell(this, proto->Spells[i].SpellId, true, pItem); - if (allowedLooters && pItem->GetProto()->GetMaxStackSize() == 1 && pItem->IsSoulBound()) + if (allowedLooters && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound()) { pItem->SetSoulboundTradeable(allowedLooters, this, true); pItem->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, GetTotalPlayedTime()); @@ -11954,9 +11954,9 @@ Item* Player::_StoreItem(uint16 pos, Item *pItem, uint32 count, bool clone, bool if (!pItem) return NULL; - if (pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || - pItem->GetProto()->Bonding == BIND_QUEST_ITEM || - (pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) + if (pItem->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || + pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM || + (pItem->GetTemplate()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) pItem->SetBinding(true); Bag* pBag = (bag == INVENTORY_SLOT_BAG_0) ? NULL : GetBagByPos(bag); @@ -11994,9 +11994,9 @@ Item* Player::_StoreItem(uint16 pos, Item *pItem, uint32 count, bool clone, bool } else { - if (pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || - pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || - (pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) + if (pItem2->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || + pItem2->GetTemplate()->Bonding == BIND_QUEST_ITEM || + (pItem2->GetTemplate()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) pItem2->SetBinding(true); pItem2->SetCount(pItem2->GetCount() + count); @@ -12058,7 +12058,7 @@ Item* Player::EquipItem(uint16 pos, Item *pItem, bool update) if (isAlive()) { - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); // item set bonuses applied only at equip and removed at unequip, and still active for broken items if (pProto && pProto->ItemSet) @@ -12197,7 +12197,7 @@ void Player::VisualizeItem(uint8 slot, Item *pItem) return; // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) - if (pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM) + if (pItem->GetTemplate()->Bonding == BIND_WHEN_EQUIPED || pItem->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM) pItem->SetBinding(true); sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); @@ -12235,7 +12235,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) { if (slot < INVENTORY_SLOT_BAG_END) { - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); // item set bonuses applied only at equip and removed at unequip, and still active for broken items if (pProto && pProto->ItemSet) @@ -12361,7 +12361,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) pItem->SetSoulboundTradeable(NULL, this, false); RemoveTradeableItem(pItem); - const ItemPrototype *proto = pItem->GetProto(); + const ItemTemplate *proto = pItem->GetTemplate(); for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger RemoveAurasDueToSpell(proto->Spells[i].SpellId); @@ -12375,7 +12375,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) // equipment and equipped bags can have applied bonuses if (slot < INVENTORY_SLOT_BAG_END) { - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); // item set bonuses applied only at equip and removed at unequip, and still active for broken items if (pProto && pProto->ItemSet) @@ -12916,7 +12916,7 @@ void Player::SwapItem(uint16 src, uint16 dst) // can be merge/fill if (msg == EQUIP_ERR_OK) { - if (pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetProto()->GetMaxStackSize()) + if (pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetTemplate()->GetMaxStackSize()) { RemoveItem(srcbag, srcslot, true); @@ -12932,8 +12932,8 @@ void Player::SwapItem(uint16 src, uint16 dst) } else { - pSrcItem->SetCount(pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetProto()->GetMaxStackSize()); - pDstItem->SetCount(pSrcItem->GetProto()->GetMaxStackSize()); + pSrcItem->SetCount(pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetTemplate()->GetMaxStackSize()); + pDstItem->SetCount(pSrcItem->GetTemplate()->GetMaxStackSize()); pSrcItem->SetState(ITEM_CHANGED, this); pDstItem->SetState(ITEM_CHANGED, this); if (IsInWorld()) @@ -13011,7 +13011,7 @@ void Player::SwapItem(uint16 src, uint16 dst) // bag swap (with items exchange) case if (emptyBag && fullBag) { - ItemPrototype const* emptyProto = emptyBag->GetProto(); + ItemTemplate const* emptyProto = emptyBag->GetTemplate(); uint32 count = 0; @@ -13021,7 +13021,7 @@ void Player::SwapItem(uint16 src, uint16 dst) if (!bagItem) continue; - ItemPrototype const* bagItemProto = bagItem->GetProto(); + ItemTemplate const* bagItemProto = bagItem->GetTemplate(); if (!bagItemProto || !ItemCanGoIntoBag(bagItemProto, emptyProto)) { // one from items not go to empty target bag @@ -13162,7 +13162,7 @@ void Player::AddItemToBuyBackSlot(Item *pItem) uint32 eslot = slot - BUYBACK_SLOT_START; SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID()); - if (ItemPrototype const *pProto = pItem->GetProto()) + if (ItemTemplate const *pProto = pItem->GetTemplate()) SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount()); else SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); @@ -13225,7 +13225,7 @@ void Player::SendEquipError(uint8 msg, Item* pItem, Item *pItem2, uint32 itemid) case EQUIP_ERR_CANT_EQUIP_LEVEL_I: case EQUIP_ERR_PURCHASE_LEVEL_TOO_LOW: { - ItemPrototype const* proto = pItem ? pItem->GetProto() : ObjectMgr::GetItemPrototype(itemid); + ItemTemplate const* proto = pItem ? pItem->GetTemplate() : sObjectMgr->GetItemTemplate(itemid); data << uint32(proto ? proto->RequiredLevel : 0); break; } @@ -13240,7 +13240,7 @@ void Player::SendEquipError(uint8 msg, Item* pItem, Item *pItem2, uint32 itemid) case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_SOCKETED_EXCEEDED: case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED: { - ItemPrototype const* proto = pItem ? pItem->GetProto() : ObjectMgr::GetItemPrototype(itemid); + ItemTemplate const* proto = pItem ? pItem->GetTemplate() : sObjectMgr->GetItemTemplate(itemid); data << uint32(proto ? proto->ItemLimitCategory : 0); break; } @@ -13346,7 +13346,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) Item* item = *itr; ++itr; // current element can be erased in UpdateDuration - if ((realtimeonly && item->GetProto()->Duration < 0) || !realtimeonly) + if ((realtimeonly && item->GetTemplate()->Duration < 0) || !realtimeonly) item->UpdateDuration(this,time); } } @@ -13507,7 +13507,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool // If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements // rather than the gem requirements itself. If the socket has no color it is a prismatic socket. if((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) - && !item->GetProto()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color) + && !item->GetTemplate()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color) { // Check if the requirements for the prismatic socket are met before applying the gem stats SpellItemEnchantmentEntry const *pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); @@ -13804,12 +13804,12 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool float addValue = 0.0f; if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) { - addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); + addValue = float(enchant_amount * item->GetTemplate()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); } else if (item->GetSlot() == EQUIPMENT_SLOT_OFFHAND) { - addValue = float(enchant_amount * item->GetProto()->Delay / 1000.0f); + addValue = float(enchant_amount * item->GetTemplate()->Delay / 1000.0f); HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); } } @@ -13880,7 +13880,7 @@ void Player::UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 // If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements // rather than the gem requirements itself. If the socket has no color it is a prismatic socket. if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) - && !m_items[i]->GetProto()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color) + && !m_items[i]->GetTemplate()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color) { SpellItemEnchantmentEntry const *pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(m_items[i]->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); @@ -16036,7 +16036,7 @@ bool Player::HasQuestForItem(uint32 itemid) const // examined item is a source item if (qinfo->ReqSourceId[j] == itemid) { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(itemid); // 'unique' item if (pProto->MaxCount && int32(GetItemCount(itemid, true)) < pProto->MaxCount) @@ -17309,7 +17309,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F Item* item = NULL; uint32 itemGuid = fields[13].GetUInt32(); uint32 itemEntry = fields[14].GetUInt32(); - if (ItemPrototype const * proto = ObjectMgr::GetItemPrototype(itemEntry)) + if (ItemTemplate const * proto = sObjectMgr->GetItemTemplate(itemEntry)) { bool remove = false; item = NewItemOrBag(proto); @@ -17425,7 +17425,7 @@ void Player::_LoadMailedItems(Mail *mail) mail->AddItem(item_guid_low, item_template); - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template); + ItemTemplate const *proto = sObjectMgr->GetItemTemplate(item_template); if (!proto) { @@ -18051,7 +18051,7 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report else if (mapDiff->hasErrorMessage) // if (missingAchievement) covered by this case SendTransferAborted(target_map, TRANSFER_ABORT_DIFFICULTY, target_difficulty); else if (missingItem) - GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), LevelMin, ObjectMgr::GetItemPrototype(missingItem)->Name1); + GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), LevelMin, sObjectMgr->GetItemTemplate(missingItem)->Name1); else if (LevelMin) GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED), LevelMin); } @@ -20154,7 +20154,7 @@ void Player::InitDisplayIds() } } -inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemPrototype const *pProto, Creature *pVendor, VendorItem const* crItem, bool bStore) +inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const *pProto, Creature *pVendor, VendorItem const* crItem, bool bStore) { ItemPosCountVec vDest; uint16 uiDest = 0; @@ -20229,7 +20229,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 if (!isAlive()) return false; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item); if (!pProto) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, item, 0); @@ -20480,7 +20480,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it if (itemId) { - if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId)) + if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId)) { for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx) { @@ -20593,7 +20593,7 @@ void Player::UpdatePotionCooldown(Spell* spell) if (!spell) { // spell/item pair let set proper cooldown (except not existed charged spell cooldown spellmods for potions) - if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_lastPotionId)) + if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(m_lastPotionId)) for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx) if (proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE) if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId)) @@ -20625,7 +20625,7 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) if (i == slot) continue; Item *pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (pItem2 && !pItem2->IsBroken() && pItem2->GetProto()->Socket[0].Color) + if (pItem2 && !pItem2->IsBroken() && pItem2->GetTemplate()->Socket[0].Color) { for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) { @@ -20641,7 +20641,7 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) if (!gemid) continue; - ItemPrototype const* gemProto = sItemStorage.LookupEntry<ItemPrototype>(gemid); + ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(gemid); if (!gemProto) continue; @@ -20702,7 +20702,7 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!pItem || !pItem->GetProto()->Socket[0].Color) + if (!pItem || !pItem->GetTemplate()->Socket[0].Color) continue; for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) @@ -20744,7 +20744,7 @@ void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!pItem || !pItem->GetProto()->Socket[0].Color) //if item has no sockets or no item is equipped go to next item + if (!pItem || !pItem->GetTemplate()->Socket[0].Color) //if item has no sockets or no item is equipped go to next item continue; //cycle all (gem)enchants @@ -21443,7 +21443,7 @@ void Player::ApplyEquipCooldown(Item * pItem) for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { - _Spell const& spellData = pItem->GetProto()->Spells[i]; + _Spell const& spellData = pItem->GetTemplate()->Spells[i]; // no spell if (!spellData.SpellId) @@ -21954,11 +21954,11 @@ void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/) return; // unequip offhand weapon if player doesn't have dual wield anymore - if (!CanDualWield() && (offItem->GetProto()->InventoryType == INVTYPE_WEAPONOFFHAND || offItem->GetProto()->InventoryType == INVTYPE_WEAPON)) + if (!CanDualWield() && (offItem->GetTemplate()->InventoryType == INVTYPE_WEAPONOFFHAND || offItem->GetTemplate()->InventoryType == INVTYPE_WEAPON)) force = true; // need unequip offhand for 2h-weapon without TitanGrip (in any from hands) - if (!force && (CanTitanGrip() || (offItem->GetProto()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed()))) + if (!force && (CanTitanGrip() || (offItem->GetTemplate()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed()))) return; ItemPosCountVec off_dest; @@ -23269,7 +23269,7 @@ uint32 Player::GetPhaseMaskForSpawn() const uint8 Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) const { - ItemPrototype const* pProto = pItem->GetProto(); + ItemTemplate const* pProto = pItem->GetTemplate(); // proto based limitations if (uint8 res = CanEquipUniqueItem(pProto,eslot,limit_count)) @@ -23285,7 +23285,7 @@ uint8 Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) c if (!enchantEntry) continue; - ItemPrototype const* pGem = ObjectMgr::GetItemPrototype(enchantEntry->GemID); + ItemTemplate const* pGem = sObjectMgr->GetItemTemplate(enchantEntry->GemID); if (!pGem) continue; @@ -23300,7 +23300,7 @@ uint8 Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) c return EQUIP_ERR_OK; } -uint8 Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 except_slot, uint32 limit_count) const +uint8 Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 except_slot, uint32 limit_count) const { // check unique-equipped on item if (itemProto->Flags & ITEM_PROTO_FLAG_UNIQUE_EQUIPPED) @@ -24581,8 +24581,8 @@ float Player::GetAverageItemLevel() if (i == EQUIPMENT_SLOT_TABARD || i == EQUIPMENT_SLOT_RANGED || i == EQUIPMENT_SLOT_OFFHAND || i == EQUIPMENT_SLOT_CHEST) continue; - if (m_items[i] && m_items[i]->GetProto()) - sum += m_items[i]->GetProto()->GetItemLevelIncludingQuality(); + if (m_items[i] && m_items[i]->GetTemplate()) + sum += m_items[i]->GetTemplate()->GetItemLevelIncludingQuality(); count++; } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index a04494c64a5..0eab635bf60 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1171,7 +1171,7 @@ class Player : public Unit, public GridObject<Player> void SetVirtualItemSlot(uint8 i, Item* item); void SetSheath(SheathState sheathed); // overwrite Unit version - uint8 FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) const; + uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = NULL) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const; Item* GetItemByGuid(uint64 guid) const; @@ -1224,13 +1224,13 @@ class Player : public Unit, public GridObject<Player> uint8 CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true) const; uint8 CanEquipUniqueItem(Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; - uint8 CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; + uint8 CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; uint8 CanUnequipItems(uint32 item, uint32 count) const; uint8 CanUnequipItem(uint16 src, bool swap) const; uint8 CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true) const; uint8 CanUseItem(Item *pItem, bool not_loading = true) const; bool HasItemTotemCategory(uint32 TotemCategory) const; - uint8 CanUseItem(ItemPrototype const *pItem) const; + uint8 CanUseItem(ItemTemplate const *pItem) const; uint8 CanUseAmmo(uint32 item) const; Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0, AllowedLooterSet* allowedLooters = NULL); Item* StoreItem(ItemPosCountVec const& pos, Item *pItem, bool update); @@ -1252,7 +1252,7 @@ class Player : public Unit, public GridObject<Player> void SetAmmo(uint32 item); void RemoveAmmo(); float GetAmmoDPS() const { return m_ammoDPS; } - bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const; + bool CheckAmmoCompatibility(const ItemTemplate *ammo_proto) const; void QuickEquipItem(uint16 pos, Item *pItem); void VisualizeItem(uint8 slot, Item *pItem); void SetVisibleItemSlot(uint8 slot, Item *pItem); @@ -1293,11 +1293,11 @@ class Player : public Unit, public GridObject<Player> bool IsTwoHandUsed() const { Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - return mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip(); + return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip(); } void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast = false); bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); - bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemPrototype const *pProto, Creature *pVendor, VendorItem const* crItem, bool bStore); + bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const *pProto, Creature *pVendor, VendorItem const* crItem, bool bStore); float GetReputationPriceDiscount(Creature const* pCreature) const; @@ -1813,7 +1813,7 @@ class Player : public Unit, public GridObject<Player> uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); } uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const; - uint32 GetSpellByProto(ItemPrototype *proto); + uint32 GetSpellByProto(ItemTemplate *proto); float GetHealthBonusFromStamina(); float GetManaBonusFromIntellect(); @@ -2047,8 +2047,8 @@ class Player : public Unit, public GridObject<Player> void _RemoveAllItemMods(); void _ApplyAllItemMods(); void _ApplyAllLevelScaleItemMods(bool apply); - void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply, bool only_level_scale = false); - void _ApplyWeaponDamage(uint8 slot, ItemPrototype const *proto, ScalingStatValuesEntry const *ssv, bool apply); + void _ApplyItemBonuses(ItemTemplate const *proto,uint8 slot,bool apply, bool only_level_scale = false); + void _ApplyWeaponDamage(uint8 slot, ItemTemplate const *proto, ScalingStatValuesEntry const *ssv, bool apply); void _ApplyAmmoBonuses(); bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot); void ToggleMetaGemsActive(uint8 exceptslot, bool apply); @@ -2060,7 +2060,7 @@ class Player : public Unit, public GridObject<Player> void UpdateEquipSpellsAtFormChange(); void CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx); void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex); - void CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item *item, ItemPrototype const * proto); + void CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item *item, ItemTemplate const * proto); void SendEquipmentSetList(); void SetEquipmentSet(uint32 index, EquipmentSet eqset); @@ -2687,9 +2687,9 @@ class Player : public Unit, public GridObject<Player> bool isAlwaysDetectableFor(WorldObject const* seer) const; private: // internal common parts for CanStore/StoreItem functions - uint8 _CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem) const; - uint8 _CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot) const; - uint8 _CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot) const; + uint8 _CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const *pProto, uint32& count, bool swap, Item *pSrcItem) const; + uint8 _CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot) const; + uint8 _CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot) const; Item* _StoreItem(uint16 pos, Item *pItem, uint32 count, bool clone, bool update); Item* _LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields); @@ -2759,7 +2759,7 @@ class Player : public Unit, public GridObject<Player> }; void AddItemsSetItem(Player*player,Item *item); -void RemoveItemsSetItem(Player*player,ItemPrototype const *proto); +void RemoveItemsSetItem(Player*player,ItemTemplate const *proto); // "the bodies of template functions must be made available in a header file" template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell* spell) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index f4eb9ff8fae..b7a7ea40e3d 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2677,7 +2677,7 @@ float Unit::GetUnitBlockChance() const if (player->CanBlock()) { Item *tmpitem = player->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if (tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block) + if (tmpitem && !tmpitem->IsBroken() && tmpitem->GetTemplate()->Block) return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); } // is player but has no block ability or no not broken shield equipped @@ -14655,7 +14655,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) if (!Weapon) return 2.4f; // fist attack - switch (Weapon->GetProto()->InventoryType) + switch (Weapon->GetTemplate()->InventoryType) { case INVTYPE_2HWEAPON: return 3.3f; @@ -14667,7 +14667,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) case INVTYPE_WEAPONMAINHAND: case INVTYPE_WEAPONOFFHAND: default: - return Weapon->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f; + return Weapon->GetTemplate()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f; } } @@ -14845,14 +14845,14 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co if (this->ToPlayer()->IsInFeralForm()) return false; - if (!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_WEAPON || !((1<<item->GetTemplate()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } else if (spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) { // Check if player is wearing shield Item *item = this->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if (!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + if (!item || item->IsBroken() || item->GetTemplate()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetTemplate()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 2fc2131d7e9..10fe9dd918d 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2186,142 +2186,276 @@ struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader> } }; -void ObjectMgr::LoadItemPrototypes() +void ObjectMgr::LoadItemTemplates() { uint32 oldMSTime = getMSTime(); - SQLItemLoader loader; - loader.Load(sItemStorage); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, unk0, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, " + // 13 14 15 16 17 18 19 20 + "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, " + // 21 22 23 24 25 26 27 28 + "RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, StatsCount, stat_type1, " + // 29 30 31 32 33 34 35 36 37 38 + "stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, " + // 39 40 41 42 43 44 45 46 47 + "stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, " + // 48 49 50 51 52 53 54 55 56 57 58 + "ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, " + // 59 60 61 62 63 64 65 66 67 68 + "nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, " + // 69 70 71 72 73 74 75 + "spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, " + // 76 77 78 79 80 81 82 + "spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, " + // 83 84 85 86 87 88 89 + "spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, " + // 90 91 92 93 94 95 96 + "spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, " + // 97 98 99 100 101 102 103 104 105 + "spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, " + // 106 107 108 109 110 111 112 113 114 115 116 117 + "startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, " + // 118 119 120 121 122 123 124 125 + "TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, " + // 126 127 128 129 130 131 132 133 + "GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, Duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, " + // 134 135 136 + "FoodType, minMoneyLoot, maxMoneyLoot FROM item_template"); - // check data correctness + if (!result) + { + sLog->outString(">> Loaded 0 item templates. DB table `item_template` is empty."); + sLog->outString(); + return; + } + + uint32 count = 0; bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES); - for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) + + do { - ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype >(i); - ItemEntry const *dbcitem = sItemStore.LookupEntry(i); - if (!proto) - { - /* to many errors, and possible not all items really used in game - if (dbcitem) - sLog->outErrorDb("Item (Entry: %u) doesn't exists in DB, but must exist.",i); - */ - continue; - } + Field *fields = result->Fetch(); + + uint32 entry = fields[0].GetUInt32(); + + ItemTemplate itemTemplate; + + itemTemplate.ItemId = entry; + itemTemplate.Class = uint32(fields[1].GetUInt8()); + itemTemplate.SubClass = uint32(fields[2].GetUInt8()); + itemTemplate.Unk0 = fields[3].GetInt32(); + itemTemplate.Name1 = fields[4].GetCString(); + itemTemplate.DisplayInfoID = fields[5].GetUInt32(); + itemTemplate.Quality = uint32(fields[6].GetUInt8()); + itemTemplate.Flags = uint32(fields[7].GetInt64()); + itemTemplate.Flags2 = fields[8].GetUInt32(); + itemTemplate.BuyCount = uint32(fields[9].GetUInt8()); + itemTemplate.BuyPrice = int32(fields[10].GetInt64()); + itemTemplate.SellPrice = fields[11].GetUInt32(); + itemTemplate.InventoryType = uint32(fields[12].GetUInt8()); + itemTemplate.AllowableClass = fields[13].GetInt32(); + itemTemplate.AllowableRace = fields[14].GetInt32(); + itemTemplate.ItemLevel = uint32(fields[15].GetUInt16()); + itemTemplate.RequiredLevel = uint32(fields[16].GetUInt8()); + itemTemplate.RequiredSkill = uint32(fields[17].GetUInt16()); + itemTemplate.RequiredSkillRank = uint32(fields[18].GetUInt16()); + itemTemplate.RequiredSpell = fields[19].GetUInt32(); + itemTemplate.RequiredHonorRank = fields[20].GetUInt32(); + itemTemplate.RequiredCityRank = fields[21].GetUInt32(); + itemTemplate.RequiredReputationFaction = uint32(fields[22].GetUInt16()); + itemTemplate.RequiredReputationRank = uint32(fields[23].GetUInt16()); + itemTemplate.MaxCount = fields[24].GetInt32(); + itemTemplate.Stackable = fields[25].GetInt32(); + itemTemplate.ContainerSlots = uint32(fields[26].GetUInt8()); + itemTemplate.StatsCount = uint32(fields[27].GetUInt8()); + + for (uint8 i = 0; i < itemTemplate.StatsCount; ++i) + { + itemTemplate.ItemStat[i].ItemStatType = uint32(fields[28 + i*2].GetUInt8()); + itemTemplate.ItemStat[i].ItemStatValue = uint32(fields[29 + i*2].GetUInt16()); + } + + itemTemplate.ScalingStatDistribution = uint32(fields[48].GetUInt16()); + itemTemplate.ScalingStatValue = fields[49].GetInt32(); + + for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) + { + itemTemplate.Damage[i].DamageMax = fields[50 + i*3].GetFloat(); + itemTemplate.Damage[i].DamageMin = fields[51 + i*3].GetFloat(); + itemTemplate.Damage[i].DamageType = uint32(fields[52 + i*3].GetUInt8()); + } + + itemTemplate.Armor = uint32(fields[56].GetUInt16()); + itemTemplate.HolyRes = uint32(fields[57].GetUInt8()); + itemTemplate.FireRes = uint32(fields[58].GetUInt8()); + itemTemplate.NatureRes = uint32(fields[59].GetUInt8()); + itemTemplate.FrostRes = uint32(fields[60].GetUInt8()); + itemTemplate.ShadowRes = uint32(fields[61].GetUInt8()); + itemTemplate.ArcaneRes = uint32(fields[62].GetUInt8()); + itemTemplate.Delay = uint32(fields[63].GetUInt16()); + itemTemplate.AmmoType = uint32(fields[64].GetUInt8()); + itemTemplate.RangedModRange = fields[65].GetFloat(); + + for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + { + itemTemplate.Spells[i].SpellId = fields[66 + i*7 ].GetInt32(); + itemTemplate.Spells[i].SpellTrigger = uint32(fields[67 + i*7].GetUInt8()); + itemTemplate.Spells[i].SpellCharges = uint32(fields[68 + i*7].GetInt16()); + itemTemplate.Spells[i].SpellPPMRate = fields[69 + i*7].GetFloat(); + itemTemplate.Spells[i].SpellCooldown = fields[70 + i*7].GetInt32(); + itemTemplate.Spells[i].SpellCategory = uint32(fields[71 + i*7].GetUInt16()); + itemTemplate.Spells[i].SpellCategoryCooldown = fields[72 + i*7].GetInt32(); + } + + itemTemplate.Bonding = uint32(fields[101].GetUInt8()); + itemTemplate.Description = fields[102].GetCString(); + itemTemplate.PageText = fields[103].GetUInt32(); + itemTemplate.LanguageID = uint32(fields[104].GetUInt8()); + itemTemplate.PageMaterial = uint32(fields[105].GetUInt8()); + itemTemplate.StartQuest = fields[106].GetUInt32(); + itemTemplate.LockID = fields[107].GetUInt32(); + itemTemplate.Material = uint32(fields[108].GetInt8()); + itemTemplate.Sheath = uint32(fields[109].GetUInt8()); + itemTemplate.RandomProperty = fields[110].GetUInt32(); + itemTemplate.RandomSuffix = fields[111].GetUInt32(); + itemTemplate.Block = fields[112].GetUInt32(); + itemTemplate.ItemSet = fields[113].GetUInt32(); + itemTemplate.MaxDurability = uint32(fields[114].GetUInt16()); + itemTemplate.Area = fields[115].GetUInt32(); + itemTemplate.Map = uint32(fields[116].GetUInt16()); + itemTemplate.BagFamily = fields[117].GetUInt32(); + itemTemplate.TotemCategory = fields[118].GetUInt32(); + + for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i) + { + itemTemplate.Socket[i].Color = uint32(fields[119 + i*2].GetUInt8()); + itemTemplate.Socket[i].Content = fields[120 + i*2].GetUInt32(); + } + + itemTemplate.socketBonus = fields[125].GetUInt32(); + itemTemplate.GemProperties = fields[126].GetUInt32(); + itemTemplate.RequiredDisenchantSkill = uint32(fields[127].GetInt16()); + itemTemplate.ArmorDamageModifier = fields[128].GetFloat(); + itemTemplate.Duration = fields[129].GetInt32(); + itemTemplate.ItemLimitCategory = uint32(fields[130].GetInt16()); + itemTemplate.HolidayId = fields[131].GetUInt32(); + itemTemplate.ScriptId = sObjectMgr->GetScriptId(fields[132].GetCString()); + itemTemplate.DisenchantID = fields[133].GetUInt32(); + itemTemplate.FoodType = uint32(fields[134].GetUInt8()); + itemTemplate.MinMoneyLoot = fields[135].GetUInt32(); + itemTemplate.MaxMoneyLoot = fields[136].GetUInt32(); + + // Checks + + ItemEntry const *dbcitem = sItemStore.LookupEntry(entry); if (dbcitem) { - if (proto->Class != dbcitem->Class) + if (itemTemplate.Class != dbcitem->Class) { - sLog->outErrorDb("Item (Entry: %u) does not have a correct class %u, must be %u .", i, proto->Class, dbcitem->Class); + sLog->outErrorDb("Item (Entry: %u) does not have a correct class %u, must be %u .", entry, itemTemplate.Class, dbcitem->Class); if (enforceDBCAttributes) - const_cast<ItemPrototype*>(proto)->Class = dbcitem->Class; + itemTemplate.Class = dbcitem->Class; } - /* disabled: have some strange wrong cases for Subclass values. - for enable also uncomment Subclass field in ItemEntry structure and in Itemfmt[] - if (proto->SubClass != dbcitem->SubClass) - { - sLog->outErrorDb("Item (Entry: %u) not correct (Class: %u, Sub: %u) pair, must be (Class: %u, Sub: %u) (still using DB value).",i,proto->Class,proto->SubClass,dbcitem->Class,dbcitem->SubClass); - // It safe let use Subclass from DB - } - */ - if (proto->Unk0 != dbcitem->Unk0) + if (itemTemplate.Unk0 != dbcitem->Unk0) { - sLog->outErrorDb("Item (Entry: %u) does not have a correct Unk0 (%i) , must be %i .", i, proto->Unk0, dbcitem->Unk0); + sLog->outErrorDb("Item (Entry: %u) does not have a correct Unk0 (%i) , must be %i .", entry, itemTemplate.Unk0, dbcitem->Unk0); if (enforceDBCAttributes) - const_cast<ItemPrototype*>(proto)->Unk0 = dbcitem->Unk0; + itemTemplate.Unk0 = dbcitem->Unk0; } - if (proto->Material != dbcitem->Material) + if (itemTemplate.Material != dbcitem->Material) { - sLog->outErrorDb("Item (Entry: %u) does not have a correct material (%i), must be %i .", i, proto->Material, dbcitem->Material); + sLog->outErrorDb("Item (Entry: %u) does not have a correct material (%i), must be %i .", entry, itemTemplate.Material, dbcitem->Material); if (enforceDBCAttributes) - const_cast<ItemPrototype*>(proto)->Material = dbcitem->Material; + itemTemplate.Material = dbcitem->Material; } - if (proto->InventoryType != dbcitem->InventoryType) + if (itemTemplate.InventoryType != dbcitem->InventoryType) { - sLog->outErrorDb("Item (Entry: %u) does not have a correct inventory type (%u), must be %u .", i, proto->InventoryType, dbcitem->InventoryType); + sLog->outErrorDb("Item (Entry: %u) does not have a correct inventory type (%u), must be %u .", entry, itemTemplate.InventoryType, dbcitem->InventoryType); if (enforceDBCAttributes) - const_cast<ItemPrototype*>(proto)->InventoryType = dbcitem->InventoryType; + itemTemplate.InventoryType = dbcitem->InventoryType; } - if (proto->DisplayInfoID != dbcitem->DisplayId) + if (itemTemplate.DisplayInfoID != dbcitem->DisplayId) { - sLog->outErrorDb("Item (Entry: %u) does not have a correct display id (%u), must be %u .", i, proto->DisplayInfoID, dbcitem->DisplayId); + sLog->outErrorDb("Item (Entry: %u) does not have a correct display id (%u), must be %u .", entry, itemTemplate.DisplayInfoID, dbcitem->DisplayId); if (enforceDBCAttributes) - const_cast<ItemPrototype*>(proto)->DisplayInfoID = dbcitem->DisplayId; + itemTemplate.DisplayInfoID = dbcitem->DisplayId; } - if (proto->Sheath != dbcitem->Sheath) + if (itemTemplate.Sheath != dbcitem->Sheath) { - sLog->outErrorDb("Item (Entry: %u) does not have a correct sheathid (%u), must be %u .", i, proto->Sheath, dbcitem->Sheath); + sLog->outErrorDb("Item (Entry: %u) does not have a correct sheathid (%u), must be %u .", entry, itemTemplate.Sheath, dbcitem->Sheath); if (enforceDBCAttributes) - const_cast<ItemPrototype*>(proto)->Sheath = dbcitem->Sheath; + itemTemplate.Sheath = dbcitem->Sheath; } } else - sLog->outErrorDb("Item (Entry: %u) does not exist in item.dbc! (not correct id?).",i); + sLog->outErrorDb("Item (Entry: %u) does not exist in item.dbc! (not correct id?).", entry); - if (proto->Class >= MAX_ITEM_CLASS) + if (itemTemplate.Class >= MAX_ITEM_CLASS) { - sLog->outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class); - const_cast<ItemPrototype*>(proto)->Class = ITEM_CLASS_MISC; + sLog->outErrorDb("Item (Entry: %u) has wrong Class value (%u)", entry, itemTemplate.Class); + itemTemplate.Class = ITEM_CLASS_MISC; } - if (proto->SubClass >= MaxItemSubclassValues[proto->Class]) + if (itemTemplate.SubClass >= MaxItemSubclassValues[itemTemplate.Class]) { - sLog->outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class); - const_cast<ItemPrototype*>(proto)->SubClass = 0;// exist for all item classes + sLog->outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",entry,itemTemplate.SubClass,itemTemplate.Class); + itemTemplate.SubClass = 0;// exist for all item classes } - if (proto->Quality >= MAX_ITEM_QUALITY) + if (itemTemplate.Quality >= MAX_ITEM_QUALITY) { - sLog->outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality); - const_cast<ItemPrototype*>(proto)->Quality = ITEM_QUALITY_NORMAL; + sLog->outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",entry,itemTemplate.Quality); + itemTemplate.Quality = ITEM_QUALITY_NORMAL; } - if (proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) + if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) { if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE)) - if ((proto->AllowableRace & faction->BaseRepRaceMask[0]) == 0) + if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0) sLog->outErrorDb("Item (Entry: %u) has value (%u) in `AllowableRace` races, not compatible with ITEM_FLAGS_EXTRA_HORDE_ONLY (%u) in Flags field, item cannot be equipped or used by these races.", - i, proto->AllowableRace, ITEM_FLAGS_EXTRA_HORDE_ONLY); + entry, itemTemplate.AllowableRace, ITEM_FLAGS_EXTRA_HORDE_ONLY); - if (proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) + if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) sLog->outErrorDb("Item (Entry: %u) has value (%u) in `Flags2` flags (ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) and ITEM_FLAGS_EXTRA_HORDE_ONLY (%u) in Flags field, this is a wrong combination.", - i, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY, ITEM_FLAGS_EXTRA_HORDE_ONLY); + entry, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY, ITEM_FLAGS_EXTRA_HORDE_ONLY); } - else if (proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) + else if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) { if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE)) - if ((proto->AllowableRace & faction->BaseRepRaceMask[0]) == 0) + if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0) sLog->outErrorDb("Item (Entry: %u) has value (%u) in `AllowableRace` races, not compatible with ITEM_FLAGS_EXTRA_ALLIANCE_ONLY (%u) in Flags field, item cannot be equipped or used by these races.", - i, proto->AllowableRace, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY); + entry, itemTemplate.AllowableRace, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY); } - if (proto->BuyCount <= 0) + if (itemTemplate.BuyCount <= 0) { - sLog->outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount); - const_cast<ItemPrototype*>(proto)->BuyCount = 1; + sLog->outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",entry,itemTemplate.BuyCount); + itemTemplate.BuyCount = 1; } - if (proto->InventoryType >= MAX_INVTYPE) + if (itemTemplate.InventoryType >= MAX_INVTYPE) { - sLog->outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType); - const_cast<ItemPrototype*>(proto)->InventoryType = INVTYPE_NON_EQUIP; + sLog->outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",entry,itemTemplate.InventoryType); + itemTemplate.InventoryType = INVTYPE_NON_EQUIP; } - if (proto->RequiredSkill >= MAX_SKILL_TYPE) + if (itemTemplate.RequiredSkill >= MAX_SKILL_TYPE) { - sLog->outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill); - const_cast<ItemPrototype*>(proto)->RequiredSkill = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",entry,itemTemplate.RequiredSkill); + itemTemplate.RequiredSkill = 0; } { // can be used in equip slot, as page read use in inventory, or spell casting at use - bool req = proto->InventoryType != INVTYPE_NON_EQUIP || proto->PageText; + bool req = itemTemplate.InventoryType != INVTYPE_NON_EQUIP || itemTemplate.PageText; if (!req) for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if (proto->Spells[j].SpellId) + if (itemTemplate.Spells[j].SpellId) { req = true; break; @@ -2330,78 +2464,78 @@ void ObjectMgr::LoadItemPrototypes() if (req) { - if (!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE)) - sLog->outErrorDb("Item (Entry: %u) does not have any playable classes (%u) in `AllowableClass` and can't be equipped or used.",i,proto->AllowableClass); + if (!(itemTemplate.AllowableClass & CLASSMASK_ALL_PLAYABLE)) + sLog->outErrorDb("Item (Entry: %u) does not have any playable classes (%u) in `AllowableClass` and can't be equipped or used.",entry,itemTemplate.AllowableClass); - if (!(proto->AllowableRace & RACEMASK_ALL_PLAYABLE)) - sLog->outErrorDb("Item (Entry: %u) does not have any playable races (%u) in `AllowableRace` and can't be equipped or used.",i,proto->AllowableRace); + if (!(itemTemplate.AllowableRace & RACEMASK_ALL_PLAYABLE)) + sLog->outErrorDb("Item (Entry: %u) does not have any playable races (%u) in `AllowableRace` and can't be equipped or used.",entry,itemTemplate.AllowableRace); } } - if (proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) + if (itemTemplate.RequiredSpell && !sSpellStore.LookupEntry(itemTemplate.RequiredSpell)) { - sLog->outErrorDb("Item (Entry: %u) has a wrong (non-existing) spell in RequiredSpell (%u)",i,proto->RequiredSpell); - const_cast<ItemPrototype*>(proto)->RequiredSpell = 0; + sLog->outErrorDb("Item (Entry: %u) has a wrong (non-existing) spell in RequiredSpell (%u)",entry,itemTemplate.RequiredSpell); + itemTemplate.RequiredSpell = 0; } - if (proto->RequiredReputationRank >= MAX_REPUTATION_RANK) - sLog->outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",i,proto->RequiredReputationRank); + if (itemTemplate.RequiredReputationRank >= MAX_REPUTATION_RANK) + sLog->outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",entry,itemTemplate.RequiredReputationRank); - if (proto->RequiredReputationFaction) + if (itemTemplate.RequiredReputationFaction) { - if (!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) + if (!sFactionStore.LookupEntry(itemTemplate.RequiredReputationFaction)) { - sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction); - const_cast<ItemPrototype*>(proto)->RequiredReputationFaction = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)", entry, itemTemplate.RequiredReputationFaction); + itemTemplate.RequiredReputationFaction = 0; } - if (proto->RequiredReputationRank == MIN_REPUTATION_RANK) - sLog->outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.",i); + if (itemTemplate.RequiredReputationRank == MIN_REPUTATION_RANK) + sLog->outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", entry); } - if (proto->MaxCount < -1) + if (itemTemplate.MaxCount < -1) { - sLog->outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.",i,proto->MaxCount); - const_cast<ItemPrototype*>(proto)->MaxCount = -1; + sLog->outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.",entry,itemTemplate.MaxCount); + itemTemplate.MaxCount = -1; } - if (proto->Stackable == 0) + if (itemTemplate.Stackable == 0) { - sLog->outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.",i,proto->Stackable); - const_cast<ItemPrototype*>(proto)->Stackable = 1; + sLog->outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.",entry,itemTemplate.Stackable); + itemTemplate.Stackable = 1; } - else if (proto->Stackable < -1) + else if (itemTemplate.Stackable < -1) { - sLog->outErrorDb("Item (Entry: %u) has too large negative in stackable (%i), replace by value (-1) no stacking limits.",i,proto->Stackable); - const_cast<ItemPrototype*>(proto)->Stackable = -1; + sLog->outErrorDb("Item (Entry: %u) has too large negative in stackable (%i), replace by value (-1) no stacking limits.",entry,itemTemplate.Stackable); + itemTemplate.Stackable = -1; } - if (proto->ContainerSlots > MAX_BAG_SIZE) + if (itemTemplate.ContainerSlots > MAX_BAG_SIZE) { - sLog->outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).",i,proto->ContainerSlots,MAX_BAG_SIZE); - const_cast<ItemPrototype*>(proto)->ContainerSlots = MAX_BAG_SIZE; + sLog->outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).",entry,itemTemplate.ContainerSlots,MAX_BAG_SIZE); + itemTemplate.ContainerSlots = MAX_BAG_SIZE; } - if (proto->StatsCount > MAX_ITEM_PROTO_STATS) + if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS) { - sLog->outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS); - const_cast<ItemPrototype*>(proto)->StatsCount = MAX_ITEM_PROTO_STATS; + sLog->outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",entry,itemTemplate.StatsCount,MAX_ITEM_PROTO_STATS); + itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS; } - for (uint8 j = 0; j < MAX_ITEM_PROTO_STATS; ++j) + for (uint8 j = 0; j < itemTemplate.StatsCount; ++j) { // for ItemStatValue != 0 - if (proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) + if (itemTemplate.ItemStat[j].ItemStatValue && itemTemplate.ItemStat[j].ItemStatType >= MAX_ITEM_MOD) { - sLog->outErrorDb("Item (Entry: %u) has wrong (non-existing?) stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); - const_cast<ItemPrototype*>(proto)->ItemStat[j].ItemStatType = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong (non-existing?) stat_type%d (%u)",entry,j+1,itemTemplate.ItemStat[j].ItemStatType); + itemTemplate.ItemStat[j].ItemStatType = 0; } - switch (proto->ItemStat[j].ItemStatType) + switch (itemTemplate.ItemStat[j].ItemStatType) { case ITEM_MOD_SPELL_HEALING_DONE: case ITEM_MOD_SPELL_DAMAGE_DONE: - sLog->outErrorDb("Item (Entry: %u) has deprecated stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); + sLog->outErrorDb("Item (Entry: %u) has deprecated stat_type%d (%u)",entry,j+1,itemTemplate.ItemStat[j].ItemStatType); break; default: break; @@ -2410,73 +2544,73 @@ void ObjectMgr::LoadItemPrototypes() for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j) { - if (proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL) + if (itemTemplate.Damage[j].DamageType >= MAX_SPELL_SCHOOL) { - sLog->outErrorDb("Item (Entry: %u) has wrong dmg_type%d (%u)",i,j+1,proto->Damage[j].DamageType); - const_cast<ItemPrototype*>(proto)->Damage[j].DamageType = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong dmg_type%d (%u)",entry,j+1,itemTemplate.Damage[j].DamageType); + itemTemplate.Damage[j].DamageType = 0; } } // special format - if ((proto->Spells[0].SpellId == 483) || (proto->Spells[0].SpellId == 55884)) + if ((itemTemplate.Spells[0].SpellId == 483) || (itemTemplate.Spells[0].SpellId == 55884)) { // spell_1 - if (proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + if (itemTemplate.Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { - sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",i,0+1,proto->Spells[0].SpellTrigger); - const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",entry,0+1,itemTemplate.Spells[0].SpellTrigger); + itemTemplate.Spells[0].SpellId = 0; + itemTemplate.Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + itemTemplate.Spells[1].SpellId = 0; + itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } // spell_2 have learning spell - if (proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) + if (itemTemplate.Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) { - sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",i,1+1,proto->Spells[1].SpellTrigger); - const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",entry,1+1,itemTemplate.Spells[1].SpellTrigger); + itemTemplate.Spells[0].SpellId = 0; + itemTemplate.Spells[1].SpellId = 0; + itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - else if (!proto->Spells[1].SpellId) + else if (!itemTemplate.Spells[1].SpellId) { - sLog->outErrorDb("Item (Entry: %u) does not have an expected spell in spellid_%d in special learning format.",i,1+1); - const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + sLog->outErrorDb("Item (Entry: %u) does not have an expected spell in spellid_%d in special learning format.",entry,1+1); + itemTemplate.Spells[0].SpellId = 0; + itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - else if (proto->Spells[1].SpellId != -1) + else if (itemTemplate.Spells[1].SpellId != -1) { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId); - if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, proto->Spells[1].SpellId, NULL)) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(itemTemplate.Spells[1].SpellId); + if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, NULL)) { - sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)",i,1+1,proto->Spells[1].SpellId); - const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)",entry,1+1,itemTemplate.Spells[1].SpellId); + itemTemplate.Spells[0].SpellId = 0; + itemTemplate.Spells[1].SpellId = 0; + itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } // allowed only in special format - else if ((proto->Spells[1].SpellId == 483) || (proto->Spells[1].SpellId == 55884)) + else if ((itemTemplate.Spells[1].SpellId == 483) || (itemTemplate.Spells[1].SpellId == 55884)) { - sLog->outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%d)",i,1+1,proto->Spells[1].SpellId); - const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + sLog->outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%d)",entry,1+1,itemTemplate.Spells[1].SpellId); + itemTemplate.Spells[0].SpellId = 0; + itemTemplate.Spells[1].SpellId = 0; + itemTemplate.Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } } // spell_3*,spell_4*,spell_5* is empty for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if (proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + if (itemTemplate.Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { - sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); - const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",entry,j+1,itemTemplate.Spells[j].SpellTrigger); + itemTemplate.Spells[j].SpellId = 0; + itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - else if (proto->Spells[j].SpellId != 0) + else if (itemTemplate.Spells[j].SpellId != 0) { - sLog->outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%d) for learning special format",i,j+1,proto->Spells[j].SpellId); - const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%d) for learning special format",entry,j+1,itemTemplate.Spells[j].SpellId); + itemTemplate.Spells[j].SpellId = 0; } } } @@ -2485,141 +2619,146 @@ void ObjectMgr::LoadItemPrototypes() { for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if (proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID) + if (itemTemplate.Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || itemTemplate.Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID) { - sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); - const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; - const_cast<ItemPrototype*>(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + sLog->outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",entry,j+1,itemTemplate.Spells[j].SpellTrigger); + itemTemplate.Spells[j].SpellId = 0; + itemTemplate.Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - if (proto->Spells[j].SpellId && proto->Spells[j].SpellId != -1) + if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1) { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId); - if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, proto->Spells[j].SpellId, NULL)) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(itemTemplate.Spells[j].SpellId); + if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, NULL)) { - sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)",i,j+1,proto->Spells[j].SpellId); - const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)",entry,j+1,itemTemplate.Spells[j].SpellId); + itemTemplate.Spells[j].SpellId = 0; } // allowed only in special format - else if ((proto->Spells[j].SpellId == 483) || (proto->Spells[j].SpellId == 55884)) + else if ((itemTemplate.Spells[j].SpellId == 483) || (itemTemplate.Spells[j].SpellId == 55884)) { - sLog->outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%d)",i,j+1,proto->Spells[j].SpellId); - const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; + sLog->outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%d)",entry,j+1,itemTemplate.Spells[j].SpellId); + itemTemplate.Spells[j].SpellId = 0; } } } } - if (proto->Bonding >= MAX_BIND_TYPE) - sLog->outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)",i,proto->Bonding); + if (itemTemplate.Bonding >= MAX_BIND_TYPE) + sLog->outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)",entry,itemTemplate.Bonding); - if (proto->PageText && !GetPageText(proto->PageText)) - sLog->outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i,proto->PageText); + if (itemTemplate.PageText && !GetPageText(itemTemplate.PageText)) + sLog->outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", entry,itemTemplate.PageText); - if (proto->LockID && !sLockStore.LookupEntry(proto->LockID)) - sLog->outErrorDb("Item (Entry: %u) has wrong LockID (%u)",i,proto->LockID); + if (itemTemplate.LockID && !sLockStore.LookupEntry(itemTemplate.LockID)) + sLog->outErrorDb("Item (Entry: %u) has wrong LockID (%u)",entry,itemTemplate.LockID); - if (proto->Sheath >= MAX_SHEATHETYPE) + if (itemTemplate.Sheath >= MAX_SHEATHETYPE) { - sLog->outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",i,proto->Sheath); - const_cast<ItemPrototype*>(proto)->Sheath = SHEATHETYPE_NONE; + sLog->outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",entry,itemTemplate.Sheath); + itemTemplate.Sheath = SHEATHETYPE_NONE; } - if (proto->RandomProperty) + if (itemTemplate.RandomProperty) { // To be implemented later - if (proto->RandomProperty == -1) - const_cast<ItemPrototype*>(proto)->RandomProperty = 0; + if (itemTemplate.RandomProperty == -1) + itemTemplate.RandomProperty = 0; - else if (!sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty))) + else if (!sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomProperty))) { - sLog->outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",i,proto->RandomProperty); - const_cast<ItemPrototype*>(proto)->RandomProperty = 0; + sLog->outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",entry,itemTemplate.RandomProperty); + itemTemplate.RandomProperty = 0; } } - if (proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix))) + if (itemTemplate.RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(itemTemplate.RandomSuffix))) { - sLog->outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",i,proto->RandomSuffix); - const_cast<ItemPrototype*>(proto)->RandomSuffix = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",entry,itemTemplate.RandomSuffix); + itemTemplate.RandomSuffix = 0; } - if (proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet)) + if (itemTemplate.ItemSet && !sItemSetStore.LookupEntry(itemTemplate.ItemSet)) { - sLog->outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)",i,proto->ItemSet); - const_cast<ItemPrototype*>(proto)->ItemSet = 0; + sLog->outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)",entry,itemTemplate.ItemSet); + itemTemplate.ItemSet = 0; } - if (proto->Area && !GetAreaEntryByAreaID(proto->Area)) - sLog->outErrorDb("Item (Entry: %u) has wrong Area (%u)",i,proto->Area); + if (itemTemplate.Area && !GetAreaEntryByAreaID(itemTemplate.Area)) + sLog->outErrorDb("Item (Entry: %u) has wrong Area (%u)",entry,itemTemplate.Area); - if (proto->Map && !sMapStore.LookupEntry(proto->Map)) - sLog->outErrorDb("Item (Entry: %u) has wrong Map (%u)",i,proto->Map); + if (itemTemplate.Map && !sMapStore.LookupEntry(itemTemplate.Map)) + sLog->outErrorDb("Item (Entry: %u) has wrong Map (%u)",entry,itemTemplate.Map); - if (proto->BagFamily) + if (itemTemplate.BagFamily) { // check bits - for (uint32 j = 0; j < sizeof(proto->BagFamily)*8; ++j) + for (uint32 j = 0; j < sizeof(itemTemplate.BagFamily)*8; ++j) { uint32 mask = 1 << j; - if ((proto->BagFamily & mask) == 0) + if ((itemTemplate.BagFamily & mask) == 0) continue; ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1); if (!bf) { - sLog->outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit",i); - const_cast<ItemPrototype*>(proto)->BagFamily &= ~mask; + sLog->outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit", entry); + itemTemplate.BagFamily &= ~mask; continue; } if (BAG_FAMILY_MASK_CURRENCY_TOKENS & mask) { - CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(proto->ItemId); + CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemTemplate.ItemId); if (!ctEntry) { - sLog->outErrorDb("Item (Entry: %u) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit",i); - const_cast<ItemPrototype*>(proto)->BagFamily &= ~mask; + sLog->outErrorDb("Item (Entry: %u) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit", entry); + itemTemplate.BagFamily &= ~mask; } } } } - if (proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory)) - sLog->outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory); + if (itemTemplate.TotemCategory && !sTotemCategoryStore.LookupEntry(itemTemplate.TotemCategory)) + sLog->outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",entry,itemTemplate.TotemCategory); for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j) { - if (proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color) + if (itemTemplate.Socket[j].Color && (itemTemplate.Socket[j].Color & SOCKET_COLOR_ALL) != itemTemplate.Socket[j].Color) { - sLog->outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)",i,j+1,proto->Socket[j].Color); - const_cast<ItemPrototype*>(proto)->Socket[j].Color = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)",entry,j+1,itemTemplate.Socket[j].Color); + itemTemplate.Socket[j].Color = 0; } } - if (proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties)) - sLog->outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",i,proto->GemProperties); + if (itemTemplate.GemProperties && !sGemPropertiesStore.LookupEntry(itemTemplate.GemProperties)) + sLog->outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",entry,itemTemplate.GemProperties); - if (proto->FoodType >= MAX_PET_DIET) + if (itemTemplate.FoodType >= MAX_PET_DIET) { - sLog->outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType); - const_cast<ItemPrototype*>(proto)->FoodType = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",entry,itemTemplate.FoodType); + itemTemplate.FoodType = 0; } - if (proto->ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(proto->ItemLimitCategory)) + if (itemTemplate.ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(itemTemplate.ItemLimitCategory)) { - sLog->outErrorDb("Item (Entry: %u) has wrong LimitCategory value (%u)",i,proto->ItemLimitCategory); - const_cast<ItemPrototype*>(proto)->ItemLimitCategory = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong LimitCategory value (%u)",entry,itemTemplate.ItemLimitCategory); + itemTemplate.ItemLimitCategory = 0; } - if (proto->HolidayId && !sHolidaysStore.LookupEntry(proto->HolidayId)) + if (itemTemplate.HolidayId && !sHolidaysStore.LookupEntry(itemTemplate.HolidayId)) { - sLog->outErrorDb("Item (Entry: %u) has wrong HolidayId value (%u)", i, proto->HolidayId); - const_cast<ItemPrototype*>(proto)->HolidayId = 0; + sLog->outErrorDb("Item (Entry: %u) has wrong HolidayId value (%u)", entry, itemTemplate.HolidayId); + itemTemplate.HolidayId = 0; } + + ItemTemplateStore[entry] = itemTemplate; + + ++count; } + while (result->NextRow()); - // check some dbc referecned items (avoid duplicate reports) + // Check if item templates for DBC referenced character start outfit are present std::set<uint32> notFoundOutfit; for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i) { @@ -2634,7 +2773,7 @@ void ObjectMgr::LoadItemPrototypes() uint32 item_id = entry->ItemId[j]; - if (!ObjectMgr::GetItemPrototype(item_id)) + if (!sObjectMgr->GetItemTemplate(item_id)) notFoundOutfit.insert(item_id); } } @@ -2642,10 +2781,19 @@ void ObjectMgr::LoadItemPrototypes() for (std::set<uint32>::const_iterator itr = notFoundOutfit.begin(); itr != notFoundOutfit.end(); ++itr) sLog->outErrorDb("Item (Entry: %u) does not exist in `item_template` but is referenced in `CharStartOutfit.dbc`", *itr); - sLog->outString(">> Loaded %u item prototypes in %u ms", sItemStorage.RecordCount, GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(">> Loaded %u item templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); } +ItemTemplate const* ObjectMgr::GetItemTemplate(uint32 entry) +{ + ItemTemplateContainer::const_iterator itr = ItemTemplateStore.find(entry); + if (itr != ItemTemplateStore.end()) + return &(itr->second); + + return NULL; +} + void ObjectMgr::LoadItemSetNameLocales() { uint32 oldMSTime = getMSTime(); @@ -2735,12 +2883,12 @@ void ObjectMgr::LoadItemSetNames() if (!itemSetItems.empty()) { - ItemPrototype const* pProto; + ItemTemplate const* pProto; for (std::set<uint32>::iterator itr = itemSetItems.begin(); itr != itemSetItems.end(); ++itr) { uint32 entry = *itr; // add data from item_template if available - pProto = ObjectMgr::GetItemPrototype(entry); + pProto = sObjectMgr->GetItemTemplate(entry); if (pProto) { sLog->outErrorDb("Item set part (Entry: %u) does not have entry in `item_set_names`, adding data from `item_template`.", entry); @@ -3172,7 +3320,7 @@ void ObjectMgr::LoadPlayerInfo() uint32 item_id = fields[2].GetUInt32(); - if (!ObjectMgr::GetItemPrototype(item_id)) + if (!sObjectMgr->GetItemTemplate(item_id)) { sLog->outErrorDb("Item id %u (race %u class %u) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.",item_id,current_race,current_class); continue; @@ -4469,7 +4617,7 @@ void ObjectMgr::LoadQuests() if (qinfo->SrcItemId) { - if (!sItemStorage.LookupEntry<ItemPrototype>(qinfo->SrcItemId)) + if (!sObjectMgr->GetItemTemplate(qinfo->SrcItemId)) { sLog->outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.", qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId); @@ -4520,7 +4668,7 @@ void ObjectMgr::LoadQuests() qinfo->SetFlag(QUEST_TRINITY_FLAGS_DELIVER); - if (!sItemStorage.LookupEntry<ItemPrototype>(id)) + if (!sObjectMgr->GetItemTemplate(id)) { sLog->outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", qinfo->GetQuestId(),j+1,id,id); @@ -4540,7 +4688,7 @@ void ObjectMgr::LoadQuests() uint32 id = qinfo->ReqSourceId[j]; if (id) { - if (!sItemStorage.LookupEntry<ItemPrototype>(id)) + if (!sObjectMgr->GetItemTemplate(id)) { sLog->outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", qinfo->GetQuestId(),j+1,id,id); @@ -4647,7 +4795,7 @@ void ObjectMgr::LoadQuests() uint32 id = qinfo->RewChoiceItemId[j]; if (id) { - if (!sItemStorage.LookupEntry<ItemPrototype>(id)) + if (!sObjectMgr->GetItemTemplate(id)) { sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", qinfo->GetQuestId(),j+1,id,id); @@ -4674,7 +4822,7 @@ void ObjectMgr::LoadQuests() uint32 id = qinfo->RewItemId[j]; if (id) { - if (!sItemStorage.LookupEntry<ItemPrototype>(id)) + if (!sObjectMgr->GetItemTemplate(id)) { sLog->outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", qinfo->GetQuestId(),j+1,id,id); @@ -5226,7 +5374,7 @@ void ObjectMgr::LoadScripts(ScriptsType type) case SCRIPT_COMMAND_CREATE_ITEM: { - if (!ObjectMgr::GetItemPrototype(tmp.CreateItem.ItemEntry)) + if (!sObjectMgr->GetItemTemplate(tmp.CreateItem.ItemEntry)) { sLog->outErrorDb("Table `%s` has nonexistent item (entry: %u) in SCRIPT_COMMAND_CREATE_ITEM for script id %u", tableName.c_str(), tmp.CreateItem.ItemEntry, tmp.id); @@ -6591,7 +6739,7 @@ void ObjectMgr::LoadAccessRequirements() if (ar.item) { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(ar.item); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(ar.item); if (!pProto) { sLog->outError("Key item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item, mapid, difficulty); @@ -6601,7 +6749,7 @@ void ObjectMgr::LoadAccessRequirements() if (ar.item2) { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(ar.item2); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(ar.item2); if (!pProto) { sLog->outError("Second item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item2, mapid, difficulty); @@ -9072,7 +9220,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max return false; } - if (!ObjectMgr::GetItemPrototype(item_id)) + if (!sObjectMgr->GetItemTemplate(item_id)) { if (pl) ChatHandler(pl).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id); @@ -9400,9 +9548,9 @@ void ObjectMgr::LoadFactionChangeItems() uint32 alliance = fields[0].GetUInt32(); uint32 horde = fields[1].GetUInt32(); - if (!ObjectMgr::GetItemPrototype(alliance)) + if (!sObjectMgr->GetItemTemplate(alliance)) sLog->outErrorDb("Item %u referenced in `player_factionchange_items` does not exist, pair skipped!", alliance); - else if (!ObjectMgr::GetItemPrototype(horde)) + else if (!sObjectMgr->GetItemTemplate(horde)) sLog->outErrorDb("Item %u referenced in `player_factionchange_items` does not exist, pair skipped!", horde); else factionchange_items[alliance] = horde; diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index adcab35c4eb..2c3fc1a05e1 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -42,12 +42,12 @@ #include <map> #include <limits> #include "ConditionMgr.h" +#include <functional> extern SQLStorage sCreatureStorage; extern SQLStorage sCreatureDataAddonStorage; extern SQLStorage sCreatureInfoAddonStorage; extern SQLStorage sGOStorage; -extern SQLStorage sItemStorage; class Group; class Guild; @@ -689,7 +689,8 @@ class ObjectMgr return sCreatureInfoAddonStorage.LookupEntry<CreatureDataAddon>(entry); } - static ItemPrototype const* GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry<ItemPrototype>(id); } + ItemTemplate const* GetItemTemplate(uint32 entry); + ItemTemplateContainer const* GetItemTemplateStore() { return &ItemTemplateStore; } ItemSetNameEntry const* GetItemSetNameEntry(uint32 itemId) { @@ -937,7 +938,7 @@ class ObjectMgr void LoadGameObjectLocales(); void LoadGameobjects(); void LoadGameobjectRespawnTimes(); - void LoadItemPrototypes(); + void LoadItemTemplates(); void LoadItemLocales(); void LoadItemSetNames(); void LoadItemSetNameLocales(); @@ -1386,6 +1387,7 @@ class ObjectMgr PlayerClassInfo playerClassInfo[MAX_CLASSES]; void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const; + PlayerInfo playerInfo[MAX_RACES][MAX_CLASSES]; typedef std::vector<uint32> PlayerXPperLevel; // [level] @@ -1412,6 +1414,8 @@ class ObjectMgr CreatureLocaleMap mCreatureLocaleMap; GameObjectDataMap mGameObjectDataMap; GameObjectLocaleMap mGameObjectLocaleMap; + + ItemTemplateContainer ItemTemplateStore; ItemLocaleMap mItemLocaleMap; ItemSetNameLocaleMap mItemSetNameLocaleMap; QuestLocaleMap mQuestLocaleMap; diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 7d65363bbce..a1c8c9b619e 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -738,7 +738,7 @@ void Group::SendLooter(Creature *pCreature, Player *pLooter) void Group::GroupLoot(Loot *loot, WorldObject* pLootedObject) { std::vector<LootItem>::iterator i; - ItemPrototype const *item; + ItemTemplate const *item; uint8 itemSlot = 0; for (i = loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot) @@ -746,7 +746,7 @@ void Group::GroupLoot(Loot *loot, WorldObject* pLootedObject) if (i->freeforall) continue; - item = ObjectMgr::GetItemPrototype(i->itemid); + item = sObjectMgr->GetItemTemplate(i->itemid); if (!item) { //sLog->outDebug("Group::GroupLoot: missing item prototype for item with id: %d", i->itemid); @@ -832,14 +832,14 @@ void Group::GroupLoot(Loot *loot, WorldObject* pLootedObject) void Group::NeedBeforeGreed(Loot *loot, WorldObject* pLootedObject) { - ItemPrototype const *item; + ItemTemplate const *item; uint8 itemSlot = 0; for (std::vector<LootItem>::iterator i=loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot) { if (i->freeforall) continue; - item = ObjectMgr::GetItemPrototype(i->itemid); + item = sObjectMgr->GetItemTemplate(i->itemid); //roll for over-threshold item if it's one-player loot if (item->Quality >= uint32(m_lootThreshold)) @@ -1120,7 +1120,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers) item->is_looted = true; roll->getLoot()->NotifyItemRemoved(roll->itemSlot); roll->getLoot()->unlootedCount--; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(roll->itemid); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(roll->itemid); player->AutoStoreLoot(pProto->DisenchantID, LootTemplates_Disenchant, true); } } diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 93a7392e50e..8b0e8350844 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -339,7 +339,7 @@ bool Guild::BankTab::LoadItemFromDB(Field* fields) return false; } - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemEntry); + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry); if (!proto) { sLog->outError("Unknown item (GUID: %u, id: %u) in guild bank, skipped.", itemGuid, itemEntry); @@ -940,7 +940,7 @@ void Guild::BankMoveItemData::LogAction(MoveItemData* pFrom) const sLog->outCommand(m_pPlayer->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u)", m_pPlayer->GetName(), m_pPlayer->GetSession()->GetAccountId(), - pFrom->GetItem()->GetProto()->Name1, pFrom->GetItem()->GetEntry(), pFrom->GetItem()->GetCount(), + pFrom->GetItem()->GetTemplate()->Name1, pFrom->GetItem()->GetEntry(), pFrom->GetItem()->GetCount(), m_pGuild->GetId()); } diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index f05c18e4735..895045aac24 100755 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -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) - continue; - - if (!(proto->Flags & ITEM_PROTO_FLAG_MILLABLE)) + if (!(itr->second.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) - continue; - - if (!(proto->Flags & ITEM_PROTO_FLAG_PROSPECTABLE)) + if (!(itr->second.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 diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 82197da0a81..7430f04f7fc 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -643,7 +643,7 @@ bool ScriptMgr::OnItemUse(Player* player, Item* item, SpellCastTargets const& ta return tmpscript->OnUse(player, item, targets); } -bool ScriptMgr::OnItemExpire(Player* player, ItemPrototype const* proto) +bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto) { ASSERT(player); ASSERT(proto); diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 80888204053..4064c8b08f6 100755 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -63,7 +63,7 @@ class WorldObject; struct AchievementCriteriaData; struct AuctionEntry; struct Condition; -struct ItemPrototype; +struct ItemTemplate; struct OutdoorPvPData; #define VISIBLE_RANGE (166.0f) //MAX visible range (size of grid) @@ -389,7 +389,7 @@ class ItemScript : public ScriptObject virtual bool OnUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) { return false; } // Called when the item expires (is destroyed). - virtual bool OnExpire(Player* /*player*/, ItemPrototype const* /*proto*/) { return false; } + virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; } }; class CreatureScript : public ScriptObject, public UpdatableScript<Creature> @@ -840,7 +840,7 @@ class ScriptMgr bool OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Item* target); bool OnQuestAccept(Player* player, Item* item, Quest const* quest); bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets); - bool OnItemExpire(Player* player, ItemPrototype const* proto); + bool OnItemExpire(Player* player, ItemTemplate const* proto); public: /* CreatureScript */ diff --git a/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp b/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp index 099309b9d12..fb18bfbda7b 100755 --- a/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp @@ -182,7 +182,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) return; } - if (it->GetProto()->Flags & ITEM_PROTO_FLAG_CONJURED || it->GetUInt32Value(ITEM_FIELD_DURATION)) + if (it->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || it->GetUInt32Value(ITEM_FIELD_DURATION)) { SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR); return; @@ -207,7 +207,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)", - GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),count); + GetPlayerName(),GetAccountId(),it->GetTemplate()->Name1,it->GetEntry(),count); } pl->ModifyMoney(-int32(deposit)); diff --git a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp index 770ed41badb..8acb73c3e94 100755 --- a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp @@ -261,7 +261,7 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket & recv_data) return; } - if (pItem->GetProto()->Flags & ITEM_PROTO_FLAG_INDESTRUCTIBLE) + if (pItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_INDESTRUCTIBLE) { _player->SendEquipError(EQUIP_ERR_CANT_DROP_SOULBOUND, NULL, NULL); return; @@ -285,7 +285,7 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data) sLog->outDetail("STORAGE: Item Query = %u", item); - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item); if (pProto) { std::string Name = pProto->Name1; @@ -446,7 +446,7 @@ void WorldSession::HandleReadItem(WorldPacket & recv_data) //sLog->outDetail("STORAGE: Read bag = %u, slot = %u", bag, slot); Item *pItem = _player->GetItemByPos(bag, slot); - if (pItem && pItem->GetProto()->PageText) + if (pItem && pItem->GetTemplate()->PageText) { WorldPacket data; @@ -550,7 +550,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data) } } - ItemPrototype const *pProto = pItem->GetProto(); + ItemTemplate const *pProto = pItem->GetTemplate(); if (pProto) { if (pProto->SellPrice > 0) @@ -764,7 +764,7 @@ void WorldSession::SendListInventory(uint64 vendorguid) { if (VendorItem const* crItem = vItems->GetItem(vendorslot)) { - if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(crItem->item)) + if (ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(crItem->item)) { if ((pProto->AllowableClass & _player->getClassMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster()) continue; @@ -1058,7 +1058,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) return; } - if (!(gift->GetProto()->Flags & ITEM_PROTO_FLAG_WRAPPER)) // cheating: non-wrapper wrapper + if (!(gift->GetTemplate()->Flags & ITEM_PROTO_FLAG_WRAPPER)) // cheating: non-wrapper wrapper { _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL); return; @@ -1109,7 +1109,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) } // maybe not correct check (it is better than nothing) - if (item->GetProto()->MaxCount>0) + if (item->GetTemplate()->MaxCount>0) { _player->SendEquipError(EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED, item, NULL); return; @@ -1167,7 +1167,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) if (!itemTarget) //missing item to socket return; - ItemPrototype const* itemProto = itemTarget->GetProto(); + ItemTemplate const* itemProto = itemTarget->GetTemplate(); if (!itemProto) return; @@ -1180,7 +1180,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) GemPropertiesEntry const *GemProps[MAX_GEM_SOCKETS]; for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //get geminfo from dbc storage - GemProps[i] = (Gems[i]) ? sGemPropertiesStore.LookupEntry(Gems[i]->GetProto()->GemProperties) : NULL; + GemProps[i] = (Gems[i]) ? sGemPropertiesStore.LookupEntry(Gems[i]->GetTemplate()->GemProperties) : NULL; for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //check for hack maybe { @@ -1225,7 +1225,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) continue; // continue check for case when attempt add 2 similar unique equipped gems in one item. - ItemPrototype const* iGemProto = Gems[i]->GetProto(); + ItemTemplate const* iGemProto = Gems[i]->GetTemplate(); // unique item (for new and already placed bit removed enchantments if (iGemProto->Flags & ITEM_PROTO_FLAG_UNIQUE_EQUIPPED) @@ -1270,14 +1270,14 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) if (Gems[j]) { // new gem - if (iGemProto->ItemLimitCategory == Gems[j]->GetProto()->ItemLimitCategory) + if (iGemProto->ItemLimitCategory == Gems[j]->GetTemplate()->ItemLimitCategory) ++limit_newcount; } else if (OldEnchants[j]) { // existing gem if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(OldEnchants[j])) - if (ItemPrototype const* jProto = ObjectMgr::GetItemPrototype(enchantEntry->GemID)) + if (ItemTemplate const* jProto = sObjectMgr->GetItemTemplate(enchantEntry->GemID)) if (iGemProto->ItemLimitCategory == jProto->ItemLimitCategory) ++limit_newcount; } @@ -1328,7 +1328,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) if (SocketBonusActivated ^ SocketBonusToBeActivated) //if there was a change... { _player->ApplyEnchantment(itemTarget,BONUS_ENCHANTMENT_SLOT,false); - itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetProto()->socketBonus : 0), 0, 0); + itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetTemplate()->socketBonus : 0), 0, 0); _player->ApplyEnchantment(itemTarget,BONUS_ENCHANTMENT_SLOT,true); //it is not displayed, client has an inbuilt system to determine if the bonus is activated } diff --git a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp index 5e8532f351b..b1a7ee6e264 100755 --- a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp @@ -201,13 +201,13 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data data << uint8(qRew->GetRewItemsCount()); if (qRew->GetRewItemsCount()) { - ItemPrototype const* iProto = NULL; + ItemTemplate const* iProto = NULL; for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) { if (!qRew->RewItemId[i]) continue; - iProto = ObjectMgr::GetItemPrototype(qRew->RewItemId[i]); + iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]); data << uint32(qRew->RewItemId[i]); data << uint32(iProto ? iProto->DisplayInfoID : 0); @@ -491,13 +491,13 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr data << uint8(itemNum); if (itemNum) { - ItemPrototype const* iProto = NULL; + ItemTemplate const* iProto = NULL; for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) { if (!qRew->RewItemId[i]) continue; - iProto = ObjectMgr::GetItemPrototype(qRew->RewItemId[i]); + iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]); data << uint32(qRew->RewItemId[i]); data << uint32(iProto ? iProto->DisplayInfoID : 0); diff --git a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp index 916ad8579e8..073bc3366ce 100755 --- a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp @@ -344,7 +344,7 @@ void WorldSession::DoLootRelease(uint64 lguid) if (!pItem) return; - ItemPrototype const* proto = pItem->GetProto(); + ItemTemplate const* proto = pItem->GetTemplate(); // destroy only 5 items from stack in case prospecting and milling if (proto->Flags & (ITEM_PROTO_FLAG_PROSPECTABLE | ITEM_PROTO_FLAG_MILLABLE)) diff --git a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp index 8e62949c7fe..d96cbf346d8 100755 --- a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp @@ -151,7 +151,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) Item* item = pl->GetItemByGuid(itemGUIDs[i]); if (item) { - ItemPrototype const* itemProto = item->GetProto(); + ItemTemplate const* itemProto = item->GetTemplate(); if(!itemProto || !(itemProto->Flags & ITEM_PROTO_FLAG_BIND_TO_ACCOUNT)) { accountBound = false; @@ -207,7 +207,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) return; } - if (item->GetProto()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION)) + if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION)) { pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM); return; @@ -249,7 +249,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)", - GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); + GetPlayerName(), GetAccountId(), item->GetTemplate()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); } item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable @@ -460,7 +460,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data) sender_name = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN); } sLog->outCommand(GetAccountId(),"GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", - GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId); + GetPlayerName(),GetAccountId(),it->GetTemplate()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId); } else if (!receive) sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid); @@ -772,4 +772,4 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/) data << uint32(0x00000000); } SendPacket(&data); -}
\ No newline at end of file +} diff --git a/src/server/game/Server/Protocol/Handlers/PetitionsHandler.cpp b/src/server/game/Server/Protocol/Handlers/PetitionsHandler.cpp index 6ac30915ff0..d28d86a0ab9 100755 --- a/src/server/game/Server/Protocol/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/PetitionsHandler.cpp @@ -179,7 +179,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) } } - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(charterid); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(charterid); if (!pProto) { _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterid, 0); diff --git a/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp b/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp index aa61e618642..85b64679764 100755 --- a/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp @@ -202,7 +202,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data) bool destroyItem = true; for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { - if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetProto()->MaxCount > 0)) + if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetTemplate()->MaxCount > 0)) { destroyItem = false; break; diff --git a/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp b/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp index 013c32abba4..cddb571ebe6 100755 --- a/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp @@ -95,7 +95,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) sLog->outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, castCount: %u, spellId: %u, Item: %u, glyphIndex: %u, data length = %i", bagIndex, slot, castCount, spellId, pItem->GetEntry(), glyphIndex, (uint32)recvPacket.size()); - ItemPrototype const *proto = pItem->GetProto(); + ItemTemplate const *proto = pItem->GetTemplate(); if (!proto) { pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL); @@ -146,7 +146,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) } // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) - if (pItem->GetProto()->Bonding == BIND_WHEN_USE || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM) + if (pItem->GetTemplate()->Bonding == BIND_WHEN_USE || pItem->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM) { if (!pItem->IsSoulBound()) { @@ -214,7 +214,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) return; } - ItemPrototype const *proto = pItem->GetProto(); + ItemTemplate const *proto = pItem->GetTemplate(); if (!proto) { pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL); @@ -618,7 +618,7 @@ void WorldSession::HandleMirrrorImageDataRequest(WorldPacket & recv_data) else if (*itr == EQUIPMENT_SLOT_BACK && pCreator->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) data << uint32(0); else if (Item const *item = pCreator->GetItemByPos(INVENTORY_SLOT_BAG_0, *itr)) - data << uint32(item->GetProto()->DisplayInfoID); + data << uint32(item->GetTemplate()->DisplayInfoID); else data << uint32(0); } diff --git a/src/server/game/Server/Protocol/Handlers/TradeHandler.cpp b/src/server/game/Server/Protocol/Handlers/TradeHandler.cpp index ae486e1f5ac..1768be12b64 100755 --- a/src/server/game/Server/Protocol/Handlers/TradeHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/TradeHandler.cpp @@ -97,8 +97,8 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/) if (Item* item = view_trade->GetItem(TradeSlots(i))) { - data << uint32(item->GetProto()->ItemId); // entry - data << uint32(item->GetProto()->DisplayInfoID);// display id + data << uint32(item->GetTemplate()->ItemId); // entry + data << uint32(item->GetTemplate()->DisplayInfoID);// display id data << uint32(item->GetCount()); // stack count // wrapped: hide stats but show giftcreator name data << uint32(item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED) ? 1 : 0); @@ -112,7 +112,7 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/) data << uint32(item->GetSpellCharges()); // charges data << uint32(item->GetItemSuffixFactor()); // SuffixFactor data << uint32(item->GetItemRandomPropertyId());// random properties id - data << uint32(item->GetProto()->LockID); // lock id + data << uint32(item->GetTemplate()->LockID); // lock id // max durability data << uint32(item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)); // durability @@ -155,7 +155,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", _player->GetName(), _player->GetSession()->GetAccountId(), - myItems[i]->GetProto()->Name1, myItems[i]->GetEntry(), myItems[i]->GetCount(), + myItems[i]->GetTemplate()->Name1, myItems[i]->GetEntry(), myItems[i]->GetCount(), trader->GetName(), trader->GetSession()->GetAccountId()); } @@ -173,7 +173,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { sLog->outCommand(trader->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", trader->GetName(), trader->GetSession()->GetAccountId(), - hisItems[i]->GetProto()->Name1, hisItems[i]->GetEntry(), hisItems[i]->GetCount(), + hisItems[i]->GetTemplate()->Name1, hisItems[i]->GetEntry(), hisItems[i]->GetCount(), _player->GetName(), _player->GetSession()->GetAccountId()); } diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 9cf9f4f3d37..ffc82198abc 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -29,7 +29,7 @@ #include "DatabaseEnv.h" #include "World.h" -struct ItemPrototype; +struct ItemTemplate; struct AuctionEntry; struct DeclinedName; struct MovementInfo; @@ -600,7 +600,7 @@ class WorldSession void HandleQueryNextMailTime(WorldPacket & recv_data); void HandleCancelChanneling(WorldPacket & recv_data); - void SendItemPageInfo(ItemPrototype *itemProto); + void SendItemPageInfo(ItemTemplate *itemProto); void HandleSplitItemOpcode(WorldPacket& recvPacket); void HandleSwapInvItemOpcode(WorldPacket& recvPacket); void HandleDestroyItemOpcode(WorldPacket& recvPacket); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 2b384325426..e743bec6465 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -3250,7 +3250,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const * aurApp, uint8 m { if (Item *pItem = target->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) { - target->ToPlayer()->_ApplyWeaponDamage(EQUIPMENT_SLOT_MAINHAND, pItem->GetProto(), NULL, apply); + target->ToPlayer()->_ApplyWeaponDamage(EQUIPMENT_SLOT_MAINHAND, pItem->GetTemplate(), NULL, apply); } } } @@ -3622,7 +3622,7 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const * aurApp, uint8 mode, uint8 attacktype = Player::GetAttackBySlot(slot); if (attacktype < MAX_ATTACK) - target->ToPlayer()->_ApplyWeaponDamage(slot, pItem->GetProto(), NULL, !apply); + target->ToPlayer()->_ApplyWeaponDamage(slot, pItem->GetTemplate(), NULL, !apply); } } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index f020ef72249..15d61322db3 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -468,7 +468,7 @@ m_caster(Caster), m_spellValue(new SpellValue(m_spellInfo)) if ((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId() == TYPEID_PLAYER) { if (Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK)) - m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetProto()->Damage[0].DamageType); + m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->Damage[0].DamageType); } } @@ -3802,7 +3802,7 @@ void Spell::SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 ca for (int8 x=0;x < 3;x++) if (spellInfo->EffectItemType[x]) item = spellInfo->EffectItemType[x]; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item); if (pProto && pProto->ItemLimitCategory) data << uint32(pProto->ItemLimitCategory); break; @@ -3981,15 +3981,15 @@ void Spell::WriteAmmoToPacket(WorldPacket * data) Item *pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK); if (pItem) { - ammoInventoryType = pItem->GetProto()->InventoryType; + ammoInventoryType = pItem->GetTemplate()->InventoryType; if (ammoInventoryType == INVTYPE_THROWN) - ammoDisplayID = pItem->GetProto()->DisplayInfoID; + ammoDisplayID = pItem->GetTemplate()->DisplayInfoID; else { uint32 ammoID = m_caster->ToPlayer()->GetUInt32Value(PLAYER_AMMO_ID); if (ammoID) { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(ammoID); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(ammoID); if (pProto) { ammoDisplayID = pProto->DisplayInfoID; @@ -4307,7 +4307,7 @@ void Spell::TakeCastItem() if (m_IsTriggeredSpell) return; - ItemPrototype const *proto = m_CastItem->GetProto(); + ItemTemplate const *proto = m_CastItem->GetTemplate(); if (!proto) { @@ -4426,10 +4426,10 @@ void Spell::TakeAmmo() Item *pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK); // wands don't have ammo - if (!pItem || pItem->IsBroken() || pItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_WAND) + if (!pItem || pItem->IsBroken() || pItem->GetTemplate()->SubClass == ITEM_SUBCLASS_WEAPON_WAND) return; - if (pItem->GetProto()->InventoryType == INVTYPE_THROWN) + if (pItem->GetTemplate()->InventoryType == INVTYPE_THROWN) { if (pItem->GetMaxStackCount() == 1) { @@ -4579,7 +4579,7 @@ void Spell::TakeReagents() return; // do not take reagents for these item casts - if (m_CastItem && m_CastItem->GetProto()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST) + if (m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST) return; Player* p_caster = (Player*)m_caster; @@ -4597,7 +4597,7 @@ void Spell::TakeReagents() // if CastItem is also spell reagent if (m_CastItem) { - ItemPrototype const *proto = m_CastItem->GetProto(); + ItemTemplate const *proto = m_CastItem->GetTemplate(); if (proto && proto->ItemId == itemid) { for (int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s) @@ -5140,10 +5140,10 @@ SpellCastResult Spell::CheckCast(bool strict) if (!pet) return SPELL_FAILED_NO_PET; - if (!pet->HaveInDiet(foodItem->GetProto())) + if (!pet->HaveInDiet(foodItem->GetTemplate())) return SPELL_FAILED_WRONG_PET_FOOD; - if (!pet->GetCurrentFoodBenefitLevel(foodItem->GetProto()->ItemLevel)) + if (!pet->GetCurrentFoodBenefitLevel(foodItem->GetTemplate()->ItemLevel)) return SPELL_FAILED_FOOD_LOWLEVEL; if (m_caster->isInCombat() || pet->isInCombat()) @@ -5224,7 +5224,7 @@ SpellCastResult Spell::CheckCast(bool strict) // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT_ITEM && !m_targets.getGOTarget() && - (!pTempItem || !pTempItem->GetProto()->LockID || !pTempItem->IsLocked())) + (!pTempItem || !pTempItem->GetTemplate()->LockID || !pTempItem->IsLocked())) return SPELL_FAILED_BAD_TARGETS; if (m_spellInfo->Id != 1842 || (m_targets.getGOTarget() && @@ -5242,7 +5242,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_BAD_TARGETS; } else if (Item* itm = m_targets.getItemTarget()) - lockId = itm->GetProto()->LockID; + lockId = itm->GetTemplate()->LockID; SkillType skillId = SKILL_NONE; int32 reqSkillValue = 0; @@ -5901,7 +5901,7 @@ SpellCastResult Spell::CheckItems() if (!p_caster->HasItemCount(itemid, 1)) return SPELL_FAILED_ITEM_NOT_READY; - ItemPrototype const *proto = m_CastItem->GetProto(); + ItemTemplate const *proto = m_CastItem->GetTemplate(); if (!proto) return SPELL_FAILED_ITEM_NOT_READY; @@ -6003,7 +6003,7 @@ SpellCastResult Spell::CheckItems() } // do not take reagents for these item casts - if (!(m_CastItem && m_CastItem->GetProto()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)) + if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)) { bool checkReagents = !m_IsTriggeredSpell && !p_caster->CanNoReagentCast(m_spellInfo); // Not own traded item (in trader trade slot) requires reagents even if triggered spell @@ -6026,7 +6026,7 @@ SpellCastResult Spell::CheckItems() // if CastItem is also spell reagent if (m_CastItem && m_CastItem->GetEntry() == itemid) { - ItemPrototype const *proto = m_CastItem->GetProto(); + ItemTemplate const *proto = m_CastItem->GetTemplate(); if (!proto) return SPELL_FAILED_ITEM_NOT_READY; for (int s=0; s < MAX_ITEM_PROTO_SPELLS; ++s) @@ -6095,7 +6095,7 @@ SpellCastResult Spell::CheckItems() uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1); if (msg != EQUIP_ERR_OK) { - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(m_spellInfo->EffectItemType[i]); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(m_spellInfo->EffectItemType[i]); // TODO: Needs review if (pProto && !(pProto->ItemLimitCategory)) { @@ -6124,7 +6124,7 @@ SpellCastResult Spell::CheckItems() if (m_targets.getItemTarget()->GetOwner() != m_caster) return SPELL_FAILED_NOT_TRADEABLE; // do not allow to enchant vellum from scroll made by vellum-prevent exploit - if (m_CastItem && m_CastItem->GetProto()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST) + if (m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST) return SPELL_FAILED_TOTEM_CATEGORY; ItemPosCountVec dest; uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1); @@ -6140,13 +6140,13 @@ SpellCastResult Spell::CheckItems() if (!targetItem) return SPELL_FAILED_ITEM_NOT_FOUND; - if (targetItem->GetProto()->ItemLevel < m_spellInfo->baseLevel) + if (targetItem->GetTemplate()->ItemLevel < m_spellInfo->baseLevel) return SPELL_FAILED_LOWLEVEL; bool isItemUsable = false; for (uint8 e = 0; e < MAX_ITEM_PROTO_SPELLS; ++e) { - ItemPrototype const *proto = targetItem->GetProto(); + ItemTemplate const *proto = targetItem->GetTemplate(); if (proto->Spells[e].SpellId && ( proto->Spells[e].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE || proto->Spells[e].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)) @@ -6202,7 +6202,7 @@ SpellCastResult Spell::CheckItems() if (m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID()) return SPELL_FAILED_CANT_BE_DISENCHANTED; - ItemPrototype const* itemProto = m_targets.getItemTarget()->GetProto(); + ItemTemplate const* itemProto = m_targets.getItemTarget()->GetTemplate(); if (!itemProto) return SPELL_FAILED_CANT_BE_DISENCHANTED; @@ -6226,13 +6226,13 @@ SpellCastResult Spell::CheckItems() if (!m_targets.getItemTarget()) return SPELL_FAILED_CANT_BE_PROSPECTED; //ensure item is a prospectable ore - if (!(m_targets.getItemTarget()->GetProto()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE)) + if (!(m_targets.getItemTarget()->GetTemplate()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE)) return SPELL_FAILED_CANT_BE_PROSPECTED; //prevent prospecting in trade slot if (m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID()) return SPELL_FAILED_CANT_BE_PROSPECTED; //Check for enough skill in jewelcrafting - uint32 item_prospectingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; + uint32 item_prospectingskilllevel = m_targets.getItemTarget()->GetTemplate()->RequiredSkillRank; if (item_prospectingskilllevel >p_caster->GetSkillValue(SKILL_JEWELCRAFTING)) return SPELL_FAILED_LOW_CASTLEVEL; //make sure the player has the required ores in inventory @@ -6249,13 +6249,13 @@ SpellCastResult Spell::CheckItems() if (!m_targets.getItemTarget()) return SPELL_FAILED_CANT_BE_MILLED; //ensure item is a millable herb - if (!(m_targets.getItemTarget()->GetProto()->Flags & ITEM_PROTO_FLAG_MILLABLE)) + if (!(m_targets.getItemTarget()->GetTemplate()->Flags & ITEM_PROTO_FLAG_MILLABLE)) return SPELL_FAILED_CANT_BE_MILLED; //prevent milling in trade slot if (m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID()) return SPELL_FAILED_CANT_BE_MILLED; //Check for enough skill in inscription - uint32 item_millingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; + uint32 item_millingskilllevel = m_targets.getItemTarget()->GetTemplate()->RequiredSkillRank; if (item_millingskilllevel >p_caster->GetSkillValue(SKILL_INSCRIPTION)) return SPELL_FAILED_LOW_CASTLEVEL; //make sure the player has the required herbs in inventory @@ -6277,7 +6277,7 @@ SpellCastResult Spell::CheckItems() if (!pItem || pItem->IsBroken()) return SPELL_FAILED_EQUIPPED_ITEM; - switch(pItem->GetProto()->SubClass) + switch(pItem->GetTemplate()->SubClass) { case ITEM_SUBCLASS_WEAPON_THROWN: { @@ -6299,7 +6299,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_NO_AMMO; } - ItemPrototype const *ammoProto = ObjectMgr::GetItemPrototype(ammo); + ItemTemplate const *ammoProto = sObjectMgr->GetItemTemplate(ammo); if (!ammoProto) return SPELL_FAILED_NO_AMMO; @@ -6307,7 +6307,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_NO_AMMO; // check ammo ws. weapon compatibility - switch(pItem->GetProto()->SubClass) + switch(pItem->GetTemplate()->SubClass) { case ITEM_SUBCLASS_WEAPON_BOW: case ITEM_SUBCLASS_WEAPON_CROSSBOW: @@ -6338,7 +6338,7 @@ SpellCastResult Spell::CheckItems() case SPELL_EFFECT_CREATE_MANA_GEM: { uint32 item_id = m_spellInfo->EffectItemType[i]; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item_id); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item_id); if (!pProto) return SPELL_FAILED_ITEM_AT_MAX_CHARGES; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index ae06e6f7505..738e0956263 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -714,13 +714,13 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex) Item *item = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK); if (item) { - float dmg_min = item->GetProto()->Damage->DamageMin; - float dmg_max = item->GetProto()->Damage->DamageMax; + float dmg_min = item->GetTemplate()->Damage->DamageMin; + float dmg_max = item->GetTemplate()->Damage->DamageMax; if (dmg_max == 0.0f && dmg_min > dmg_max) damage += int32(dmg_min); else damage += irand(int32(dmg_min), int32(dmg_max)); - damage += int32(m_caster->ToPlayer()->GetAmmoDPS()*item->GetProto()->Delay*0.001f); + damage += int32(m_caster->ToPlayer()->GetAmmoDPS()*item->GetTemplate()->Delay*0.001f); } } } @@ -2377,7 +2377,7 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) Player* player = (Player*)unitTarget; uint32 newitemid = itemtype; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(newitemid); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(newitemid); if (!pProto) { player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL); @@ -2458,7 +2458,7 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) } // set the "Crafted by ..." property of the item - if (pItem->GetProto()->Class != ITEM_CLASS_CONSUMABLE && pItem->GetProto()->Class != ITEM_CLASS_QUEST && newitemid != 6265 && newitemid != 6948) + if (pItem->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && pItem->GetTemplate()->Class != ITEM_CLASS_QUEST && newitemid != 6265 && newitemid != 6948) pItem->SetUInt32Value(ITEM_FIELD_CREATOR, player->GetGUIDLow()); // send info to the client @@ -2811,7 +2811,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) } else if (itemTarget) { - lockId = itemTarget->GetProto()->LockID; + lockId = itemTarget->GetTemplate()->LockID; guid = itemTarget->GetGUID(); } else @@ -3478,7 +3478,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) else { // do not increase skill if vellum used - if (!(m_CastItem && m_CastItem->GetProto()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)) + if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)) p_caster->UpdateCraftSkill(m_spellInfo->Id); uint32 enchant_id = m_spellInfo->EffectMiscValue[effIndex]; @@ -3498,7 +3498,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) { sLog->outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(),p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1,itemTarget->GetEntry(), + itemTarget->GetTemplate()->Name1,itemTarget->GetEntry(), item_owner->GetName(),item_owner->GetSession()->GetAccountId()); } @@ -3559,7 +3559,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) { sLog->outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(),p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1,itemTarget->GetEntry(), + itemTarget->GetTemplate()->Name1,itemTarget->GetEntry(), item_owner->GetName(),item_owner->GetSession()->GetAccountId()); } @@ -3689,7 +3689,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) { sLog->outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(), p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1, itemTarget->GetEntry(), + itemTarget->GetTemplate()->Name1, itemTarget->GetEntry(), item_owner->GetName(), item_owner->GetSession()->GetAccountId()); } @@ -3987,7 +3987,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex) // 50% more damage with daggers if (m_caster->GetTypeId() == TYPEID_PLAYER) if (Item* item = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType, true)) - if (item->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) + if (item->GetTemplate()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) totalDamagePercentMod *= 1.5f; } // Mutilate (for each hand) @@ -5697,7 +5697,7 @@ void Spell::EffectDisEnchant(SpellEffIndex /*effIndex*/) return; Player* p_caster = (Player*)m_caster; - if (!itemTarget || !itemTarget->GetProto()->DisenchantID) + if (!itemTarget || !itemTarget->GetTemplate()->DisenchantID) return; p_caster->UpdateCraftSkill(m_spellInfo->Id); @@ -5740,7 +5740,7 @@ void Spell::EffectFeedPet(SpellEffIndex effIndex) if (!pet->isAlive()) return; - int32 benefit = pet->GetCurrentFoodBenefitLevel(foodItem->GetProto()->ItemLevel); + int32 benefit = pet->GetCurrentFoodBenefitLevel(foodItem->GetTemplate()->ItemLevel); if (benefit <= 0) return; @@ -6484,7 +6484,7 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/) return; Player* p_caster = (Player*)m_caster; - if (!itemTarget || !(itemTarget->GetProto()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE)) + if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE)) return; if (itemTarget->GetCount() < 5) @@ -6493,7 +6493,7 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/) if (sWorld->getBoolConfig(CONFIG_SKILL_PROSPECTING)) { uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_JEWELCRAFTING); - uint32 reqSkillValue = itemTarget->GetProto()->RequiredSkillRank; + uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank; p_caster->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue); } @@ -6506,7 +6506,7 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/) return; Player* p_caster = (Player*)m_caster; - if (!itemTarget || !(itemTarget->GetProto()->Flags & ITEM_PROTO_FLAG_MILLABLE)) + if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_MILLABLE)) return; if (itemTarget->GetCount() < 5) @@ -6515,7 +6515,7 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/) if (sWorld->getBoolConfig(CONFIG_SKILL_MILLING)) { uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_INSCRIPTION); - uint32 reqSkillValue = itemTarget->GetProto()->RequiredSkillRank; + uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank; p_caster->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue); } @@ -6874,7 +6874,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const * // level of pet summoned using engineering item based at engineering skill level if (m_CastItem && caster->GetTypeId() == TYPEID_PLAYER) - if (ItemPrototype const *proto = m_CastItem->GetProto()) + if (ItemTemplate const *proto = m_CastItem->GetTemplate()) if (proto->RequiredSkill == SKILL_ENGINERING) if (uint16 skill202 = caster->ToPlayer()->GetSkillValue(SKILL_ENGINERING)) level = skill202/5; @@ -7095,7 +7095,7 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/) uint32 item_id = m_spellInfo->EffectItemType[0]; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item_id); + ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(item_id); if (!pProto) { player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 4711415d2fd..7a78f5f404a 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2366,7 +2366,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const *spellInfo, Player *pl, bool msg) } // also possible IsLootCraftingSpell case but fake item must exist anyway - else if (!ObjectMgr::GetItemPrototype(spellInfo->EffectItemType[i])) + else if (!sObjectMgr->GetItemTemplate(spellInfo->EffectItemType[i])) { if (msg) { @@ -2404,7 +2404,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const *spellInfo, Player *pl, bool msg) { for (uint8 j = 0; j < MAX_SPELL_REAGENTS; ++j) { - if (spellInfo->Reagent[j] > 0 && !ObjectMgr::GetItemPrototype(spellInfo->Reagent[j])) + if (spellInfo->Reagent[j] > 0 && !sObjectMgr->GetItemTemplate(spellInfo->Reagent[j])) { if (msg) { diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 0590a450248..7ceaa5e0065 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1326,7 +1326,7 @@ void World::SetInitialWorldSettings() sDisableMgr->LoadDisables(); // must be before loading quests and items sLog->outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts - sObjectMgr->LoadItemPrototypes(); + sObjectMgr->LoadItemTemplates(); sLog->outString("Loading Item set names..."); // must be after LoadItemPrototypes sObjectMgr->LoadItemSetNames(); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index c6936727885..33dad2ff918 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -965,7 +965,7 @@ public: return false; handler->GetSession()->GetPlayer()->DestroyItem(i->GetBagSlot(), i->GetSlot(), true); - sScriptMgr->OnItemExpire(handler->GetSession()->GetPlayer(), i->GetProto()); + sScriptMgr->OnItemExpire(handler->GetSession()->GetPlayer(), i->GetTemplate()); return true; } diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 0b1bb311f0b..a6ac7c9b597 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -201,9 +201,9 @@ public: sObjectMgr->AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost); - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId); - handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); + handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,itemTemplate->Name1,maxcount,incrtime,extendedcost); return true; } @@ -419,9 +419,9 @@ public: return false; } - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId); - handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); + handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,itemTemplate->Name1); return true; } @@ -1299,7 +1299,7 @@ public: uint32 ItemID = atoi(pItemID); uint32 SlotID = atoi(pSlotID); - ItemPrototype* tmpItem = ObjectMgr::GetItemPrototype(ItemID); + ItemPrototype* tmpItem = sObjectMgr->GetItemTemplate(ItemID); bool added = false; if (tmpItem) diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 41d45f7a033..df5f9703ab2 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -76,18 +76,14 @@ public: } // check item starting quest (it can work incorrectly if added without item in inventory) - for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) - { - ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); - if (!pProto) - continue; + ItemTemplateContainer const* itc = sObjectMgr->GetItemTemplateStore(); + ItemTemplateContainer::const_iterator result = find_if(itc->begin(), itc->end(), Finder<uint32, ItemTemplate>(entry, &ItemTemplate::StartQuest)); - if (pProto->StartQuest == entry) - { - handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); - handler->SetSentErrorMessage(true); - return false; - } + if (result != itc->end()) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, result->second.ItemId); + handler->SetSentErrorMessage(true); + return false; } // ok, normal (creature/GO starting) quest diff --git a/src/server/scripts/World/item_scripts.cpp b/src/server/scripts/World/item_scripts.cpp index 71c3a1661ed..c248738a6d6 100644 --- a/src/server/scripts/World/item_scripts.cpp +++ b/src/server/scripts/World/item_scripts.cpp @@ -189,7 +189,7 @@ class item_mysterious_egg : public ItemScript { public: item_mysterious_egg() : ItemScript("item_mysterious_egg") { } - bool OnExpire(Player *pPlayer, ItemPrototype const * /*pItemProto*/) + bool OnExpire(Player *pPlayer, ItemTemplate const * /*pItemProto*/) { ItemPosCountVec dest; uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 39883, 1); // Cracked Egg @@ -209,7 +209,7 @@ class item_disgusting_jar : public ItemScript public: item_disgusting_jar() : ItemScript("item_disgusting_jar") {} - bool OnExpire(Player *pPlayer, ItemPrototype const * /*pItemProto*/) + bool OnExpire(Player *pPlayer, ItemTemplate const * /*pItemProto*/) { ItemPosCountVec dest; uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 44718, 1); // Ripe Disgusting Jar diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp index 314b781e773..798ca9a86e4 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -233,10 +233,10 @@ bool EquippedOk(Player* pPlayer, uint32 spellId) { pItem = pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, j); if (pItem) - if (pItem->GetProto()->RequiredSpell == reqSpell) + if (pItem->GetTemplate()->RequiredSpell == reqSpell) { //player has item equipped that require specialty. Not allow to unlearn, player has to unequip first - sLog->outDebug(LOG_FILTER_TSCR, "TSCR: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetProto()->ItemId); + sLog->outDebug(LOG_FILTER_TSCR, "TSCR: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetTemplate()->ItemId); return false; } } diff --git a/src/server/shared/Database/SQLStorage.cpp b/src/server/shared/Database/SQLStorage.cpp index 6fcb7b1af9d..0ed1986486e 100755 --- a/src/server/shared/Database/SQLStorage.cpp +++ b/src/server/shared/Database/SQLStorage.cpp @@ -25,14 +25,11 @@ const char CreatureDataAddonInfofmt[]="iiiiiis"; const char CreatureInfoAddonInfofmt[]="iiiiiis"; const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiissi"; const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisii"; -const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii"; -const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii"; SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template"); SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon"); SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template"); -SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template"); void SQLStorage::Free () { diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index a6a76439bdb..2e5d9a12ad7 100755 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -24,6 +24,16 @@ #include <string> #include <vector> +// Searcher for map of structs +template<typename T, class S> struct Finder +{ + T val_; + T S::* idMember_; + + Finder(T val, T S::* idMember) : val_(val), idMember_(idMember) {} + bool operator()(const std::pair<int, S> &obj) { return obj.second.*idMember_ == val_; } +}; + struct Tokens: public std::vector<char*> { Tokens(const std::string &src, const char sep, uint32 vectorReserve = 0); |