Hooks
static bool BeforeCvMilitaryAI_LogStrategy(CvMilitaryAI* self, MilitaryAIStrategyTypes eStrategy, bool bValue);static void AfterCvMilitaryAI_LogStrategy(CvMilitaryAI* self, MilitaryAIStrategyTypes eStrategy, bool bValue);static void ReplaceCvMilitaryAI_LogStrategy(void (*original)(CvMilitaryAI*, MilitaryAIStrategyTypes, bool), CvMilitaryAI* self, MilitaryAIStrategyTypes eStrategy, bool bValue);CivRegisterBefore<CivHooks::CvMilitaryAI_LogStrategy>(host, &BeforeCvMilitaryAI_LogStrategy);CivRegisterAfter<CivHooks::CvMilitaryAI_LogStrategy>(host, &AfterCvMilitaryAI_LogStrategy);CivRegisterReplace<CivHooks::CvMilitaryAI_LogStrategy>(host, &ReplaceCvMilitaryAI_LogStrategy);
Code
4129/// Log that a strategy is being turned on or off4130void CvMilitaryAI::LogStrategy(MilitaryAIStrategyTypes eStrategy, bool bValue)4131{4132 if(GC.getLogging() && GC.getAILogging())4133 {4134 CvString strOutBuf;4135 CvString strBaseString;4136 CvString strTemp;4137 CvString playerName;4138 CvString strLogName;4139 FILogFile* pLog;41404141 // Open the right file - strategies are logged to the flavor log, not the military one4142 playerName = GetPlayer()->getCivilizationShortDescription();4143 if(GC.getPlayerAndCityAILogSplit())4144 {4145 strLogName = "FlavorAILog_" + playerName + ".csv";4146 }4147 else4148 {4149 strLogName = "FlavorAILog.csv";4150 }4151 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);41524153 // Get the leading info for this line4154 strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());4155 strBaseString += playerName + ", ";41564157 // Strategy Info4158 CvMilitaryAIStrategyXMLEntry* pEntry = GC.getMilitaryAIStrategyInfo(eStrategy);4159 const char* szType = (pEntry != NULL)? pEntry->GetType() : NULL;41604161 strTemp.Format("%s, %d", szType, bValue);4162 strOutBuf = strBaseString + strTemp;4163 pLog->Msg(strOutBuf);41644165 // Also - write to Other Logs, so that we know what the player is doing in there as well41664167 if(GC.getPlayerAndCityAILogSplit())4168 {4169 strLogName = "TechAILog_" + playerName + ".csv";4170 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);4171 pLog->Msg(strOutBuf);41724173 CvString cityName;41744175 CvCity* pLoopCity;4176 int iLoop;41774178 for(pLoopCity = GetPlayer()->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GetPlayer()->nextCity(&iLoop))4179 {4180 cityName = pLoopCity->getName();4181 strLogName= "CityStrategyAILog_" + playerName + "_" + cityName + ".csv";4182 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);4183 pLog->Msg(strOutBuf);4184 }4185 }4186 else4187 {4188 pLog = LOGFILEMGR.GetLog("CityStrategyAILog.csv", FILogFile::kDontTimeStamp);4189 pLog->Msg(strOutBuf);4190 pLog = LOGFILEMGR.GetLog("TechAILog.csv", FILogFile::kDontTimeStamp);4191 pLog->Msg(strOutBuf);4192 }4193 }4194}