I am neither stepping over nor stepping into it. I use the Debug->Continue option (hit F5). The breakpoints are basically just functioning as pauses so I can see where the code is running (which I thought was the point).
Here's my code currently, some changes in red:
On a blind guess (thanks to a friend at work who helped me think of it), I added the ELSE statement to the IF in int CvCity::getGlobalReligionYieldByReligion() that was giving me the infinite loop. I still don't know why it was doing that, but adding the ELSE-break statement fixed it.
I also added the IF(isHolyCity()) to void CvCity::updateGlobalReligionYield(). Now, when the GlobalReligionCount calls an update, CvCity skips the 21 steps of going through each religion for each yield if the City is not a Holy City. Since shrines can only be in Holy Cities, I've saved some clock time!
As for the bonus not being applied, the problem is with if (GC.getBuildingInfo((BuildingTypes)iI).getGlobalReligionYields() != NO_RELIGION && getNumActiveBuilding((BuildingTypes)iI) > 0). Something in there is failing, and so the game skips the iYield += line and goes straight to the return line.
I'm also firmly convinced, that if I can just find a way to actually use CvCity::hasShrine(), then I'd be set. I had tried this change below to int CvCity::getGlobalReligionYieldByReligion(), which, with the new IF check in void CvCity::updateGlobalReligionYield(), resulted in my Yield changes showing up only in holy cities, instead of everywhere. But the bonus shows up with or without a shrine:
Now, if I could replace the IF(isHolyCity()) I installed in void CvCity::updateGlobalReligionYield() with IF(hasShrine()), then I'd be golden. But when I attempted that, I got this error:
Sooooo close......
EDIT: No, I didn't touch CvGame::countReligionLevels.
Here's my code currently, some changes in red:
Code:
int CvCity::getGlobalReligionYield(YieldTypes eIndex) const
{
FAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
FAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex expected to be < NUM_YIELD_TYPES");
return m_aiGlobalReligionYield[eIndex];
}
int CvCity::getGlobalReligionYieldByReligion(YieldTypes eIndex, ReligionTypes eReligion) const
{
int iYield;
FAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
FAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex expected to be < NUM_YIELD_TYPES");
FAssertMsg(eReligion >= 0, "eReligion expected to be >= 0");
FAssertMsg(eReligion < GC.getNumReligionInfos(), "GC.getNumReligionInfos expected to be >= 0");
iYield = 0;
if (isHasReligion(eReligion))
{
for (int iI = 0; iI < GC.getNumBuildingInfos(); iI++)
{
if (GC.getBuildingInfo((BuildingTypes)iI).getGlobalReligionYields() != NO_RELIGION && getNumActiveBuilding((BuildingTypes)iI) > 0)
{
iYield += getNumActiveBuilding((BuildingTypes)iI) * GC.getReligionInfo(eReligion).getGlobalReligionYield(eIndex) * GC.getGameINLINE().countReligionLevels(eReligion);
}
[COLOR="Red"] else
{
break;
}[/COLOR]
}
}
return iYield;
}
void CvCity::updateGlobalReligionYield(YieldTypes eIndex)
{
int iOldYield = getGlobalReligionYield(eIndex);
int iNewYield = 0;
for (int iI = 0; iI < GC.getNumReligionInfos(); iI++)
{
iNewYield += getGlobalReligionYieldByReligion(eIndex, (ReligionTypes)iI);
}
if (iOldYield != iNewYield)
{
m_aiGlobalReligionYield[eIndex] = iNewYield;
FAssert(getGlobalReligionYield(eIndex) >= 0);
changeBaseYieldRate(eIndex, (iNewYield - iOldYield));
}
}
void CvCity::updateGlobalReligionYield()
{
int iI;
[COLOR="Red"] if (isHolyCity())[/COLOR]
{
for (iI = 0; iI < NUM_YIELD_TYPES; iI++)
{
updateGlobalReligionYield((YieldTypes)iI);
}
}
}
On a blind guess (thanks to a friend at work who helped me think of it), I added the ELSE statement to the IF in int CvCity::getGlobalReligionYieldByReligion() that was giving me the infinite loop. I still don't know why it was doing that, but adding the ELSE-break statement fixed it.

I also added the IF(isHolyCity()) to void CvCity::updateGlobalReligionYield(). Now, when the GlobalReligionCount calls an update, CvCity skips the 21 steps of going through each religion for each yield if the City is not a Holy City. Since shrines can only be in Holy Cities, I've saved some clock time!

As for the bonus not being applied, the problem is with if (GC.getBuildingInfo((BuildingTypes)iI).getGlobalReligionYields() != NO_RELIGION && getNumActiveBuilding((BuildingTypes)iI) > 0). Something in there is failing, and so the game skips the iYield += line and goes straight to the return line.
I'm also firmly convinced, that if I can just find a way to actually use CvCity::hasShrine(), then I'd be set. I had tried this change below to int CvCity::getGlobalReligionYieldByReligion(), which, with the new IF check in void CvCity::updateGlobalReligionYield(), resulted in my Yield changes showing up only in holy cities, instead of everywhere. But the bonus shows up with or without a shrine:
Code:
if (isHasReligion(eReligion))
{
iYield += GC.getReligionInfo(eReligion).getGlobalReligionYield(eIndex) * GC.getGameINLINE().countReligionLevels(eReligion);;
}
return iYield;
}
But if I try using if (hasShrine(eReligion)), I get this error instead:CvCity.cpp(8442) : error C2660: 'CvCity::hasShrine' : function does not take 0 arguments
which makes perfect sense, as void CvCity::updateGlobalReligionYield() doesn't have any variables mentioned. And can't. I tried, backing up through the call list through CvPlayer, CvGame, and back to CvPlayer. I don't remember now which one didn't like it, but one of them really didn't like having variables on this function. I think the solution might be to declare new variables within the function itself (a-la BonusTypes eBonus in int CvCity::getCorporationYieldByCorporation(YieldTypes eIndex, CorporationTypes eCorporation) const), but I don't know how to do that...CvCity.cpp(8442) : error C2065: 'eReligion' : undeclared identifier
Sooooo close......
EDIT: No, I didn't touch CvGame::countReligionLevels.