I'm trying to make it so that buildings don't work when conditions would preclude them being constructed. For instance, a temple should not continue to create happiness if the religion for it no longer exists in the city .
The first thing I wanted to do with this though was I wanted to make a Steel Foundry that requires Iron and Coal and produces Steel, but I want it to stop working if the supply of Iron is cut off.
Thus, I tried to modify CvCity like this
I have tried to mess with Process Building in other ways, and any time I change anything about it, I get something that compiles but causes a loss of interface on game start. In the example above, I get a loss of interface if any building has the conditions for it to work as I want, but otherwise it works fine.
Am I misunderstanding what ProcessBuilding does? Why the loss of interface? Error popup says its related to tech tree and shows the science advisor screen with nothing filled in, then I get the main screen with no HUD.
The first thing I wanted to do with this though was I wanted to make a Steel Foundry that requires Iron and Coal and produces Steel, but I want it to stop working if the supply of Iron is cut off.
Thus, I tried to modify CvCity like this
Code:
void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bObsolete)//this is the function I'm dealing with
{
...//didn't include a bunch of irelevant stuff I didn't change
//this is the block that I assume normally gives a building free bonuses
if (GC.getBuildingInfo(eBuilding).getFreeBonus() != NO_BONUS)
{
changeFreeBonus(((BonusTypes)(GC.getBuildingInfo(eBuilding).getFreeBonus())), (GC.getGameINLINE().getNumFreeBonuses(eBuilding) * iChange));
}
//and I followed it with this, intending to change free bonuses to zero if the prereq bonus is not there
//Tholish NoFreeBonusWithoutPrereqBonus START
if (GC.getBuildingInfo(eBuilding).getPrereqAndBonus() != NO_BONUS) {
if (!hasBonus((BonusTypes)GC.getBuildingInfo(eBuilding).getPrereqAndBonus()))
{
if (GC.getBuildingInfo(eBuilding).getFreeBonus() != NO_BONUS)
{
changeFreeBonus(((BonusTypes)(GC.getBuildingInfo(eBuilding).getFreeBonus())), (0 * iChange));
}
}
}
//Tholish NoFreeBonusWithoutPrereqBonus END
...
I have tried to mess with Process Building in other ways, and any time I change anything about it, I get something that compiles but causes a loss of interface on game start. In the example above, I get a loss of interface if any building has the conditions for it to work as I want, but otherwise it works fine.
Am I misunderstanding what ProcessBuilding does? Why the loss of interface? Error popup says its related to tech tree and shows the science advisor screen with nothing filled in, then I get the main screen with no HUD.