Bazaar developer reference

CvMinorCivAI::DoTestQuestsOnFirstContact(PlayerTypes)

Defined in
CvMinorCivAI.cpp, line 3805
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoTestQuestsOnFirstContact

Hooks

static bool BeforeCvMinorCivAI_DoTestQuestsOnFirstContact(CvMinorCivAI* self, PlayerTypes eMajor);static void AfterCvMinorCivAI_DoTestQuestsOnFirstContact(CvMinorCivAI* self, PlayerTypes eMajor);static void ReplaceCvMinorCivAI_DoTestQuestsOnFirstContact(void (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes eMajor);CivRegisterBefore<CivHooks::CvMinorCivAI_DoTestQuestsOnFirstContact>(host, &BeforeCvMinorCivAI_DoTestQuestsOnFirstContact);CivRegisterAfter<CivHooks::CvMinorCivAI_DoTestQuestsOnFirstContact>(host, &AfterCvMinorCivAI_DoTestQuestsOnFirstContact);CivRegisterReplace<CivHooks::CvMinorCivAI_DoTestQuestsOnFirstContact>(host, &ReplaceCvMinorCivAI_DoTestQuestsOnFirstContact);

Code

3802/// Called on first contact with major.  Have major join global quests that are already in progress (ex. contests).3803/// Works on the assumption that this minor can only give out one of each type of global quest at a time.3804/// Works on the assumption that any quests eMajor would be given in this way are valid for eMajor without having to check.3805void CvMinorCivAI::DoTestQuestsOnFirstContact(PlayerTypes eMajor)3806{3807	CvAssertMsg(eMajor >= 0, "eMajor is expected to be non-negative (invalid Index)");3808	CvAssertMsg(eMajor < MAX_MAJOR_CIVS, "eMajor is expected to be within maximum bounds (invalid Index)");3809	if(eMajor < 0 || eMajor >= MAX_MAJOR_CIVS) return;38103811	//antonjs: consider: make this less hacky3812	if(GetNumActiveGlobalQuests() > 0)3813	{3814		std::set<MinorCivQuestTypes> setGlobalQuests;38153816		MinorCivQuestTypes eQuestType;3817		for(uint iPlayerLoop = 0; iPlayerLoop < m_QuestsGiven.size(); iPlayerLoop++)3818		{3819			for(uint iQuestLoop = 0; iQuestLoop < m_QuestsGiven[iPlayerLoop].size(); iQuestLoop++)3820			{3821				CvMinorCivQuest quest = m_QuestsGiven[iPlayerLoop][iQuestLoop];3822				CvMinorCivQuest* pQuest = &quest;3823				if(!pQuest)3824				{3825					CvAssertMsg(false, "pQuest should not be NULL. Please send Anton your save file and version.");3826					continue;3827				}3828				eQuestType = pQuest->GetType();3829				if(IsGlobalQuest(eQuestType))3830				{3831					// Haven't addressed this quest type yet?3832					if(setGlobalQuests.find(eQuestType) == setGlobalQuests.end())3833					{3834						// Can we give a copy of this quest to this player?3835						if(IsValidQuestCopyForPlayer(eMajor, pQuest))3836						{3837							AddQuestCopyForPlayer(eMajor, pQuest);3838							setGlobalQuests.insert(eQuestType);3839						}3840					}3841				}3842			}3843		}3844	}3845}

Calls

Called by