From 1fd8ad7496f520efa9e49f3678b412d7f5a9382d Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 29 Oct 2009 13:25:34 +0300 Subject: [PATCH] [8752] Changes in mail template related server load checks. * Allow loot for not used in quest mail templates. This let use mail template based mails from scripts for example. * Not allow use same mail template id in more ine quests. --- src/game/LootMgr.cpp | 9 ++++----- src/game/ObjectMgr.cpp | 23 ++++++++++++++++++----- src/shared/revision_nr.h | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index f3cfccdae..203bc24df 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -1262,11 +1262,10 @@ void LoadLootTemplates_Mail() LootTemplates_Mail.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot - ObjectMgr::QuestMap const& questMap = objmgr.GetQuestTemplates(); - for(ObjectMgr::QuestMap::const_iterator itr = questMap.begin(); itr != questMap.end(); ++itr ) - if(uint32 mail_template_id = itr->second->GetRewMailTemplateId()) - if(ids_set.count(mail_template_id)) - ids_set.erase(mail_template_id); + for(uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i ) + if(sMailTemplateStore.LookupEntry(i)) + if(ids_set.count(i)) + ids_set.erase(i); // output error for any still listed (not referenced from appropriate table) ids LootTemplates_Mail.ReportUnusedIds(ids_set); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 358f12ab4..914e24ce8 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -3278,6 +3278,9 @@ void ObjectMgr::LoadQuests() delete result; // Post processing + + std::map usedMailTemplates; + for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); ++iter) { Quest * qinfo = iter->second; @@ -3766,21 +3769,31 @@ void ObjectMgr::LoadQuests() } } - if(qinfo->RewMailTemplateId) + if (qinfo->RewMailTemplateId) { - if(!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId)) + if (!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId)) { sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId); qinfo->RewMailTemplateId = 0; // no mail will send to player qinfo->RewMailDelaySecs = 0; // no mail will send to player } + else if (usedMailTemplates.find(qinfo->RewMailTemplateId) != usedMailTemplates.end()) + { + std::map::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewMailTemplateId); + sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.", + qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId,used_mt_itr->second); + qinfo->RewMailTemplateId = 0; // no mail will send to player + qinfo->RewMailDelaySecs = 0; // no mail will send to player + } + else + usedMailTemplates[qinfo->RewMailTemplateId] = qinfo->GetQuestId(); } - if(qinfo->NextQuestInChain) + if (qinfo->NextQuestInChain) { QuestMap::iterator qNextItr = mQuestTemplates.find(qinfo->NextQuestInChain); - if(qNextItr == mQuestTemplates.end()) + if (qNextItr == mQuestTemplates.end()) { sLog.outErrorDb("Quest %u has `NextQuestInChain` = %u but quest %u does not exist, quest chain will not work.", qinfo->GetQuestId(),qinfo->NextQuestInChain ,qinfo->NextQuestInChain ); @@ -3791,7 +3804,7 @@ void ObjectMgr::LoadQuests() } // fill additional data stores - if(qinfo->PrevQuestId) + if (qinfo->PrevQuestId) { if (mQuestTemplates.find(abs(qinfo->GetPrevQuestId())) == mQuestTemplates.end()) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index be9c44e86..e11f574e1 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8751" + #define REVISION_NR "8752" #endif // __REVISION_NR_H__ -- 2.11.4.GIT