int CvCity::calculateNumCitiesMaintenance() const
{
return (calculateNumCitiesMaintenanceTimes100() / 100);
}
int CvCity::calculateNumCitiesMaintenanceTimes100() const
{
int iNumCitiesPercent = 100;
iNumCitiesPercent *= (getPopulation() + 17);
iNumCitiesPercent /= 18;
iNumCitiesPercent *= GC.getWorldInfo(GC.getMapINLINE().getWorldSize()).getNumCitiesMaintenancePercent();
iNumCitiesPercent /= 100;
iNumCitiesPercent *= GC.getHandicapInfo(getHandicapType()).getNumCitiesMaintenancePercent();
iNumCitiesPercent /= 100;
int iNumVassalCities = 0;
for (int iPlayer = 0; iPlayer < MAX_CIV_PLAYERS; iPlayer++)
{
CvPlayer& kLoopPlayer = GET_PLAYER((PlayerTypes)iPlayer);
if (kLoopPlayer.getTeam() != getTeam() && GET_TEAM(kLoopPlayer.getTeam()).isVassal(getTeam()))
{
iNumVassalCities += kLoopPlayer.getNumCities();
}
}
iNumVassalCities /= std::max(1, GET_TEAM(getTeam()).getNumMembers());
int iNumCitiesMaintenance = (GET_PLAYER(getOwnerINLINE()).getNumCities() + iNumVassalCities) * iNumCitiesPercent;
iNumCitiesMaintenance = std::min(iNumCitiesMaintenance, GC.getHandicapInfo(getHandicapType()).getMaxNumCitiesMaintenance() * 100);
iNumCitiesMaintenance *= std::max(0, (GET_PLAYER(getOwnerINLINE()).getNumCitiesMaintenanceModifier() + 100));
iNumCitiesMaintenance /= 100;
FAssert(iNumCitiesMaintenance >= 0);
return iNumCitiesMaintenance;
}