mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Globals: revert back to unordered_map for templates
Partial revert of commitb64c504314See discussion onb64c504314
This commit is contained in:
@@ -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