I am totally stuck. However I change the following piece of code I added to the CvPlayer.cpp, the game will crash on me when I try to change Civic. Please take a look and tell me what's possibly wrong. My change is in the bottom, bold type
There are several things I changed:
1. I added 3 new tags to CvCivicInfos.xml. They are: ImprovementType, GreatPeopleUnitClass, and iGreatPeopleRateChange. I've also properly implemented them into CvInfo.h and CvInfo.cpp, or at least I believe I've done so.
2. What I want to achieve with the code is: when A civic change happens, I want each city to gain certain amount of GP point per certain improvement type. For example, when I switch to Universal Suffrage, every of my city will gain GP points toward great merchant per Town improvement the city has.
Well, I tried to alter the code in every way I could imagine, but it always crash when I attempt to switch civic. SDK is so Awesome!
Code:
void CvPlayer::processCivics(CivicTypes eCivic, int iChange)
{
int iI, iJ;
changeGreatPeopleRateModifier(GC.getCivicInfo(eCivic).getGreatPeopleRateModifier() * iChange);
changeGreatGeneralRateModifier(GC.getCivicInfo(eCivic).getGreatGeneralRateModifier() * iChange);
changeDomesticGreatGeneralRateModifier(GC.getCivicInfo(eCivic).getDomesticGreatGeneralRateModifier() * iChange);
changeStateReligionGreatPeopleRateModifier(GC.getCivicInfo(eCivic).getStateReligionGreatPeopleRateModifier() * iChange);
changeDistanceMaintenanceModifier(GC.getCivicInfo(eCivic).getDistanceMaintenanceModifier() * iChange);
changeNumCitiesMaintenanceModifier(GC.getCivicInfo(eCivic).getNumCitiesMaintenanceModifier() * iChange);
changeCorporationMaintenanceModifier(GC.getCivicInfo(eCivic).getCorporationMaintenanceModifier() * iChange);
changeExtraHealth(GC.getCivicInfo(eCivic).getExtraHealth() * iChange);
changeFreeExperience(GC.getCivicInfo(eCivic).getFreeExperience() * iChange);
changeWorkerSpeedModifier(GC.getCivicInfo(eCivic).getWorkerSpeedModifier() * iChange);
changeImprovementUpgradeRateModifier(GC.getCivicInfo(eCivic).getImprovementUpgradeRateModifier() * iChange);
changeMilitaryProductionModifier(GC.getCivicInfo(eCivic).getMilitaryProductionModifier() * iChange);
changeBaseFreeUnits(GC.getCivicInfo(eCivic).getBaseFreeUnits() * iChange);
changeBaseFreeMilitaryUnits(GC.getCivicInfo(eCivic).getBaseFreeMilitaryUnits() * iChange);
changeFreeUnitsPopulationPercent(GC.getCivicInfo(eCivic).getFreeUnitsPopulationPercent() * iChange);
changeFreeMilitaryUnitsPopulationPercent(GC.getCivicInfo(eCivic).getFreeMilitaryUnitsPopulationPercent() * iChange);
changeGoldPerUnit(GC.getCivicInfo(eCivic).getGoldPerUnit() * iChange);
changeGoldPerMilitaryUnit(GC.getCivicInfo(eCivic).getGoldPerMilitaryUnit() * iChange);
changeHappyPerMilitaryUnit(GC.getCivicInfo(eCivic).getHappyPerMilitaryUnit() * iChange);
changeMilitaryFoodProductionCount((GC.getCivicInfo(eCivic).isMilitaryFoodProduction()) ? iChange : 0);
changeMaxConscript(getWorldSizeMaxConscript(eCivic) * iChange);
changeNoUnhealthyPopulationCount((GC.getCivicInfo(eCivic).isNoUnhealthyPopulation()) ? iChange : 0);
changeBuildingOnlyHealthyCount((GC.getCivicInfo(eCivic).isBuildingOnlyHealthy()) ? iChange : 0);
changeLargestCityHappiness(GC.getCivicInfo(eCivic).getLargestCityHappiness() * iChange);
changeWarWearinessModifier(GC.getCivicInfo(eCivic).getWarWearinessModifier() * iChange);
changeFreeSpecialist(GC.getCivicInfo(eCivic).getFreeSpecialist() * iChange);
changeTradeRoutes(GC.getCivicInfo(eCivic).getTradeRoutes() * iChange);
changeNoForeignTradeCount(GC.getCivicInfo(eCivic).isNoForeignTrade() * iChange);
changeNoCorporationsCount(GC.getCivicInfo(eCivic).isNoCorporations() * iChange);
changeNoForeignCorporationsCount(GC.getCivicInfo(eCivic).isNoForeignCorporations() * iChange);
changeStateReligionCount((GC.getCivicInfo(eCivic).isStateReligion()) ? iChange : 0);
changeNoNonStateReligionSpreadCount((GC.getCivicInfo(eCivic).isNoNonStateReligionSpread()) ? iChange : 0);
changeStateReligionHappiness(GC.getCivicInfo(eCivic).getStateReligionHappiness() * iChange);
changeNonStateReligionHappiness(GC.getCivicInfo(eCivic).getNonStateReligionHappiness() * iChange);
changeStateReligionUnitProductionModifier(GC.getCivicInfo(eCivic).getStateReligionUnitProductionModifier() * iChange);
changeStateReligionBuildingProductionModifier(GC.getCivicInfo(eCivic).getStateReligionBuildingProductionModifier() * iChange);
changeStateReligionFreeExperience(GC.getCivicInfo(eCivic).getStateReligionFreeExperience() * iChange);
changeExpInBorderModifier(GC.getCivicInfo(eCivic).getExpInBorderModifier() * iChange);
for (iI = 0; iI < NUM_YIELD_TYPES; iI++)
{
changeYieldRateModifier(((YieldTypes)iI), (GC.getCivicInfo(eCivic).getYieldModifier(iI) * iChange));
changeCapitalYieldRateModifier(((YieldTypes)iI), (GC.getCivicInfo(eCivic).getCapitalYieldModifier(iI) * iChange));
changeTradeYieldModifier(((YieldTypes)iI), (GC.getCivicInfo(eCivic).getTradeYieldModifier(iI) * iChange));
}
for (iI = 0; iI < NUM_COMMERCE_TYPES; iI++)
{
changeCommerceRateModifier(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getCommerceModifier(iI) * iChange));
changeCapitalCommerceRateModifier(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getCapitalCommerceModifier(iI) * iChange));
changeSpecialistExtraCommerce(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getSpecialistExtraCommerce(iI) * iChange));
}
for (iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)
{
BuildingTypes eOurBuilding = (BuildingTypes)GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings(iI);
if (NO_BUILDING != eOurBuilding)
{
changeExtraBuildingHappiness(eOurBuilding, (GC.getCivicInfo(eCivic).getBuildingHappinessChanges(iI) * iChange));
changeExtraBuildingHealth(eOurBuilding, (GC.getCivicInfo(eCivic).getBuildingHealthChanges(iI) * iChange));
}
}
for (iI = 0; iI < GC.getNumFeatureInfos(); iI++)
{
changeFeatureHappiness(((FeatureTypes)iI), (GC.getCivicInfo(eCivic).getFeatureHappinessChanges(iI) * iChange));
}
for (iI = 0; iI < GC.getNumHurryInfos(); iI++)
{
changeHurryCount(((HurryTypes)iI), ((GC.getCivicInfo(eCivic).isHurry(iI)) ? iChange : 0));
}
for (iI = 0; iI < GC.getNumSpecialBuildingInfos(); iI++)
{
changeSpecialBuildingNotRequiredCount(((SpecialBuildingTypes)iI), ((GC.getCivicInfo(eCivic).isSpecialBuildingNotRequired(iI)) ? iChange : 0));
}
for (iI = 0; iI < GC.getNumSpecialistInfos(); iI++)
{
changeSpecialistValidCount(((SpecialistTypes)iI), ((GC.getCivicInfo(eCivic).isSpecialistValid(iI)) ? iChange : 0));
}
for (iI = 0; iI < GC.getNumImprovementInfos(); iI++)
{
for (iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)
{
changeImprovementYieldChange(((ImprovementTypes)iI), ((YieldTypes)iJ), (GC.getCivicInfo(eCivic).getImprovementYieldChanges(iI, iJ) * iChange));
}
}
[B]CvCity* pLoopCity;
int iLoop, totalGreatPeopleRateChange;
UnitTypes eGreatPeopleUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(GC.getCivicInfo(eCivic).getGreatPeopleUnitClass())));
if (eGreatPeopleUnit != NO_UNIT)
{
for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{
totalGreatPeopleRateChange = pLoopCity->countNumImprovedPlots((ImprovementTypes)(GC.getCivicInfo(eCivic).getImprovementType()), 0) * GC.getCivicInfo(eCivic).getGreatPeopleRateChange() * iChange;
pLoopCity->changeGreatPeopleUnitRate(eGreatPeopleUnit, totalGreatPeopleRateChange);
}[/B]
}
}
There are several things I changed:
1. I added 3 new tags to CvCivicInfos.xml. They are: ImprovementType, GreatPeopleUnitClass, and iGreatPeopleRateChange. I've also properly implemented them into CvInfo.h and CvInfo.cpp, or at least I believe I've done so.
2. What I want to achieve with the code is: when A civic change happens, I want each city to gain certain amount of GP point per certain improvement type. For example, when I switch to Universal Suffrage, every of my city will gain GP points toward great merchant per Town improvement the city has.
Well, I tried to alter the code in every way I could imagine, but it always crash when I attempt to switch civic. SDK is so Awesome!