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.
This commit is contained in:
Aokromes committed 2018-05-12 13:23:19 +02:00
1 parent ae1abb63be
commit 98364454ca
3 files changed
+7 -9

No files matched your search

@@ -374,11 +374,6 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
}
return false;
case DISABLE_TYPE_QUEST:
if (!unit)
return true;
if (Player const* player = unit->ToPlayer())
if (player->IsGameMaster())
return false;
return true;
case DISABLE_TYPE_BATTLEGROUND:
case DISABLE_TYPE_OUTDOORPVP:
+1 -1
View File
@@ -15205,7 +15205,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
// cast spells after mark quest complete (some spells have quest completed state requirements in spell_area data)
if (quest->GetRewSpellCast() > 0)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpellCast());
SpellInfo const* spellInfo = ASSERT_NOTNULL(sSpellMgr->GetSpellInfo(quest->GetRewSpellCast()));
if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !quest->HasFlag(QUEST_FLAGS_PLAYER_CAST_ON_COMPLETE))
{
if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID()))
+6 -3
View File
@@ -26,6 +26,7 @@ EndScriptData */
#include "Chat.h"
#include "DatabaseEnv.h"
#include "DBCStores.h"
#include "DisableMgr.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ReputationMgr.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);
@@ -185,7 +186,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);
@@ -289,7 +291,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);