Check if the owner is following this religion, or not following ANY religion at all
If he is, check if this city has the religion
If we have the religion, we get the default bonus of this religion in every city
Oh for pete's sake...
Thank-you both for explaining that to me. I'll be able to read things a little better going forward.
I've been looking in the completely wrong place. This snippet adds a (Commerce) bonus to each city that is following the State religion of the Civ! That's not what I need at all!
Ok, so, since CvCity seems to contain (if I understand correctly) calculations that will be run on every city, and I only want to deal with what happens in the city that builds a Shrine and nowhere else, I should be messing about in... umm, hmm... where? There's no "CvBuildings" file, not that I can see. Would it be CvPlayer?
EDIT: Think I found it. It's still CvCity, but I should be copying getExtraSpecialistYield, right? With this piece of code I think:
Code:
if (GC.getBuildingInfo(eBuilding).getGlobalReligionYields() != NO_RELIGION)
{
iYield += (GC.getReligionInfo((ReligionTypes)(GC.getBuildingInfo(eBuilding).getGlobalReligionYields())).getGlobalReligionYields(eIndex) * GC.getGameINLINE().countReligionLevels((ReligionTypes)(GC.getBuildingInfo(eBuilding).getGlobalReligionYields()))) * getNumActiveBuilding(eBuilding);
}
EDIT AGAIN: OK, I think I'm getting close. I stil have a major problem, I'm not quite sure how to re-word the bolded line to make it make more sense in comparison to the original line for Specialists. It definately doesn't work as-is, and I know there's a better way to word it, but I'm having trouble putting it together.
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::getGlobalReligionYield(YieldTypes eIndex, ReligionTypes eReligion, eBuilding) const
{
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");
// return ((getSpecialistCount(eSpecialist) + getFreeSpecialistCount(eSpecialist)) * GET_PLAYER(getOwnerINLINE()).getSpecialistExtraYield(eSpecialist, eIndex));
// return ((
[B]return GC.getReligionInfo((ReligionTypes)(GC.getBuildingInfo(eBuilding).getGlobalReligionYields()).getGlobalReligionYields(eIndex)) * GC.getGameINLINE().countReligionLevels((ReligionTypes)(GC.getBuildingInfo(eBuilding).getGlobalReligionYields())) * getNumActiveBuilding(eBuilding);[/B]
}
void CvCity::updateGlobalReligionYield(YieldTypes eYield)
{
int iOldYield;
int iNewYield;
int iI;
FAssertMsg(eYield >= 0, "eYield expected to be >= 0");
FAssertMsg(eYield < NUM_YIELD_TYPES, "eYield expected to be < NUM_YIELD_TYPES");
iOldYield = getGlobalReligionYield(eYield);
iNewYield = 0;
for (iI = 0; iI < GC.getNumReligionInfos(); iI++)
{
iNewYield += getGlobalReligionYield(eYield, ((ReligionTypes)iI));
}
if (iOldYield != iNewYield)
{
m_aiGlobalReligionYield[eYield] = iNewYield;
FAssert(getGlobalReligionYield(eYield) >= 0);
changeBaseYieldRate(eYield, (iNewYield - iOldYield));
}
}
void CvCity::updateGlobalReligionYield()
{
int iI;
for (iI = 0; iI < NUM_YIELD_TYPES; iI++)
{
updateGlobalReligionYield((YieldTypes)iI);
}
}


You need to remove the eBuilding parameter from getGlobalReligionYield() and loop over all buildings inside the function. IIRC, you added CvBuildingInfo.getGlobalReligionYield(YieldTypes), right?
You are trying to call getGlobalReligionYields() which takes no parameters, but you should be calling getGlobalReligionYield(YieldTypes) [note the lack of trailing s on the name] which takes a yield type. The former function returns the full array, but we only want one value here.
You are correctly passing in two parameters: the yield type and religion, but you've declared the function to require a building type. This isn't needed since the function returns the global religion yield for all building types by using a loop.

I get a complete stall of CivIV as soon as I found a city.





