aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp102
1 files changed, 45 insertions, 57 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 1a5c7ad64c5..8240b0c3482 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -3629,8 +3629,8 @@ void ObjectMgr::LoadQuests()
}
// Load `quest_visual_effect` join table with quest_objectives because visual effects are based on objective ID (core stores objectives by their index in quest)
- // 0 1 2 3 4 5
- result = WorldDatabase.Query("SELECT v.ID, o.ID, o.QuestID, o.StorageIndex, v.Index, v.VisualEffect FROM quest_visual_effect AS v LEFT JOIN quest_objectives AS o ON v.ID = o.ID ORDER BY v.Index DESC");
+ // 0 1 2 3 4
+ result = WorldDatabase.Query("SELECT v.ID, o.ID, o.QuestID, v.Index, v.VisualEffect FROM quest_visual_effect AS v LEFT JOIN quest_objectives AS o ON v.ID = o.ID ORDER BY v.Index DESC");
if (!result)
{
@@ -3679,8 +3679,8 @@ void ObjectMgr::LoadQuests()
// additional quest integrity checks (GO, creature_template and item_template must be loaded already)
- if (qinfo->GetQuestMethod() >= 3)
- TC_LOG_ERROR("sql.sql", "Quest %u has `Method` = %u, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod());
+ if (qinfo->GetQuestType() >= MAX_QUEST_TYPES)
+ TC_LOG_ERROR("sql.sql", "Quest %u has `Method` = %u, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestType());
if (qinfo->SpecialFlags & ~QUEST_SPECIAL_FLAGS_DB_ALLOWED)
{
@@ -3743,32 +3743,32 @@ void ObjectMgr::LoadQuests()
}
// client quest log visual (area case)
- if (qinfo->ZoneOrSort > 0)
+ if (qinfo->QuestSortID > 0)
{
- if (!GetAreaEntryByAreaID(qinfo->ZoneOrSort))
+ if (!GetAreaEntryByAreaID(qinfo->QuestSortID))
{
- TC_LOG_ERROR("sql.sql", "Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.",
- qinfo->GetQuestId(), qinfo->ZoneOrSort);
+ TC_LOG_ERROR("sql.sql", "Quest %u has `QuestSortID` = %u (zone case) but zone with this id does not exist.",
+ qinfo->GetQuestId(), qinfo->QuestSortID);
// no changes, quest not dependent from this value but can have problems at client
}
}
// client quest log visual (sort case)
- if (qinfo->ZoneOrSort < 0)
+ if (qinfo->QuestSortID < 0)
{
- QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort));
+ QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->QuestSortID));
if (!qSort)
{
- TC_LOG_ERROR("sql.sql", "Quest %u has `ZoneOrSort` = %i (sort case) but quest sort with this id does not exist.",
- qinfo->GetQuestId(), qinfo->ZoneOrSort);
+ TC_LOG_ERROR("sql.sql", "Quest %u has `QuestSortID` = %i (sort case) but quest sort with this id does not exist.",
+ qinfo->GetQuestId(), qinfo->QuestSortID);
// no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check)
}
//check for proper RequiredSkillId value (skill case)
- if (uint32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort)))
+ if (uint32 skill_id = SkillByQuestSort(-int32(qinfo->QuestSortID)))
{
if (qinfo->RequiredSkillId != skill_id)
{
- TC_LOG_ERROR("sql.sql", "Quest %u has `ZoneOrSort` = %i but `RequiredSkillId` does not have a corresponding value (%d).",
- qinfo->GetQuestId(), qinfo->ZoneOrSort, skill_id);
+ TC_LOG_ERROR("sql.sql", "Quest %u has `QuestSortID` = %i but `RequiredSkillId` does not have a corresponding value (%d).",
+ qinfo->GetQuestId(), qinfo->QuestSortID, skill_id);
//override, and force proper value here?
}
}
@@ -3902,31 +3902,24 @@ void ObjectMgr::LoadQuests()
}
}
- for (uint32 j = 0; j < qinfo->Objectives.size(); ++j)
+ for (QuestObjective const& obj : qinfo->GetObjectives())
{
- QuestObjective& obj = qinfo->Objectives[j];
-
- // Might be intended in blizz so it is debug output
- if (!obj.ID)
- {
- TC_LOG_DEBUG("sql.sql", "Quest %u is missing objective %u", qinfo->GetQuestId(), j);
- // Prevent objective to be parsed as QUEST_OBJECTIVE_MONSTER
- obj.Type = QUEST_OBJECTIVE_NONE;
- continue;
- }
-
- if (!obj.ObjectID)
- {
- TC_LOG_ERROR("sql.sql", "Quest %u objective %u has `ObjectID` = 0, quest can't be done.", qinfo->GetQuestId(), j);
- // no changes, quest can't be done for this requirement
- continue;
- }
-
- if (!obj.Amount)
+ // Check storage index for objectives which store data
+ if (obj.StorageIndex < 0)
{
- TC_LOG_ERROR("sql.sql", "Quest %u objective %u has `Amount` = 0, quest can't be done.", qinfo->GetQuestId(), j);
- // no changes, quest can't be done for this requirement
- continue;
+ switch (obj.Type)
+ {
+ case QUEST_OBJECTIVE_MONSTER:
+ case QUEST_OBJECTIVE_ITEM:
+ case QUEST_OBJECTIVE_GAMEOBJECT:
+ case QUEST_OBJECTIVE_TALKTO:
+ case QUEST_OBJECTIVE_PLAYERKILLS:
+ case QUEST_OBJECTIVE_AREATRIGGER:
+ TC_LOG_ERROR("sql.sql", "Quest %u objective %u has invalid StorageIndex = %d for objective type %u", qinfo->GetQuestId(), obj.ID, obj.StorageIndex, obj.Type);
+ break;
+ default:
+ break;
+ }
}
switch (obj.Type)
@@ -3934,48 +3927,43 @@ void ObjectMgr::LoadQuests()
case QUEST_OBJECTIVE_ITEM:
qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER);
if (!sObjectMgr->GetItemTemplate(obj.ObjectID))
- {
TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing item entry %u, quest can't be done.",
- qinfo->GetQuestId(), j, obj.ObjectID);
- obj.Amount = 0; // prevent incorrect work of quest
- }
+ qinfo->GetQuestId(), obj.ID, obj.ObjectID);
break;
case QUEST_OBJECTIVE_MONSTER:
- qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_KILL | QUEST_SPECIAL_FLAGS_CAST | QUEST_SPECIAL_FLAGS_SPEAKTO);
+ qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_KILL | QUEST_SPECIAL_FLAGS_CAST);
if (!sObjectMgr->GetCreatureTemplate(obj.ObjectID))
- {
TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing creature entry %u, quest can't be done.",
- qinfo->GetQuestId(), j, uint32(obj.ObjectID));
- obj.Amount = 0; // quest can't be done for this requirement
- }
+ qinfo->GetQuestId(), obj.ID, uint32(obj.ObjectID));
break;
case QUEST_OBJECTIVE_GAMEOBJECT:
- qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_KILL | QUEST_SPECIAL_FLAGS_CAST | QUEST_SPECIAL_FLAGS_SPEAKTO);
+ qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_KILL | QUEST_SPECIAL_FLAGS_CAST);
if (!sObjectMgr->GetGameObjectTemplate(obj.ObjectID))
- {
TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing gameobject entry %u, quest can't be done.",
- qinfo->GetQuestId(), j, uint32(obj.ObjectID));
- obj.Amount = 0; // quest can't be done for this requirement
- }
+ qinfo->GetQuestId(), obj.ID, uint32(obj.ObjectID));
+ break;
+ case QUEST_OBJECTIVE_TALKTO:
+ // Need checks (is it creature only?)
+ qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_CAST | QUEST_SPECIAL_FLAGS_SPEAKTO);
break;
case QUEST_OBJECTIVE_MIN_REPUTATION:
case QUEST_OBJECTIVE_MAX_REPUTATION:
if (!sFactionStore.LookupEntry(obj.ObjectID))
- TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing faction id %u", qinfo->GetQuestId(), j, obj.ObjectID);
+ TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing faction id %u", qinfo->GetQuestId(), obj.ID, obj.ObjectID);
break;
case QUEST_OBJECTIVE_PLAYERKILLS:
qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL);
if (obj.Amount <= 0)
- TC_LOG_ERROR("sql.sql", "Quest %u objective %u has invalid player kills count %d", qinfo->GetQuestId(), j, obj.Amount);
+ TC_LOG_ERROR("sql.sql", "Quest %u objective %u has invalid player kills count %d", qinfo->GetQuestId(), obj.ID, obj.Amount);
break;
case QUEST_OBJECTIVE_CURRENCY:
if (!sCurrencyTypesStore.LookupEntry(obj.ObjectID))
- TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing currency %u", qinfo->GetQuestId(), j, obj.ObjectID);
+ TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing currency %u", qinfo->GetQuestId(), obj.ID, obj.ObjectID);
if (obj.Amount <= 0)
- TC_LOG_ERROR("sql.sql", "Quest %u objective %u has invalid currency amount %d", qinfo->GetQuestId(), j, obj.Amount);
+ TC_LOG_ERROR("sql.sql", "Quest %u objective %u has invalid currency amount %d", qinfo->GetQuestId(), obj.ID, obj.Amount);
break;
default:
- TC_LOG_ERROR("sql.sql", "Quest %u objective %u has unknown type %u", qinfo->GetQuestId(), j, obj.Type);
+ TC_LOG_ERROR("sql.sql", "Quest %u objective %u has unhandled type %u", qinfo->GetQuestId(), obj.ID, obj.Type);
}
}