aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2018-05-05 19:17:52 +0200
committerShauren <shauren.trinity@gmail.com>2021-09-26 16:21:11 +0200
commit330881518a5912939a2a26a7f3dbc64ccf74b5cc (patch)
treebf3ce505e2348f8c750c99160bf90fcb881b9752
parentab740026b30b80e8599a0ad8c8a8eb466b6f4222 (diff)
Core/Quest: Fix crash caused by disabled quests
Fix crash happening when a disabled quest was added and rewarded (through a GM command). Disabled quests are not validated on startup and they can reference invalid spells. (cherry picked from commit 5f6af8c6cbe7c5a622dd51a77e0d27db33c99118)
-rw-r--r--src/server/game/Conditions/DisableMgr.cpp5
-rw-r--r--src/server/game/Entities/Player/Player.cpp4
-rw-r--r--src/server/scripts/Commands/cs_quest.cpp9
3 files changed, 8 insertions, 10 deletions
diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp
index 1c1d9f4cb99..f1dbec72ba0 100644
--- a/src/server/game/Conditions/DisableMgr.cpp
+++ b/src/server/game/Conditions/DisableMgr.cpp
@@ -354,11 +354,6 @@ bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const* ref, uint8
}
return false;
case DISABLE_TYPE_QUEST:
- if (!ref)
- return true;
- if (Player const* player = ref->ToPlayer())
- if (player->IsGameMaster())
- return false;
return true;
case DISABLE_TYPE_BATTLEGROUND:
case DISABLE_TYPE_OUTDOORPVP:
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 2bb930747c5..f8eedbe9752 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -15755,7 +15755,7 @@ void Player::RewardQuest(Quest const* quest, LootItemType rewardType, uint32 rew
// cast spells after mark quest complete (some spells have quest completed state requirements in spell_area data)
if (quest->GetRewSpell() > 0)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpell(), GetMap()->GetDifficultyID());
+ SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(quest->GetRewSpell(), GetMap()->GetDifficultyID());
Unit* caster = this;
if (questGiver && questGiver->isType(TYPEMASK_UNIT) && !quest->HasFlag(QUEST_FLAGS_PLAYER_CAST_ON_COMPLETE) && !spellInfo->HasTargetType(TARGET_UNIT_CASTER))
if (Unit* unit = questGiver->ToUnit())
@@ -15771,7 +15771,7 @@ void Player::RewardQuest(Quest const* quest, LootItemType rewardType, uint32 rew
if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition))
continue;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(displaySpell.SpellId, GetMap()->GetDifficultyID());
+ SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(displaySpell.SpellId, GetMap()->GetDifficultyID());
Unit* caster = this;
if (questGiver && questGiver->isType(TYPEMASK_UNIT) && !quest->HasFlag(QUEST_FLAGS_PLAYER_CAST_ON_COMPLETE) && !spellInfo->HasTargetType(TARGET_UNIT_CASTER))
if (Unit* unit = questGiver->ToUnit())
diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp
index 527b9680805..1e85ced4e1c 100644
--- a/src/server/scripts/Commands/cs_quest.cpp
+++ b/src/server/scripts/Commands/cs_quest.cpp
@@ -26,6 +26,7 @@ EndScriptData */
#include "Chat.h"
#include "DatabaseEnv.h"
#include "DB2Stores.h"
+#include "DisableMgr.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "RBAC.h"
@@ -73,7 +74,7 @@ public:
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
- if (!quest)
+ if (!quest || DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, entry, nullptr))
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
handler->SetSentErrorMessage(true);
@@ -188,7 +189,8 @@ public:
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
// If player doesn't have the quest
- if (!quest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE)
+ if (!quest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE
+ || DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, entry, nullptr))
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
handler->SetSentErrorMessage(true);
@@ -286,7 +288,8 @@ public:
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
// If player doesn't have the quest
- if (!quest || player->GetQuestStatus(entry) != QUEST_STATUS_COMPLETE)
+ if (!quest || player->GetQuestStatus(entry) != QUEST_STATUS_COMPLETE
+ || DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, entry, nullptr))
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
handler->SetSentErrorMessage(true);