Bazaar developer reference

CvCityReligions::GetReligiousMajority()

Defined in
CvReligionClasses.cpp, line 3592
Class
CvCityReligions
Hook name
CivHooks::CvCityReligions_GetReligiousMajority

Hooks

static bool BeforeCvCityReligions_GetReligiousMajority(CvCityReligions* self, ReligionTypes& result);static void AfterCvCityReligions_GetReligiousMajority(CvCityReligions* self, ReligionTypes& result);static ReligionTypes ReplaceCvCityReligions_GetReligiousMajority(ReligionTypes (*original)(CvCityReligions*), CvCityReligions* self);CivRegisterBefore<CivHooks::CvCityReligions_GetReligiousMajority>(host, &BeforeCvCityReligions_GetReligiousMajority);CivRegisterAfter<CivHooks::CvCityReligions_GetReligiousMajority>(host, &AfterCvCityReligions_GetReligiousMajority);CivRegisterReplace<CivHooks::CvCityReligions_GetReligiousMajority>(host, &ReplaceCvCityReligions_GetReligiousMajority);

Code

3591/// Is there a religion that at least half of the population follows?3592ReligionTypes CvCityReligions::GetReligiousMajority()3593{3594	int iTotalFollowers = 0;3595	int iMostFollowerPressure = 0;3596	int iMostFollowers = -1;3597	ReligionTypes eMostFollowers = NO_RELIGION;3598	ReligionInCityList::iterator religionIt;35993600	for(religionIt = m_ReligionStatus.begin(); religionIt != m_ReligionStatus.end(); ++religionIt)3601	{3602		iTotalFollowers += religionIt->m_iFollowers;36033604		if(religionIt->m_iFollowers > iMostFollowers || religionIt->m_iFollowers == iMostFollowers && religionIt->m_iPressure > iMostFollowerPressure)3605		{3606			iMostFollowers = religionIt->m_iFollowers;3607			iMostFollowerPressure = religionIt->m_iPressure;3608			eMostFollowers = religionIt->m_eReligion;3609		}3610	}36113612	if ((iMostFollowers * 2) >= iTotalFollowers)3613	{3614		return eMostFollowers;3615	}3616	else3617	{3618		return NO_RELIGION;3619	}3620}

Calls

Called by

74 functions in 11 files