diff --git a/src/game/Anticheat/MovementAnticheat/MovementAnticheat.cpp b/src/game/Anticheat/MovementAnticheat/MovementAnticheat.cpp index 9d00a59a5..c676d0ca8 100644 --- a/src/game/Anticheat/MovementAnticheat/MovementAnticheat.cpp +++ b/src/game/Anticheat/MovementAnticheat/MovementAnticheat.cpp @@ -829,7 +829,7 @@ bool MovementAnticheat::HandleSplineDone(Player* pPlayer, MovementInfo const& mo } #define JUMP_FLAG_THRESHOLD 5 -#define FAR_FALL_FLAG_TIME 3000 +#define FAR_FALL_FLAG_TIME 3000u #define HEIGHT_LEEWAY 5.0f bool ShouldResetNoFallTimeCheck(MovementInfo const& movementInfo, uint16 opcode) diff --git a/src/game/AuctionHouse/AuctionHouseMgr.cpp b/src/game/AuctionHouse/AuctionHouseMgr.cpp index 34bc51177..51edfb00f 100644 --- a/src/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouse/AuctionHouseMgr.cpp @@ -369,7 +369,7 @@ void AuctionHouseMgr::LoadAuctionItems() uint32 itemGuid = fields[10].GetUInt32(); uint32 itemId = fields[11].GetUInt32(); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(itemId); if (!proto) { diff --git a/src/game/Battlegrounds/BattleGround.cpp b/src/game/Battlegrounds/BattleGround.cpp index 49dc0b545..31a9d5311 100644 --- a/src/game/Battlegrounds/BattleGround.cpp +++ b/src/game/Battlegrounds/BattleGround.cpp @@ -767,7 +767,7 @@ void BattleGround::SendRewardMarkByMail(Player* pPlayer, uint32 mark, uint32 cou if (!bmEntry) return; - ItemPrototype const* markProto = ObjectMgr::GetItemPrototype(mark); + ItemPrototype const* markProto = sObjectMgr.GetItemPrototype(mark); if (!markProto) return; diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index c58825c38..9523a8436 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -2098,7 +2098,7 @@ bool ChatHandler::isValidChatMessage(char const* message) if (reader.eof()) // : must be return false; - linkedItem = ObjectMgr::GetItemPrototype(atoi(buffer)); + linkedItem = sObjectMgr.GetItemPrototype(atoi(buffer)); if (!linkedItem) { DEBUG_LOG("ChatHandler::isValidChatMessage got invalid itemID %u in |item command", atoi(buffer)); diff --git a/src/game/Chat/MasterPlayer.cpp b/src/game/Chat/MasterPlayer.cpp index b2aef72ba..d2611ed45 100644 --- a/src/game/Chat/MasterPlayer.cpp +++ b/src/game/Chat/MasterPlayer.cpp @@ -231,7 +231,7 @@ void MasterPlayer::LoadMailedItems(QueryResult* result) continue; mail->AddItem(itemGuidLow, itemId); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(itemId); if (!proto) { diff --git a/src/game/Commands/CharacterCommands.cpp b/src/game/Commands/CharacterCommands.cpp index 283cf533f..ef081ef25 100644 --- a/src/game/Commands/CharacterCommands.cpp +++ b/src/game/Commands/CharacterCommands.cpp @@ -1933,7 +1933,7 @@ bool ChatHandler::HandleCharacterHasItemCommand(char* args) if (!ExtractPlayerTarget(&args, &plTarget, &target_guid, &target_name)) return false; - ItemPrototype const* pItem = ObjectMgr::GetItemPrototype(itemId); + ItemPrototype const* pItem = sObjectMgr.GetItemPrototype(itemId); if (!pItem) { @@ -3076,7 +3076,7 @@ bool ChatHandler::HandleAddItemCommand(char* args) DETAIL_LOG(GetMangosString(LANG_ADDITEM), itemId, count); - if (!ObjectMgr::GetItemPrototype(itemId)) + if (!sObjectMgr.GetItemPrototype(itemId)) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); SetSentErrorMessage(true); @@ -3308,20 +3308,16 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) DETAIL_LOG(GetMangosString(LANG_ADDITEMSET), itemsetId); bool found = false; - for (uint32 id = 0; id < sItemStorage.GetMaxEntry(); id++) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - ItemPrototype const* pProto = sItemStorage.LookupEntry(id); - if (!pProto) - continue; - - if (pProto->ItemSet == itemsetId) + if (itr.second.ItemSet == itemsetId) { found = true; ItemPosCountVec dest; - InventoryResult msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1); + InventoryResult msg = plTarget->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 = plTarget->StoreNewItem(dest, itr.second.ItemId, true); // remove binding (let GM give it to another player later) if (pl == plTarget) @@ -3333,8 +3329,8 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) } else { - pl->SendEquipError(msg, nullptr, nullptr, pProto->ItemId); - PSendSysMessage(LANG_ITEM_CANNOT_CREATE, pProto->ItemId, 1); + pl->SendEquipError(msg, nullptr, nullptr, itr.second.ItemId); + PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itr.second.ItemId, 1); } } } @@ -3363,7 +3359,7 @@ bool ChatHandler::HandleListItemCommand(char* args) return false; } - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_id); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(item_id); if (!itemProto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); @@ -4868,15 +4864,11 @@ bool ChatHandler::HandleQuestAddCommand(char* args) } // check item starting quest (it can work incorrectly if added without item in inventory) - for (uint32 id = 0; id < sItemStorage.GetMaxEntry(); ++id) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - ItemPrototype const* pProto = sItemStorage.LookupEntry(id); - if (!pProto) - continue; - - if (pProto->StartQuest == entry) + if (itr.second.StartQuest == entry) { - PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); + PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, itr.second.ItemId); SetSentErrorMessage(true); return false; } @@ -4996,7 +4988,7 @@ bool ChatHandler::HandleQuestStatusCommand(char* args) { rewardInfo << "item: " << questData.m_reward_choice << " "; - const auto itemProto = sItemStorage.LookupEntry(questData.m_reward_choice); + const auto itemProto = sObjectMgr.GetItemPrototype(questData.m_reward_choice); if (itemProto) { @@ -5479,7 +5471,7 @@ bool ChatHandler::HandleGroupAddItemCommand(char* args) if (!ExtractUInt32(&args, itemId)) return false; - if (!ObjectMgr::GetItemPrototype(itemId)) + if (!sObjectMgr.GetItemPrototype(itemId)) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); SetSentErrorMessage(true); diff --git a/src/game/Commands/CreatureCommands.cpp b/src/game/Commands/CreatureCommands.cpp index 5d380166c..aa9bf3fd1 100644 --- a/src/game/Commands/CreatureCommands.cpp +++ b/src/game/Commands/CreatureCommands.cpp @@ -957,7 +957,7 @@ bool ChatHandler::HandleNpcAddWeaponCommand(char* args) if (!ExtractUInt32(&args, uiSlotId)) return false; - ItemPrototype const* pItemProto = ObjectMgr::GetItemPrototype(uiItemId); + ItemPrototype const* pItemProto = sObjectMgr.GetItemPrototype(uiItemId); if (!pItemProto) { @@ -1011,7 +1011,7 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(char* args) sObjectMgr.AddVendorItem(vendor_entry, itemId, maxcount, incrtime, itemflags); - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, pProto->Name1, maxcount, incrtime); return true; @@ -1045,7 +1045,7 @@ bool ChatHandler::HandleNpcDelVendorItemCommand(char* args) return false; } - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, pProto->Name1); return true; diff --git a/src/game/Commands/DebugCommands.cpp b/src/game/Commands/DebugCommands.cpp index 7301ef0ef..a2d797667 100644 --- a/src/game/Commands/DebugCommands.cpp +++ b/src/game/Commands/DebugCommands.cpp @@ -1894,7 +1894,7 @@ bool ChatHandler::HandleDebugLootTableCommand(char* args) { if (itr.first == checkItem || !checkItem) { - ItemPrototype const* proto = sItemStorage.LookupEntry(itr.first); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(itr.first); if (!proto) continue; @@ -1916,7 +1916,7 @@ bool ChatHandler::HandleDebugItemEnchantCommand(int lootid, uint32 simCount) uint32 const MAX_TIME = 30; auto startTime = time(nullptr); - ItemPrototype const* proto = sItemStorage.LookupEntry(lootid); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(lootid); if (!proto) { PSendSysMessage("Error: invalid item id %u", lootid); @@ -1985,17 +1985,19 @@ bool IsSimilarItem(ItemPrototype const* proto1, ItemPrototype const* proto2) bool ChatHandler::HandleFactionChangeItemsCommand(char* c) { - for (uint32 id = 0; id < sItemStorage.GetMaxEntry(); id++) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - ItemPrototype const* proto1 = sItemStorage.LookupEntry(id); - if (!proto1) - continue; + uint32 id = itr.first; + ItemPrototype const* proto1 = &itr.second; + Races currMountRace; uint8 currRaceNum = 0; if (sObjectMgr.GetMountDataByEntry(id, currMountRace, currRaceNum)) continue; + if (proto1->Quality <= 1) continue; + bool inDb = false; for (std::map::const_iterator it2 = sObjectMgr.factionchange_items.begin(); it2 != sObjectMgr.factionchange_items.end(); ++it2) { @@ -2018,18 +2020,20 @@ bool ChatHandler::HandleFactionChangeItemsCommand(char* c) if (!canEquip) { ItemPrototype const* similar = nullptr; - for (uint32 id2 = 0; id2 < sItemStorage.GetMaxEntry(); id2++) - if (ItemPrototype const* proto2 = sItemStorage.LookupEntry(id2)) - if (proto1 != proto2 && IsSimilarItem(proto1, proto2)) + for (auto const& itr2 : sObjectMgr.GetItemPrototypeMap()) + { + ItemPrototype const* proto2 = &itr2.second; + if (proto1 != proto2 && IsSimilarItem(proto1, proto2)) + { + if (similar) { - if (similar) - { - // Ambiguity. Other similar items. - similar = nullptr; - break; - } - similar = proto2; + // Ambiguity. Other similar items. + similar = nullptr; + break; } + similar = proto2; + } + } PSendSysMessage("Item %u not handled ! Similar item : %u", proto1->ItemId, similar ? similar->ItemId : 0); diff --git a/src/game/Commands/LookupCommands.cpp b/src/game/Commands/LookupCommands.cpp index 6560afc45..2b40c734f 100644 --- a/src/game/Commands/LookupCommands.cpp +++ b/src/game/Commands/LookupCommands.cpp @@ -172,7 +172,7 @@ bool ChatHandler::HandleListCreatureCommand(char* args) void ChatHandler::ShowItemListHelper(uint32 itemId, int loc_idx, Player* target /*=nullptr*/) { - ItemPrototype const* itemProto = sItemStorage.LookupEntry(itemId); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(itemId); if (!itemProto) return; @@ -222,11 +222,9 @@ bool ChatHandler::HandleLookupItemCommand(char* args) uint32 counter = 0; // Search in `item_template` - for (uint32 id = 0; id < sItemStorage.GetMaxEntry(); id++) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - ItemPrototype const* pProto = sItemStorage.LookupEntry(id); - if (!pProto) - continue; + ItemPrototype const* pProto = &itr.second; int loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) diff --git a/src/game/Commands/MiscCommands.cpp b/src/game/Commands/MiscCommands.cpp index cc4953e26..c35e32cf2 100644 --- a/src/game/Commands/MiscCommands.cpp +++ b/src/game/Commands/MiscCommands.cpp @@ -920,7 +920,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) return false; } - ItemPrototype const* item_proto = ObjectMgr::GetItemPrototype(itemId); + ItemPrototype const* item_proto = sObjectMgr.GetItemPrototype(itemId); if (!item_proto) { PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); diff --git a/src/game/Conditions.cpp b/src/game/Conditions.cpp index 8a7b44732..cafc3dee5 100644 --- a/src/game/Conditions.cpp +++ b/src/game/Conditions.cpp @@ -790,7 +790,7 @@ bool ConditionEntry::IsValid() case CONDITION_ITEM: case CONDITION_ITEM_WITH_BANK: { - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_value1); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(m_value1); if (!proto) { if (!sObjectMgr.IsExistingItemId(m_value1)) @@ -814,7 +814,7 @@ bool ConditionEntry::IsValid() } case CONDITION_ITEM_EQUIPPED: { - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_value1); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(m_value1); if (!proto) { if (!sObjectMgr.IsExistingItemId(m_value1)) diff --git a/src/game/Database/SQLStorages.cpp b/src/game/Database/SQLStorages.cpp index 3d8d6605f..8b1f45292 100644 --- a/src/game/Database/SQLStorages.cpp +++ b/src/game/Database/SQLStorages.cpp @@ -32,8 +32,6 @@ char const GameObjectDisplayInfoAddonfmt[] = "iffffff"; char const EquipmentInfofmt[] = "iiii"; char const GameObjectInfosrcfmt[] = "iiisiifiiiiiiiiiiiiiiiiiiiiiiiiiis"; char const GameObjectInfodstfmt[] = "iiisiifiiiiiiiiiiiiiiiiiiiiiiiiiii"; -char const ItemPrototypesrcfmt[] = "iiissiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiififfiffiffiffiffiiiiiiiiiiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiiiiiiiiiiiiiiiiiiiiiii"; -char const ItemPrototypedstfmt[] = "iiissiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiififfiffiffiffiffiiiiiiiiiiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiiiiiiiiiiiiiiiiiiiiiiix"; char const PageTextfmt[] = "isi"; char const MapEntrysrcfmt[] = "iiiiiiiffss"; char const MapEntrydstfmt[] = "iiiiiiiffsi"; @@ -48,7 +46,6 @@ SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt, "guid", "creature SQLStorage sCreatureDisplayInfoAddonStorage(CreatureDisplayInfoAddonfmt, "display_id", "creature_display_info_addon"); SQLStorage sGameObjectDisplayInfoAddonStorage(GameObjectDisplayInfoAddonfmt, "display_id", "gameobject_display_info_addon"); SQLStorage sEquipmentStorage(EquipmentInfofmt, "entry", "creature_equip_template"); -SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry", "item_template"); SQLStorage sPageTextStore(PageTextfmt, "entry", "page_text"); SQLStorage sMapStorage(MapEntrysrcfmt, MapEntrydstfmt, "entry", "map_template"); SQLStorage sConditionStorage(ConditionsSrcFmt, ConditionsDstFmt, "condition_entry", "conditions"); diff --git a/src/game/Database/SQLStorages.h b/src/game/Database/SQLStorages.h index 751d90758..4871c16e1 100644 --- a/src/game/Database/SQLStorages.h +++ b/src/game/Database/SQLStorages.h @@ -31,7 +31,6 @@ extern SQLStorage sCreatureDisplayInfoAddonStorage; extern SQLStorage sGameObjectDisplayInfoAddonStorage; extern SQLStorage sEquipmentStorage; extern SQLStorage sPageTextStore; -extern SQLStorage sItemStorage; extern SQLStorage sMapStorage; extern SQLStorage sConditionStorage; extern SQLStorage sAreaStorage; diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 76c418257..afc54c04d 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -502,7 +502,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid npcG data << uint32(pQuest->RewChoiceItemId[i]); data << uint32(pQuest->RewChoiceItemCount[i]); - IProto = ObjectMgr::GetItemPrototype(pQuest->RewChoiceItemId[i]); + IProto = sObjectMgr.GetItemPrototype(pQuest->RewChoiceItemId[i]); if (IProto) data << uint32(IProto->DisplayInfoID); @@ -518,7 +518,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid npcG data << uint32(pQuest->RewItemId[i]); data << uint32(pQuest->RewItemCount[i]); - IProto = ObjectMgr::GetItemPrototype(pQuest->RewItemId[i]); + IProto = sObjectMgr.GetItemPrototype(pQuest->RewItemId[i]); if (IProto) data << uint32(IProto->DisplayInfoID); @@ -706,7 +706,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU data << uint32(pQuest->GetRewChoiceItemsCount()); for (uint32 i = 0; i < pQuest->GetRewChoiceItemsCount(); ++i) { - pItem = ObjectMgr::GetItemPrototype(pQuest->RewChoiceItemId[i]); + pItem = sObjectMgr.GetItemPrototype(pQuest->RewChoiceItemId[i]); data << uint32(pQuest->RewChoiceItemId[i]); data << uint32(pQuest->RewChoiceItemCount[i]); @@ -720,7 +720,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU data << uint32(pQuest->GetRewItemsCount()); for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i) { - pItem = ObjectMgr::GetItemPrototype(pQuest->RewItemId[i]); + pItem = sObjectMgr.GetItemPrototype(pQuest->RewItemId[i]); data << uint32(pQuest->RewItemId[i]); data << uint32(pQuest->RewItemCount[i]); @@ -796,7 +796,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* pQuest, ObjectGuid npcG { if (!pQuest->ReqItemId[i]) continue; - pItem = ObjectMgr::GetItemPrototype(pQuest->ReqItemId[i]); + pItem = sObjectMgr.GetItemPrototype(pQuest->ReqItemId[i]); data << uint32(pQuest->ReqItemId[i]); data << uint32(pQuest->ReqItemCount[i]); diff --git a/src/game/Group/Group.cpp b/src/game/Group/Group.cpp index d30582868..e86014134 100644 --- a/src/game/Group/Group.cpp +++ b/src/game/Group/Group.cpp @@ -802,7 +802,7 @@ void Group::GroupLoot(Creature* creature, Loot *loot) if (lootItem.freeforall) continue; - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(lootItem.itemid); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(lootItem.itemid); if (!itemProto) { DEBUG_LOG("Group::GroupLoot: missing item prototype for item with id: %d", lootItem.itemid); @@ -825,7 +825,7 @@ void Group::NeedBeforeGreed(Creature* creature, Loot *loot) if (lootItem.freeforall) continue; - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(lootItem.itemid); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(lootItem.itemid); if (!itemProto) { DEBUG_LOG("Group::NeedBeforeGreed: missing item prototype for item with id: %d", lootItem.itemid); @@ -844,7 +844,7 @@ void Group::MasterLoot(Creature* creature, Loot* loot) { for (auto& i : loot->items) { - ItemPrototype const* item = ObjectMgr::GetItemPrototype(i.itemid); + ItemPrototype const* item = sObjectMgr.GetItemPrototype(i.itemid); if (!item) continue; if (item->Quality < uint32(m_lootThreshold)) @@ -953,7 +953,7 @@ void Group::StartLootRoll(Creature* lootTarget, LootMethod method, Loot* loot, u LootItem const& lootItem = loot->items[itemSlot]; - ItemPrototype const* item = ObjectMgr::GetItemPrototype(lootItem.itemid); + ItemPrototype const* item = sObjectMgr.GetItemPrototype(lootItem.itemid); Roll* r = new Roll(lootTarget->GetObjectGuid(), lootItem); diff --git a/src/game/Handlers/ItemHandler.cpp b/src/game/Handlers/ItemHandler.cpp index 3eede2413..5ba9a111b 100644 --- a/src/game/Handlers/ItemHandler.cpp +++ b/src/game/Handlers/ItemHandler.cpp @@ -303,8 +303,8 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket& recv_data) DETAIL_LOG("STORAGE: Item Query = %u", item); - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); - if (pProto && (pProto->m_bDiscovered || (GetSecurity() > SEC_PLAYER))) + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(item); + if (pProto && (pProto->Discovered || (GetSecurity() > SEC_PLAYER))) { std::string Name = pProto->Name1; std::string Description = pProto->Description; @@ -445,7 +445,7 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket& recv_data) } else { - if (pProto && !pProto->m_bDiscovered) + if (pProto && !pProto->Discovered) { std::stringstream oss; oss << "Requested info for undiscovered item " << pProto->ItemId; @@ -816,7 +816,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid, uint8 menu_type) if (crItem) { - if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(crItem->item)) + if (ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(crItem->item)) { if (!_player->IsGameMaster()) { @@ -1118,7 +1118,7 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket& recv_data) recv_data.read_skip(); // guid DEBUG_LOG("WORLD: CMSG_ITEM_NAME_QUERY %u", itemid); - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemid); if (pProto) { std::string Name; diff --git a/src/game/Handlers/PetitionsHandler.cpp b/src/game/Handlers/PetitionsHandler.cpp index a20438009..dc7612875 100644 --- a/src/game/Handlers/PetitionsHandler.cpp +++ b/src/game/Handlers/PetitionsHandler.cpp @@ -117,7 +117,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recv_data) } } - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(charterid); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(charterid); if (!pProto) { _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, charterid, 0); diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 908dc535a..c7c86b9fb 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -270,7 +270,7 @@ bool LootStoreItem::Roll(bool rate) const if (mincountOrRef < 0) // reference case return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemid); float qualityModifier = pProto && rate ? sWorld.getConfig(qualityToRate[pProto->Quality]) : 1.0f; @@ -294,7 +294,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); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(itemid); if (!proto) { sLog.outErrorDb("Table '%s' entry %d item %d: item entry not listed in `item_template` - skipped", store.GetName(), entry, itemid); @@ -344,7 +344,7 @@ LootItem::LootItem(LootStoreItem const& li) itemid = li.itemid; conditionId = li.conditionId; - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(itemid); freeforall = proto && (proto->Flags & ITEM_FLAG_PARTY_LOOT); needs_quest = li.needs_quest; @@ -362,7 +362,7 @@ LootItem::LootItem(uint32 itemid_, uint32 count_, int32 randomPropertyId_) itemid = itemid_; conditionId = 0; - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(itemid); freeforall = proto && (proto->Flags & ITEM_FLAG_PARTY_LOOT); needs_quest = false; @@ -382,7 +382,7 @@ bool LootItem::AllowedForPlayer(Player const* player, WorldObject const* lootTar if (conditionId && !IsConditionSatisfied(conditionId, player, player->GetMap(), lootTarget, CONDITION_FROM_LOOT)) return false; - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemid); if (!pProto) return false; @@ -457,9 +457,9 @@ LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Play // Inserts the item into the loot (called by LootTemplate processors) void Loot::AddItem(LootStoreItem const& item) { - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item.itemid); - if (proto && !proto->m_bDiscovered) - proto->m_bDiscovered = true; + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(item.itemid); + if (proto && !proto->Discovered) + proto->Discovered = true; if (item.needs_quest && proto && (proto->Flags & ITEM_FLAG_PARTY_LOOT)) m_hasFFAQuestItems = true; @@ -811,7 +811,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.GetItemPrototype(li.itemid)->DisplayInfoID); b << uint32(0); b << uint32(li.randomPropertyId); //b << uint8(0); // slot type - will send after this function call @@ -1383,17 +1383,14 @@ void LoadLootTemplates_Disenchant() LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - if (ItemPrototype const* proto = sItemStorage.LookupEntry(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 (ids_set.find(lootid) == ids_set.end()) + LootTemplates_Disenchant.ReportNotExistedId(lootid); + else + ids_setUsed.insert(lootid); } } for (const auto itr : ids_setUsed) @@ -1447,19 +1444,16 @@ void LoadLootTemplates_Item() LootTemplates_Item.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - if (ItemPrototype const* proto = sItemStorage.LookupEntry(i)) - { - if (!(proto->Flags & ITEM_FLAG_LOOTABLE)) - continue; + if (!(itr.second.Flags & ITEM_FLAG_LOOTABLE)) + continue; - if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0) - ids_set.erase(proto->ItemId); - // wdb have wrong data cases, so skip by default - else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) - LootTemplates_Item.ReportNotExistedId(proto->ItemId); - } + if (ids_set.find(itr.second.ItemId) != ids_set.end() || itr.second.MaxMoneyLoot > 0) + ids_set.erase(itr.second.ItemId); + // wdb have wrong data cases, so skip by default + else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) + LootTemplates_Item.ReportNotExistedId(itr.second.ItemId); } // output error for any still listed (not referenced from appropriate table) ids diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 5423873cb..af711ba3c 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -3645,9 +3645,116 @@ void ObjectMgr::FillObtainedItemsList(std::set& obtainedItems) void ObjectMgr::LoadItemPrototypes() { - sItemStorage.LoadProgressive(sWorld.GetWowPatch()); + m_itemPrototypesMap.clear(); + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 + std::unique_ptr result(WorldDatabase.PQuery("SELECT `entry`, `class`, `subclass`, `name`, `description`, `display_id`, `quality`, `flags`, `buy_count`, `buy_price`, `sell_price`, `inventory_type`, `allowable_class`, `allowable_race`, `item_level`, `required_level`, `required_skill`, `required_skill_rank`, `required_spell`, `required_honor_rank`, `required_city_rank`, `required_reputation_faction`, `required_reputation_rank`, `max_count`, `stackable`, `container_slots`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `delay`, `range_mod`, `ammo_type`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `dmg_min3`, `dmg_max3`, `dmg_type3`, `dmg_min4`, `dmg_max4`, `dmg_type4`, `dmg_min5`, `dmg_max5`, `dmg_type5`, `block`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmrate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmrate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmrate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmrate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmrate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `page_text`, `page_language`, `page_material`, `start_quest`, `lock_id`, `material`, `sheath`, `random_property`, `set_id`, `max_durability`, `area_bound`, `map_bound`, `duration`, `bag_family`, `disenchant_id`, `food_type`, `min_money_loot`, `max_money_loot`, `wrapped_gift`, `extra_flags`, `other_team_entry` " + " FROM `item_template` t1 WHERE `patch`=(SELECT max(`patch`) FROM `item_template` t2 WHERE t1.`entry`=t2.`entry` && `patch` <= %u)", sWorld.GetWowPatch())); + if (!result) + { + BarGoLink bar(1); + bar.step(); + + sLog.outString(); + sLog.outString(">> Loaded 0 item definitions"); + sLog.outErrorDb("`item_template` table is empty!"); + return; + } + + BarGoLink bar(result->GetRowCount()); + + do + { + bar.step(); + Field* fields = result->Fetch(); + uint32 entry = fields[ 0].GetUInt32(); + + ItemPrototype& item = m_itemPrototypesMap[entry]; + item.ItemId = entry; + item.Class = fields[ 1].GetUInt8(); + item.SubClass = fields[ 2].GetUInt8(); + item.Name1 = strdup(fields[3].GetString()); + item.Description = strdup(fields[4].GetString()); + item.DisplayInfoID = fields[ 5].GetUInt32(); + item.Quality = fields[ 6].GetUInt8(); + item.Flags = fields[ 7].GetUInt32(); + item.BuyCount = fields[ 8].GetUInt8(); + item.BuyPrice = fields[ 9].GetUInt32(); + item.SellPrice = fields[10].GetUInt32(); + item.InventoryType = fields[11].GetUInt8(); + item.AllowableClass = fields[12].GetInt32(); + item.AllowableRace = fields[13].GetInt32(); + item.ItemLevel = fields[14].GetUInt8(); + item.RequiredLevel = fields[15].GetUInt8(); + item.RequiredSkill = fields[16].GetUInt16(); + item.RequiredSkillRank = fields[17].GetUInt16(); + item.RequiredSpell = fields[18].GetUInt32(); + item.RequiredHonorRank = fields[19].GetUInt32(); + item.RequiredCityRank = fields[20].GetUInt32(); + item.RequiredReputationFaction = fields[21].GetUInt16(); + item.RequiredReputationRank = fields[22].GetUInt16(); + item.MaxCount = fields[23].GetUInt16(); + item.Stackable = fields[24].GetUInt16(); + item.ContainerSlots = fields[25].GetUInt8(); + for (int i = 0; i < MAX_ITEM_PROTO_STATS; i++) + { + item.ItemStat[i].ItemStatType = fields[26 + i*2].GetUInt8(); + item.ItemStat[i].ItemStatValue = fields[27 + i*2].GetInt16(); + } + item.Delay = fields[46].GetUInt16(); + item.RangedModRange = fields[47].GetFloat(); + item.AmmoType = fields[48].GetUInt8(); + for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; i++) + { + item.Damage[i].DamageMin = fields[49 + i*3].GetFloat(); + item.Damage[i].DamageMax = fields[50 + i*3].GetFloat(); + item.Damage[i].DamageType = fields[51 + i*3].GetUInt8(); + } + item.Block = fields[64].GetUInt32(); + item.Armor = fields[65].GetInt16(); + item.HolyRes = fields[66].GetInt16(); + item.FireRes = fields[67].GetInt16(); + item.NatureRes = fields[68].GetInt16(); + item.FrostRes = fields[69].GetInt16(); + item.ShadowRes = fields[70].GetInt16(); + item.ArcaneRes = fields[71].GetInt16(); + for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; i++) + { + item.Spells[i].SpellId = fields[72 + i*7].GetUInt32(); + item.Spells[i].SpellTrigger = fields[73 + i*7].GetUInt8(); + item.Spells[i].SpellCharges = fields[74 + i*7].GetInt16(); + item.Spells[i].SpellPPMRate = fields[75 + i*7].GetFloat(); + item.Spells[i].SpellCooldown = fields[76 + i*7].GetInt32(); + item.Spells[i].SpellCategory = fields[77 + i*7].GetUInt16(); + item.Spells[i].SpellCategoryCooldown = fields[78 + i*7].GetInt32(); + } + item.Bonding = fields[107].GetUInt8(); + item.PageText = fields[108].GetUInt32(); + item.LanguageID = fields[109].GetUInt8(); + item.PageMaterial = fields[110].GetUInt8(); + item.StartQuest = fields[111].GetUInt32(); + item.LockID = fields[112].GetUInt32(); + item.Material = fields[113].GetInt16(); + item.Sheath = fields[114].GetUInt8(); + item.RandomProperty = fields[115].GetUInt32(); + item.ItemSet = fields[116].GetUInt32(); + item.MaxDurability = fields[117].GetUInt32(); + item.Area = fields[118].GetUInt32(); + item.Map = fields[119].GetInt16(); + item.Duration = fields[120].GetUInt32(); + item.BagFamily = fields[121].GetInt32(); + item.DisenchantID = fields[122].GetUInt32(); + item.FoodType = fields[123].GetUInt8(); + item.MinMoneyLoot = fields[124].GetUInt32(); + item.MaxMoneyLoot = fields[125].GetUInt32(); + item.WrappedGift = fields[126].GetUInt32(); + item.ExtraFlags = fields[127].GetUInt8(); + item.OtherTeamEntry = fields[128].GetUInt32(); + } + while (result->NextRow()); + m_QuestStartingItemsMap.clear(); - sLog.outString(">> Loaded %u item prototypes", sItemStorage.GetRecordCount()); + sLog.outString(">> Loaded %u item prototypes", (uint32)m_itemPrototypesMap.size()); sLog.outString(); // Load all currently obtained items by players. @@ -3655,16 +3762,15 @@ void ObjectMgr::LoadItemPrototypes() FillObtainedItemsList(obtainedItems); // check data correctness - for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i) + for (const auto& item : GetItemPrototypeMap()) { - ItemPrototype const* proto = sItemStorage.LookupEntry(i); - if (!proto) - continue; + uint32 i = item.first; + ItemPrototype const* proto = &item.second; if ((obtainedItems.find(i) != obtainedItems.end()) || proto->HasExtraFlag(ITEM_EXTRA_MAIL_STATIONERY) || !sWorld.getConfig(CONFIG_BOOL_PREVENT_ITEM_DATAMINING)) - proto->m_bDiscovered = true; + proto->Discovered = true; CorrectItemDisplayIds(i, const_cast(proto)->DisplayInfoID); @@ -3924,7 +4030,7 @@ void ObjectMgr::LoadItemPrototypes() if (proto->WrappedGift) { if (ItemPrototype const* pGift = GetItemPrototype(proto->WrappedGift)) - pGift->m_bDiscovered = true; + pGift->Discovered = true; else { sLog.outErrorDb("Item (Entry: %u) has wrong (nonexistent) item in WrappedGift (%u)", i, proto->WrappedGift); @@ -4047,7 +4153,7 @@ void ObjectMgr::LoadItemRequiredTarget() uint32 uiType = fields[1].GetUInt32(); uint32 uiTargetEntry = fields[2].GetUInt32(); - ItemPrototype const* pItemProto = sItemStorage.LookupEntry(uiItemId); + ItemPrototype const* pItemProto = GetItemPrototype(uiItemId); if (!pItemProto) { @@ -4362,7 +4468,7 @@ void ObjectMgr::LoadPlayerInfo() uint32 item_id = fields[2].GetUInt32(); if (ItemPrototype const* pProto = GetItemPrototype(item_id)) - pProto->m_bDiscovered = true; + pProto->Discovered = true; else { 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); @@ -5281,9 +5387,13 @@ void ObjectMgr::LoadQuests() if (qinfo->SrcItemId) { - if (ItemPrototype const* pItemProto = sItemStorage.LookupEntry(qinfo->SrcItemId)) + if (ItemPrototype const* pItemProto = GetItemPrototype(qinfo->SrcItemId)) { - pItemProto->m_bDiscovered = true; // all quest items count as discovered + pItemProto->Discovered = true; // all quest items count as discovered + + if (pItemProto->SourceQuestLevel < 0 || uint32(pItemProto->SourceQuestLevel) > qinfo->MinLevel) + pItemProto->SourceQuestLevel = int32(std::min(qinfo->MinLevel, INT32_MAX)); + if (qinfo->SrcItemCount == 0) { sLog.outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.", @@ -5335,8 +5445,8 @@ void ObjectMgr::LoadQuests() qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER); - if (ItemPrototype const* pItemProto = sItemStorage.LookupEntry(id)) - pItemProto->m_bDiscovered = true; + if (ItemPrototype const* pItemProto = GetItemPrototype(id)) + pItemProto->Discovered = true; else { sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", @@ -5356,8 +5466,8 @@ void ObjectMgr::LoadQuests() { if (uint32 id = qinfo->ReqSourceId[j]) { - if (ItemPrototype const* pItemProto = sItemStorage.LookupEntry(id)) - pItemProto->m_bDiscovered = true; + if (ItemPrototype const* pItemProto = GetItemPrototype(id)) + pItemProto->Discovered = true; else { sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", @@ -5464,10 +5574,13 @@ void ObjectMgr::LoadQuests() { if (uint32 id = qinfo->RewChoiceItemId[j]) { - if (ItemPrototype const* pItemProto = sItemStorage.LookupEntry(id)) + if (ItemPrototype const* pItemProto = GetItemPrototype(id)) { choice_found = true; - pItemProto->m_bDiscovered = true; + pItemProto->Discovered = true; + + if (pItemProto->SourceQuestLevel < 0 || uint32(pItemProto->SourceQuestLevel) > qinfo->MinLevel) + pItemProto->SourceQuestLevel = int32(std::min(qinfo->MinLevel, INT32_MAX)); } else { @@ -5503,8 +5616,13 @@ void ObjectMgr::LoadQuests() { if (uint32 id = qinfo->RewItemId[j]) { - if (ItemPrototype const* pItemProto = sItemStorage.LookupEntry(id)) - pItemProto->m_bDiscovered = true; + if (ItemPrototype const* pItemProto = GetItemPrototype(id)) + { + pItemProto->Discovered = true; + + if (pItemProto->SourceQuestLevel < 0 || uint32(pItemProto->SourceQuestLevel) > qinfo->MinLevel) + pItemProto->SourceQuestLevel = int32(std::min(qinfo->MinLevel, INT32_MAX)); + } else { sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", @@ -10432,7 +10550,7 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 } if (ItemPrototype const* pItemProto = GetItemPrototype(item_id)) - pItemProto->m_bDiscovered = true; // all vendor items count as discovered + pItemProto->Discovered = true; // all vendor items count as discovered else { if (pl) diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 2f88d7178..9603515dc 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -201,6 +201,7 @@ class FindCreatureData typedef std::unordered_map FactionsMap; typedef std::unordered_map FactionTemplatesMap; typedef std::unordered_map SoundEntryMap; +typedef std::unordered_map ItemPrototypeMap; typedef std::unordered_map GameObjectDataMap; typedef GameObjectDataMap::value_type GameObjectDataPair; @@ -628,7 +629,19 @@ class ObjectMgr return sCreatureDataAddonStorage.LookupEntry(lowguid); } - static ItemPrototype const* GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry(id); } + ItemPrototype const* GetItemPrototype(uint32 id) const + { + auto iter = m_itemPrototypesMap.find(id); + if (iter == m_itemPrototypesMap.end()) + return nullptr; + + return &iter->second; + } + + ItemPrototypeMap const& GetItemPrototypeMap() const + { + return m_itemPrototypesMap; + } CreatureClassLevelStats const* GetCreatureClassLevelStats(uint32 unitClass, uint32 level) const; @@ -1511,6 +1524,7 @@ class ObjectMgr FactionTemplatesMap m_FactionTemplatesMap; SoundEntryMap m_SoundEntriesMap; + ItemPrototypeMap m_itemPrototypesMap; typedef std::vector> SkillLineAbiilityStore; SkillLineAbiilityStore m_SkillLineAbilities; diff --git a/src/game/Objects/Bag.cpp b/src/game/Objects/Bag.cpp index c13a2bba5..bc14b0b7d 100644 --- a/src/game/Objects/Bag.cpp +++ b/src/game/Objects/Bag.cpp @@ -59,7 +59,7 @@ void Bag::RemoveFromWorld() bool Bag::Create(uint32 guidlow, uint32 itemid, ObjectGuid ownerGuid) { - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(itemid); if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE) return false; diff --git a/src/game/Objects/Corpse.cpp b/src/game/Objects/Corpse.cpp index 94bfd76d5..0060bb54d 100644 --- a/src/game/Objects/Corpse.cpp +++ b/src/game/Objects/Corpse.cpp @@ -214,7 +214,7 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields) { uint32 visualbase = slot * 2; uint32 item_id = GetUInt32ValueFromArray(data, visualbase); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(item_id); if (!proto) { SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0); diff --git a/src/game/Objects/Creature.cpp b/src/game/Objects/Creature.cpp index 05c6d30e0..b8f563b3f 100644 --- a/src/game/Objects/Creature.cpp +++ b/src/game/Objects/Creature.cpp @@ -3196,7 +3196,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) if (vCount->lastIncrementTime + vCount->restockDelay <= ptime) { - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(vItem->item); uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vCount->restockDelay); if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount) @@ -3241,7 +3241,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us if (vCount->lastIncrementTime + vCount->restockDelay <= ptime) { - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(vItem->item); uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vCount->restockDelay); if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount) @@ -4015,7 +4015,7 @@ void Creature::SetVirtualItem(VirtualItemSlot slot, uint32 item_id) return; } - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(item_id); if (!proto) { sLog.outError("Not listed in 'item_template' item (ID:%u) used as virtual item for %s", item_id, GetGuidStr().c_str()); diff --git a/src/game/Objects/Item.cpp b/src/game/Objects/Item.cpp index 27fca9b75..7502c7325 100644 --- a/src/game/Objects/Item.cpp +++ b/src/game/Objects/Item.cpp @@ -207,7 +207,7 @@ bool Item::Create(uint32 guidlow, uint32 itemid, ObjectGuid ownerGuid) SetGuidValue(ITEM_FIELD_OWNER, ownerGuid); SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid()); - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(itemid); if (!itemProto) return false; @@ -220,7 +220,7 @@ bool Item::Create(uint32 guidlow, uint32 itemid, ObjectGuid ownerGuid) SetUInt32Value(ITEM_FIELD_DURATION, itemProto->Duration); - itemProto->m_bDiscovered = true; + itemProto->Discovered = true; return true; } @@ -521,7 +521,7 @@ void Item::LoadLootFromDB(Field* fields) } // normal item case - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(item_id); if (!proto) { @@ -554,7 +554,7 @@ void Item::DeleteFromInventoryDB() ItemPrototype const* Item::GetProto() const { - return ObjectMgr::GetItemPrototype(GetEntry()); + return sObjectMgr.GetItemPrototype(GetEntry()); } Player* Item::GetOwner()const @@ -779,7 +779,7 @@ uint32 ItemPrototype::GetProficiencySpell() const int32 Item::GenerateItemRandomPropertyId(uint32 item_id) { - ItemPrototype const* itemProto = sItemStorage.LookupEntry(item_id); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(item_id); if (!itemProto) return 0; @@ -1094,7 +1094,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, ObjectGuid playerGuid) if (count < 1) return nullptr; //don't create item at zero count - if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item)) + if (ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(item)) { if (count > pProto->GetMaxStackSize()) count = pProto->GetMaxStackSize(); diff --git a/src/game/Objects/ItemPrototype.h b/src/game/Objects/ItemPrototype.h index 836ec062a..5a8454439 100644 --- a/src/game/Objects/ItemPrototype.h +++ b/src/game/Objects/ItemPrototype.h @@ -409,25 +409,25 @@ enum ItemExtraFlags struct _ItemDamage { - float DamageMin; - float DamageMax; - uint32 DamageType; // id from Resistances.dbc + float DamageMin = 0.0f; + float DamageMax = 0.0f; + uint32 DamageType = 0; // id from Resistances.dbc }; struct _ItemStat { - uint32 ItemStatType; - int32 ItemStatValue; + uint32 ItemStatType = 0; + int32 ItemStatValue = 0; }; struct _ItemSpell { - uint32 SpellId; // id from Spell.dbc - uint32 SpellTrigger; - int32 SpellCharges; - float SpellPPMRate; - int32 SpellCooldown; - uint32 SpellCategory; // id from SpellCategory.dbc - int32 SpellCategoryCooldown; + uint32 SpellId = 0; // id from Spell.dbc + uint32 SpellTrigger = 0; + int32 SpellCharges = 0; + float SpellPPMRate = 0.0f; + int32 SpellCooldown = 0; + uint32 SpellCategory = 0; // id from SpellCategory.dbc + int32 SpellCategoryCooldown = 0; }; #define MAX_ITEM_PROTO_DAMAGES 5 @@ -436,70 +436,72 @@ struct _ItemSpell struct ItemPrototype { - uint32 ItemId; - uint32 Class; // id from ItemClass.dbc - uint32 SubClass; // id from ItemSubClass.dbc - char* Name1; - char* Description; - uint32 DisplayInfoID; // id from ItemDisplayInfo.dbc - uint32 Quality; - uint32 Flags; - uint32 BuyCount; - uint32 BuyPrice; - uint32 SellPrice; - uint32 InventoryType; - uint32 AllowableClass; - uint32 AllowableRace; - uint32 ItemLevel; - uint32 RequiredLevel; - uint32 RequiredSkill; // id from SkillLine.dbc - uint32 RequiredSkillRank; - uint32 RequiredSpell; // id from Spell.dbc - uint32 RequiredHonorRank; - uint32 RequiredCityRank; - uint32 RequiredReputationFaction; // id from Faction.dbc - uint32 RequiredReputationRank; - uint32 MaxCount; - uint32 Stackable; - uint32 ContainerSlots; - _ItemStat ItemStat[MAX_ITEM_PROTO_STATS]; - uint32 Delay; - float RangedModRange; - uint32 AmmoType; - _ItemDamage Damage[MAX_ITEM_PROTO_DAMAGES]; - uint32 Block; - int32 Armor; - int32 HolyRes; - int32 FireRes; - int32 NatureRes; - int32 FrostRes; - int32 ShadowRes; - int32 ArcaneRes; - _ItemSpell Spells[MAX_ITEM_PROTO_SPELLS]; - uint32 Bonding; - uint32 PageText; - uint32 LanguageID; - uint32 PageMaterial; - uint32 StartQuest; // id from QuestCache.wdb - uint32 LockID; - uint32 Material; // id from Material.dbc - uint32 Sheath; - uint32 RandomProperty; // id from ItemRandomProperties.dbc - uint32 ItemSet; // id from ItemSet.dbc - uint32 MaxDurability; - uint32 Area; // id from AreaTable.dbc - uint32 Map; // id from Map.dbc - uint32 Duration; - uint32 BagFamily; - uint32 DisenchantID; - uint32 FoodType; - uint32 MinMoneyLoot; - uint32 MaxMoneyLoot; - uint32 WrappedGift; - uint32 ExtraFlags; // see ItemExtraFlags - uint32 OtherTeamEntry; + uint32 ItemId = 0; + uint32 Class = 0; // id from ItemClass.dbc + uint32 SubClass = 0; // id from ItemSubClass.dbc + char* Name1 = nullptr; + char* Description = nullptr; + uint32 DisplayInfoID = 0; // id from ItemDisplayInfo.dbc + uint32 Quality = 0; + uint32 Flags = 0; + uint32 BuyCount = 0; + uint32 BuyPrice = 0; + uint32 SellPrice = 0; + uint32 InventoryType = 0; + uint32 AllowableClass = 0; + uint32 AllowableRace = 0; + uint32 ItemLevel = 0; + uint32 RequiredLevel = 0; + uint32 RequiredSkill = 0; // id from SkillLine.dbc + uint32 RequiredSkillRank = 0; + uint32 RequiredSpell = 0; // id from Spell.dbc + uint32 RequiredHonorRank = 0; + uint32 RequiredCityRank = 0; + uint32 RequiredReputationFaction = 0; // id from Faction.dbc + uint32 RequiredReputationRank = 0; + uint32 MaxCount = 0; + uint32 Stackable = 0; + uint32 ContainerSlots = 0; + _ItemStat ItemStat[MAX_ITEM_PROTO_STATS] = {}; + uint32 Delay = 0; + float RangedModRange = 0.0f; + uint32 AmmoType = 0; + _ItemDamage Damage[MAX_ITEM_PROTO_DAMAGES] = {}; + uint32 Block = 0; + int32 Armor = 0; + int32 HolyRes = 0; + int32 FireRes = 0; + int32 NatureRes = 0; + int32 FrostRes = 0; + int32 ShadowRes = 0; + int32 ArcaneRes = 0; + _ItemSpell Spells[MAX_ITEM_PROTO_SPELLS] = {}; + uint32 Bonding = 0; + uint32 PageText = 0; + uint32 LanguageID = 0; + uint32 PageMaterial = 0; + uint32 StartQuest = 0; // id from QuestCache.wdb + uint32 LockID = 0; + uint32 Material = 0; // id from Material.dbc + uint32 Sheath = 0; + uint32 RandomProperty = 0; // id from ItemRandomProperties.dbc + uint32 ItemSet = 0; // id from ItemSet.dbc + uint32 MaxDurability = 0; + uint32 Area = 0; // id from AreaTable.dbc + uint32 Map = 0; // id from Map.dbc + uint32 Duration = 0; + uint32 BagFamily = 0; + uint32 DisenchantID = 0; + uint32 FoodType = 0; + uint32 MinMoneyLoot = 0; + uint32 MaxMoneyLoot = 0; + uint32 WrappedGift = 0; + uint32 ExtraFlags = 0; // see ItemExtraFlags + uint32 OtherTeamEntry = 0; - mutable bool m_bDiscovered = false; // has item been discovered by players + // values assigned by core + mutable int32 SourceQuestLevel = -1; // minimum level of quest that rewards this item + mutable bool Discovered = false; // has item been discovered by players // helpers bool CanChangeEquipStateInCombat() const diff --git a/src/game/Objects/Object.cpp b/src/game/Objects/Object.cpp index e043197b9..b1b93c655 100644 --- a/src/game/Objects/Object.cpp +++ b/src/game/Objects/Object.cpp @@ -891,7 +891,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u // Static item flags are part of that field prior to patch 1.7. if (index == ITEM_FIELD_FLAGS) { - if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(GetEntry())) + if (ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(GetEntry())) *data << uint16(pProto->Flags); else *data << uint16(0); diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 54daec465..3fe640471 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -2062,7 +2062,7 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) { uint32 visualbase = slot * 2; // entry, perm ench., temp ench. uint32 item_id = GetUInt32ValueFromArray(data, visualbase); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(item_id); if (!proto) { *p_data << uint32(0); @@ -4228,7 +4228,7 @@ void Player::_LoadSpellCooldowns(QueryResult* result) ItemPrototype const* itemProto = nullptr; if (itemId) { - itemProto = ObjectMgr::GetItemPrototype(itemId); + itemProto = sObjectMgr.GetItemPrototype(itemId); if (!itemProto) { sLog.outError("%s has unknown item ID %u in `character_spell_cooldown`, skipping.", GetGuidStr().c_str(), itemId); @@ -4684,7 +4684,7 @@ void Player::DeleteFromDB(ObjectGuid playerGuid, uint32 accountId, bool updateRe uint32 itemGuidLow = fields2[10].GetUInt32(); uint32 itemId = fields2[11].GetUInt32(); - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemId); + ItemPrototype const* itemProto = sObjectMgr.GetItemPrototype(itemId); if (!itemProto) { CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid` = '%u'", itemGuidLow); @@ -6278,7 +6278,7 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Pl } case ACTION_BUTTON_ITEM: { - if (!ObjectMgr::GetItemPrototype(action)) + if (!sObjectMgr.GetItemPrototype(action)) return false; break; } @@ -7761,7 +7761,7 @@ void Player::_ApplyAmmoBonuses() float currentAmmoDPS; - ItemPrototype const* ammo_proto = ObjectMgr::GetItemPrototype(ammo_id); + ItemPrototype const* ammo_proto = sObjectMgr.GetItemPrototype(ammo_id); if (!ammo_proto || ammo_proto->Class != ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) currentAmmoDPS = 0.0f; else @@ -9062,7 +9062,7 @@ bool Player::HasItemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot) InventoryResult Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count) const { - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(entry); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(entry); if (!pProto) { if (no_space_count) @@ -9302,7 +9302,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &de { DEBUG_LOG("STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(entry); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(entry); if (!pProto) { if (no_space_count) @@ -10345,7 +10345,7 @@ InventoryResult 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); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(item); if (pProto) { if (pProto->InventoryType != INVTYPE_AMMO) @@ -11775,7 +11775,7 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint { if (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) { - ItemPrototype const* proto = pItem ? pItem->GetProto() : ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* proto = pItem ? pItem->GetProto() : sObjectMgr.GetItemPrototype(itemid); data << uint32(proto ? proto->RequiredLevel : 0); } data << (pItem ? pItem->GetObjectGuid() : ObjectGuid()); @@ -14516,7 +14516,7 @@ bool Player::HasQuestForItem(uint32 itemid) const // examined item is a source item if (qinfo->ReqSourceId[j] == itemid) { - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemid); // 'unique' item if (pProto->MaxCount && GetItemCount(itemid, true) < pProto->MaxCount) @@ -15662,7 +15662,7 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM uint32 item_lowguid = fields[12].GetUInt32(); uint32 item_id = fields[13].GetUInt32(); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id); + ItemPrototype const* proto = sObjectMgr.GetItemPrototype(item_id); if (!proto) { @@ -18414,7 +18414,7 @@ bool Player::BuyItemFromVendor(ObjectGuid vendorGuid, uint32 item, uint8 count, if (!IsAlive()) return false; - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(item); if (!pProto) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item, 0); @@ -21233,7 +21233,7 @@ bool Player::ChangeItemsForRace(uint8 oldRace, uint8 newRace) CHANGERACE_ERR("Pas de monture pour la race %u dans `player_factionchange_mounts` pour transferer %u.", mountNewRace, item->GetEntry()); continue; } - ItemPrototype const* pNewMountProto = ObjectMgr::GetItemPrototype(newMountId); + ItemPrototype const* pNewMountProto = sObjectMgr.GetItemPrototype(newMountId); CHANGERACE_LOG("Changement de la monture %u en %u.", item->GetEntry(), newMountId); if (!pNewMountProto || !item->ChangeEntry(pNewMountProto)) { @@ -21248,7 +21248,7 @@ bool Player::ChangeItemsForRace(uint8 oldRace, uint8 newRace) // 2- Les items a inverser for (std::map::const_iterator it = sObjectMgr.factionchange_items.begin(); it != sObjectMgr.factionchange_items.end(); ++it) { - ItemPrototype const* pNewItemProto = ObjectMgr::GetItemPrototype(newTeam == ALLIANCE ? it->first : it->second); + ItemPrototype const* pNewItemProto = sObjectMgr.GetItemPrototype(newTeam == ALLIANCE ? it->first : it->second); if (!pNewItemProto) continue; uint32 removeItemId = newTeam == ALLIANCE ? it->second : it->first; diff --git a/src/game/PlayerBots/CombatBotBaseAI.cpp b/src/game/PlayerBots/CombatBotBaseAI.cpp index aae46f320..1a3b5e8f1 100644 --- a/src/game/PlayerBots/CombatBotBaseAI.cpp +++ b/src/game/PlayerBots/CombatBotBaseAI.cpp @@ -2634,14 +2634,12 @@ void CombatBotBaseAI::EquipRandomGearInEmptySlots() LearnArmorProficiencies(); std::map> itemsPerSlot; - for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - ItemPrototype const* pProto = sItemStorage.LookupEntry(i); - if (!pProto) - continue; + ItemPrototype const* pProto = &itr.second; // Only items that have already been discovered by someone - if (!pProto->m_bDiscovered) + if (!pProto->Discovered) continue; // Skip unobtainable items @@ -2652,18 +2650,27 @@ void CombatBotBaseAI::EquipRandomGearInEmptySlots() if (pProto->Class != ITEM_CLASS_WEAPON && pProto->Class != ITEM_CLASS_ARMOR) continue; - // No item level check for tabards and shirts - if (pProto->InventoryType != INVTYPE_TABARD && pProto->InventoryType != INVTYPE_BODY) + // No tabards and shirts + if (pProto->InventoryType == INVTYPE_TABARD || pProto->InventoryType == INVTYPE_BODY) + continue; + + if (pProto->SourceQuestLevel < 0) { // Avoid higher level items with no level requirement if (!pProto->RequiredLevel && pProto->ItemLevel > me->GetLevel()) continue; - - // Avoid low level items - if ((pProto->ItemLevel + sWorld.getConfig(CONFIG_UINT32_PARTY_BOT_RANDOM_GEAR_LEVEL_DIFFERENCE)) < me->GetLevel()) + } + else + { + // Item is from a high level quest + if (uint32(pProto->SourceQuestLevel) > me->GetLevel()) continue; } + // Avoid low level items + if ((pProto->ItemLevel + sWorld.getConfig(CONFIG_UINT32_PARTY_BOT_RANDOM_GEAR_LEVEL_DIFFERENCE)) < me->GetLevel()) + continue; + if (me->CanUseItem(pProto) != EQUIP_ERR_OK) continue; @@ -2709,7 +2716,6 @@ void CombatBotBaseAI::EquipRandomGearInEmptySlots() continue; } - itemsPerSlot[slot].push_back(pProto); // Unique item @@ -2915,11 +2921,9 @@ void CombatBotBaseAI::AddHunterAmmo() } ItemPrototype const* pAmmoProto = nullptr; - for (uint32 i = 1; i < sItemStorage.GetMaxEntry(); ++i) + for (auto const& itr : sObjectMgr.GetItemPrototypeMap()) { - ItemPrototype const* pProto = sItemStorage.LookupEntry(i); - if (!pProto) - continue; + ItemPrototype const* pProto = &itr.second; if (pProto->Class == ITEM_CLASS_PROJECTILE && pProto->SubClass == ammoType && diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index 89fd3b515..9157079e6 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -451,7 +451,7 @@ void ScriptMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) case SCRIPT_COMMAND_REMOVE_ITEM: case SCRIPT_COMMAND_CREATE_ITEM: { - if (!ObjectMgr::GetItemPrototype(tmp.createItem.itemId)) + if (!sObjectMgr.GetItemPrototype(tmp.createItem.itemId)) { if (!sObjectMgr.IsExistingItemId(tmp.createItem.itemId)) { @@ -483,7 +483,7 @@ void ScriptMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) { if (tmp.setEquipment.slot[i] > 0) { - if (!ObjectMgr::GetItemPrototype(tmp.setEquipment.slot[i])) + if (!sObjectMgr.GetItemPrototype(tmp.setEquipment.slot[i])) { if (!sObjectMgr.IsExistingItemId(tmp.createItem.itemId)) { diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index b65308765..8daa607c4 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -4779,7 +4779,7 @@ void Spell::WriteAmmoToPacket(WorldPacket* data) uint32 ammoID = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID); if (ammoID) { - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(ammoID); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(ammoID); if (pProto) { ammoDisplayID = pProto->DisplayInfoID; @@ -7925,7 +7925,7 @@ SpellCastResult Spell::CheckItems() if (!ammo) return SPELL_FAILED_NO_AMMO; - ItemPrototype const* ammoProto = ObjectMgr::GetItemPrototype(ammo); + ItemPrototype const* ammoProto = sObjectMgr.GetItemPrototype(ammo); if (!ammoProto) return SPELL_FAILED_NO_AMMO; diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index ab9a98c00..928eea435 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -2562,7 +2562,7 @@ void Spell::DoCreateItem(SpellEffectIndex eff_idx, uint32 itemtype) Player* player = (Player*)unitTarget; uint32 newitemid = itemtype; - ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(newitemid); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(newitemid); if (!pProto) { player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr); diff --git a/src/game/Spells/SpellMgr.cpp b/src/game/Spells/SpellMgr.cpp index de77c508d..2b6528e1c 100644 --- a/src/game/Spells/SpellMgr.cpp +++ b/src/game/Spells/SpellMgr.cpp @@ -2273,7 +2273,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) // craft spell for crafting nonexistent item (break client recipes list show) case SPELL_EFFECT_CREATE_ITEM: { - if (!ObjectMgr::GetItemPrototype(spellInfo->EffectItemType[i])) + if (!sObjectMgr.GetItemPrototype(spellInfo->EffectItemType[i])) { if (msg) { @@ -2311,7 +2311,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) { for (int j : spellInfo->Reagent) { - if (j > 0 && !ObjectMgr::GetItemPrototype(j)) + if (j > 0 && !sObjectMgr.GetItemPrototype(j)) { if (msg) {