Hooks
static bool BeforeCvDiplomacyAI_LogMinorCivBullyUnit(CvDiplomacyAI* self, PlayerTypes eMinor, int iOldFriendshipTimes100, int iNewFriendshipTimes100, UnitTypes eUnit, bool bSuccess, int iBullyMetricScore);static void AfterCvDiplomacyAI_LogMinorCivBullyUnit(CvDiplomacyAI* self, PlayerTypes eMinor, int iOldFriendshipTimes100, int iNewFriendshipTimes100, UnitTypes eUnit, bool bSuccess, int iBullyMetricScore);static void ReplaceCvDiplomacyAI_LogMinorCivBullyUnit(void (*original)(CvDiplomacyAI*, PlayerTypes, int, int, UnitTypes, bool, int), CvDiplomacyAI* self, PlayerTypes eMinor, int iOldFriendshipTimes100, int iNewFriendshipTimes100, UnitTypes eUnit, bool bSuccess, int iBullyMetricScore);CivRegisterBefore<CivHooks::CvDiplomacyAI_LogMinorCivBullyUnit>(host, &BeforeCvDiplomacyAI_LogMinorCivBullyUnit);CivRegisterAfter<CivHooks::CvDiplomacyAI_LogMinorCivBullyUnit>(host, &AfterCvDiplomacyAI_LogMinorCivBullyUnit);CivRegisterReplace<CivHooks::CvDiplomacyAI_LogMinorCivBullyUnit>(host, &ReplaceCvDiplomacyAI_LogMinorCivBullyUnit);
Code
24773void CvDiplomacyAI::LogMinorCivBullyUnit(PlayerTypes eMinor, int iOldFriendshipTimes100, int iNewFriendshipTimes100, UnitTypes eUnit, bool bSuccess, int iBullyMetricScore)24774{24775 if(GC.getLogging() && GC.getAILogging())24776 {24777 CvString strLogName;2477824779 CvString strOutBuf;24780 CvString strBaseString;2478124782 CvString playerName;24783 CvString otherPlayerName;2478424785 CvString strTemp;2478624787 playerName = GetPlayer()->getCivilizationShortDescription();2478824789 // Open the log file24790 if(GC.getPlayerAndCityAILogSplit())24791 strLogName = "DiplomacyAI_MinorCiv_Log_" + playerName + ".csv";24792 else24793 strLogName = "DiplomacyAI_MinorCiv_Log.csv";2479424795 FILogFile* pLog;24796 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);2479724798 // Turn number24799 strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());2480024801 // Our Name24802 strBaseString += playerName;2480324804 // Their Name24805 otherPlayerName = GET_PLAYER(eMinor).getCivilizationShortDescription();24806 strBaseString += ", " + otherPlayerName;2480724808 strOutBuf = strBaseString;2480924810 // Unit tribute24811 strTemp.Format("Unit Bully: %s", eUnit == (UnitTypes) GC.getInfoTypeForString("UNIT_WORKER") ? "Worker" : "Other unit");24812 strOutBuf += ", " + strTemp;2481324814 strTemp.Format("Friendship: %d to %d", iOldFriendshipTimes100 / 100, iNewFriendshipTimes100 / 100);24815 strOutBuf += ", " + strTemp;2481624817 LogGrandStrategy(strOutBuf);2481824819 // City State type24820 strOutBuf += ", ";24821 strOutBuf += GC.getMinorCivInfo(GET_PLAYER(eMinor).GetMinorCivAI()->GetMinorCivType())->GetType();2482224823 // Did it work?24824 if(bSuccess)24825 {24826 strOutBuf += ", ";24827 strOutBuf += "Success!";24828 }24829 else24830 {24831 strOutBuf += ", ";24832 strOutBuf += "Failure";24833 }2483424835 // Append the bully metric score24836 strTemp.Format("Bully Score: %d", iBullyMetricScore);24837 strOutBuf += ", " + strTemp;2483824839 pLog->Msg(strOutBuf);2484024841 OutputDebugString("\n");24842 OutputDebugString(strOutBuf);24843 OutputDebugString("\n");24844 }24845}