Bazaar developer reference

CvMinorCivAI::DoObsoleteQuestsForPlayer(PlayerTypes, MinorCivQuestTypes)

Defined in
CvMinorCivAI.cpp, line 3957
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoObsoleteQuestsForPlayer

Hooks

static bool BeforeCvMinorCivAI_DoObsoleteQuestsForPlayer(CvMinorCivAI* self, PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType);static void AfterCvMinorCivAI_DoObsoleteQuestsForPlayer(CvMinorCivAI* self, PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType);static void ReplaceCvMinorCivAI_DoObsoleteQuestsForPlayer(void (*original)(CvMinorCivAI*, PlayerTypes, MinorCivQuestTypes), CvMinorCivAI* self, PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType);CivRegisterBefore<CivHooks::CvMinorCivAI_DoObsoleteQuestsForPlayer>(host, &BeforeCvMinorCivAI_DoObsoleteQuestsForPlayer);CivRegisterAfter<CivHooks::CvMinorCivAI_DoObsoleteQuestsForPlayer>(host, &AfterCvMinorCivAI_DoObsoleteQuestsForPlayer);CivRegisterReplace<CivHooks::CvMinorCivAI_DoObsoleteQuestsForPlayer>(host, &ReplaceCvMinorCivAI_DoObsoleteQuestsForPlayer);

Code

3955// Process obsolete quests that are active, and seed countdowns if needed.3956// If no quest type is specified, will check all quest types.3957void CvMinorCivAI::DoObsoleteQuestsForPlayer(PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType)3958{3959	CvAssertMsg(ePlayer >= 0, "ePlayer is expected to be non-negative (invalid Index)");3960	CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "ePlayer is expected to be within maximum bounds (invalid Index)");3961	if(ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return;39623963	bool bCheckAllQuests = true;3964#if defined(MOD_EVENTS_QUESTS)3965	if (eSpecifyQuestType > NO_MINOR_CIV_QUEST_TYPE && eSpecifyQuestType < GC.getNumQuestInfos())3966#else3967	if (eSpecifyQuestType > NO_MINOR_CIV_QUEST_TYPE && eSpecifyQuestType < NUM_MINOR_CIV_QUEST_TYPES)3968#endif3969		bCheckAllQuests = false;39703971	bool bQuestRevokedFromBullying = false;39723973	QuestListForPlayer::iterator itr_quest;3974	for(itr_quest = m_QuestsGiven[ePlayer].begin(); itr_quest != m_QuestsGiven[ePlayer].end(); itr_quest++)3975	{3976		if(bCheckAllQuests || itr_quest->GetType() == eSpecifyQuestType)3977		{3978			if(itr_quest->IsObsolete())3979			{3980				int iOldFriendshipTimes100 = GetEffectiveFriendshipWithMajorTimes100(ePlayer);3981				bool bCancelled = itr_quest->DoCancelQuest();3982				int iNewFriendshipTimes100 = GetEffectiveFriendshipWithMajorTimes100(ePlayer);3983				3984				if (bCancelled)3985				{3986					if(itr_quest->IsRevoked())3987						bQuestRevokedFromBullying = true;39883989					GET_PLAYER(ePlayer).GetDiplomacyAI()->LogMinorCivQuestCancelled(GetPlayer()->GetID(), iOldFriendshipTimes100, iNewFriendshipTimes100, itr_quest->GetType());3990				}3991			}3992		}3993	}39943995	// If quest(s) were revoked because of bullying, send out a notification3996	if(bQuestRevokedFromBullying)3997	{3998		Localization::String strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_QUEST_ENDED_REVOKED");3999		Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_QUEST_ENDED_REVOKED");4000		strMessage << GetPlayer()->getNameKey();4001		strSummary << GetPlayer()->getNameKey();4002		AddQuestNotification(strMessage.toUTF8(), strSummary.toUTF8(), ePlayer);4003	}4004}

Calls

Called by