Hooks
static bool BeforeCvEconomicAI_LogStrategy(CvEconomicAI* self, EconomicAIStrategyTypes eStrategy, bool bValue);static void AfterCvEconomicAI_LogStrategy(CvEconomicAI* self, EconomicAIStrategyTypes eStrategy, bool bValue);static void ReplaceCvEconomicAI_LogStrategy(void (*original)(CvEconomicAI*, EconomicAIStrategyTypes, bool), CvEconomicAI* self, EconomicAIStrategyTypes eStrategy, bool bValue);CivRegisterBefore<CivHooks::CvEconomicAI_LogStrategy>(host, &BeforeCvEconomicAI_LogStrategy);CivRegisterAfter<CivHooks::CvEconomicAI_LogStrategy>(host, &AfterCvEconomicAI_LogStrategy);CivRegisterReplace<CivHooks::CvEconomicAI_LogStrategy>(host, &ReplaceCvEconomicAI_LogStrategy);
Code
2896/// Log that a strategy is being turned on or off2897void CvEconomicAI::LogStrategy(EconomicAIStrategyTypes eStrategy, bool bValue)2898{2899 if(GC.getLogging() && GC.getAILogging())2900 {2901 // Find the name of this civ and city2902 CvString playerName = GetPlayer()->getCivilizationShortDescription();29032904 // Open the log file2905 CvString strLogName = "FlavorAILog.csv";2906 if(GC.getPlayerAndCityAILogSplit())2907 {2908 strLogName = "FlavorAILog_" + playerName + ".csv";2909 }29102911 FILogFile* pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);29122913 // Get the leading info for this line2914 CvString strBaseString;2915 strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());2916 strBaseString += playerName + ", ";29172918 CvString strOutBuf = strBaseString;29192920 // Strategy Info2921 CvEconomicAIStrategyXMLEntry* pEconomicAIStrategyEntry = GC.getEconomicAIStrategyInfo(eStrategy);2922 if(pEconomicAIStrategyEntry != NULL)2923 {2924 CvString strTemp;2925 strTemp.Format("%s, %d", pEconomicAIStrategyEntry->GetType(), bValue);2926 strOutBuf += strTemp;2927 }29282929 pLog->Msg(strOutBuf);29302931 // Also - write to Other Logs, so that we know what the player is doing in there as well29322933 if(GC.getPlayerAndCityAILogSplit())2934 {2935 strLogName = "TechAILog_" + playerName + ".csv";2936 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);2937 pLog->Msg(strOutBuf);29382939 CvString cityName;29402941 CvCity* pLoopCity;2942 int iLoop;29432944 for(pLoopCity = GetPlayer()->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GetPlayer()->nextCity(&iLoop))2945 {2946 cityName = pLoopCity->getName();2947 strLogName = "CityStrategyAILog_" + playerName + "_" + cityName + ".csv";2948 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);2949 pLog->Msg(strOutBuf);2950 }2951 }2952 else2953 {2954 pLog = LOGFILEMGR.GetLog("CityStrategyAILog.csv", FILogFile::kDontTimeStamp);2955 pLog->Msg(strOutBuf);2956 pLog = LOGFILEMGR.GetLog("TechAILog.csv", FILogFile::kDontTimeStamp);2957 pLog->Msg(strOutBuf);2958 }2959 }2960}