diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2018-01-18 00:53:45 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2018-01-18 01:07:29 -0300 |
| commit | b75ff7d4bf13fb4778843c99521223becc096ca0 (patch) | |
| tree | 8caeb1afa4fd0367a41b90d7793625d7afb86528 /src/server/scripts/Commands | |
| parent | e519e14df8d846285f1d29fb7e5aa0b151c6f74e (diff) | |
Core/Globals: revert back to unordered_map for templates
Partial revert of commit b64c5043140dc7b7908e259e441de16cc0261320
See discussion on https://github.com/TrinityCore/TrinityCore/commit/b64c5043140dc7b7908e259e441de16cc0261320
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_lookup.cpp | 70 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 12 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_quest.cpp | 4 |
3 files changed, 35 insertions, 51 deletions
diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 44e137b5567..2accfc462d2 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -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; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index ba3a34f98b1..bf163a208b3 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -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); } } diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index c31f5462e8f..a97cfb19827 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -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; } |
