diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 276 | ||||
| -rw-r--r-- | src/server/game/Quests/QuestDef.cpp | 206 | ||||
| -rw-r--r-- | src/server/game/Quests/QuestDef.h | 315 |
4 files changed, 388 insertions, 417 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e2033dd834c..38625f4295c 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -15467,10 +15467,10 @@ bool Player::SatisfyQuestLog(bool msg) const bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) { // No previous quest (might be first quest in a series) - if (qInfo->prevQuests.empty()) + if (qInfo->PrevQuests.empty()) return true; - for (Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter) + for (auto iter = qInfo->PrevQuests.begin(); iter != qInfo->PrevQuests.end(); ++iter) { uint32 prevId = abs(*iter); @@ -15774,10 +15774,10 @@ bool Player::SatisfyQuestNextChain(Quest const* qInfo, bool msg) const bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg) { // No previous quest in chain - if (qInfo->prevChainQuests.empty()) + if (qInfo->PrevChainQuests.empty()) return true; - for (Quest::PrevChainQuests::const_iterator iter = qInfo->prevChainQuests.begin(); iter != qInfo->prevChainQuests.end(); ++iter) + for (auto iter = qInfo->PrevChainQuests.begin(); iter != qInfo->PrevChainQuests.end(); ++iter) { QuestStatusMap::const_iterator itr = m_QuestStatus.find(*iter); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index e3828d7930b..1e2cfed0166 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4012,7 +4012,7 @@ void ObjectMgr::LoadQuests() _questTemplates[newQuest->GetQuestId()] = newQuest; } while (result->NextRow()); - std::map<uint32, uint32> usedMailTemplates; + std::unordered_map<uint32, uint32> usedMailTemplates; // Load `quest_details` // 0 1 2 3 4 5 6 7 8 @@ -4109,258 +4109,260 @@ void ObjectMgr::LoadQuests() } // Post processing - for (QuestMap::iterator iter = _questTemplates.begin(); iter != _questTemplates.end(); ++iter) + for (auto iter = _questTemplates.begin(); iter != _questTemplates.end(); ++iter) { // skip post-loading checks for disabled quests if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, nullptr)) continue; - Quest * qinfo = iter->second; + Quest* qinfo = iter->second; // 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->SpecialFlags & ~QUEST_SPECIAL_FLAGS_DB_ALLOWED) + if (qinfo->_specialFlags & ~QUEST_SPECIAL_FLAGS_DB_ALLOWED) { TC_LOG_ERROR("sql.sql", "Quest %u has `SpecialFlags` = %u > max allowed value. Correct `SpecialFlags` to value <= %u", - qinfo->GetQuestId(), qinfo->SpecialFlags, QUEST_SPECIAL_FLAGS_DB_ALLOWED); - qinfo->SpecialFlags &= QUEST_SPECIAL_FLAGS_DB_ALLOWED; + qinfo->GetQuestId(), qinfo->_specialFlags, QUEST_SPECIAL_FLAGS_DB_ALLOWED); + qinfo->_specialFlags &= QUEST_SPECIAL_FLAGS_DB_ALLOWED; } - if (qinfo->Flags & QUEST_FLAGS_DAILY && qinfo->Flags & QUEST_FLAGS_WEEKLY) + if (qinfo->_flags & QUEST_FLAGS_DAILY && qinfo->_flags & QUEST_FLAGS_WEEKLY) { TC_LOG_ERROR("sql.sql", "Weekly Quest %u is marked as daily quest in `Flags`, removed daily flag.", qinfo->GetQuestId()); - qinfo->Flags &= ~QUEST_FLAGS_DAILY; + qinfo->_flags &= ~QUEST_FLAGS_DAILY; } - if (qinfo->Flags & QUEST_FLAGS_DAILY) + if (qinfo->_flags & QUEST_FLAGS_DAILY) { - if (!(qinfo->SpecialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE)) + if (!(qinfo->_specialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE)) { TC_LOG_ERROR("sql.sql", "Daily Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId()); - qinfo->SpecialFlags |= QUEST_SPECIAL_FLAGS_REPEATABLE; + qinfo->_specialFlags |= QUEST_SPECIAL_FLAGS_REPEATABLE; } } - if (qinfo->Flags & QUEST_FLAGS_WEEKLY) + if (qinfo->_flags & QUEST_FLAGS_WEEKLY) { - if (!(qinfo->SpecialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE)) + if (!(qinfo->_specialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE)) { TC_LOG_ERROR("sql.sql", "Weekly Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId()); - qinfo->SpecialFlags |= QUEST_SPECIAL_FLAGS_REPEATABLE; + qinfo->_specialFlags |= QUEST_SPECIAL_FLAGS_REPEATABLE; } } - if (qinfo->SpecialFlags & QUEST_SPECIAL_FLAGS_MONTHLY) + if (qinfo->_specialFlags & QUEST_SPECIAL_FLAGS_MONTHLY) { - if (!(qinfo->SpecialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE)) + if (!(qinfo->_specialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE)) { TC_LOG_ERROR("sql.sql", "Monthly quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId()); - qinfo->SpecialFlags |= QUEST_SPECIAL_FLAGS_REPEATABLE; + qinfo->_specialFlags |= QUEST_SPECIAL_FLAGS_REPEATABLE; } } - if (qinfo->Flags & QUEST_FLAGS_TRACKING) + if (qinfo->_flags & QUEST_FLAGS_TRACKING) { // at auto-reward can be rewarded only RewardChoiceItemId[0] - for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j ) + for (uint32 j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j) { if (uint32 id = qinfo->RewardChoiceItemId[j]) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardChoiceItemId%d` = %u but item from `RewardChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_TRACKING.", - qinfo->GetQuestId(), j+1, id, j+1); + qinfo->GetQuestId(), j + 1, id, j + 1); // no changes, quest ignore this data } } } // client quest log visual (area case) - if (qinfo->ZoneOrSort > 0) + if (qinfo->_zoneOrSort > 0) { - if (!sAreaTableStore.LookupEntry(qinfo->ZoneOrSort)) + if (!sAreaTableStore.LookupEntry(qinfo->_zoneOrSort)) { TC_LOG_ERROR("sql.sql", "Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.", - qinfo->GetQuestId(), qinfo->ZoneOrSort); + qinfo->GetQuestId(), qinfo->_zoneOrSort); // 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->_zoneOrSort < 0) { - QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort)); + QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->_zoneOrSort)); 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); + qinfo->GetQuestId(), qinfo->_zoneOrSort); // 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(-qinfo->_zoneOrSort)) { - if (qinfo->RequiredSkillId != skill_id) + 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); + qinfo->GetQuestId(), qinfo->_zoneOrSort, skill_id); //override, and force proper value here? } } } // RequiredClasses, can be 0/CLASSMASK_ALL_PLAYABLE to allow any class - if (qinfo->RequiredClasses) + if (qinfo->_requiredClasses) { - if (!(qinfo->RequiredClasses & CLASSMASK_ALL_PLAYABLE)) + if (!(qinfo->_requiredClasses & CLASSMASK_ALL_PLAYABLE)) { - TC_LOG_ERROR("sql.sql", "Quest %u does not contain any playable classes in `RequiredClasses` (%u), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->RequiredClasses); - qinfo->RequiredClasses = 0; + TC_LOG_ERROR("sql.sql", "Quest %u does not contain any playable classes in `RequiredClasses` (%u), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->_requiredClasses); + qinfo->_requiredClasses = 0; } } + // AllowableRaces, can be 0/RACEMASK_ALL_PLAYABLE to allow any race - if (qinfo->AllowableRaces) + if (qinfo->_allowableRaces) + { + if (!(qinfo->_allowableRaces & RACEMASK_ALL_PLAYABLE)) { - if (!(qinfo->AllowableRaces & RACEMASK_ALL_PLAYABLE)) - { - TC_LOG_ERROR("sql.sql", "Quest %u does not contain any playable races in `AllowableRaces` (%u), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->AllowableRaces); - qinfo->AllowableRaces = 0; - } + TC_LOG_ERROR("sql.sql", "Quest %u does not contain any playable races in `AllowableRaces` (%u), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->_allowableRaces); + qinfo->_allowableRaces = 0; } + } + // RequiredSkillId, can be 0 - if (qinfo->RequiredSkillId) + if (qinfo->_requiredSkillId) { - if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkillId)) + if (!sSkillLineStore.LookupEntry(qinfo->_requiredSkillId)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredSkillId` = %u but this skill does not exist", - qinfo->GetQuestId(), qinfo->RequiredSkillId); + qinfo->GetQuestId(), qinfo->_requiredSkillId); } } - if (qinfo->RequiredSkillPoints) + if (qinfo->_requiredSkillPoints) { - if (qinfo->RequiredSkillPoints > sWorld->GetConfigMaxSkillValue()) + if (qinfo->_requiredSkillPoints > sWorld->GetConfigMaxSkillValue()) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredSkillPoints` = %u but max possible skill is %u, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredSkillPoints, sWorld->GetConfigMaxSkillValue()); + qinfo->GetQuestId(), qinfo->_requiredSkillPoints, sWorld->GetConfigMaxSkillValue()); // no changes, quest can't be done for this requirement } } // else Skill quests can have 0 skill level, this is ok - if (qinfo->RequiredFactionId2 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId2)) + if (qinfo->_requiredFactionId2 && !sFactionStore.LookupEntry(qinfo->_requiredFactionId2)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredFactionId2` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredFactionId2, qinfo->RequiredFactionId2); + qinfo->GetQuestId(), qinfo->_requiredFactionId2, qinfo->_requiredFactionId2); // no changes, quest can't be done for this requirement } - if (qinfo->RequiredFactionId1 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId1)) + if (qinfo->_requiredFactionId1 && !sFactionStore.LookupEntry(qinfo->_requiredFactionId1)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredFactionId1` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredFactionId1, qinfo->RequiredFactionId1); + qinfo->GetQuestId(), qinfo->_requiredFactionId1, qinfo->_requiredFactionId1); // no changes, quest can't be done for this requirement } - if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction)) + if (qinfo->_requiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->_requiredMinRepFaction)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredMinRepFaction, qinfo->RequiredMinRepFaction); + qinfo->GetQuestId(), qinfo->_requiredMinRepFaction, qinfo->_requiredMinRepFaction); // no changes, quest can't be done for this requirement } - if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction)) + if (qinfo->_requiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->_requiredMaxRepFaction)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredMaxRepFaction, qinfo->RequiredMaxRepFaction); + qinfo->GetQuestId(), qinfo->_requiredMaxRepFaction, qinfo->_requiredMaxRepFaction); // no changes, quest can't be done for this requirement } - if (qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > ReputationMgr::Reputation_Cap) + if (qinfo->_requiredMinRepValue && qinfo->_requiredMinRepValue > ReputationMgr::Reputation_Cap) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredMinRepValue, ReputationMgr::Reputation_Cap); + qinfo->GetQuestId(), qinfo->_requiredMinRepValue, ReputationMgr::Reputation_Cap); // no changes, quest can't be done for this requirement } - if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue) + if (qinfo->_requiredMinRepValue && qinfo->_requiredMaxRepValue && qinfo->_requiredMaxRepValue <= qinfo->_requiredMinRepValue) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredMaxRepValue, qinfo->RequiredMinRepValue); + qinfo->GetQuestId(), qinfo->_requiredMaxRepValue, qinfo->_requiredMinRepValue); // no changes, quest can't be done for this requirement } - if (!qinfo->RequiredFactionId1 && qinfo->RequiredFactionValue1 != 0) + if (!qinfo->_requiredFactionId1 && qinfo->_requiredFactionValue1 != 0) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredFactionValue1` = %d but `RequiredFactionId1` is 0, value has no effect", - qinfo->GetQuestId(), qinfo->RequiredFactionValue1); + qinfo->GetQuestId(), qinfo->_requiredFactionValue1); // warning } - if (!qinfo->RequiredFactionId2 && qinfo->RequiredFactionValue2 != 0) + if (!qinfo->_requiredFactionId2 && qinfo->_requiredFactionValue2 != 0) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredFactionValue2` = %d but `RequiredFactionId2` is 0, value has no effect", - qinfo->GetQuestId(), qinfo->RequiredFactionValue2); + qinfo->GetQuestId(), qinfo->_requiredFactionValue2); // warning } - if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue != 0) + if (!qinfo->_requiredMinRepFaction && qinfo->_requiredMinRepValue != 0) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect", - qinfo->GetQuestId(), qinfo->RequiredMinRepValue); + qinfo->GetQuestId(), qinfo->_requiredMinRepValue); // warning } - if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue != 0) + if (!qinfo->_requiredMaxRepFaction && qinfo->_requiredMaxRepValue != 0) { TC_LOG_ERROR("sql.sql", "Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect", - qinfo->GetQuestId(), qinfo->RequiredMaxRepValue); + qinfo->GetQuestId(), qinfo->_requiredMaxRepValue); // warning } - if (qinfo->RewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->RewardTitleId)) + if (qinfo->_rewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->_rewardTitleId)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId()); - qinfo->RewardTitleId = 0; + qinfo->_rewardTitleId = 0; // quest can't reward this title } - if (qinfo->StartItem) + if (qinfo->_startItem) { - if (!sObjectMgr->GetItemTemplate(qinfo->StartItem)) + if (!sObjectMgr->GetItemTemplate(qinfo->_startItem)) { TC_LOG_ERROR("sql.sql", "Quest %u has `StartItem` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->StartItem, qinfo->StartItem); - qinfo->StartItem = 0; // quest can't be done for this requirement + qinfo->GetQuestId(), qinfo->_startItem, qinfo->_startItem); + qinfo->_startItem = 0; // quest can't be done for this requirement } - else if (qinfo->StartItemCount == 0) + else if (qinfo->_startItemCount == 0) { TC_LOG_ERROR("sql.sql", "Quest %u has `StartItem` = %u but `StartItemCount` = 0, set to 1 but need fix in DB.", - qinfo->GetQuestId(), qinfo->StartItem); - qinfo->StartItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB + qinfo->GetQuestId(), qinfo->_startItem); + qinfo->_startItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB } } - else if (qinfo->StartItemCount>0) + else if (qinfo->_startItemCount > 0) { TC_LOG_ERROR("sql.sql", "Quest %u has `StartItem` = 0 but `StartItemCount` = %u, useless value.", - qinfo->GetQuestId(), qinfo->StartItemCount); - qinfo->StartItemCount=0; // no quest work changes in fact + qinfo->GetQuestId(), qinfo->_startItemCount); + qinfo->_startItemCount = 0; // no quest work changes in fact } - if (qinfo->SourceSpellid) + if (qinfo->_sourceSpellid) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SourceSpellid); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_sourceSpellid); if (!spellInfo) { TC_LOG_ERROR("sql.sql", "Quest %u has `SourceSpellid` = %u but spell %u doesn't exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid); - qinfo->SourceSpellid = 0; // quest can't be done for this requirement + qinfo->GetQuestId(), qinfo->_sourceSpellid, qinfo->_sourceSpellid); + qinfo->_sourceSpellid = 0; // quest can't be done for this requirement } else if (!SpellMgr::IsSpellValid(spellInfo)) { TC_LOG_ERROR("sql.sql", "Quest %u has `SourceSpellid` = %u but spell %u is broken, quest can't be done.", - qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid); - qinfo->SourceSpellid = 0; // quest can't be done for this requirement + qinfo->GetQuestId(), qinfo->_sourceSpellid, qinfo->_sourceSpellid); + qinfo->_sourceSpellid = 0; // quest can't be done for this requirement } } @@ -4512,7 +4514,7 @@ void ObjectMgr::LoadQuests() { if (qinfo->RewardFactionId[j]) { - if (abs(qinfo->RewardFactionValueId[j]) > 9) + if (std::abs(qinfo->RewardFactionValueId[j]) > 9) { TC_LOG_ERROR("sql.sql", "Quest %u has RewardFactionValueId%d = %i. That is outside the range of valid values (-9 to 9).", qinfo->GetQuestId(), j+1, qinfo->RewardFactionValueId[j]); } @@ -4531,126 +4533,118 @@ void ObjectMgr::LoadQuests() } } - if (qinfo->RewardDisplaySpell) + if (qinfo->_rewardDisplaySpell) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardDisplaySpell); - + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_rewardDisplaySpell); if (!spellInfo) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardDisplaySpell` = %u but spell %u does not exist, spell removed as display reward.", - qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell); - qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest + qinfo->GetQuestId(), qinfo->_rewardDisplaySpell, qinfo->_rewardDisplaySpell); + qinfo->_rewardDisplaySpell = 0; // no spell reward will display for this quest } else if (!SpellMgr::IsSpellValid(spellInfo)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardDisplaySpell` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell); - qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest + qinfo->GetQuestId(), qinfo->_rewardDisplaySpell, qinfo->_rewardDisplaySpell); + qinfo->_rewardDisplaySpell = 0; // no spell reward will display for this quest } - else if (GetTalentSpellCost(qinfo->RewardDisplaySpell)) + else if (GetTalentSpellCost(qinfo->_rewardDisplaySpell)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardDisplaySpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewardDisplaySpell, qinfo->RewardDisplaySpell); - qinfo->RewardDisplaySpell = 0; // no spell reward will display for this quest + qinfo->GetQuestId(), qinfo->_rewardDisplaySpell, qinfo->_rewardDisplaySpell); + qinfo->_rewardDisplaySpell = 0; // no spell reward will display for this quest } } - if (qinfo->RewardSpell > 0) + if (qinfo->_rewardSpell > 0) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpell); - + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_rewardSpell); if (!spellInfo) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardSpell` = %u but spell %u does not exist, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell); - qinfo->RewardSpell = 0; // no spell will be cast on player + qinfo->GetQuestId(), qinfo->_rewardSpell, qinfo->_rewardSpell); + qinfo->_rewardSpell = 0; // no spell will be cast on player } else if (!SpellMgr::IsSpellValid(spellInfo)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardSpell` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell); - qinfo->RewardSpell = 0; // no spell will be cast on player + qinfo->GetQuestId(), qinfo->_rewardSpell, qinfo->_rewardSpell); + qinfo->_rewardSpell = 0; // no spell will be cast on player } - else if (GetTalentSpellCost(qinfo->RewardSpell)) + else if (GetTalentSpellCost(qinfo->_rewardSpell)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardDisplaySpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell); - qinfo->RewardSpell = 0; // no spell will be cast on player + qinfo->GetQuestId(), qinfo->_rewardSpell, qinfo->_rewardSpell); + qinfo->_rewardSpell = 0; // no spell will be cast on player } } - if (qinfo->RewardMailTemplateId) + if (qinfo->_rewardMailTemplateId) { - if (!sMailTemplateStore.LookupEntry(qinfo->RewardMailTemplateId)) + if (!sMailTemplateStore.LookupEntry(qinfo->_rewardMailTemplateId)) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", - qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId); - qinfo->RewardMailTemplateId = 0; // no mail will send to player - qinfo->RewardMailDelay = 0; // no mail will send to player - qinfo->RewardMailSenderEntry = 0; + qinfo->GetQuestId(), qinfo->_rewardMailTemplateId, qinfo->_rewardMailTemplateId); + qinfo->_rewardMailTemplateId = 0; // no mail will send to player + qinfo->_rewardMailDelay = 0; // no mail will send to player + qinfo->_rewardMailSenderEntry = 0; } - else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end()) + else if (usedMailTemplates.find(qinfo->_rewardMailTemplateId) != usedMailTemplates.end()) { - std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewardMailTemplateId); + auto used_mt_itr = usedMailTemplates.find(qinfo->_rewardMailTemplateId); TC_LOG_ERROR("sql.sql", "Quest %u has `RewardMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.", - qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second); - qinfo->RewardMailTemplateId = 0; // no mail will send to player - qinfo->RewardMailDelay = 0; // no mail will send to player - qinfo->RewardMailSenderEntry = 0; + qinfo->GetQuestId(), qinfo->_rewardMailTemplateId, qinfo->_rewardMailTemplateId, used_mt_itr->second); + qinfo->_rewardMailTemplateId = 0; // no mail will send to player + qinfo->_rewardMailDelay = 0; // no mail will send to player + qinfo->_rewardMailSenderEntry = 0; } else - usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId(); + usedMailTemplates.emplace(qinfo->_rewardMailTemplateId, qinfo->GetQuestId()); } - if (qinfo->RewardNextQuest) + if (qinfo->_rewardNextQuest) { - QuestMap::iterator qNextItr = _questTemplates.find(qinfo->RewardNextQuest); + auto qNextItr = _questTemplates.find(qinfo->_rewardNextQuest); if (qNextItr == _questTemplates.end()) { TC_LOG_ERROR("sql.sql", "Quest %u has `RewardNextQuest` = %u but quest %u does not exist, quest chain will not work.", - qinfo->GetQuestId(), qinfo->RewardNextQuest, qinfo->RewardNextQuest); - qinfo->RewardNextQuest = 0; + qinfo->GetQuestId(), qinfo->_rewardNextQuest, qinfo->_rewardNextQuest); + qinfo->_rewardNextQuest = 0; } else - qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId()); + qNextItr->second->PrevChainQuests.push_back(qinfo->GetQuestId()); } // fill additional data stores - if (qinfo->PrevQuestId) + if (qinfo->_prevQuestId) { - if (_questTemplates.find(abs(qinfo->GetPrevQuestId())) == _questTemplates.end()) - { - TC_LOG_ERROR("sql.sql", "Quest %d has PrevQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId()); - } + if (_questTemplates.find(std::abs(qinfo->_prevQuestId)) == _questTemplates.end()) + TC_LOG_ERROR("sql.sql", "Quest %u has PrevQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->_prevQuestId); else - { - qinfo->prevQuests.push_back(qinfo->PrevQuestId); - } + qinfo->PrevQuests.push_back(qinfo->_prevQuestId); } - if (qinfo->NextQuestId) + if (qinfo->_nextQuestId) { - QuestMap::iterator qNextItr = _questTemplates.find(abs(qinfo->GetNextQuestId())); + auto qNextItr = _questTemplates.find(std::abs(qinfo->GetNextQuestId())); if (qNextItr == _questTemplates.end()) - { - TC_LOG_ERROR("sql.sql", "Quest %d has NextQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId()); - } + TC_LOG_ERROR("sql.sql", "Quest %u has NextQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId()); else { - int32 signedQuestId = qinfo->NextQuestId < 0 ? -int32(qinfo->GetQuestId()) : int32(qinfo->GetQuestId()); - qNextItr->second->prevQuests.push_back(signedQuestId); + int32 signedQuestId = qinfo->_nextQuestId < 0 ? -int32(qinfo->GetQuestId()) : int32(qinfo->GetQuestId()); + qNextItr->second->PrevQuests.push_back(signedQuestId); } } - if (qinfo->ExclusiveGroup) - mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId())); - if (qinfo->TimeAllowed) + if (qinfo->_exclusiveGroup) + mExclusiveQuestGroups.emplace(qinfo->_exclusiveGroup, qinfo->GetQuestId()); + if (qinfo->_timeAllowed) qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED); - if (qinfo->RequiredPlayerKills) + if (qinfo->_requiredPlayerKills) qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL); } diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 61f7694c724..6c3b15436e7 100644 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -26,78 +26,70 @@ Quest::Quest(Field* questRecord) { - EmoteOnIncomplete = 0; - EmoteOnComplete = 0; - _reqItemsCount = 0; - _reqCreatureOrGOcount = 0; - _rewItemsCount = 0; - _rewChoiceItemsCount = 0; - _eventIdForQuest = 0; - - Id = questRecord[0].GetUInt32(); - Method = questRecord[1].GetUInt8(); - Level = questRecord[2].GetInt16(); - MinLevel = questRecord[3].GetUInt8(); - ZoneOrSort = questRecord[4].GetInt16(); - Type = questRecord[5].GetUInt16(); - SuggestedPlayers = questRecord[6].GetUInt8(); - TimeAllowed = questRecord[7].GetUInt32(); - AllowableRaces = questRecord[8].GetUInt16(); - RequiredFactionId1 = questRecord[9].GetUInt16(); - RequiredFactionId2 = questRecord[10].GetUInt16(); - RequiredFactionValue1 = questRecord[11].GetInt32(); - RequiredFactionValue2 = questRecord[12].GetInt32(); - RewardNextQuest = questRecord[13].GetUInt32(); - RewardXPDifficulty = questRecord[14].GetUInt8(); - RewardMoney = questRecord[15].GetInt32(); - RewardBonusMoney = questRecord[16].GetUInt32(); - RewardDisplaySpell = questRecord[17].GetUInt32(); - RewardSpell = questRecord[18].GetInt32(); - RewardHonor = questRecord[19].GetUInt32(); - RewardKillHonor = questRecord[20].GetFloat(); - StartItem = questRecord[21].GetUInt32(); - Flags = questRecord[22].GetUInt32(); - RewardTitleId = questRecord[23].GetUInt8(); - RequiredPlayerKills = questRecord[24].GetUInt8(); - RewardTalents = questRecord[25].GetUInt8(); - RewardArenaPoints = questRecord[26].GetUInt16(); - - for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) + _id = questRecord[0].GetUInt32(); + _method = questRecord[1].GetUInt8(); + _level = questRecord[2].GetInt16(); + _minLevel = questRecord[3].GetUInt8(); + _zoneOrSort = questRecord[4].GetInt16(); + _type = questRecord[5].GetUInt16(); + _suggestedPlayers = questRecord[6].GetUInt8(); + _timeAllowed = questRecord[7].GetUInt32(); + _allowableRaces = questRecord[8].GetUInt16(); + _requiredFactionId1 = questRecord[9].GetUInt16(); + _requiredFactionId2 = questRecord[10].GetUInt16(); + _requiredFactionValue1 = questRecord[11].GetInt32(); + _requiredFactionValue2 = questRecord[12].GetInt32(); + _rewardNextQuest = questRecord[13].GetUInt32(); + _rewardXPDifficulty = questRecord[14].GetUInt8(); + _rewardMoney = questRecord[15].GetInt32(); + _rewardBonusMoney = questRecord[16].GetUInt32(); + _rewardDisplaySpell = questRecord[17].GetUInt32(); + _rewardSpell = questRecord[18].GetInt32(); + _rewardHonor = questRecord[19].GetUInt32(); + _rewardKillHonor = questRecord[20].GetFloat(); + _startItem = questRecord[21].GetUInt32(); + _flags = questRecord[22].GetUInt32(); + _rewardTitleId = questRecord[23].GetUInt8(); + _requiredPlayerKills = questRecord[24].GetUInt8(); + _rewardTalents = questRecord[25].GetUInt8(); + _rewardArenaPoints = questRecord[26].GetUInt16(); + + for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i) { - RewardItemId[i] = questRecord[27+i*2].GetUInt32(); - RewardItemIdCount[i] = questRecord[28+i*2].GetUInt16(); + RewardItemId[i] = questRecord[27 + i * 2].GetUInt32(); + RewardItemIdCount[i] = questRecord[28 + i * 2].GetUInt16(); if (RewardItemId[i]) ++_rewItemsCount; } - for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) { - RewardChoiceItemId[i] = questRecord[35+i*2].GetUInt32(); - RewardChoiceItemCount[i] = questRecord[36+i*2].GetUInt16(); + RewardChoiceItemId[i] = questRecord[35 + i * 2].GetUInt32(); + RewardChoiceItemCount[i] = questRecord[36 + i * 2].GetUInt16(); if (RewardChoiceItemId[i]) ++_rewChoiceItemsCount; } - for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) { - RewardFactionId[i] = questRecord[47+i*3].GetUInt16(); - RewardFactionValueId[i] = questRecord[48+i*3].GetInt32(); - RewardFactionValueIdOverride[i] = questRecord[49+i*3].GetInt32(); + RewardFactionId[i] = questRecord[47 + i * 3].GetUInt16(); + RewardFactionValueId[i] = questRecord[48 + i * 3].GetInt32(); + RewardFactionValueIdOverride[i] = questRecord[49 + i * 3].GetInt32(); } - POIContinent = questRecord[62].GetUInt16(); - POIx = questRecord[63].GetFloat(); - POIy = questRecord[64].GetFloat(); - POIPriority = questRecord[65].GetUInt32(); - Title = questRecord[66].GetString(); - Objectives = questRecord[67].GetString(); - Details = questRecord[68].GetString(); - AreaDescription = questRecord[69].GetString(); - CompletedText = questRecord[70].GetString(); - - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + _poiContinent = questRecord[62].GetUInt16(); + _poiX = questRecord[63].GetFloat(); + _poiY = questRecord[64].GetFloat(); + _poiPriority = questRecord[65].GetUInt32(); + _title = questRecord[66].GetString(); + _objectives = questRecord[67].GetString(); + _details = questRecord[68].GetString(); + _areaDescription = questRecord[69].GetString(); + _completedText = questRecord[70].GetString(); + + for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { RequiredNpcOrGo[i] = questRecord[71+i].GetInt32(); RequiredNpcOrGoCount[i] = questRecord[75+i].GetUInt16(); @@ -107,13 +99,13 @@ Quest::Quest(Field* questRecord) ++_reqCreatureOrGOcount; } - for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) + for (uint32 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) { ItemDrop[i] = questRecord[79+i].GetUInt32(); ItemDropQuantity[i] = questRecord[83+i].GetUInt16(); } - for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { RequiredItemId[i] = questRecord[87+i].GetUInt32(); RequiredItemCount[i] = questRecord[93+i].GetUInt16(); @@ -124,14 +116,6 @@ Quest::Quest(Field* questRecord) // int8 Unknown0 = questRecord[99].GetUInt8(); // int32 VerifiedBuild = questRecord[104].GetInt32(); - - for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - { - DetailsEmote[i] = 0; - DetailsEmoteDelay[i] = 0; - OfferRewardEmote[i] = 0; - OfferRewardEmoteDelay[i] = 0; - } } void Quest::LoadQuestDetails(Field* fields) @@ -153,67 +137,67 @@ void Quest::LoadQuestDetails(Field* fields) void Quest::LoadQuestRequestItems(Field* fields) { - EmoteOnComplete = fields[1].GetUInt16(); - EmoteOnIncomplete = fields[2].GetUInt16(); + _emoteOnComplete = fields[1].GetUInt16(); + _emoteOnIncomplete = fields[2].GetUInt16(); - if (!sEmotesStore.LookupEntry(EmoteOnComplete)) - TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnComplete (%u) set for quest %u.", EmoteOnComplete, fields[0].GetUInt32()); + if (!sEmotesStore.LookupEntry(_emoteOnComplete)) + TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnComplete (%u) set for quest %u.", _emoteOnComplete, fields[0].GetUInt32()); - if (!sEmotesStore.LookupEntry(EmoteOnIncomplete)) - TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnIncomplete (%u) set for quest %u.", EmoteOnIncomplete, fields[0].GetUInt32()); + if (!sEmotesStore.LookupEntry(_emoteOnIncomplete)) + TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnIncomplete (%u) set for quest %u.", _emoteOnIncomplete, fields[0].GetUInt32()); - RequestItemsText = fields[3].GetString(); + _requestItemsText = fields[3].GetString(); } void Quest::LoadQuestOfferReward(Field* fields) { - for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) + for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i) { - if (!sEmotesStore.LookupEntry(fields[1+i].GetUInt16())) + if (!sEmotesStore.LookupEntry(fields[1 + i].GetUInt16())) { - TC_LOG_ERROR("sql.sql", "Table `quest_offer_reward` has non-existing Emote%i (%u) set for quest %u. Skipped.", 1+i, fields[1+i].GetUInt16(), fields[0].GetUInt32()); + TC_LOG_ERROR("sql.sql", "Table `quest_offer_reward` has non-existing Emote%i (%u) set for quest %u. Skipped.", 1 + i, fields[1 + i].GetUInt16(), fields[0].GetUInt32()); continue; } - OfferRewardEmote[i] = fields[1+i].GetUInt16(); + OfferRewardEmote[i] = fields[1 + i].GetUInt16(); } - for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmoteDelay[i] = fields[5+i].GetUInt32(); + for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i) + OfferRewardEmoteDelay[i] = fields[5 + i].GetUInt32(); - OfferRewardText = fields[9].GetString(); + _offerRewardText = fields[9].GetString(); } void Quest::LoadQuestTemplateAddon(Field* fields) { - MaxLevel = fields[1].GetUInt8(); - RequiredClasses = fields[2].GetUInt32(); - SourceSpellid = fields[3].GetUInt32(); - PrevQuestId = fields[4].GetInt32(); - NextQuestId = fields[5].GetInt32(); - ExclusiveGroup = fields[6].GetInt32(); - RewardMailTemplateId = fields[7].GetUInt32(); - RewardMailDelay = fields[8].GetUInt32(); - RequiredSkillId = fields[9].GetUInt16(); - RequiredSkillPoints = fields[10].GetUInt16(); - RequiredMinRepFaction = fields[11].GetUInt16(); - RequiredMaxRepFaction = fields[12].GetUInt16(); - RequiredMinRepValue = fields[13].GetInt32(); - RequiredMaxRepValue = fields[14].GetInt32(); - StartItemCount = fields[15].GetUInt8(); - RewardMailSenderEntry = fields[16].GetUInt32(); - SpecialFlags = fields[17].GetUInt8(); - - if (SpecialFlags & QUEST_SPECIAL_FLAGS_AUTO_ACCEPT) - Flags |= QUEST_FLAGS_AUTO_ACCEPT; + _maxLevel = fields[1].GetUInt8(); + _requiredClasses = fields[2].GetUInt32(); + _sourceSpellid = fields[3].GetUInt32(); + _prevQuestId = fields[4].GetInt32(); + _nextQuestId = fields[5].GetInt32(); + _exclusiveGroup = fields[6].GetInt32(); + _rewardMailTemplateId = fields[7].GetUInt32(); + _rewardMailDelay = fields[8].GetUInt32(); + _requiredSkillId = fields[9].GetUInt16(); + _requiredSkillPoints = fields[10].GetUInt16(); + _requiredMinRepFaction = fields[11].GetUInt16(); + _requiredMaxRepFaction = fields[12].GetUInt16(); + _requiredMinRepValue = fields[13].GetInt32(); + _requiredMaxRepValue = fields[14].GetInt32(); + _startItemCount = fields[15].GetUInt8(); + _rewardMailSenderEntry = fields[16].GetUInt32(); + _specialFlags = fields[17].GetUInt8(); + + if (_specialFlags & QUEST_SPECIAL_FLAGS_AUTO_ACCEPT) + _flags |= QUEST_FLAGS_AUTO_ACCEPT; } uint32 Quest::XPValue(Player* player) const { if (player) { - int32 quest_level = (Level == -1 ? player->getLevel() : Level); - const QuestXPEntry* xpentry = sQuestXPStore.LookupEntry(quest_level); + int32 quest_level = (_level == -1 ? player->getLevel() : _level); + QuestXPEntry const* xpentry = sQuestXPStore.LookupEntry(quest_level); if (!xpentry) return 0; @@ -223,7 +207,7 @@ uint32 Quest::XPValue(Player* player) const else if (diffFactor > 10) diffFactor = 10; - uint32 xp = diffFactor * xpentry->Exp[RewardXPDifficulty] / 10; + uint32 xp = diffFactor * xpentry->Exp[_rewardXPDifficulty] / 10; if (xp <= 100) xp = 5 * ((xp + 2) / 5); else if (xp <= 500) @@ -242,11 +226,11 @@ uint32 Quest::XPValue(Player* player) const int32 Quest::GetRewOrReqMoney() const { // RequiredMoney: the amount is the negative copper sum. - if (RewardMoney <= 0) - return RewardMoney; + if (_rewardMoney <= 0) + return _rewardMoney; // RewardMoney: the positive amount - return int32(RewardMoney * sWorld->getRate(RATE_MONEY_QUEST)); + return int32(_rewardMoney * sWorld->getRate(RATE_MONEY_QUEST)); } uint32 Quest::GetRewMoneyMaxLevel() const @@ -256,7 +240,7 @@ uint32 Quest::GetRewMoneyMaxLevel() const return 0; // Else, return the rewarded copper sum modified by the rate - return uint32(RewardBonusMoney * sWorld->getRate(RATE_MONEY_MAX_LEVEL_QUEST)); + return uint32(_rewardBonusMoney * sWorld->getRate(RATE_MONEY_MAX_LEVEL_QUEST)); } bool Quest::IsAutoAccept() const @@ -266,12 +250,12 @@ bool Quest::IsAutoAccept() const bool Quest::IsAutoComplete() const { - return !sWorld->getBoolConfig(CONFIG_QUEST_IGNORE_AUTO_COMPLETE) && (Method == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE)); + return !sWorld->getBoolConfig(CONFIG_QUEST_IGNORE_AUTO_COMPLETE) && (_method == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE)); } bool Quest::IsRaidQuest(Difficulty difficulty) const { - switch (Type) + switch (_type) { case QUEST_TYPE_RAID: return true; @@ -283,7 +267,7 @@ bool Quest::IsRaidQuest(Difficulty difficulty) const break; } - if ((Flags & QUEST_FLAGS_RAID) != 0) + if ((_flags & QUEST_FLAGS_RAID) != 0) return true; return false; diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 50f5ae76866..b2ff1e4625e 100644 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -203,102 +203,104 @@ class TC_GAME_API Quest uint32 XPValue(Player* player) const; - bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; } - void SetFlag(uint32 flag) { Flags |= flag; } + bool HasFlag(uint32 flag) const { return (_flags & flag) != 0; } + void SetFlag(uint32 flag) { _flags |= flag; } - bool HasSpecialFlag(uint32 flag) const { return (SpecialFlags & flag) != 0; } - void SetSpecialFlag(uint32 flag) { SpecialFlags |= flag; } + bool HasSpecialFlag(uint32 flag) const { return (_specialFlags & flag) != 0; } + void SetSpecialFlag(uint32 flag) { _specialFlags |= flag; } // table data accessors: - uint32 GetQuestId() const { return Id; } - uint32 GetQuestMethod() const { return Method; } - int32 GetZoneOrSort() const { return ZoneOrSort; } - uint32 GetMinLevel() const { return MinLevel; } - uint32 GetMaxLevel() const { return MaxLevel; } - int32 GetQuestLevel() const { return Level; } - uint32 GetType() const { return Type; } - uint32 GetRequiredClasses() const { return RequiredClasses; } - uint32 GetAllowableRaces() const { return AllowableRaces; } - uint32 GetRequiredSkill() const { return RequiredSkillId; } - uint32 GetRequiredSkillValue() const { return RequiredSkillPoints; } - uint32 GetRepObjectiveFaction() const { return RequiredFactionId1; } - int32 GetRepObjectiveValue() const { return RequiredFactionValue1; } - uint32 GetRepObjectiveFaction2() const { return RequiredFactionId2; } - int32 GetRepObjectiveValue2() const { return RequiredFactionValue2; } - uint32 GetRequiredMinRepFaction() const { return RequiredMinRepFaction; } - int32 GetRequiredMinRepValue() const { return RequiredMinRepValue; } - uint32 GetRequiredMaxRepFaction() const { return RequiredMaxRepFaction; } - int32 GetRequiredMaxRepValue() const { return RequiredMaxRepValue; } - uint32 GetSuggestedPlayers() const { return SuggestedPlayers; } - uint32 GetTimeAllowed() const { return TimeAllowed; } - int32 GetPrevQuestId() const { return PrevQuestId; } - int32 GetNextQuestId() const { return NextQuestId; } - int32 GetExclusiveGroup() const { return ExclusiveGroup; } - uint32 GetNextQuestInChain() const { return RewardNextQuest; } - uint32 GetCharTitleId() const { return RewardTitleId; } - uint32 GetPlayersSlain() const { return RequiredPlayerKills; } - uint32 GetBonusTalents() const { return RewardTalents; } - int32 GetRewArenaPoints() const {return RewardArenaPoints; } - uint32 GetXPId() const { return RewardXPDifficulty; } - uint32 GetSrcItemId() const { return StartItem; } - uint32 GetSrcItemCount() const { return StartItemCount; } - uint32 GetSrcSpell() const { return SourceSpellid; } - std::string const& GetTitle() const { return Title; } - std::string const& GetDetails() const { return Details; } - std::string const& GetObjectives() const { return Objectives; } - std::string const& GetOfferRewardText() const { return OfferRewardText; } - std::string const& GetRequestItemsText() const { return RequestItemsText; } - std::string const& GetAreaDescription() const { return AreaDescription; } - std::string const& GetCompletedText() const { return CompletedText; } + uint32 GetQuestId() const { return _id; } + uint32 GetQuestMethod() const { return _method; } + int32 GetZoneOrSort() const { return _zoneOrSort; } + uint32 GetMinLevel() const { return _minLevel; } + uint32 GetMaxLevel() const { return _maxLevel; } + int32 GetQuestLevel() const { return _level; } + uint32 GetType() const { return _type; } + uint32 GetRequiredClasses() const { return _requiredClasses; } + uint32 GetAllowableRaces() const { return _allowableRaces; } + uint32 GetRequiredSkill() const { return _requiredSkillId; } + uint32 GetRequiredSkillValue() const { return _requiredSkillPoints; } + uint32 GetRepObjectiveFaction() const { return _requiredFactionId1; } + int32 GetRepObjectiveValue() const { return _requiredFactionValue1; } + uint32 GetRepObjectiveFaction2() const { return _requiredFactionId2; } + int32 GetRepObjectiveValue2() const { return _requiredFactionValue2; } + uint32 GetRequiredMinRepFaction() const { return _requiredMinRepFaction; } + int32 GetRequiredMinRepValue() const { return _requiredMinRepValue; } + uint32 GetRequiredMaxRepFaction() const { return _requiredMaxRepFaction; } + int32 GetRequiredMaxRepValue() const { return _requiredMaxRepValue; } + uint32 GetSuggestedPlayers() const { return _suggestedPlayers; } + uint32 GetTimeAllowed() const { return _timeAllowed; } + int32 GetPrevQuestId() const { return _prevQuestId; } + int32 GetNextQuestId() const { return _nextQuestId; } + int32 GetExclusiveGroup() const { return _exclusiveGroup; } + uint32 GetNextQuestInChain() const { return _rewardNextQuest; } + uint32 GetCharTitleId() const { return _rewardTitleId; } + uint32 GetPlayersSlain() const { return _requiredPlayerKills; } + uint32 GetBonusTalents() const { return _rewardTalents; } + int32 GetRewArenaPoints() const {return _rewardArenaPoints; } + uint32 GetXPId() const { return _rewardXPDifficulty; } + uint32 GetSrcItemId() const { return _startItem; } + uint32 GetSrcItemCount() const { return _startItemCount; } + uint32 GetSrcSpell() const { return _sourceSpellid; } + std::string const& GetTitle() const { return _title; } + std::string const& GetDetails() const { return _details; } + std::string const& GetObjectives() const { return _objectives; } + std::string const& GetOfferRewardText() const { return _offerRewardText; } + std::string const& GetRequestItemsText() const { return _requestItemsText; } + std::string const& GetAreaDescription() const { return _areaDescription; } + std::string const& GetCompletedText() const { return _completedText; } int32 GetRewOrReqMoney() const; - uint32 GetRewHonorAddition() const { return RewardHonor; } - float GetRewHonorMultiplier() const { return RewardKillHonor; } + uint32 GetRewHonorAddition() const { return _rewardHonor; } + float GetRewHonorMultiplier() const { return _rewardKillHonor; } uint32 GetRewMoneyMaxLevel() const; // use in XP calculation at client - uint32 GetRewSpell() const { return RewardDisplaySpell; } - int32 GetRewSpellCast() const { return RewardSpell; } - uint32 GetRewMailTemplateId() const { return RewardMailTemplateId; } - uint32 GetRewMailDelaySecs() const { return RewardMailDelay; } - uint32 GetRewMailSenderEntry() const { return RewardMailSenderEntry; } - uint32 GetPOIContinent() const { return POIContinent; } - float GetPOIx() const { return POIx; } - float GetPOIy() const { return POIy; } - uint32 GetPointOpt() const { return POIPriority; } - uint32 GetIncompleteEmote() const { return EmoteOnIncomplete; } - uint32 GetCompleteEmote() const { return EmoteOnComplete; } - bool IsRepeatable() const { return SpecialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE; } + uint32 GetRewSpell() const { return _rewardDisplaySpell; } + int32 GetRewSpellCast() const { return _rewardSpell; } + uint32 GetRewMailTemplateId() const { return _rewardMailTemplateId; } + uint32 GetRewMailDelaySecs() const { return _rewardMailDelay; } + uint32 GetRewMailSenderEntry() const { return _rewardMailSenderEntry; } + uint32 GetPOIContinent() const { return _poiContinent; } + float GetPOIx() const { return _poiX; } + float GetPOIy() const { return _poiY; } + uint32 GetPointOpt() const { return _poiPriority; } + uint32 GetIncompleteEmote() const { return _emoteOnIncomplete; } + uint32 GetCompleteEmote() const { return _emoteOnComplete; } + bool IsRepeatable() const { return _specialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE; } bool IsAutoAccept() const; bool IsAutoComplete() const; - uint32 GetFlags() const { return Flags; } - bool IsDaily() const { return (Flags & QUEST_FLAGS_DAILY) != 0; } - bool IsWeekly() const { return (Flags & QUEST_FLAGS_WEEKLY) != 0; } - bool IsMonthly() const { return (SpecialFlags & QUEST_SPECIAL_FLAGS_MONTHLY) != 0; } - bool IsSeasonal() const { return (ZoneOrSort == -QUEST_SORT_SEASONAL || ZoneOrSort == -QUEST_SORT_SPECIAL || ZoneOrSort == -QUEST_SORT_LUNAR_FESTIVAL || ZoneOrSort == -QUEST_SORT_MIDSUMMER || ZoneOrSort == -QUEST_SORT_BREWFEST || ZoneOrSort == -QUEST_SORT_LOVE_IS_IN_THE_AIR || ZoneOrSort == -QUEST_SORT_NOBLEGARDEN) && !IsRepeatable(); } - bool IsDailyOrWeekly() const { return (Flags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) != 0; } + uint32 GetFlags() const { return _flags; } + bool IsDaily() const { return (_flags & QUEST_FLAGS_DAILY) != 0; } + bool IsWeekly() const { return (_flags & QUEST_FLAGS_WEEKLY) != 0; } + bool IsMonthly() const { return (_specialFlags & QUEST_SPECIAL_FLAGS_MONTHLY) != 0; } + bool IsSeasonal() const { return (_zoneOrSort == -QUEST_SORT_SEASONAL || _zoneOrSort == -QUEST_SORT_SPECIAL || _zoneOrSort == -QUEST_SORT_LUNAR_FESTIVAL || _zoneOrSort == -QUEST_SORT_MIDSUMMER || _zoneOrSort == -QUEST_SORT_BREWFEST || _zoneOrSort == -QUEST_SORT_LOVE_IS_IN_THE_AIR || _zoneOrSort == -QUEST_SORT_NOBLEGARDEN) && !IsRepeatable(); } + bool IsDailyOrWeekly() const { return (_flags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) != 0; } bool IsRaidQuest(Difficulty difficulty) const; bool IsAllowedInRaid(Difficulty difficulty) const; - bool IsDFQuest() const { return (SpecialFlags & QUEST_SPECIAL_FLAGS_DF_QUEST) != 0; } + bool IsDFQuest() const { return (_specialFlags & QUEST_SPECIAL_FLAGS_DF_QUEST) != 0; } uint32 CalculateHonorGain(uint8 level) const; bool CanIncreaseRewardedQuestCounters() const; // multiple values + std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; - uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT]; - uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT]; - uint32 ItemDrop[QUEST_SOURCE_ITEM_IDS_COUNT]; - uint32 ItemDropQuantity[QUEST_SOURCE_ITEM_IDS_COUNT]; - int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject - uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]; - uint32 RewardChoiceItemId[QUEST_REWARD_CHOICES_COUNT]; - uint32 RewardChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]; - uint32 RewardItemId[QUEST_REWARDS_COUNT]; - uint32 RewardItemIdCount[QUEST_REWARDS_COUNT]; - uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT]; - int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT]; - int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT]; - uint32 DetailsEmote[QUEST_EMOTE_COUNT]; - uint32 DetailsEmoteDelay[QUEST_EMOTE_COUNT]; - uint32 OfferRewardEmote[QUEST_EMOTE_COUNT]; - uint32 OfferRewardEmoteDelay[QUEST_EMOTE_COUNT]; + + uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT] = { }; + uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT] = { }; + uint32 ItemDrop[QUEST_SOURCE_ITEM_IDS_COUNT] = { }; + uint32 ItemDropQuantity[QUEST_SOURCE_ITEM_IDS_COUNT] = { }; + int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT] = { }; // >0 Creature <0 Gameobject + uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT] = { }; + uint32 RewardChoiceItemId[QUEST_REWARD_CHOICES_COUNT] = { }; + uint32 RewardChoiceItemCount[QUEST_REWARD_CHOICES_COUNT] = { }; + uint32 RewardItemId[QUEST_REWARDS_COUNT] = { }; + uint32 RewardItemIdCount[QUEST_REWARDS_COUNT] = { }; + uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT] = { }; + int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT] = { }; + int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT] = { }; + uint32 DetailsEmote[QUEST_EMOTE_COUNT] = { }; + uint32 DetailsEmoteDelay[QUEST_EMOTE_COUNT] = { }; + uint32 OfferRewardEmote[QUEST_EMOTE_COUNT] = { }; + uint32 OfferRewardEmoteDelay[QUEST_EMOTE_COUNT] = { }; uint32 GetReqItemsCount() const { return _reqItemsCount; } uint32 GetReqCreatureOrGOcount() const { return _reqCreatureOrGOcount; } @@ -312,96 +314,87 @@ class TC_GAME_API Quest void InitializeQueryData(); WorldPacket BuildQueryData(LocaleConstant loc) const; - typedef std::vector<int32> PrevQuests; - PrevQuests prevQuests; - typedef std::vector<uint32> PrevChainQuests; - PrevChainQuests prevChainQuests; + std::vector<int32> PrevQuests; + std::vector<uint32> PrevChainQuests; WorldPacket QueryData[TOTAL_LOCALES]; // cached data private: - uint32 _reqItemsCount; - uint32 _reqCreatureOrGOcount; - uint32 _rewChoiceItemsCount; - uint32 _rewItemsCount; - uint16 _eventIdForQuest; + uint32 _reqItemsCount = 0; + uint32 _reqCreatureOrGOcount = 0; + uint32 _rewChoiceItemsCount = 0; + uint32 _rewItemsCount = 0; + uint16 _eventIdForQuest = 0; // table data - protected: - uint32 Id; - uint32 Method; - int32 ZoneOrSort; - uint32 MinLevel; - int32 Level; - uint32 Type; - uint32 AllowableRaces; - uint32 RequiredFactionId1; - int32 RequiredFactionValue1; - uint32 RequiredFactionId2; - int32 RequiredFactionValue2; - uint32 SuggestedPlayers; - uint32 TimeAllowed; - uint32 Flags; - uint32 RewardTitleId; - uint32 RequiredPlayerKills; - uint32 RewardTalents; - int32 RewardArenaPoints; - uint32 RewardNextQuest; - uint32 RewardXPDifficulty; - uint32 StartItem; - std::string Title; - std::string Details; - std::string Objectives; - std::string OfferRewardText; - std::string RequestItemsText; - std::string AreaDescription; - std::string CompletedText; - uint32 RewardHonor; - float RewardKillHonor; - int32 RewardMoney; - uint32 RewardBonusMoney; - uint32 RewardDisplaySpell; - int32 RewardSpell; - uint32 POIContinent; - float POIx; - float POIy; - uint32 POIPriority; - uint32 EmoteOnIncomplete; - uint32 EmoteOnComplete; + uint32 _id = 0; + uint32 _method = 0; + int32 _zoneOrSort = 0; + uint32 _minLevel = 0; + int32 _level = 0; + uint32 _type = 0; + uint32 _allowableRaces = 0; + uint32 _requiredFactionId1 = 0; + int32 _requiredFactionValue1 = 0; + uint32 _requiredFactionId2 = 0; + int32 _requiredFactionValue2 = 0; + uint32 _suggestedPlayers = 0; + uint32 _timeAllowed = 0; + uint32 _flags = 0; + uint32 _rewardTitleId = 0; + uint32 _requiredPlayerKills = 0; + uint32 _rewardTalents = 0; + int32 _rewardArenaPoints = 0; + uint32 _rewardNextQuest = 0; + uint32 _rewardXPDifficulty = 0; + uint32 _startItem = 0; + std::string _title; + std::string _details; + std::string _objectives; + std::string _offerRewardText; + std::string _requestItemsText; + std::string _areaDescription; + std::string _completedText; + uint32 _rewardHonor = 0; + float _rewardKillHonor = 0.f; + int32 _rewardMoney = 0; + uint32 _rewardBonusMoney = 0; + uint32 _rewardDisplaySpell = 0; + int32 _rewardSpell = 0; + uint32 _poiContinent = 0; + float _poiX = 0.f; + float _poiY = 0.f; + uint32 _poiPriority = 0; + uint32 _emoteOnIncomplete = 0; + uint32 _emoteOnComplete = 0; // quest_template_addon table (custom data) - uint32 MaxLevel = 0; - uint32 RequiredClasses = 0; - uint32 SourceSpellid = 0; - int32 PrevQuestId = 0; - int32 NextQuestId = 0; - int32 ExclusiveGroup = 0; - uint32 RewardMailTemplateId = 0; - uint32 RewardMailDelay = 0; - uint32 RequiredSkillId = 0; - uint32 RequiredSkillPoints = 0; - uint32 RequiredMinRepFaction = 0; - int32 RequiredMinRepValue = 0; - uint32 RequiredMaxRepFaction = 0; - int32 RequiredMaxRepValue = 0; - uint32 StartItemCount = 0; - uint32 RewardMailSenderEntry = 0; - uint32 SpecialFlags = 0; // custom flags, not sniffed/WDB + uint32 _maxLevel = 0; + uint32 _requiredClasses = 0; + uint32 _sourceSpellid = 0; + int32 _prevQuestId = 0; + int32 _nextQuestId = 0; + int32 _exclusiveGroup = 0; + uint32 _rewardMailTemplateId = 0; + uint32 _rewardMailDelay = 0; + uint32 _requiredSkillId = 0; + uint32 _requiredSkillPoints = 0; + uint32 _requiredMinRepFaction = 0; + int32 _requiredMinRepValue = 0; + uint32 _requiredMaxRepFaction = 0; + int32 _requiredMaxRepValue = 0; + uint32 _startItemCount = 0; + uint32 _rewardMailSenderEntry = 0; + uint32 _specialFlags = 0; // custom flags, not sniffed/WDB }; struct QuestStatusData { - QuestStatusData(): Status(QUEST_STATUS_NONE), Timer(0), PlayerCount(0), Explored(false) - { - memset(ItemCount, 0, QUEST_ITEM_OBJECTIVES_COUNT * sizeof(uint16)); - memset(CreatureOrGOCount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint16)); - } - - QuestStatus Status; - uint32 Timer; - uint16 ItemCount[QUEST_ITEM_OBJECTIVES_COUNT]; - uint16 CreatureOrGOCount[QUEST_OBJECTIVES_COUNT]; - uint16 PlayerCount; - bool Explored; + QuestStatus Status = QUEST_STATUS_NONE; + uint32 Timer = 0; + uint16 ItemCount[QUEST_ITEM_OBJECTIVES_COUNT] = { }; + uint16 CreatureOrGOCount[QUEST_OBJECTIVES_COUNT] = { }; + uint16 PlayerCount = 0; + bool Explored = false; }; #endif |
