Core/Quest: Fix crash in GetQuestDialogStatus()
Port From (https://github.com/TrinityCore/TrinityCore/commit/b1b5a6a591be621e23905a7f320a3db1dc96cf7f)
This commit is contained in:
@@ -27,6 +27,7 @@ using Game.Networking.Packets;
|
|||||||
using Game.Spells;
|
using Game.Spells;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Game.AI;
|
||||||
|
|
||||||
namespace Game.Entities
|
namespace Game.Entities
|
||||||
{
|
{
|
||||||
@@ -373,27 +374,27 @@ namespace Game.Entities
|
|||||||
case HighGuid.Creature:
|
case HighGuid.Creature:
|
||||||
case HighGuid.Pet:
|
case HighGuid.Pet:
|
||||||
case HighGuid.Vehicle:
|
case HighGuid.Vehicle:
|
||||||
{
|
{
|
||||||
Creature creature = ObjectAccessor.GetCreatureOrPetOrVehicle(this, guid);
|
Creature creature = ObjectAccessor.GetCreatureOrPetOrVehicle(this, guid);
|
||||||
if (creature != null)
|
if (creature != null)
|
||||||
objectQR = Global.ObjectMgr.GetCreatureQuestRelationBounds(creature.GetEntry());
|
objectQR = Global.ObjectMgr.GetCreatureQuestRelationBounds(creature.GetEntry());
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HighGuid.GameObject:
|
case HighGuid.GameObject:
|
||||||
{
|
{
|
||||||
//we should obtain map from GetMap() in 99% of cases. Special case
|
//we should obtain map from GetMap() in 99% of cases. Special case
|
||||||
//only for quests which cast teleport spells on player
|
//only for quests which cast teleport spells on player
|
||||||
Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId());
|
Map _map = IsInWorld ? GetMap() : Global.MapMgr.FindMap(GetMapId(), GetInstanceId());
|
||||||
Cypher.Assert(_map != null);
|
Cypher.Assert(_map != null);
|
||||||
GameObject gameObject = _map.GetGameObject(guid);
|
GameObject gameObject = _map.GetGameObject(guid);
|
||||||
if (gameObject != null)
|
if (gameObject != null)
|
||||||
objectQR = Global.ObjectMgr.GetGOQuestRelationBounds(gameObject.GetEntry());
|
objectQR = Global.ObjectMgr.GetGOQuestRelationBounds(gameObject.GetEntry());
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -695,26 +696,26 @@ namespace Game.Entities
|
|||||||
case TypeId.Container:
|
case TypeId.Container:
|
||||||
case TypeId.AzeriteItem:
|
case TypeId.AzeriteItem:
|
||||||
case TypeId.AzeriteEmpoweredItem:
|
case TypeId.AzeriteEmpoweredItem:
|
||||||
|
{
|
||||||
|
Item item = (Item)questGiver;
|
||||||
|
Global.ScriptMgr.OnQuestAccept(this, item, quest);
|
||||||
|
|
||||||
|
// destroy not required for quest finish quest starting item
|
||||||
|
bool destroyItem = true;
|
||||||
|
foreach (QuestObjective obj in quest.Objectives)
|
||||||
{
|
{
|
||||||
Item item = (Item)questGiver;
|
if (obj.Type == QuestObjectiveType.Item && obj.ObjectID == item.GetEntry() && item.GetTemplate().GetMaxCount() > 0)
|
||||||
Global.ScriptMgr.OnQuestAccept(this, item, quest);
|
|
||||||
|
|
||||||
// destroy not required for quest finish quest starting item
|
|
||||||
bool destroyItem = true;
|
|
||||||
foreach (QuestObjective obj in quest.Objectives)
|
|
||||||
{
|
{
|
||||||
if (obj.Type == QuestObjectiveType.Item && obj.ObjectID == item.GetEntry() && item.GetTemplate().GetMaxCount() > 0)
|
destroyItem = false;
|
||||||
{
|
break;
|
||||||
destroyItem = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroyItem)
|
|
||||||
DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (destroyItem)
|
||||||
|
DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TypeId.GameObject:
|
case TypeId.GameObject:
|
||||||
PlayerTalkClass.ClearMenus();
|
PlayerTalkClass.ClearMenus();
|
||||||
questGiver.ToGameObject().GetAI().QuestAccept(this, quest);
|
questGiver.ToGameObject().GetAI().QuestAccept(this, quest);
|
||||||
@@ -1852,25 +1853,33 @@ namespace Game.Entities
|
|||||||
switch (questgiver.GetTypeId())
|
switch (questgiver.GetTypeId())
|
||||||
{
|
{
|
||||||
case TypeId.GameObject:
|
case TypeId.GameObject:
|
||||||
|
{
|
||||||
|
GameObjectAI ai = questgiver.ToGameObject().GetAI();
|
||||||
|
if (ai != null)
|
||||||
{
|
{
|
||||||
QuestGiverStatus? questStatus = questgiver.ToGameObject().GetAI().GetDialogStatus(this);
|
var questStatus = ai.GetDialogStatus(this);
|
||||||
if (questStatus.HasValue)
|
if (questStatus.HasValue)
|
||||||
return questStatus.Value;
|
return questStatus.Value;
|
||||||
|
|
||||||
qr = Global.ObjectMgr.GetGOQuestRelationBounds(questgiver.GetEntry());
|
|
||||||
qir = Global.ObjectMgr.GetGOQuestInvolvedRelationBounds(questgiver.GetEntry());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qr = Global.ObjectMgr.GetGOQuestRelationBounds(questgiver.GetEntry());
|
||||||
|
qir = Global.ObjectMgr.GetGOQuestInvolvedRelationBounds(questgiver.GetEntry());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TypeId.Unit:
|
case TypeId.Unit:
|
||||||
|
{
|
||||||
|
CreatureAI ai = questgiver.ToCreature().GetAI();
|
||||||
|
if (ai != null)
|
||||||
{
|
{
|
||||||
QuestGiverStatus? questStatus = questgiver.ToCreature().GetAI().GetDialogStatus(this);
|
QuestGiverStatus? questStatus = ai.GetDialogStatus(this);
|
||||||
if (questStatus.HasValue)
|
if (questStatus.HasValue)
|
||||||
return questStatus.Value;
|
return questStatus.Value;
|
||||||
|
|
||||||
qr = Global.ObjectMgr.GetCreatureQuestRelationBounds(questgiver.GetEntry());
|
|
||||||
qir = Global.ObjectMgr.GetCreatureQuestInvolvedRelationBounds(questgiver.GetEntry());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qr = Global.ObjectMgr.GetCreatureQuestRelationBounds(questgiver.GetEntry());
|
||||||
|
qir = Global.ObjectMgr.GetCreatureQuestInvolvedRelationBounds(questgiver.GetEntry());
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// it's impossible, but check
|
// it's impossible, but check
|
||||||
Log.outError(LogFilter.Player, "GetQuestDialogStatus called for unexpected type {0}", questgiver.GetTypeId());
|
Log.outError(LogFilter.Player, "GetQuestDialogStatus called for unexpected type {0}", questgiver.GetTypeId());
|
||||||
|
|||||||
Reference in New Issue
Block a user