aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOvahlord <dreadkiller@gmx.de>2024-07-06 21:42:36 +0200
committerOvahlord <dreadkiller@gmx.de>2024-07-06 21:42:36 +0200
commit0fe73dc2b6527b7f0088ac310679d1c9e9c630ff (patch)
treee5a40cfbc184bc0f5ac73caf673eeb354c290225 /src
parent6cbd1a241a19ff4f10ea468fa7bedd644c1050b6 (diff)
Core/Quests: fixed an oversight in quest query initialization which was causing crashes in debug mode
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp4
-rw-r--r--src/server/game/Quests/QuestDef.cpp20
-rw-r--r--src/server/game/Quests/QuestDef.h2
3 files changed, 14 insertions, 12 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 03cec46bb9d..d7f686ceb62 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -4598,8 +4598,8 @@ void ObjectMgr::LoadQuests()
// 0 1 2 3 4 5 6
{ "QuestID, Type1, Type2, Type3, Type4, Type5, Type6", "quest_reward_choice_items", "", "reward choice items", &Quest::LoadRewardChoiceItems },
- // 0 1 2 3
- { "QuestID, SpellID, PlayerConditionID, Type", "quest_reward_display_spell", "ORDER BY QuestID ASC, Idx ASC", "reward display spells", &Quest::LoadRewardDisplaySpell },
+ // 0 1 2 3 4
+ { "QuestID, Idx, SpellID, PlayerConditionID, Type", "quest_reward_display_spell", "ORDER BY QuestID ASC, Idx ASC", "reward display spells", &Quest::LoadRewardDisplaySpell },
// 0 1 2 3 4 5 6 7 8
{ "ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4", "quest_details", "", "details", &Quest::LoadQuestDetails },
diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp
index ed7ceb10b6b..9de14cfd28f 100644
--- a/src/server/game/Quests/QuestDef.cpp
+++ b/src/server/game/Quests/QuestDef.cpp
@@ -142,9 +142,16 @@ Quest::~Quest()
void Quest::LoadRewardDisplaySpell(Field* fields)
{
- uint32 spellId = fields[1].GetUInt32();
- uint32 playerConditionId = fields[2].GetUInt32();
- uint32 type = fields[3].GetUInt32();
+ uint32 idx = fields[1].GetUInt32();
+ uint32 spellId = fields[2].GetUInt32();
+ uint32 playerConditionId = fields[3].GetUInt32();
+ uint32 type = fields[4].GetUInt32();
+
+ if (idx >= QUEST_REWARD_DISPLAY_SPELL_COUNT)
+ {
+ TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` has an out of range Idx ({}) set for quest {} and spell {}. Skipped.", idx, fields[0].GetUInt32(), spellId);
+ return;
+ }
if (!sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE))
{
@@ -167,7 +174,7 @@ void Quest::LoadRewardDisplaySpell(Field* fields)
type = AsUnderlyingType(QuestCompleteSpellType::LegacyBehavior);
}
- RewardDisplaySpell.emplace_back(spellId, playerConditionId, QuestCompleteSpellType(type));
+ RewardDisplaySpell[idx] = QuestRewardDisplaySpell(spellId, playerConditionId, QuestCompleteSpellType(type));
}
void Quest::LoadRewardChoiceItems(Field* fields)
@@ -673,12 +680,7 @@ WorldPacket Quest::BuildQueryData(LocaleConstant loc, Player* player) const
response.Info.RewardBonusMoney = GetRewMoneyMaxLevel();
for (uint8 i = 0; i < QUEST_REWARD_DISPLAY_SPELL_COUNT; ++i)
- {
- if (RewardDisplaySpell.empty() || RewardDisplaySpell.size() < i)
- continue;
-
response.Info.RewardDisplaySpell[i] = RewardDisplaySpell[i].SpellId;
- }
response.Info.RewardSpell = GetRewSpell();
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index 87304dea1a4..edcde0fd66f 100644
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -659,7 +659,7 @@ class TC_GAME_API Quest
bool CanIncreaseRewardedQuestCounters() const;
// multiple values
- std::vector<QuestRewardDisplaySpell> RewardDisplaySpell;
+ std::array<QuestRewardDisplaySpell, QUEST_REWARD_DISPLAY_SPELL_COUNT> RewardDisplaySpell = { };
std::array<uint32, QUEST_REWARD_ITEM_COUNT> RewardItemId = { };
std::array<uint32, QUEST_REWARD_ITEM_COUNT> RewardItemCount = { };
std::array<uint32, QUEST_ITEM_DROP_COUNT> ItemDrop = { };