I have the following code around line 886 of CvCityStrategyAI.cpp:
I believe that my code is being executed properly, because I puppeted some cities and saw them prioritize culture buildings heavily, even before maintenance-free buildings.
However, my logging code did not work. Nothing gets written to log.txt. I believe this is a function of how the game uses the DLL, not a fault in my code. So my question is, have any of you come up with some useful ways to write to log files as your C++ code is being executed?
Code:
// If the City is a puppet, it avoids Wonders (because the human can't change it if he wants to build it somewhere else!)
if(GetCity()->IsPuppet())
{
const CvBuildingClassInfo& kBuildingClassInfo = pkBuildingInfo->GetBuildingClassInfo();
int foodYield = pkBuildingInfo->GetYieldChange(YIELD_FOOD);
int prodYield = pkBuildingInfo->GetYieldChange(YIELD_PRODUCTION);
int goldYield = pkBuildingInfo->GetYieldChange(YIELD_GOLD);
int scienceYield = pkBuildingInfo->GetYieldChange(YIELD_SCIENCE);
int cultureYield = pkBuildingInfo->GetYieldChange(YIELD_CULTURE);
int faithYield = pkBuildingInfo->GetYieldChange(YIELD_FAITH);
int happyYield = pkBuildingInfo->GetHappiness();
int goldMaint = pkBuildingInfo->GetGoldMaintenance();
FILE * pFile;
pFile = fopen ("log.txt", "w");
fprintf (pFile,
"iTempWeight=%i, foodYield=%i, prodYield=%i, goldYield=%i, scienceYield=%i, cultureYield=%i, faithYield=%i, happyYield=%i, goldMaint=%i\n",
iTempWeight, foodYield, prodYield, goldYield, scienceYield, cultureYield, faithYield, happyYield, goldMaint);
fclose (pFile);
if (cultureYield)
iTempWeight *= 10;
I believe that my code is being executed properly, because I puppeted some cities and saw them prioritize culture buildings heavily, even before maintenance-free buildings.
However, my logging code did not work. Nothing gets written to log.txt. I believe this is a function of how the game uses the DLL, not a fault in my code. So my question is, have any of you come up with some useful ways to write to log files as your C++ code is being executed?