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;
}
[b] if (getReligionCount() == 0)[/b]
{
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;
}
}
}
}
}
}