Bazaar developer reference

CvMinorCivAI::DoCompletedQuestsForPlayer(PlayerTypes, MinorCivQuestTypes)

Defined in
CvMinorCivAI.cpp, line 3911
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoCompletedQuestsForPlayer

Hooks

static bool BeforeCvMinorCivAI_DoCompletedQuestsForPlayer(CvMinorCivAI* self, PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType);static void AfterCvMinorCivAI_DoCompletedQuestsForPlayer(CvMinorCivAI* self, PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType);static void ReplaceCvMinorCivAI_DoCompletedQuestsForPlayer(void (*original)(CvMinorCivAI*, PlayerTypes, MinorCivQuestTypes), CvMinorCivAI* self, PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType);CivRegisterBefore<CivHooks::CvMinorCivAI_DoCompletedQuestsForPlayer>(host, &BeforeCvMinorCivAI_DoCompletedQuestsForPlayer);CivRegisterAfter<CivHooks::CvMinorCivAI_DoCompletedQuestsForPlayer>(host, &AfterCvMinorCivAI_DoCompletedQuestsForPlayer);CivRegisterReplace<CivHooks::CvMinorCivAI_DoCompletedQuestsForPlayer>(host, &ReplaceCvMinorCivAI_DoCompletedQuestsForPlayer);

Code

3909// Process completed quests that are active, and seed countdowns if needed.3910// If no quest type is specified, will check all quest types.3911void CvMinorCivAI::DoCompletedQuestsForPlayer(PlayerTypes ePlayer, MinorCivQuestTypes eSpecifyQuestType)3912{3913	CvAssertMsg(ePlayer >= 0, "ePlayer is expected to be non-negative (invalid Index)");3914	CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "ePlayer is expected to be within maximum bounds (invalid Index)");3915	if(ePlayer < 0 || ePlayer >= MAX_MAJOR_CIVS) return;39163917	bool bCheckAllQuests = true;3918#if defined(MOD_EVENTS_QUESTS)3919	if (eSpecifyQuestType > NO_MINOR_CIV_QUEST_TYPE && eSpecifyQuestType < GC.getNumQuestInfos())3920#else3921	if (eSpecifyQuestType > NO_MINOR_CIV_QUEST_TYPE && eSpecifyQuestType < NUM_MINOR_CIV_QUEST_TYPES)3922#endif3923		bCheckAllQuests = false;39243925	QuestListForPlayer::iterator itr_quest;3926	for (itr_quest = m_QuestsGiven[ePlayer].begin(); itr_quest != m_QuestsGiven[ePlayer].end(); itr_quest++)3927	{3928		if (bCheckAllQuests || itr_quest->GetType() == eSpecifyQuestType)3929		{3930			if (itr_quest->IsComplete())3931			{3932				int iOldFriendshipTimes100 = GetEffectiveFriendshipWithMajorTimes100(ePlayer);3933				bool bCompleted = itr_quest->DoFinishQuest();3934				int iNewFriendshipTimes100 = GetEffectiveFriendshipWithMajorTimes100(ePlayer);3935				3936				if (bCompleted)3937				{3938					GET_PLAYER(ePlayer).GetDiplomacyAI()->LogMinorCivQuestFinished(GetPlayer()->GetID(), iOldFriendshipTimes100, iNewFriendshipTimes100, itr_quest->GetType());3939				}3940			}3941		}3942	}3943}

Calls

Called by