mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Globals: revert back to unordered_map for templates
Partial revert of commitb64c504314See discussion onb64c504314
This commit is contained in:
@@ -66,11 +66,10 @@ bool AuctionBotSeller::Initialize()
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "Loading npc vendor items for filter..");
|
||||
CreatureTemplateContainer const& creatures = sObjectMgr->GetCreatureTemplates();
|
||||
for (auto const& creatureTemplate : creatures)
|
||||
if (creatureTemplate)
|
||||
if (VendorItemData const* data = sObjectMgr->GetNpcVendorItemList(creatureTemplate->Entry))
|
||||
for (VendorItem const& vendorItem : data->m_items)
|
||||
npcItems.insert(vendorItem.item);
|
||||
for (auto const& creatureTemplatePair : creatures)
|
||||
if (VendorItemData const* data = sObjectMgr->GetNpcVendorItemList(creatureTemplatePair.first))
|
||||
for (VendorItem const& vendorItem : data->m_items)
|
||||
npcItems.insert(vendorItem.item);
|
||||
|
||||
TC_LOG_DEBUG("ahbot", "Npc vendor filter has %u items", (uint32)npcItems.size());
|
||||
|
||||
|
||||
@@ -927,15 +927,12 @@ void BattlegroundMgr::LoadBattleMastersEntry()
|
||||
void BattlegroundMgr::CheckBattleMasters()
|
||||
{
|
||||
CreatureTemplateContainer const& ctc = sObjectMgr->GetCreatureTemplates();
|
||||
for (auto const& creatureTemplate : ctc)
|
||||
for (auto const& creatureTemplatePair : ctc)
|
||||
{
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
if ((creatureTemplate->npcflag & UNIT_NPC_FLAG_BATTLEMASTER) && mBattleMastersMap.find(creatureTemplate->Entry) == mBattleMastersMap.end())
|
||||
if ((creatureTemplatePair.second.npcflag & UNIT_NPC_FLAG_BATTLEMASTER) && !mBattleMastersMap.count(creatureTemplatePair.first))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Creature_Template Entry: %u has UNIT_NPC_FLAG_BATTLEMASTER, but no data in the `battlemaster_entry` table. Removing flag.", creatureTemplate->Entry);
|
||||
const_cast<CreatureTemplate*>(creatureTemplate.get())->npcflag &= ~UNIT_NPC_FLAG_BATTLEMASTER;
|
||||
TC_LOG_ERROR("sql.sql", "Creature_Template Entry: %u has UNIT_NPC_FLAG_BATTLEMASTER, but no data in the `battlemaster_entry` table. Removing flag.", creatureTemplatePair.first);
|
||||
const_cast<CreatureTemplate&>(creatureTemplatePair.second).npcflag &= ~UNIT_NPC_FLAG_BATTLEMASTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "Bag.h"
|
||||
#include "Chat.h"
|
||||
#include "Containers.h"
|
||||
#include "CreatureAIFactory.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DisableMgr.h"
|
||||
@@ -376,7 +377,7 @@ void ObjectMgr::LoadCreatureTemplates()
|
||||
"InhabitType, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, "
|
||||
// 70 71 72 73 74 75
|
||||
"movementId, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName "
|
||||
"FROM creature_template ORDER BY entry DESC");
|
||||
"FROM creature_template");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -384,32 +385,24 @@ void ObjectMgr::LoadCreatureTemplates()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
uint32 const maxCreatureId = (*result)[0].GetUInt32();
|
||||
_creatureTemplateStore.resize(maxCreatureId + 1);
|
||||
_creatureTemplateStore.reserve(result->GetRowCount());
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
LoadCreatureTemplate(fields);
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
// Checking needs to be done after loading because of the difficulty self referencing
|
||||
for (auto const& creatureTemplate : _creatureTemplateStore)
|
||||
if (creatureTemplate)
|
||||
CheckCreatureTemplate(creatureTemplate.get());
|
||||
for (auto const& ctPair : _creatureTemplateStore)
|
||||
CheckCreatureTemplate(&ctPair.second);
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u creature definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " creature definitions in %u ms", _creatureTemplateStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureTemplate(Field* fields)
|
||||
{
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
|
||||
_creatureTemplateStore[entry] = Trinity::make_unique<CreatureTemplate>();
|
||||
CreatureTemplate& creatureTemplate = *_creatureTemplateStore[entry].get();
|
||||
CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry];
|
||||
|
||||
creatureTemplate.Entry = entry;
|
||||
|
||||
@@ -2479,7 +2472,7 @@ void ObjectMgr::LoadItemTemplates()
|
||||
// 126 127 128 129 130 131 132 133
|
||||
"GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
|
||||
// 134 135 136
|
||||
"FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template ORDER BY entry DESC");
|
||||
"FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -2487,9 +2480,7 @@ void ObjectMgr::LoadItemTemplates()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 const maxItemId = (*result)[0].GetUInt32();
|
||||
_itemTemplateStore.resize(maxItemId + 1);
|
||||
uint32 count = 0;
|
||||
_itemTemplateStore.reserve(result->GetRowCount());
|
||||
bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
|
||||
|
||||
do
|
||||
@@ -2497,9 +2488,7 @@ void ObjectMgr::LoadItemTemplates()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
|
||||
_itemTemplateStore[entry] = std::make_unique<ItemTemplate>();
|
||||
ItemTemplate& itemTemplate = *_itemTemplateStore[entry].get();
|
||||
ItemTemplate& itemTemplate = _itemTemplateStore[entry];
|
||||
|
||||
itemTemplate.ItemId = entry;
|
||||
itemTemplate.Class = uint32(fields[1].GetUInt8());
|
||||
@@ -3021,10 +3010,7 @@ void ObjectMgr::LoadItemTemplates()
|
||||
|
||||
// Load cached data
|
||||
itemTemplate._LoadTotalAP();
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
} while (result->NextRow());
|
||||
|
||||
// Check if item templates for DBC referenced character start outfit are present
|
||||
std::set<uint32> notFoundOutfit;
|
||||
@@ -3049,12 +3035,12 @@ void ObjectMgr::LoadItemTemplates()
|
||||
for (std::set<uint32>::const_iterator itr = notFoundOutfit.begin(); itr != notFoundOutfit.end(); ++itr)
|
||||
TC_LOG_ERROR("sql.sql", "Item (Entry: %u) does not exist in `item_template` but is referenced in `CharStartOutfit.dbc`", *itr);
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u item templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " item templates in %u ms", _itemTemplateStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
ItemTemplate const* ObjectMgr::GetItemTemplate(uint32 entry) const
|
||||
{
|
||||
return entry < _itemTemplateStore.size() ? _itemTemplateStore[entry].get() : nullptr;
|
||||
return Trinity::Containers::MapGetValuePtr(_itemTemplateStore, entry);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadItemSetNameLocales()
|
||||
@@ -4180,17 +4166,14 @@ void ObjectMgr::LoadQuests()
|
||||
"RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, "
|
||||
// 99 100 101 102 103
|
||||
"Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4"
|
||||
" FROM quest_template ORDER BY ID DESC");
|
||||
" FROM quest_template");
|
||||
if (!result)
|
||||
{
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 quests definitions. DB table `quest_template` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 const maxQuestId = (*result)[0].GetUInt32();
|
||||
_questTemplates.resize(maxQuestId + 1);
|
||||
|
||||
uint32 count = 0;
|
||||
_questTemplates.reserve(result->GetRowCount());
|
||||
|
||||
// create multimap previous quest for each existed quest
|
||||
// some quests can have many previous maps set by NextQuestId in previous quest
|
||||
@@ -4199,9 +4182,8 @@ void ObjectMgr::LoadQuests()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
std::unique_ptr<Quest> newQuest = Trinity::make_unique<Quest>(fields);
|
||||
_questTemplates[newQuest->GetQuestId()] = std::move(newQuest);
|
||||
++count;
|
||||
uint32 questId = fields[0].GetUInt32();
|
||||
_questTemplates.emplace(std::piecewise_construct, std::forward_as_tuple(questId), std::forward_as_tuple(fields));
|
||||
} while (result->NextRow());
|
||||
|
||||
std::unordered_map<uint32, uint32> usedMailTemplates;
|
||||
@@ -4248,11 +4230,9 @@ void ObjectMgr::LoadQuests()
|
||||
Field* fields = result->Fetch();
|
||||
uint32 questId = fields[0].GetUInt32();
|
||||
|
||||
if (questId < _questTemplates.size() && _questTemplates[questId])
|
||||
{
|
||||
Quest* const quest = _questTemplates[questId].get();
|
||||
(quest->*loader.LoaderFunction)(fields);
|
||||
}
|
||||
auto itr = _questTemplates.find(questId);
|
||||
if (itr != _questTemplates.end())
|
||||
(itr->second.*loader.LoaderFunction)(fields);
|
||||
else
|
||||
TC_LOG_ERROR("server.loading", "Table `%s` has data for quest %u but such quest does not exist", loader.TableName, questId);
|
||||
} while (result->NextRow());
|
||||
@@ -4260,14 +4240,13 @@ void ObjectMgr::LoadQuests()
|
||||
}
|
||||
|
||||
// Post processing
|
||||
for (auto& qinfo : _questTemplates)
|
||||
for (auto& questPair : _questTemplates)
|
||||
{
|
||||
if (!qinfo)
|
||||
// skip post-loading checks for disabled quests
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, questPair.first, nullptr))
|
||||
continue;
|
||||
|
||||
// skip post-loading checks for disabled quests
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, qinfo->GetQuestId(), nullptr))
|
||||
continue;
|
||||
Quest* qinfo = &questPair.second;
|
||||
|
||||
// additional quest integrity checks (GO, creature_template and item_template must be loaded already)
|
||||
|
||||
@@ -4760,7 +4739,7 @@ void ObjectMgr::LoadQuests()
|
||||
|
||||
if (uint32 rewardNextQuest = qinfo->_rewardNextQuest)
|
||||
{
|
||||
if (rewardNextQuest >= _questTemplates.size() || !_questTemplates[rewardNextQuest])
|
||||
if (!_questTemplates.count(rewardNextQuest))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Quest %u has `RewardNextQuest` = %u but quest %u does not exist, quest chain will not work.",
|
||||
qinfo->GetQuestId(), qinfo->_rewardNextQuest, qinfo->_rewardNextQuest);
|
||||
@@ -4771,16 +4750,17 @@ void ObjectMgr::LoadQuests()
|
||||
// fill additional data stores
|
||||
if (uint32 prevQuestId = std::abs(qinfo->_prevQuestId))
|
||||
{
|
||||
if (prevQuestId >= _questTemplates.size() || !_questTemplates[prevQuestId])
|
||||
if (!_questTemplates.count(prevQuestId))
|
||||
TC_LOG_ERROR("sql.sql", "Quest %u has PrevQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->_prevQuestId);
|
||||
}
|
||||
|
||||
if (uint32 nextQuestId = qinfo->_nextQuestId)
|
||||
{
|
||||
if (nextQuestId >= _questTemplates.size() || !_questTemplates[nextQuestId])
|
||||
auto nextQuestItr = _questTemplates.find(nextQuestId);
|
||||
if (nextQuestItr == _questTemplates.end())
|
||||
TC_LOG_ERROR("sql.sql", "Quest %u has NextQuestId %u, but no such quest", qinfo->GetQuestId(), qinfo->_nextQuestId);
|
||||
else
|
||||
_questTemplates[nextQuestId]->DependentPreviousQuests.push_back(qinfo->GetQuestId());
|
||||
nextQuestItr->second.DependentPreviousQuests.push_back(qinfo->GetQuestId());
|
||||
}
|
||||
|
||||
if (qinfo->_exclusiveGroup)
|
||||
@@ -4841,7 +4821,7 @@ void ObjectMgr::LoadQuests()
|
||||
}
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u quests definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " quests definitions in %u ms", _questTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadQuestStartersAndEnders()
|
||||
@@ -5237,14 +5217,9 @@ void ObjectMgr::LoadEventScripts()
|
||||
|
||||
std::set<uint32> evt_scripts;
|
||||
// Load all possible script entries from gameobjects
|
||||
for (auto const& gameObjectTemplate : _gameObjectTemplateStore)
|
||||
{
|
||||
if (!gameObjectTemplate)
|
||||
continue;
|
||||
|
||||
if (uint32 eventId = gameObjectTemplate->GetEventScriptId())
|
||||
for (auto const& gameObjectTemplatePair : _gameObjectTemplateStore)
|
||||
if (uint32 eventId = gameObjectTemplatePair.second.GetEventScriptId())
|
||||
evt_scripts.insert(eventId);
|
||||
}
|
||||
|
||||
// Load all possible script entries from spells
|
||||
for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
|
||||
@@ -6277,7 +6252,7 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt
|
||||
|
||||
Quest const* ObjectMgr::GetQuestTemplate(uint32 quest_id) const
|
||||
{
|
||||
return quest_id < _questTemplates.size() ? _questTemplates[quest_id].get() : nullptr;
|
||||
return Trinity::Containers::MapGetValuePtr(_questTemplates, quest_id);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGraveyardZones()
|
||||
@@ -7000,7 +6975,7 @@ void ObjectMgr::LoadGameObjectTemplate()
|
||||
"Data0, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, "
|
||||
// 21 22 23 24 25 26 27 28 29 30 31 32 33
|
||||
"Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20, Data21, Data22, Data23, AIName, ScriptName "
|
||||
"FROM gameobject_template ORDER BY entry DESC");
|
||||
"FROM gameobject_template");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -7008,17 +6983,14 @@ void ObjectMgr::LoadGameObjectTemplate()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 const maxGameObjectId = (*result)[0].GetUInt32();
|
||||
_gameObjectTemplateStore.resize(maxGameObjectId + 1);
|
||||
uint32 count = 0;
|
||||
_gameObjectTemplateStore.reserve(result->GetRowCount());
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
|
||||
_gameObjectTemplateStore[entry] = Trinity::make_unique<GameObjectTemplate>();
|
||||
GameObjectTemplate& got = *_gameObjectTemplateStore[entry].get();
|
||||
GameObjectTemplate& got = _gameObjectTemplateStore[entry];
|
||||
got.entry = entry;
|
||||
got.type = uint32(fields[1].GetUInt8());
|
||||
got.displayId = fields[2].GetUInt32();
|
||||
@@ -7171,12 +7143,9 @@ void ObjectMgr::LoadGameObjectTemplate()
|
||||
CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0);
|
||||
break;
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u game object templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " game object templates in %u ms", _gameObjectTemplateStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGameObjectTemplateAddons()
|
||||
@@ -7645,18 +7614,15 @@ void ObjectMgr::LoadQuestPOI()
|
||||
|
||||
_questPOIStore.clear(); // need for reload case
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
// 0 1 2 3 4 5 6 7
|
||||
QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID DESC");
|
||||
QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi");
|
||||
if (!result)
|
||||
{
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 const maxQuestId = (*result)[0].GetUInt32();
|
||||
_questPOIStore.resize(maxQuestId + 1);
|
||||
_questPOIStore.reserve(result->GetRowCount());
|
||||
|
||||
// 0 1 2 3
|
||||
QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2");
|
||||
@@ -7715,26 +7681,24 @@ void ObjectMgr::LoadQuestPOI()
|
||||
{
|
||||
POI.QuestPOIBlobPointStats = POIs[questId][id];
|
||||
|
||||
auto& questPOI = _questPOIStore[questId];
|
||||
if (!questPOI)
|
||||
auto itr = _questPOIStore.find(questId);
|
||||
if (itr == _questPOIStore.end())
|
||||
{
|
||||
QuestPOIWrapper wrapper;
|
||||
QuestPOIData data;
|
||||
data.QuestID = questId;
|
||||
wrapper.POIData = data;
|
||||
|
||||
questPOI = Trinity::make_unique<QuestPOIWrapper>(std::move(wrapper));
|
||||
std::tie(itr, std::ignore) = _questPOIStore.emplace(questId, std::move(wrapper));
|
||||
}
|
||||
|
||||
questPOI->POIData.QuestPOIBlobDataStats.push_back(POI);
|
||||
itr->second.POIData.QuestPOIBlobDataStats.push_back(POI);
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest %u POI id %u", questId, id);
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u quest POI definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " quest POI definitions in %u ms", _questPOIStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadNPCSpellClickSpells()
|
||||
@@ -7790,15 +7754,12 @@ void ObjectMgr::LoadNPCSpellClickSpells()
|
||||
|
||||
// all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
|
||||
// NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
|
||||
for (auto const& creatureTemplate : _creatureTemplateStore)
|
||||
for (auto& creatureTemplatePair : _creatureTemplateStore)
|
||||
{
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
if ((creatureTemplate->npcflag & UNIT_NPC_FLAG_SPELLCLICK) && _spellClickInfoStore.find(creatureTemplate->Entry) == _spellClickInfoStore.end())
|
||||
if ((creatureTemplatePair.second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && !_spellClickInfoStore.count(creatureTemplatePair.first))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "npc_spellclick_spells: Creature template %u has UNIT_NPC_FLAG_SPELLCLICK but no data in spellclick table! Removing flag", creatureTemplate->Entry);
|
||||
const_cast<CreatureTemplate*>(creatureTemplate.get())->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
|
||||
TC_LOG_ERROR("sql.sql", "npc_spellclick_spells: Creature template %u has UNIT_NPC_FLAG_SPELLCLICK but no data in spellclick table! Removing flag", creatureTemplatePair.first);
|
||||
creatureTemplatePair.second.npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7857,7 +7818,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, QuestRelationsReve
|
||||
uint32 quest = result->Fetch()[1].GetUInt32();
|
||||
uint32 poolId = result->Fetch()[2].GetUInt32();
|
||||
|
||||
if (quest >= _questTemplates.size() || !_questTemplates[quest])
|
||||
if (!_questTemplates.count(quest))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `%s`: Quest %u listed for entry %u does not exist.", table.c_str(), quest, id);
|
||||
continue;
|
||||
@@ -8146,50 +8107,39 @@ void ObjectMgr::LoadGameObjectForQuests()
|
||||
uint32 count = 0;
|
||||
|
||||
// collect GO entries for GO that must activated
|
||||
for (auto const& gameObjectTemplate : _gameObjectTemplateStore)
|
||||
for (auto const& gameObjectTemplatePair : _gameObjectTemplateStore)
|
||||
{
|
||||
if (!gameObjectTemplate)
|
||||
continue;
|
||||
|
||||
switch (gameObjectTemplate->type)
|
||||
switch (gameObjectTemplatePair.second.type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER:
|
||||
_gameObjectForQuestStore.insert(gameObjectTemplate->entry);
|
||||
++count;
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
{
|
||||
// scan GO chest with loot including quest items
|
||||
uint32 lootId = gameObjectTemplate->GetLootId();
|
||||
uint32 lootId = gameObjectTemplatePair.second.GetLootId();
|
||||
// find quest loot for GO
|
||||
if (gameObjectTemplate->chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(lootId))
|
||||
{
|
||||
_gameObjectForQuestStore.insert(gameObjectTemplate->entry);
|
||||
++count;
|
||||
}
|
||||
break;
|
||||
if (gameObjectTemplatePair.second.chest.questId || LootTemplates_Gameobject.HaveQuestLootFor(lootId))
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_GENERIC:
|
||||
{
|
||||
if (gameObjectTemplate->_generic.questID > 0) //quests objects
|
||||
{
|
||||
_gameObjectForQuestStore.insert(gameObjectTemplate->entry);
|
||||
++count;
|
||||
}
|
||||
break;
|
||||
if (gameObjectTemplatePair.second._generic.questID > 0) //quests objects
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
{
|
||||
if (gameObjectTemplate->goober.questId > 0) //quests objects
|
||||
{
|
||||
_gameObjectForQuestStore.insert(gameObjectTemplate->entry);
|
||||
++count;
|
||||
}
|
||||
break;
|
||||
if (gameObjectTemplatePair.second.goober.questId > 0) //quests objects
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
_gameObjectForQuestStore.insert(gameObjectTemplatePair.first);
|
||||
++count;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u GameObjects for quests in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -8693,7 +8643,7 @@ void ObjectMgr::LoadTrainerSpell()
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %d Trainers in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::LoadReferenceVendor(int32 vendor, int32 item, std::set<uint32> *skip_vendors)
|
||||
uint32 ObjectMgr::LoadReferenceVendor(int32 vendor, int32 item, std::set<uint32>* skip_vendors)
|
||||
{
|
||||
// find all items from the reference vendor
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_NPC_VENDOR_REF);
|
||||
@@ -9301,15 +9251,12 @@ void ObjectMgr::LoadCreatureClassLevelStats()
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
for (auto const& creatureTemplate : _creatureTemplateStore)
|
||||
for (auto const& creatureTemplatePair : _creatureTemplateStore)
|
||||
{
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
for (uint16 lvl = creatureTemplate->minlevel; lvl <= creatureTemplate->maxlevel; ++lvl)
|
||||
for (uint16 lvl = creatureTemplatePair.second.minlevel; lvl <= creatureTemplatePair.second.maxlevel; ++lvl)
|
||||
{
|
||||
if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, creatureTemplate->unit_class)) == _creatureBaseStatsStore.end())
|
||||
TC_LOG_ERROR("sql.sql", "Missing base stats for creature class %u level %u", creatureTemplate->unit_class, lvl);
|
||||
if (!_creatureBaseStatsStore.count(MAKE_PAIR16(lvl, creatureTemplatePair.second.unit_class)))
|
||||
TC_LOG_ERROR("sql.sql", "Missing base stats for creature class %u level %u", creatureTemplatePair.second.unit_class, lvl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9528,7 +9475,7 @@ void ObjectMgr::LoadFactionChangeTitles()
|
||||
|
||||
GameObjectTemplate const* ObjectMgr::GetGameObjectTemplate(uint32 entry) const
|
||||
{
|
||||
return entry < _gameObjectTemplateStore.size() ? _gameObjectTemplateStore[entry].get() : nullptr;
|
||||
return Trinity::Containers::MapGetValuePtr(_gameObjectTemplateStore, entry);
|
||||
}
|
||||
|
||||
GameObjectTemplateAddon const* ObjectMgr::GetGameObjectTemplateAddon(uint32 entry) const
|
||||
@@ -9542,12 +9489,12 @@ GameObjectTemplateAddon const* ObjectMgr::GetGameObjectTemplateAddon(uint32 entr
|
||||
|
||||
CreatureTemplate const* ObjectMgr::GetCreatureTemplate(uint32 entry) const
|
||||
{
|
||||
return entry < _creatureTemplateStore.size() ? _creatureTemplateStore[entry].get() : nullptr;
|
||||
return Trinity::Containers::MapGetValuePtr(_creatureTemplateStore, entry);
|
||||
}
|
||||
|
||||
QuestPOIWrapper const* ObjectMgr::GetQuestPOIWrapper(uint32 questId) const
|
||||
{
|
||||
return questId < _questPOIStore.size() ? _questPOIStore[questId].get() : nullptr;
|
||||
return Trinity::Containers::MapGetValuePtr(_questPOIStore, questId);
|
||||
}
|
||||
|
||||
VehicleAccessoryList const* ObjectMgr::GetVehicleAccessoryList(Vehicle* veh) const
|
||||
@@ -9685,33 +9632,28 @@ void ObjectMgr::InitializeQueriesData(QueryDataGroup mask)
|
||||
|
||||
// Initialize Query data for creatures
|
||||
if (mask & QUERY_DATA_CREATURES)
|
||||
for (auto const& creatureTemplate : _creatureTemplateStore)
|
||||
if (creatureTemplate)
|
||||
creatureTemplate->InitializeQueryData();
|
||||
for (auto& creatureTemplatePair : _creatureTemplateStore)
|
||||
creatureTemplatePair.second.InitializeQueryData();
|
||||
|
||||
// Initialize Query Data for gameobjects
|
||||
if (mask & QUERY_DATA_GAMEOBJECTS)
|
||||
for (auto const& gameObjectTemplate : _gameObjectTemplateStore)
|
||||
if (gameObjectTemplate)
|
||||
gameObjectTemplate->InitializeQueryData();
|
||||
for (auto& gameObjectTemplatePair : _gameObjectTemplateStore)
|
||||
gameObjectTemplatePair.second.InitializeQueryData();
|
||||
|
||||
// Initialize Query Data for items
|
||||
if (mask & QUERY_DATA_ITEMS)
|
||||
for (auto const& itemTemplate : _itemTemplateStore)
|
||||
if (itemTemplate)
|
||||
itemTemplate->InitializeQueryData();
|
||||
for (auto& itemTemplatePair : _itemTemplateStore)
|
||||
itemTemplatePair.second.InitializeQueryData();
|
||||
|
||||
// Initialize Query Data for quests
|
||||
if (mask & QUERY_DATA_QUESTS)
|
||||
for (auto const& questTemplate : _questTemplates)
|
||||
if (questTemplate)
|
||||
questTemplate->InitializeQueryData();
|
||||
for (auto& questTemplatePair : _questTemplates)
|
||||
questTemplatePair.second.InitializeQueryData();
|
||||
|
||||
// Initialize Quest POI data
|
||||
if (mask & QUERY_DATA_POIS)
|
||||
for (auto const& poiTemplate : _questPOIStore)
|
||||
if (poiTemplate)
|
||||
poiTemplate->InitializeQueryData();
|
||||
for (auto& poiWrapperPair : _questPOIStore)
|
||||
poiWrapperPair.second.InitializeQueryData();
|
||||
}
|
||||
|
||||
void QuestPOIWrapper::InitializeQueryData()
|
||||
|
||||
@@ -169,7 +169,7 @@ struct GameTele
|
||||
std::wstring wnameLow;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, GameTele > GameTeleContainer;
|
||||
typedef std::unordered_map<uint32, GameTele> GameTeleContainer;
|
||||
|
||||
enum ScriptsType
|
||||
{
|
||||
@@ -411,7 +411,7 @@ struct ScriptInfo
|
||||
};
|
||||
|
||||
typedef std::multimap<uint32, ScriptInfo> ScriptMap;
|
||||
typedef std::map<uint32, ScriptMap > ScriptMapMap;
|
||||
typedef std::map<uint32, ScriptMap> ScriptMapMap;
|
||||
typedef std::multimap<uint32 /*spell id*/, std::pair<uint32 /*script id*/, bool /*enabled*/>> SpellScriptsContainer;
|
||||
typedef std::pair<SpellScriptsContainer::iterator, SpellScriptsContainer::iterator> SpellScriptsBounds;
|
||||
TC_GAME_API extern ScriptMapMap sSpellScripts;
|
||||
@@ -538,7 +538,7 @@ struct QuestGreetingLocale
|
||||
};
|
||||
|
||||
typedef std::map<ObjectGuid, ObjectGuid> LinkedRespawnContainer;
|
||||
typedef std::vector<std::unique_ptr<CreatureTemplate>> CreatureTemplateContainer;
|
||||
typedef std::unordered_map<uint32, CreatureTemplate> CreatureTemplateContainer;
|
||||
typedef std::unordered_map<uint32, CreatureAddon> CreatureTemplateAddonContainer;
|
||||
typedef std::unordered_map<ObjectGuid::LowType, CreatureData> CreatureDataContainer;
|
||||
typedef std::unordered_map<ObjectGuid::LowType, CreatureAddon> CreatureAddonContainer;
|
||||
@@ -547,7 +547,7 @@ typedef std::unordered_map<uint8, EquipmentInfo> EquipmentInfoContainerInternal;
|
||||
typedef std::unordered_map<uint32, EquipmentInfoContainerInternal> EquipmentInfoContainer;
|
||||
typedef std::unordered_map<uint32, CreatureModelInfo> CreatureModelContainer;
|
||||
typedef std::unordered_map<uint32, std::vector<uint32>> CreatureQuestItemMap;
|
||||
typedef std::vector<std::unique_ptr<GameObjectTemplate>> GameObjectTemplateContainer;
|
||||
typedef std::unordered_map<uint32, GameObjectTemplate> GameObjectTemplateContainer;
|
||||
typedef std::unordered_map<uint32, GameObjectTemplateAddon> GameObjectTemplateAddonContainer;
|
||||
typedef std::unordered_map<ObjectGuid::LowType, GameObjectData> GameObjectDataContainer;
|
||||
typedef std::unordered_map<ObjectGuid::LowType, GameObjectAddon> GameObjectAddonContainer;
|
||||
@@ -558,7 +558,7 @@ typedef std::unordered_map<uint16, std::vector<InstanceSpawnGroupInfo>> Instance
|
||||
typedef std::map<TempSummonGroupKey, std::vector<TempSummonData>> TempSummonDataContainer;
|
||||
typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleContainer;
|
||||
typedef std::unordered_map<uint32, GameObjectLocale> GameObjectLocaleContainer;
|
||||
typedef std::vector<std::unique_ptr<ItemTemplate>> ItemTemplateContainer;
|
||||
typedef std::unordered_map<uint32, ItemTemplate> ItemTemplateContainer;
|
||||
typedef std::unordered_map<uint32, ItemLocale> ItemLocaleContainer;
|
||||
typedef std::unordered_map<uint32, ItemSetNameLocale> ItemSetNameLocaleContainer;
|
||||
typedef std::unordered_map<uint32, QuestLocale> QuestLocaleContainer;
|
||||
@@ -798,7 +798,7 @@ struct QuestPOIWrapper
|
||||
QuestPOIWrapper() : QueryDataBuffer(0) { }
|
||||
};
|
||||
|
||||
typedef std::vector<std::unique_ptr<QuestPOIWrapper>> QuestPOIContainer;
|
||||
typedef std::unordered_map<uint32, QuestPOIWrapper> QuestPOIContainer;
|
||||
|
||||
struct QuestGreeting
|
||||
{
|
||||
@@ -905,7 +905,7 @@ class TC_GAME_API ObjectMgr
|
||||
|
||||
static ObjectMgr* instance();
|
||||
|
||||
typedef std::vector<std::unique_ptr<Quest>> QuestContainer;
|
||||
typedef std::unordered_map<uint32, Quest> QuestContainer;
|
||||
|
||||
typedef std::unordered_map<uint32, AreaTrigger> AreaTriggerContainer;
|
||||
|
||||
@@ -925,7 +925,7 @@ class TC_GAME_API ObjectMgr
|
||||
|
||||
GameObjectTemplate const* GetGameObjectTemplate(uint32 entry) const;
|
||||
GameObjectTemplateContainer const& GetGameObjectTemplates() const { return _gameObjectTemplateStore; }
|
||||
uint32 LoadReferenceVendor(int32 vendor, int32 item_id, std::set<uint32> *skip_vendors);
|
||||
uint32 LoadReferenceVendor(int32 vendor, int32 item_id, std::set<uint32>* skip_vendors);
|
||||
|
||||
void LoadGameObjectTemplate();
|
||||
void LoadGameObjectTemplateAddons();
|
||||
|
||||
@@ -1959,17 +1959,14 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
||||
// Disable all old-faction specific quests
|
||||
{
|
||||
ObjectMgr::QuestContainer const& questTemplates = sObjectMgr->GetQuestTemplates();
|
||||
for (auto const& quest : questTemplates)
|
||||
for (auto const& questTemplatePair : questTemplates)
|
||||
{
|
||||
if (!quest)
|
||||
continue;
|
||||
|
||||
uint32 newRaceMask = (newTeam == ALLIANCE) ? RACEMASK_ALLIANCE : RACEMASK_HORDE;
|
||||
if (!(quest->GetAllowableRaces() & newRaceMask))
|
||||
if (!(questTemplatePair.second.GetAllowableRaces() & newRaceMask))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_QUESTSTATUS_REWARDED_ACTIVE_BY_QUEST);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->setUInt32(1, quest->GetQuestId());
|
||||
stmt->setUInt32(1, questTemplatePair.first);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,15 +789,12 @@ void LoadLootTemplates_Creature()
|
||||
|
||||
// Remove real entries and check loot existence
|
||||
CreatureTemplateContainer const& ctc = sObjectMgr->GetCreatureTemplates();
|
||||
for (auto const& creatureTemplate : ctc)
|
||||
for (auto const& creatureTemplatePair : ctc)
|
||||
{
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
if (uint32 lootid = creatureTemplate->lootid)
|
||||
if (uint32 lootid = creatureTemplatePair.second.lootid)
|
||||
{
|
||||
if (lootIdSet.find(lootid) == lootIdSet.end())
|
||||
LootTemplates_Creature.ReportNonExistingId(lootid, "Creature", creatureTemplate->Entry);
|
||||
if (!lootIdSet.count(lootid))
|
||||
LootTemplates_Creature.ReportNonExistingId(lootid, "Creature", creatureTemplatePair.first);
|
||||
else
|
||||
lootIdSetUsed.insert(lootid);
|
||||
}
|
||||
@@ -828,15 +825,12 @@ void LoadLootTemplates_Disenchant()
|
||||
uint32 count = LootTemplates_Disenchant.LoadAndCollectLootIds(lootIdSet);
|
||||
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplate : its)
|
||||
for (auto const& itemTemplatePair : its)
|
||||
{
|
||||
if (!itemTemplate)
|
||||
continue;
|
||||
|
||||
if (uint32 lootid = itemTemplate->DisenchantID)
|
||||
if (uint32 lootid = itemTemplatePair.second.DisenchantID)
|
||||
{
|
||||
if (lootIdSet.find(lootid) == lootIdSet.end())
|
||||
LootTemplates_Disenchant.ReportNonExistingId(lootid, "Item", itemTemplate->ItemId);
|
||||
if (!lootIdSet.count(lootid))
|
||||
LootTemplates_Disenchant.ReportNonExistingId(lootid, "Item", itemTemplatePair.first);
|
||||
else
|
||||
lootIdSetUsed.insert(lootid);
|
||||
}
|
||||
@@ -888,15 +882,12 @@ void LoadLootTemplates_Gameobject()
|
||||
|
||||
// remove real entries and check existence loot
|
||||
GameObjectTemplateContainer const& gotc = sObjectMgr->GetGameObjectTemplates();
|
||||
for (auto const& gameObjectTemplate : gotc)
|
||||
for (auto const& gameObjectTemplatePair : gotc)
|
||||
{
|
||||
if (!gameObjectTemplate)
|
||||
continue;
|
||||
|
||||
if (uint32 lootid = gameObjectTemplate->GetLootId())
|
||||
if (uint32 lootid = gameObjectTemplatePair.second.GetLootId())
|
||||
{
|
||||
if (lootIdSet.find(lootid) == lootIdSet.end())
|
||||
LootTemplates_Gameobject.ReportNonExistingId(lootid, "Gameobject", gameObjectTemplate->entry);
|
||||
if (!lootIdSet.count(lootid))
|
||||
LootTemplates_Gameobject.ReportNonExistingId(lootid, "Gameobject", gameObjectTemplatePair.first);
|
||||
else
|
||||
lootIdSetUsed.insert(lootid);
|
||||
}
|
||||
@@ -925,14 +916,9 @@ void LoadLootTemplates_Item()
|
||||
|
||||
// remove real entries and check existence loot
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplate : its)
|
||||
{
|
||||
if (!itemTemplate)
|
||||
continue;
|
||||
|
||||
if (lootIdSet.find(itemTemplate->ItemId) != lootIdSet.end() && (itemTemplate->Flags & ITEM_FLAG_HAS_LOOT))
|
||||
lootIdSet.erase(itemTemplate->ItemId);
|
||||
}
|
||||
for (auto const& itemTemplatePair : its)
|
||||
if (lootIdSet.count(itemTemplatePair.first) > 0 && (itemTemplatePair.second.Flags & ITEM_FLAG_HAS_LOOT))
|
||||
lootIdSet.erase(itemTemplatePair.first);
|
||||
|
||||
// output error for any still listed (not referenced from appropriate table) ids
|
||||
LootTemplates_Item.ReportUnusedIds(lootIdSet);
|
||||
@@ -954,13 +940,13 @@ void LoadLootTemplates_Milling()
|
||||
|
||||
// remove real entries and check existence loot
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplate : its)
|
||||
for (auto const& itemTemplatePair : its)
|
||||
{
|
||||
if (!itemTemplate || !(itemTemplate->Flags & ITEM_FLAG_IS_MILLABLE))
|
||||
if (!(itemTemplatePair.second.Flags & ITEM_FLAG_IS_MILLABLE))
|
||||
continue;
|
||||
|
||||
if (lootIdSet.find(itemTemplate->ItemId) != lootIdSet.end())
|
||||
lootIdSet.erase(itemTemplate->ItemId);
|
||||
if (lootIdSet.count(itemTemplatePair.first) > 0)
|
||||
lootIdSet.erase(itemTemplatePair.first);
|
||||
}
|
||||
|
||||
// output error for any still listed (not referenced from appropriate table) ids
|
||||
@@ -983,15 +969,12 @@ void LoadLootTemplates_Pickpocketing()
|
||||
|
||||
// Remove real entries and check loot existence
|
||||
CreatureTemplateContainer const& ctc = sObjectMgr->GetCreatureTemplates();
|
||||
for (auto const& creatureTemplate : ctc)
|
||||
for (auto const& creatureTemplatePair : ctc)
|
||||
{
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
if (uint32 lootid = creatureTemplate->pickpocketLootId)
|
||||
if (uint32 lootid = creatureTemplatePair.second.pickpocketLootId)
|
||||
{
|
||||
if (lootIdSet.find(lootid) == lootIdSet.end())
|
||||
LootTemplates_Pickpocketing.ReportNonExistingId(lootid, "Creature", creatureTemplate->Entry);
|
||||
if (!lootIdSet.count(lootid))
|
||||
LootTemplates_Pickpocketing.ReportNonExistingId(lootid, "Creature", creatureTemplatePair.first);
|
||||
else
|
||||
lootIdSetUsed.insert(lootid);
|
||||
}
|
||||
@@ -1020,13 +1003,13 @@ void LoadLootTemplates_Prospecting()
|
||||
|
||||
// remove real entries and check existence loot
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplate : its)
|
||||
for (auto const& itemTemplatePair : its)
|
||||
{
|
||||
if (!itemTemplate || !(itemTemplate->Flags & ITEM_FLAG_IS_PROSPECTABLE))
|
||||
if (!(itemTemplatePair.second.Flags & ITEM_FLAG_IS_PROSPECTABLE))
|
||||
continue;
|
||||
|
||||
if (lootIdSet.find(itemTemplate->ItemId) != lootIdSet.end())
|
||||
lootIdSet.erase(itemTemplate->ItemId);
|
||||
if (lootIdSet.count(itemTemplatePair.first) > 0)
|
||||
lootIdSet.erase(itemTemplatePair.first);
|
||||
}
|
||||
|
||||
// output error for any still listed (not referenced from appropriate table) ids
|
||||
@@ -1073,15 +1056,12 @@ void LoadLootTemplates_Skinning()
|
||||
|
||||
// remove real entries and check existence loot
|
||||
CreatureTemplateContainer const& ctc = sObjectMgr->GetCreatureTemplates();
|
||||
for (auto const& creatureTemplate : ctc)
|
||||
for (auto const& creatureTemplatePair : ctc)
|
||||
{
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
if (uint32 lootid = creatureTemplate->SkinLootId)
|
||||
if (uint32 lootid = creatureTemplatePair.second.SkinLootId)
|
||||
{
|
||||
if (lootIdSet.find(lootid) == lootIdSet.end())
|
||||
LootTemplates_Skinning.ReportNonExistingId(lootid, "Creature", creatureTemplate->Entry);
|
||||
if (!lootIdSet.count(lootid))
|
||||
LootTemplates_Skinning.ReportNonExistingId(lootid, "Creature", creatureTemplatePair.first);
|
||||
else
|
||||
lootIdSetUsed.insert(lootid);
|
||||
}
|
||||
|
||||
@@ -2270,22 +2270,22 @@ void SpellMgr::LoadPetDefaultSpells()
|
||||
uint32 countData = 0;
|
||||
|
||||
CreatureTemplateContainer const& ctc = sObjectMgr->GetCreatureTemplates();
|
||||
for (auto const& creatureTemplate : ctc)
|
||||
for (auto const& creatureTemplatePair : ctc)
|
||||
{
|
||||
if (!creatureTemplate || !creatureTemplate->PetSpellDataId)
|
||||
if (!creatureTemplatePair.second.PetSpellDataId)
|
||||
continue;
|
||||
|
||||
// for creature with PetSpellDataId get default pet spells from dbc
|
||||
CreatureSpellDataEntry const* spellDataEntry = sCreatureSpellDataStore.LookupEntry(creatureTemplate->PetSpellDataId);
|
||||
CreatureSpellDataEntry const* spellDataEntry = sCreatureSpellDataStore.LookupEntry(creatureTemplatePair.second.PetSpellDataId);
|
||||
if (!spellDataEntry)
|
||||
continue;
|
||||
|
||||
int32 petSpellsId = -int32(creatureTemplate->PetSpellDataId);
|
||||
int32 petSpellsId = -int32(creatureTemplatePair.second.PetSpellDataId);
|
||||
PetDefaultSpellsEntry petDefSpells;
|
||||
for (uint8 j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
|
||||
petDefSpells.spellid[j] = spellDataEntry->spellId[j];
|
||||
|
||||
if (LoadPetDefaultSpells_helper(creatureTemplate.get(), petDefSpells))
|
||||
if (LoadPetDefaultSpells_helper(&creatureTemplatePair.second, petDefSpells))
|
||||
{
|
||||
mPetDefaultSpellsMap[petSpellsId] = petDefSpells;
|
||||
++countData;
|
||||
|
||||
@@ -177,12 +177,9 @@ public:
|
||||
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
|
||||
|
||||
CreatureTemplateContainer const& ctc = sObjectMgr->GetCreatureTemplates();
|
||||
for (auto const& creatureTemplate : ctc)
|
||||
for (auto const& creatureTemplatePair : ctc)
|
||||
{
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
uint32 id = creatureTemplate->Entry;
|
||||
uint32 id = creatureTemplatePair.first;
|
||||
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
|
||||
if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(id))
|
||||
{
|
||||
@@ -211,7 +208,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string const& name = creatureTemplate->Name;
|
||||
std::string const& name = creatureTemplatePair.second.Name;
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
@@ -416,16 +413,13 @@ public:
|
||||
|
||||
// Search in `item_template`
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplate : its)
|
||||
for (auto const& itemTemplatePair : its)
|
||||
{
|
||||
if (!itemTemplate)
|
||||
continue;
|
||||
|
||||
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
|
||||
if (localeIndex >= 0)
|
||||
{
|
||||
uint8 ulocaleIndex = uint8(localeIndex);
|
||||
if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplate->ItemId))
|
||||
if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplatePair.first))
|
||||
{
|
||||
if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty())
|
||||
{
|
||||
@@ -440,9 +434,9 @@ public:
|
||||
}
|
||||
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate->ItemId, itemTemplate->ItemId, name.c_str());
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplatePair.first, itemTemplatePair.first, name.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate->ItemId, name.c_str());
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplatePair.first, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
@@ -453,7 +447,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string const& name = itemTemplate->Name1;
|
||||
std::string const& name = itemTemplatePair.second.Name1;
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
@@ -466,9 +460,9 @@ public:
|
||||
}
|
||||
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate->ItemId, itemTemplate->ItemId, name.c_str());
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplatePair.first, itemTemplatePair.first, name.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate->ItemId, name.c_str());
|
||||
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplatePair.first, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
@@ -571,13 +565,10 @@ public:
|
||||
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
|
||||
|
||||
GameObjectTemplateContainer const& gotc = sObjectMgr->GetGameObjectTemplates();
|
||||
for (auto const& gameObjectTemplate : gotc)
|
||||
for (auto const& gameObjectTemplatePair : gotc)
|
||||
{
|
||||
if (!gameObjectTemplate)
|
||||
continue;
|
||||
|
||||
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
|
||||
if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplate->entry))
|
||||
if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplatePair.first))
|
||||
{
|
||||
if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
|
||||
{
|
||||
@@ -591,9 +582,9 @@ public:
|
||||
}
|
||||
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate->entry, gameObjectTemplate->entry, name.c_str());
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplatePair.first, gameObjectTemplatePair.first, name.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate->entry, name.c_str());
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplatePair.first, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
@@ -603,7 +594,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string const& name = gameObjectTemplate->name;
|
||||
std::string const& name = gameObjectTemplatePair.second.name;
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
@@ -616,9 +607,9 @@ public:
|
||||
}
|
||||
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate->entry, gameObjectTemplate->entry, name.c_str());
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplatePair.first, gameObjectTemplatePair.first, name.c_str());
|
||||
else
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate->entry, name.c_str());
|
||||
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplatePair.first, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
@@ -653,20 +644,17 @@ public:
|
||||
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
|
||||
|
||||
ObjectMgr::QuestContainer const& questTemplates = sObjectMgr->GetQuestTemplates();
|
||||
for (auto const& qInfo : questTemplates)
|
||||
for (auto const& questTemplatePair : questTemplates)
|
||||
{
|
||||
if (!qInfo)
|
||||
continue;
|
||||
|
||||
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
|
||||
if (localeIndex >= 0)
|
||||
{
|
||||
uint8 ulocaleIndex = uint8(localeIndex);
|
||||
if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId()))
|
||||
if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(questTemplatePair.first))
|
||||
{
|
||||
if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty())
|
||||
{
|
||||
std::string title = questLocale->Title[ulocaleIndex];
|
||||
std::string const& title = questLocale->Title[ulocaleIndex];
|
||||
|
||||
if (Utf8FitTo(title, wNamePart))
|
||||
{
|
||||
@@ -680,9 +668,7 @@ public:
|
||||
|
||||
if (target)
|
||||
{
|
||||
QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
|
||||
|
||||
switch (status)
|
||||
switch (target->GetQuestStatus(questTemplatePair.first))
|
||||
{
|
||||
case QUEST_STATUS_COMPLETE:
|
||||
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
|
||||
@@ -699,9 +685,9 @@ public:
|
||||
}
|
||||
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr);
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, questTemplatePair.first, questTemplatePair.first, questTemplatePair.second.GetQuestLevel(), title.c_str(), statusStr);
|
||||
else
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr);
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, questTemplatePair.first, title.c_str(), statusStr);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
@@ -712,7 +698,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string title = qInfo->GetTitle();
|
||||
std::string const& title = questTemplatePair.second.GetTitle();
|
||||
if (title.empty())
|
||||
continue;
|
||||
|
||||
@@ -728,9 +714,7 @@ public:
|
||||
|
||||
if (target)
|
||||
{
|
||||
QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
|
||||
|
||||
switch (status)
|
||||
switch (target->GetQuestStatus(questTemplatePair.first))
|
||||
{
|
||||
case QUEST_STATUS_COMPLETE:
|
||||
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
|
||||
@@ -747,9 +731,9 @@ public:
|
||||
}
|
||||
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr);
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, questTemplatePair.first, questTemplatePair.first, questTemplatePair.second.GetQuestLevel(), title.c_str(), statusStr);
|
||||
else
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr);
|
||||
handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, questTemplatePair.first, title.c_str(), statusStr);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
|
||||
@@ -1343,17 +1343,17 @@ public:
|
||||
|
||||
bool found = false;
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplate : its)
|
||||
for (auto const& itemTemplatePair : its)
|
||||
{
|
||||
if (!itemTemplate || itemTemplate->ItemSet != itemSetId)
|
||||
if (itemTemplatePair.second.ItemSet != itemSetId)
|
||||
continue;
|
||||
|
||||
found = true;
|
||||
ItemPosCountVec dest;
|
||||
InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemTemplate->ItemId, 1);
|
||||
InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemTemplatePair.first, 1);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
Item* item = playerTarget->StoreNewItem(dest, itemTemplate->ItemId, true);
|
||||
Item* item = playerTarget->StoreNewItem(dest, itemTemplatePair.first, true);
|
||||
|
||||
// remove binding (let GM give it to another player later)
|
||||
if (player == playerTarget)
|
||||
@@ -1365,8 +1365,8 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
player->SendEquipError(msg, nullptr, nullptr, itemTemplate->ItemId);
|
||||
handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemTemplate->ItemId, 1);
|
||||
player->SendEquipError(msg, nullptr, nullptr, itemTemplatePair.first);
|
||||
handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemTemplatePair.first, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,12 +84,12 @@ public:
|
||||
ItemTemplateContainer const& itc = sObjectMgr->GetItemTemplateStore();
|
||||
auto itr = std::find_if(std::begin(itc), std::end(itc), [quest](ItemTemplateContainer::value_type const& value)
|
||||
{
|
||||
return value && value->StartQuest == quest->GetQuestId();
|
||||
return value.second.StartQuest == quest->GetQuestId();
|
||||
});
|
||||
|
||||
if (itr != std::end(itc))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, (*itr)->ItemId);
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, itr->first);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user