Hooks
static bool BeforeCvDiplomacyAI_LogOpinionUpdate(CvDiplomacyAI* self, PlayerTypes ePlayer, std::vector<int>& viOpinionValues);static void AfterCvDiplomacyAI_LogOpinionUpdate(CvDiplomacyAI* self, PlayerTypes ePlayer, std::vector<int>& viOpinionValues);static void ReplaceCvDiplomacyAI_LogOpinionUpdate(void (*original)(CvDiplomacyAI*, PlayerTypes, std::vector<int>&), CvDiplomacyAI* self, PlayerTypes ePlayer, std::vector<int>& viOpinionValues);CivRegisterBefore<CivHooks::CvDiplomacyAI_LogOpinionUpdate>(host, &BeforeCvDiplomacyAI_LogOpinionUpdate);CivRegisterAfter<CivHooks::CvDiplomacyAI_LogOpinionUpdate>(host, &AfterCvDiplomacyAI_LogOpinionUpdate);CivRegisterReplace<CivHooks::CvDiplomacyAI_LogOpinionUpdate>(host, &ReplaceCvDiplomacyAI_LogOpinionUpdate);
Code
25795/// Log Opinion Update25796void CvDiplomacyAI::LogOpinionUpdate(PlayerTypes ePlayer, std::vector<int>& viOpinionValues)25797{25798 if(GC.getLogging() && GC.getAILogging())25799 {25800 CvString strOutBuf;25801 CvString strBaseString;25802 CvString strTemp;25803 CvString playerName;25804 CvString otherPlayerName;25805 CvString strDesc;25806 CvString strLogName;2580725808 // Find the name of this civ and city25809 playerName = GetPlayer()->getCivilizationShortDescription();2581025811 // Open the log file25812 if(GC.getPlayerAndCityAILogSplit())25813 {25814 strLogName = "DiplomacyAI_Approach_Log_" + playerName + ".csv";25815 }25816 else25817 {25818 strLogName = "DiplomacyAI_Approach_Log.csv";25819 }2582025821 FILogFile* pLog;25822 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);2582325824 // Get the leading info for this line25825 strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());25826 strBaseString += playerName;2582725828 otherPlayerName = GET_PLAYER(ePlayer).getCivilizationShortDescription();25829 strBaseString += ", " + otherPlayerName;2583025831 strTemp.Format("OPINION");25832 strOutBuf += ", " + strTemp;2583325834 MajorCivOpinionTypes eMajorCivOpinion;25835 // MinorCivOpinionTypes eMinorCivOpinion;2583625837 // Major Civs25838 if(!GET_PLAYER(ePlayer).isMinorCiv())25839 {25840 // Current Opinion25841 switch(GetMajorCivOpinion(ePlayer))25842 {25843 case MAJOR_CIV_OPINION_ALLY:25844 strTemp.Format("** ALLY **");25845 break;25846 case MAJOR_CIV_OPINION_FRIEND:25847 strTemp.Format("FRIEND");25848 break;25849 case MAJOR_CIV_OPINION_FAVORABLE:25850 strTemp.Format("Favorable");25851 break;25852 case MAJOR_CIV_OPINION_NEUTRAL:25853 strTemp.Format("N");25854 break;25855 case MAJOR_CIV_OPINION_COMPETITOR:25856 strTemp.Format("Competitor");25857 break;25858 case MAJOR_CIV_OPINION_ENEMY:25859 strTemp.Format("ENEMY");25860 break;25861 case MAJOR_CIV_OPINION_UNFORGIVABLE:25862 strTemp.Format("**UNFORGIVABLE**");25863 break;25864 default:25865 strTemp.Format("XXX");25866 break;25867 }25868 strOutBuf += ", " + strTemp;2586925870 for(int iMajorCivOpinionLoop = 0; iMajorCivOpinionLoop < NUM_MAJOR_CIV_OPINION_TYPES; iMajorCivOpinionLoop++)25871 {25872 eMajorCivOpinion = (MajorCivOpinionTypes) iMajorCivOpinionLoop;2587325874 switch(eMajorCivOpinion)25875 {25876 case MAJOR_CIV_OPINION_ALLY:25877 strTemp.Format("Ally");25878 break;25879 case MAJOR_CIV_OPINION_FRIEND:25880 strTemp.Format("Friend");25881 break;25882 case MAJOR_CIV_OPINION_NEUTRAL:25883 strTemp.Format("Neutral");25884 break;25885 case MAJOR_CIV_OPINION_COMPETITOR:25886 strTemp.Format("Competitor");25887 break;25888 case MAJOR_CIV_OPINION_ENEMY:25889 strTemp.Format("Enemy");25890 break;25891 default:25892 strTemp.Format("XXX");25893 break;25894 }25895 strOutBuf += ", " + strTemp;2589625897 strTemp.Format("%d", viOpinionValues[eMajorCivOpinion]);25898 strOutBuf += ", " + strTemp;25899 }2590025901 strOutBuf = strBaseString + strOutBuf;25902 pLog->Msg(strOutBuf);25903 }25904 }25905}