Religions dont spread naturally if a city already has a religion. It is handled in the void CvCity::doReligion() function in CvCity.cpp:
Code:
void CvCity::doReligion()
{
CvCity* pLoopCity;
int iRandThreshold;
int iSpread;
int iLoop;
int iI, iJ;
CyCity* pyCity = new CyCity(this);
CyArgsList argsList;
argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCity)); // pass in city class
long lResult=0;
gDLL->getPythonIFace()->callFunction(PYGameModule, "doReligion", argsList.makeFunctionArgs(), &lResult);
delete pyCity; // python fxn must not hold on to this pointer
if (lResult == 1)
{
return;
}
if (getReligionCount() == 0)
{
for (iI = 0; iI < GC.getNumReligionInfos(); iI++)
{
if (!isHasReligion((ReligionTypes)iI))
{
if ((iI == GET_PLAYER(getOwnerINLINE()).getStateReligion()) || !(GET_PLAYER(getOwnerINLINE()).isNoNonStateReligionSpread()))
{
iRandThreshold = 0;
for (iJ = 0; iJ < MAX_PLAYERS; iJ++)
{
if (GET_PLAYER((PlayerTypes)iJ).isAlive())
{
for (pLoopCity = GET_PLAYER((PlayerTypes)iJ).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iJ).nextCity(&iLoop))
{
if (pLoopCity->isConnectedTo(this))
{
iSpread = pLoopCity->getReligionInfluence((ReligionTypes)iI);
iSpread *= GC.getReligionInfo((ReligionTypes)iI).getSpreadFactor();
if (iSpread > 0)
{
iSpread /= max(1, (((GC.getDefineINT("RELIGION_SPREAD_DISTANCE_DIVISOR") * plotDistance(getX_INLINE(), getY_INLINE(), pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE())) / GC.getMapINLINE().maxPlotDistance()) - 5));
//iSpread /= (getReligionCount() + 1);
iRandThreshold = max(iRandThreshold, iSpread);
}
}
}
}
}
if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("RELIGION_SPREAD_RAND"), "Religion Spread") < iRandThreshold)
{
setHasReligion(((ReligionTypes)iI), true, true);
break;
}
}
}
}
}
}
Note the bolded check which only allows the spread function to run if the city doesn't already have a religion.
The following is the doReligion we use in FfH2:
Code:
void CvCity::doReligion()
{
CvCity* pLoopCity;
int iRandThreshold;
int iSpread;
int iLoop;
int iI, iJ;
CyCity* pyCity = new CyCity(this);
CyArgsList argsList;
argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCity)); // pass in city class
long lResult=0;
gDLL->getPythonIFace()->callFunction(PYGameModule, "doReligion", argsList.makeFunctionArgs(), &lResult);
delete pyCity; // python fxn must not hold on to this pointer
if (lResult == 1)
{
return;
}
//FfH: Modified by Kael 05/17/2006 to allow up to 3 religions to spread naturally
// if (getReligionCount() == 0)
if (getReligionCount() < 3)
//FfH: End Modify
{
for (iI = 0; iI < GC.getNumReligionInfos(); iI++)
{
//FfH: Modified by Chalid 05/17/2006 to block opposed religion spreads
// if (!isHasReligion((ReligionTypes)iI))
if (!isHasReligion((ReligionTypes)iI) &&
!(isHasReligion((ReligionTypes)GC.getInfoTypeForString("RELIGION_THE_ORDER")) && iI == GC.getInfoTypeForString("RELIGION_THE_ASHEN_VEIL")) &&
!(isHasReligion((ReligionTypes)GC.getInfoTypeForString("RELIGION_THE_ASHEN_VEIL")) && iI == GC.getInfoTypeForString("RELIGION_THE_ORDER")))
//FfH: End Modify
{
if ((iI == GET_PLAYER(getOwnerINLINE()).getStateReligion()) || !(GET_PLAYER(getOwnerINLINE()).isNoNonStateReligionSpread()))
{
iRandThreshold = 0;
for (iJ = 0; iJ < MAX_PLAYERS; iJ++)
{
if (GET_PLAYER((PlayerTypes)iJ).isAlive())
{
for (pLoopCity = GET_PLAYER((PlayerTypes)iJ).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iJ).nextCity(&iLoop))
{
if (pLoopCity->isConnectedTo(this))
{
iSpread = pLoopCity->getReligionInfluence((ReligionTypes)iI);
iSpread *= GC.getReligionInfo((ReligionTypes)iI).getSpreadFactor();
if (iSpread > 0)
{
iSpread /= max(1, (((GC.getDefineINT("RELIGION_SPREAD_DISTANCE_DIVISOR") * plotDistance(getX_INLINE(), getY_INLINE(), pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE())) / GC.getMapINLINE().maxPlotDistance()) - 5));
//iSpread /= (getReligionCount() + 1);
//FfH: Added by Kael 05/17/2006 to modify the spread chances
if (GET_PLAYER(getOwnerINLINE()).hasTrait((TraitTypes)GC.getInfoTypeForString("TRAIT_AGNOSTIC")))
{
iSpread = iSpread / 2;
}
iSpread = iSpread / ((getReligionCount() + 1) * (getReligionCount() + 1));
//FfH: End Add
iRandThreshold = max(iRandThreshold, iSpread);
}
}
}
}
}
if (GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("RELIGION_SPREAD_RAND"), "Religion Spread") < iRandThreshold)
{
setHasReligion(((ReligionTypes)iI), true, true);
break;
}
}
}
}
}
}
The stopping of spread on the opposed spread of the Ashen Veil and the Order and the modification of the spread chances if the leader has the Agnostic trait are FfH specific and probably aren't of much interest to you (unless you'd like to do something similiar). But the change of the amount of religions that will spread naturally to 3 (the number we felt was a fair amount for spread) and the exponential decrease in spread chance based on the number of existing religions is probably what you are looking for.