Permalink
Browse files

Core/Quests: Resolve ambiguity between QUEST_STATUS_COMPLETED and rew…

…arded state by implementing QUEST_STATUS_REWARDED. The latter is not used in the database explicitly, only in the core. This is to prevent overhead by iterating over the rewarded quests storage multiple times.

All relevant upper level code has been updated accordingly to the best of my ability.
  • Loading branch information...
1 parent 57ee357 commit d399daab597144c9c1f813e0443c6f12963beeae @Machiavell1 Machiavell1 committed Jan 13, 2011
@@ -14084,7 +14084,7 @@ void Player::PrepareQuestMenu(uint64 guid)
{
uint32 quest_id = i->second;
QuestStatus status = GetQuestStatus(quest_id);
- if (status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(quest_id))
+ if (status == QUEST_STATUS_COMPLETE)
qm.AddMenuItem(quest_id, 4);
else if (status == QUEST_STATUS_INCOMPLETE)
qm.AddMenuItem(quest_id, 4);
@@ -15234,7 +15234,7 @@ QuestStatus Player::GetQuestStatus(uint32 quest_id) const
if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id))
if (!qInfo->IsRepeatable() && m_RewardedQuests.find(quest_id) != m_RewardedQuests.end())
- return QUEST_STATUS_COMPLETE;
+ return QUEST_STATUS_REWARDED;
}
return QUEST_STATUS_NONE;
}
@@ -100,6 +100,7 @@ enum QuestStatus
QUEST_STATUS_INCOMPLETE = 3,
//QUEST_STATUS_AVAILABLE = 4,
QUEST_STATUS_FAILED = 5,
+ QUEST_STATUS_REWARDED = 6, // Not used in DB
MAX_QUEST_STATUS
};
@@ -4864,7 +4864,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
uint32 spellID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 0);
uint32 questID = SpellMgr::CalculateSpellEffectAmount(m_spellInfo, 1);
- if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE && !unitTarget->ToPlayer()->GetQuestRewardStatus (questID))
+ if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE)
unitTarget->CastSpell(unitTarget, spellID, true);
return;
@@ -65,7 +65,7 @@ class npc_archmage_malin : public CreatureScript
if (pCreature->isQuestGiver())
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
- if (pPlayer->GetQuestStatus(11223) == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(11223))
+ if (pPlayer->GetQuestStatus(11223) == QUEST_STATUS_COMPLETE)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_MALIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
@@ -282,11 +282,14 @@ class npc_arthas : public CreatureScript
switch (pAI->uiGossipStep)
{
case 0: //This one is a workaround since the very beggining of the script is wrong.
- if (pPlayer->GetQuestStatus(13149) != QUEST_STATUS_COMPLETE)
+ {
+ QuestStatus status = pPlayer->GetQuestStatus(13149);
+ if (status != QUEST_STATUS_COMPLETE && status != QUEST_STATUS_REWARDED)
return false;
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ARTHAS_0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
pPlayer->SEND_GOSSIP_MENU(907, pCreature->GetGUID());
break;
+ }
case 1:
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ARTHAS_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ARTHAS_1, pCreature->GetGUID());
@@ -80,7 +80,7 @@ class npc_erozion : public CreatureScript
if (pInstance && pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE && !pPlayer->HasItemCount(ITEM_ENTRY_BOMBS,1))
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_EROZION1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- if (!pPlayer->GetQuestRewardStatus(QUEST_ENTRY_RETURN) && pPlayer->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE)
+ if (pPlayer->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_EROZION2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
pPlayer->SEND_GOSSIP_MENU(9778, pCreature->GetGUID());
@@ -184,11 +184,13 @@ class npc_jaina_or_sylvanas_hor : public CreatureScript
if (pCreature->isQuestGiver())
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
- if (pPlayer->GetQuestStatus(m_isSylvana ? QUEST_DELIVRANCE_FROM_THE_PIT_H2 : QUEST_DELIVRANCE_FROM_THE_PIT_A2) == QUEST_STATUS_COMPLETE)
+ QuestStatus status = pPlayer->GetQuestStatus(m_isSylvana ? QUEST_DELIVRANCE_FROM_THE_PIT_H2 : QUEST_DELIVRANCE_FROM_THE_PIT_A2);
+ if (status == QUEST_STATUS_COMPLETE || status == QUEST_STATUS_REWARDED)
pPlayer->ADD_GOSSIP_ITEM( 0, "Can you remove the sword?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
// once last quest is completed, she offers this shortcut of the starting event
- if (pPlayer->GetQuestStatus(m_isSylvana ? QUEST_WRATH_OF_THE_LICH_KING_H2 : QUEST_WRATH_OF_THE_LICH_KING_A2) == QUEST_STATUS_COMPLETE)
+ status = pPlayer->GetQuestStatus(m_isSylvana ? QUEST_WRATH_OF_THE_LICH_KING_H2 : QUEST_WRATH_OF_THE_LICH_KING_A2);
+ if (status == QUEST_STATUS_COMPLETE || status == QUEST_STATUS_REWARDED)
pPlayer->ADD_GOSSIP_ITEM( 0, "Dark Lady, I think I hear Arthas coming. Whatever you're going to do, do it quickly.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
@@ -1112,8 +1112,8 @@ class go_amberpine_outhouse : public GameObjectScript
bool OnGossipHello(Player *pPlayer, GameObject *pGO)
{
- if (pPlayer->GetQuestStatus(QUEST_DOING_YOUR_DUTY) == QUEST_STATUS_INCOMPLETE ||
- (pPlayer->GetQuestStatus(QUEST_DOING_YOUR_DUTY) == QUEST_STATUS_COMPLETE))
+ QuestStatus status = pPlayer->GetQuestStatus(QUEST_DOING_YOUR_DUTY);
+ if (status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_COMPLETE || status == QUEST_STATUS_REWARDED)
{
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_USE_OUTHOUSE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
pPlayer->SEND_GOSSIP_MENU(GOSSIP_OUTHOUSE_VACANT, pGO->GetGUID());
@@ -112,7 +112,7 @@ class npc_taxi : public CreatureScript
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9);
//Spinebreaker Post
- if (pPlayer->GetQuestStatus(10242) == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(10242))
+ if (pPlayer->GetQuestStatus(10242) == QUEST_STATUS_COMPLETE)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10);
break;
case 23413: // Blade's Edge Mountains - Skyguard Handler Irena
@@ -132,7 +132,7 @@ class npc_taxi : public CreatureScript
break;
case 20162: // Netherstorm - Veronia
//Behind Enemy Lines
- if (pPlayer->GetQuestStatus(10652) && !pPlayer->GetQuestRewardStatus(10652))
+ if (pPlayer->GetQuestStatus(10652) != QUEST_STATUS_REWARDED)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_VERONIA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 15);
break;
case 23415: // Terokkar Forest - Skyguard Handler Deesak
@@ -170,6 +170,7 @@ class npc_taxi : public CreatureScript
case 26602:
if (pCreature->isTaxi())
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, GOSSIP_THRICESTAR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 26);
+
if (pPlayer->GetQuestStatus(11692) == QUEST_STATUS_COMPLETE)
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_THRICESTAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 27);
break;

0 comments on commit d399daa

Please sign in to comment.