Duke176
Warlord
Hi all, long itme since last question, you thought you freed of me?
Here is my new noob question:
Target - make a loop throw the city buildings and make the city menu return the ammount of oil consumed for normal usages. Building have some set XML ordinary Consumption that should be added or decreased from normal city usage.
For ex. City - pop=5 - normal usage = 1 each turn
with Factory = normal usage + 5... so on.
All right so the game should, when you check a city, loop throw the buildings and get values of iOilConsumption from XML and add them all togheter for total.
(I know the part of getting infos from XML to SDK and the function I wan't to show you it's not complite)
As you see I used the 1st function to create the new one.
Is this correct, is not, why? (i've always hated these kind of functions
)
Thx. for attention and for help!

Here is my new noob question:
Target - make a loop throw the city buildings and make the city menu return the ammount of oil consumed for normal usages. Building have some set XML ordinary Consumption that should be added or decreased from normal city usage.
For ex. City - pop=5 - normal usage = 1 each turn
with Factory = normal usage + 5... so on.
All right so the game should, when you check a city, loop throw the buildings and get values of iOilConsumption from XML and add them all togheter for total.
(I know the part of getting infos from XML to SDK and the function I wan't to show you it's not complite)
Code:
int CvCity::getBonusHealth(BonusTypes eBonus) const
{
int iHealth;
int iI;
iHealth = GC.getBonusInfo(eBonus).getHealth();
for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
{
if (hasActiveBuilding((BuildingTypes)iI))
{
iHealth += GC.getBuildingInfo((BuildingTypes) iI).getBonusHealthChanges(eBonus);
}
}
return iHealth;
}
//-------------- MAKE FUNCTIONS FOR OIL CONSUMPTION ----------------------
//get buildings oil consumption per turn
int CvCity::getOilConsumptionPerBuildings(BuildingTypes eBuilding) const
{
int iOilCons;
int iI;
iOilCons = 0;
// iOilCons = GC.getBuildingInfo(eBuilding).getOilConsumption();
for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
{
if (hasActiveBuilding((BuildingTypes)iI))
{
iOilCons += GC.getBuildingInfo((BuildingTypes) iI).getOilConsumption();
}
}
return iOilCons;
}
//--------------------- END ---------------------------------------
As you see I used the 1st function to create the new one.
Is this correct, is not, why? (i've always hated these kind of functions

Thx. for attention and for help!