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
+3 -31
View File
@@ -1232,10 +1232,7 @@ 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:
case TypeId.Player:
{ {
//For AutoSubmition was added plr case there as it almost same exclute AI script cases. //For AutoSubmition was added plr case there as it almost same exclute AI script cases.
// Send next quest // Send next quest
@@ -1253,33 +1250,8 @@ namespace Game.Entities
} }
PlayerTalkClass.ClearMenus(); PlayerTalkClass.ClearMenus();
Creature creatureQGiver = questGiver.ToCreature(); questGiver.ToCreature()?.GetAI().OnQuestReward(this, quest, rewardType, rewardId);
if (creatureQGiver != null) questGiver.ToGameObject()?.GetAI().OnQuestReward(this, quest, rewardType, rewardId);
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.ToGameObject()?.GetAI()?.OnQuestReward(this, quest, rewardType, rewardId);
break;
}
default:
break;
} }
Global.ScriptMgr.OnQuestStatusChange(this, questId); Global.ScriptMgr.OnQuestStatusChange(this, questId);