Core/Quests: Fixed crash in Player::RewardQuest

Port From (https://github.com/TrinityCore/TrinityCore/commit/f93b4d6c438b337d15bf1666f6f0e050beb97ce4)
This commit is contained in:
hondacrx
2023-06-24 08:52:27 -04:00
parent 49a07ebcce
commit 8b746a8996
+13 -41
View File
@@ -1232,54 +1232,26 @@ namespace Game.Entities
//lets remove flag for delayed teleports //lets remove flag for delayed teleports
SetCanDelayTeleport(false); SetCanDelayTeleport(false);
switch (questGiver.GetTypeId()) if (questGiver != null && questGiver.IsTypeMask(TypeMask.Unit | TypeMask.GameObject))
{ {
case TypeId.Unit: //For AutoSubmition was added plr case there as it almost same exclute AI script cases.
case TypeId.Player: // Send next quest
Quest nextQuest = GetNextQuest(questGiver, quest);
if (nextQuest != null)
{ {
//For AutoSubmition was added plr case there as it almost same exclute AI script cases. // Only send the quest to the player if the conditions are met
// Send next quest if (CanTakeQuest(nextQuest, false))
Quest nextQuest = GetNextQuest(questGiver, quest);
if (nextQuest != null)
{ {
// Only send the quest to the player if the conditions are met if (nextQuest.IsAutoAccept() && CanAddQuest(nextQuest, true))
if (CanTakeQuest(nextQuest, false)) AddQuestAndCheckCompletion(nextQuest, questGiver);
{
if (nextQuest.IsAutoAccept() && CanAddQuest(nextQuest, true))
AddQuestAndCheckCompletion(nextQuest, questGiver);
PlayerTalkClass.SendQuestGiverQuestDetails(nextQuest, questGiver.GetGUID(), true, false); PlayerTalkClass.SendQuestGiverQuestDetails(nextQuest, questGiver.GetGUID(), true, false);
}
} }
PlayerTalkClass.ClearMenus();
Creature creatureQGiver = questGiver.ToCreature();
if (creatureQGiver != null)
creatureQGiver.GetAI().OnQuestReward(this, quest, rewardType, rewardId);
break;
} }
case TypeId.GameObject:
{
// Send next quest
Quest nextQuest = GetNextQuest(questGiver, quest);
if (nextQuest != null)
{
// Only send the quest to the player if the conditions are met
if (CanTakeQuest(nextQuest, false))
{
if (nextQuest.IsAutoAccept() && CanAddQuest(nextQuest, true))
AddQuestAndCheckCompletion(nextQuest, questGiver);
PlayerTalkClass.SendQuestGiverQuestDetails(nextQuest, questGiver.GetGUID(), true, false); PlayerTalkClass.ClearMenus();
} questGiver.ToCreature()?.GetAI().OnQuestReward(this, quest, rewardType, rewardId);
} questGiver.ToGameObject()?.GetAI().OnQuestReward(this, quest, rewardType, rewardId);
PlayerTalkClass.ClearMenus();
questGiver.ToGameObject()?.GetAI()?.OnQuestReward(this, quest, rewardType, rewardId);
break;
}
default:
break;
} }
Global.ScriptMgr.OnQuestStatusChange(this, questId); Global.ScriptMgr.OnQuestStatusChange(this, questId);