mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[11497] Fixed another source of crash at accept quest from item.
OnQuestAccept script calls moved into Player::AddQuest before remove/replace quest starting item. Its still called only at quest accept ofc (questGiver object != NULL only in like case.
This commit is contained in:
parent
4b00269ccc
commit
d111d1a4b3
3 changed files with 48 additions and 42 deletions
|
|
@ -13728,31 +13728,6 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )
|
||||||
questStatusData.m_creatureOrGOcount[i] = 0;
|
questStatusData.m_creatureOrGOcount[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove start item if not need
|
|
||||||
if (questGiver && questGiver->isType(TYPEMASK_ITEM))
|
|
||||||
{
|
|
||||||
// destroy not required for quest finish quest starting item
|
|
||||||
bool notRequiredItem = true;
|
|
||||||
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
|
||||||
{
|
|
||||||
if (pQuest->ReqItemId[i] == questGiver->GetEntry())
|
|
||||||
{
|
|
||||||
notRequiredItem = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pQuest->GetSrcItemId() == questGiver->GetEntry())
|
|
||||||
notRequiredItem = false;
|
|
||||||
|
|
||||||
if (notRequiredItem)
|
|
||||||
DestroyItem(((Item*)questGiver)->GetBagSlot(), ((Item*)questGiver)->GetSlot(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
GiveQuestSourceItemIfNeed(pQuest);
|
|
||||||
|
|
||||||
AdjustQuestReqItemCount( pQuest, questStatusData );
|
|
||||||
|
|
||||||
if( pQuest->GetRepObjectiveFaction() )
|
if( pQuest->GetRepObjectiveFaction() )
|
||||||
if(FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->GetRepObjectiveFaction()))
|
if(FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->GetRepObjectiveFaction()))
|
||||||
GetReputationMgr().SetVisible(factionEntry);
|
GetReputationMgr().SetVisible(factionEntry);
|
||||||
|
|
@ -13778,9 +13753,53 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )
|
||||||
if (questStatusData.uState != QUEST_NEW)
|
if (questStatusData.uState != QUEST_NEW)
|
||||||
questStatusData.uState = QUEST_CHANGED;
|
questStatusData.uState = QUEST_CHANGED;
|
||||||
|
|
||||||
//starting initial quest script
|
// quest accept scripts
|
||||||
if(questGiver && pQuest->GetQuestStartScript()!=0)
|
if (questGiver)
|
||||||
GetMap()->ScriptsStart(sQuestStartScripts, pQuest->GetQuestStartScript(), questGiver, this);
|
{
|
||||||
|
switch (questGiver->GetTypeId())
|
||||||
|
{
|
||||||
|
case TYPEID_UNIT:
|
||||||
|
sScriptMgr.OnQuestAccept(this, (Creature*)questGiver, pQuest);
|
||||||
|
break;
|
||||||
|
case TYPEID_ITEM:
|
||||||
|
case TYPEID_CONTAINER:
|
||||||
|
sScriptMgr.OnQuestAccept(this, (Item*)questGiver, pQuest);
|
||||||
|
break;
|
||||||
|
case TYPEID_GAMEOBJECT:
|
||||||
|
sScriptMgr.OnQuestAccept(this, (GameObject*)questGiver, pQuest);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// starting initial DB quest script
|
||||||
|
if (pQuest->GetQuestStartScript() != 0)
|
||||||
|
GetMap()->ScriptsStart(sQuestStartScripts, pQuest->GetQuestStartScript(), questGiver, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove start item if not need
|
||||||
|
if (questGiver && questGiver->isType(TYPEMASK_ITEM))
|
||||||
|
{
|
||||||
|
// destroy not required for quest finish quest starting item
|
||||||
|
bool notRequiredItem = true;
|
||||||
|
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
||||||
|
{
|
||||||
|
if (pQuest->ReqItemId[i] == questGiver->GetEntry())
|
||||||
|
{
|
||||||
|
notRequiredItem = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pQuest->GetSrcItemId() == questGiver->GetEntry())
|
||||||
|
notRequiredItem = false;
|
||||||
|
|
||||||
|
if (notRequiredItem)
|
||||||
|
DestroyItem(((Item*)questGiver)->GetBagSlot(), ((Item*)questGiver)->GetSlot(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
GiveQuestSourceItemIfNeed(pQuest);
|
||||||
|
|
||||||
|
AdjustQuestReqItemCount( pQuest, questStatusData );
|
||||||
|
|
||||||
// Some spells applied at quest activation
|
// Some spells applied at quest activation
|
||||||
SpellAreaForQuestMapBounds saBounds = sSpellMgr.GetSpellAreaForQuestMapBounds(quest_id,true);
|
SpellAreaForQuestMapBounds saBounds = sSpellMgr.GetSpellAreaForQuestMapBounds(quest_id,true);
|
||||||
|
|
|
||||||
|
|
@ -185,19 +185,6 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data )
|
||||||
|
|
||||||
_player->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest);
|
_player->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest);
|
||||||
|
|
||||||
switch(pObject->GetTypeId())
|
|
||||||
{
|
|
||||||
case TYPEID_UNIT:
|
|
||||||
sScriptMgr.OnQuestAccept(_player, (Creature*)pObject, qInfo);
|
|
||||||
break;
|
|
||||||
case TYPEID_ITEM:
|
|
||||||
case TYPEID_CONTAINER:
|
|
||||||
sScriptMgr.OnQuestAccept(_player, (Item*)pObject, qInfo);
|
|
||||||
break;
|
|
||||||
case TYPEID_GAMEOBJECT:
|
|
||||||
sScriptMgr.OnQuestAccept(_player, (GameObject*)pObject, qInfo);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
_player->PlayerTalkClass->CloseGossip();
|
_player->PlayerTalkClass->CloseGossip();
|
||||||
|
|
||||||
if( qInfo->GetSrcSpell() > 0 )
|
if( qInfo->GetSrcSpell() > 0 )
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11496"
|
#define REVISION_NR "11497"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue