From 3c9f268b5375b432c8c557bad09c74420f3d42d7 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 18 Mar 2011 18:55:35 +0300 Subject: [PATCH] [11263] Revert "[11262] Revert "[11261] Check gaps in quest RewChoiceItem* data."" This reverts commit 714d48a99e2ccc9404b34ebcfec50b2d8300fc46. Additiona reserch show that no any know cases when data in RewChoiceItem* have gaps except detected wrong data cases. So check good have in 3.x/2.x for better data intergrity checks. --- src/game/ObjectMgr.cpp | 13 ++++++++++++- src/shared/revision_nr.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 79fb495e7..c3b8fca31 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4083,7 +4083,8 @@ void ObjectMgr::LoadQuests() } } - for(int j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j ) + bool choice_found = false; + for(int j = QUEST_REWARD_CHOICES_COUNT-1; j >=0; --j ) { if (uint32 id = qinfo->RewChoiceItemId[j]) { @@ -4093,6 +4094,8 @@ void ObjectMgr::LoadQuests() qinfo->GetQuestId(),j+1,id,id); qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this } + else + choice_found = true; if (!qinfo->RewChoiceItemCount[j]) { @@ -4101,6 +4104,14 @@ void ObjectMgr::LoadQuests() // no changes, quest can't be done } } + else if (choice_found) // client crash if have gap in item reward choices + { + sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemId%d` = %u, client can crash at like data.", + qinfo->GetQuestId(),j+1,j+2,qinfo->RewChoiceItemId[j+1]); + // fill gap by clone later filled choice + qinfo->RewChoiceItemId[j] = qinfo->RewChoiceItemId[j+1]; + qinfo->RewChoiceItemCount[j] = qinfo->RewChoiceItemCount[j+1]; + } else if (qinfo->RewChoiceItemCount[j]>0) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.", diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 0e5d5811f..f509bbae1 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 "11262" + #define REVISION_NR "11263" #endif // __REVISION_NR_H__