Hooks
static bool BeforeCvCityStrategyAI_LogCityProduction(CvCityStrategyAI* self, CvCityBuildable buildable, bool bRush);static void AfterCvCityStrategyAI_LogCityProduction(CvCityStrategyAI* self, CvCityBuildable buildable, bool bRush);static void ReplaceCvCityStrategyAI_LogCityProduction(void (*original)(CvCityStrategyAI*, CvCityBuildable, bool), CvCityStrategyAI* self, CvCityBuildable buildable, bool bRush);CivRegisterBefore<CivHooks::CvCityStrategyAI_LogCityProduction>(host, &BeforeCvCityStrategyAI_LogCityProduction);CivRegisterAfter<CivHooks::CvCityStrategyAI_LogCityProduction>(host, &AfterCvCityStrategyAI_LogCityProduction);CivRegisterReplace<CivHooks::CvCityStrategyAI_LogCityProduction>(host, &ReplaceCvCityStrategyAI_LogCityProduction);
Code
2021/// Log the chosen item to build2022void CvCityStrategyAI::LogCityProduction(CvCityBuildable buildable, bool bRush)2023{2024 if(GC.getLogging() && GC.getAILogging())2025 {2026 CvString strOutBuf;2027 CvString strBaseString;2028 CvString strTemp;2029 CvString playerName;2030 CvString cityName;2031 CvString strDesc;20322033 // Find the name of this civ and city2034 playerName = GET_PLAYER(m_pCity->getOwner()).getCivilizationShortDescription();2035 cityName = m_pCity->getName();20362037 FILogFile* pLog;2038 pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName, cityName), FILogFile::kDontTimeStamp);20392040 // Get the leading info for this line2041 strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());2042 strBaseString += playerName + ", " + cityName + ", ";20432044 switch(buildable.m_eBuildableType)2045 {2046 case CITY_BUILDABLE_BUILDING:2047 {2048 CvBuildingEntry* pEntry = GC.GetGameBuildings()->GetEntry(buildable.m_iIndex);2049 if(pEntry != NULL)2050 {2051 strDesc = pEntry->GetDescription();2052 }2053 }2054 break;2055 case CITY_BUILDABLE_UNIT:2056 case CITY_BUILDABLE_UNIT_FOR_OPERATION:2057 case CITY_BUILDABLE_UNIT_FOR_ARMY:2058 {2059 CvUnitEntry* pEntry = GC.GetGameUnits()->GetEntry(buildable.m_iIndex);2060 if(pEntry != NULL)2061 {2062 strDesc = pEntry->GetDescription();20632064 }2065 }2066 break;2067 case CITY_BUILDABLE_PROJECT:2068 {2069 CvProjectEntry* pEntry = GC.GetGameProjects()->GetEntry(buildable.m_iIndex);2070 if(pEntry != NULL)2071 {2072 strDesc = pEntry->GetDescription();20732074 }2075 }2076 break;2077 case CITY_BUILDABLE_PROCESS:2078 {2079 CvProcessInfo* pEntry = GC.getProcessInfo((ProcessTypes)buildable.m_iIndex);2080 if (pEntry != NULL)2081 {2082 strDesc = pEntry->GetDescription();2083 }2084 }2085 break;2086 }20872088 if(bRush)2089 {2090 strTemp.Format("SEED: %d, CHOSEN: %s, Rush if possible, TURNS: %d", GC.getGame().getJonRand().getSeed(), strDesc.c_str(), buildable.m_iTurnsToConstruct);2091 }2092 else2093 {2094 strTemp.Format("SEED: %d, CHOSEN: %s, Do not rush, TURNS: %d", GC.getGame().getJonRand().getSeed(), strDesc.c_str(), buildable.m_iTurnsToConstruct);2095 }20962097 strOutBuf = strBaseString + strTemp;2098 pLog->Msg(strOutBuf);2099 }2100}