Код:
/// Convert some percentage of followers from one religion to another
void CvCityReligions::ConvertPercentFollowers(ReligionTypes eToReligion, ReligionTypes eFromReligion, int iPercent)
{
int iPressureConverting = 0;
// Find old religion
ReligionInCityList::iterator it;
for(it = m_ReligionStatus.begin(); it != m_ReligionStatus.end(); it++)
{
if(it->m_eReligion == eFromReligion)
{
iPressureConverting = it->m_iPressure * iPercent / 100;
it->m_iPressure -= iPressureConverting;
if (it->m_iPressure < 0)
{
it->m_iPressure = 0;
}
}
}
AddReligiousPressure(FOLLOWER_CHANGE_SCRIPTED_CONVERSION, eToReligion, iPressureConverting, NO_PLAYER);
}
/// Add pressure to recruit followers to a religion
void CvCityReligions::AddReligiousPressure(CvReligiousFollowChangeReason eReason, ReligionTypes eReligion, int iPressure, PlayerTypes eResponsiblePlayer)
{
bool bFoundIt = false;
ReligionTypes eOldMajorityReligion = GetReligiousMajority();
ReligionInCityList::iterator it;
for(it = m_ReligionStatus.begin(); it != m_ReligionStatus.end(); it++)
{
if(it->m_eReligion == eReligion)
{
it->m_iPressure += iPressure;
bFoundIt = true;
}
// If this is pressure from a real religion, reduce presence of pantheon by the same amount
else if(eReligion > RELIGION_PANTHEON && it->m_eReligion == RELIGION_PANTHEON)
{
it->m_iPressure = max(0, (it->m_iPressure - iPressure));
}
else if (it->m_eReligion > RELIGION_PANTHEON && eReason == FOLLOWER_CHANGE_MISSIONARY)
{
const CvReligion *pReligion = GC.getGame().GetGameReligions()->GetReligion(eReligion, NO_PLAYER);
int iPressureErosion = pReligion->m_Beliefs.GetOtherReligionPressureErosion(); // Normally 0
if (iPressureErosion > 0)
{
int iErosionAmount = iPressureErosion * iPressure / 100;
it->m_iPressure = max(0, (it->m_iPressure - iErosionAmount));
}
}
}
// Didn't find it, add new entry
if(!bFoundIt)
{
CvReligionInCity newReligion(eReligion, false, 0, iPressure);
m_ReligionStatus.push_back(newReligion);
}
RecomputeFollowers(eReason, eOldMajorityReligion, eResponsiblePlayer);
}