void CvCity::updateStrengthValue()
{
VALIDATE_OBJECT
AI_PERF_FORMAT("City-AI-perf.csv", ("CvCity::updateStrengthValue, Turn %03d, %s, %s", GC.getGame().getElapsedGameTurns(), GetPlayer()->getCivilizationShortDescription(), getName().c_str()) );
// Default Strength
int iStrengthValue = /*600*/ GC.getCITY_STRENGTH_DEFAULT();
// Population mod
iStrengthValue += getPopulation() * /*25*/ GC.getCITY_STRENGTH_POPULATION_CHANGE();
// Building Defense
int iBuildingDefense = m_pCityBuildings->GetBuildingDefense();
iBuildingDefense *= (100 + m_pCityBuildings->GetBuildingDefenseMod());
iBuildingDefense /= 100;
iStrengthValue += iBuildingDefense;
// Garrisoned Unit
CvUnit* pGarrisonedUnit = GetGarrisonedUnit();
int iStrengthFromUnits = 0;
if(pGarrisonedUnit)
{
int iMaxHits = GC.getMAX_HIT_POINTS();
iStrengthFromUnits = pGarrisonedUnit->GetBaseCombatStrength() * 100 * (iMaxHits - pGarrisonedUnit->getDamage()) / iMaxHits;
}
iStrengthValue += ((iStrengthFromUnits * 100) / /*300*/ GC.getCITY_STRENGTH_UNIT_DIVISOR());
// Tech Progress increases City Strength
int iTechProgress = GET_TEAM(getTeam()).GetTeamTechs()->GetNumTechsKnown() * 100 / GC.getNumTechInfos();
// Want progress to be a value between 0 and 5
double fTechProgress = iTechProgress / 100.0 * /*5*/ GC.getCITY_STRENGTH_TECH_BASE();
double fTechExponent = /*2.0f*/ GC.getCITY_STRENGTH_TECH_EXPONENT();
int iTechMultiplier = /*2*/ GC.getCITY_STRENGTH_TECH_MULTIPLIER();
// The way all of this adds up...
// 25% of the way through the game provides an extra 3.12
// 50% of the way through the game provides an extra 12.50
// 75% of the way through the game provides an extra 28.12
// 100% of the way through the game provides an extra 50.00
double fTechMod = pow(fTechProgress, fTechExponent);
fTechMod *= iTechMultiplier;
fTechMod *= 100; // Bring it back into hundreds
iStrengthValue += (int)(fTechMod + 0.005); // Adding a small amount to prevent small fp accuracy differences from generating a different integer result on the Mac and PC. Assuming fTechMod is positive, round to nearest hundredth
int iStrengthMod = 0;
// Player-wide strength mod (Policies, etc.)
iStrengthMod += GET_PLAYER(getOwner()).GetCityStrengthMod();
// Apply Mod
iStrengthValue *= (100 + iStrengthMod);
iStrengthValue /= 100;
m_iStrengthValue = iStrengthValue;
// Terrain mod
if(plot()->isHills())
{
m_iStrengthValue += /*3*/ GC.getCITY_STRENGTH_HILL_CHANGE();
}
DLLUI->setDirty(CityInfo_DIRTY_BIT, true);
}