Bazaar developer reference

CvDiplomacyAI::LogWarStatus()

Defined in
CvDiplomacyAI.cpp, line 26479
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_LogWarStatus

Hooks

static bool BeforeCvDiplomacyAI_LogWarStatus(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_LogWarStatus(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_LogWarStatus(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_LogWarStatus>(host, &BeforeCvDiplomacyAI_LogWarStatus);CivRegisterAfter<CivHooks::CvDiplomacyAI_LogWarStatus>(host, &AfterCvDiplomacyAI_LogWarStatus);CivRegisterReplace<CivHooks::CvDiplomacyAI_LogWarStatus>(host, &ReplaceCvDiplomacyAI_LogWarStatus);

Code

26478/// Log Diplomatic War status with other Players26479void CvDiplomacyAI::LogWarStatus()26480{26481	if(GC.getLogging() && GC.getAILogging())26482	{26483		CvString strOutBuf;26484		CvString strBaseString;26485		CvString playerName;26486		CvString otherPlayerName;26487		CvString strMinorString;26488		CvString strDesc;26489		CvString strLogName;26490		CvString strTemp;2649126492		// Find the name of this civ and city26493		playerName = GetPlayer()->getCivilizationShortDescription();2649426495		// Open the log file26496		if(GC.getPlayerAndCityAILogSplit())26497		{26498			strLogName = "DiplomacyAI_War_Log_" + playerName + ".csv";26499		}26500		else26501		{26502			strLogName = "DiplomacyAI_War_Log.csv";26503		}2650426505		FILogFile* pLog;26506		pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);2650726508		// Get the leading info for this line26509		strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());26510		strBaseString += playerName;2651126512		int iPlayerLoop;26513		PlayerTypes eLoopPlayer;2651426515		bool bLogPlayer;2651626517		// Loop through all (known) Players26518		for(iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)26519		{26520			eLoopPlayer = (PlayerTypes) iPlayerLoop;2652126522			if(IsPlayerValid(eLoopPlayer))26523			{26524				if(IsAtWar(eLoopPlayer))26525				{26526					bLogPlayer = true;26527				}26528				else if(GetWarState(eLoopPlayer) != NO_WAR_STATE_TYPE)26529				{26530					bLogPlayer = true;26531				}26532				else if(GetWarGoal(eLoopPlayer) != NO_WAR_GOAL_TYPE)26533				{26534					bLogPlayer = true;26535				}26536				else26537				{26538					bLogPlayer = false;26539				}2654026541				// Should we actually record a log entry for this player?26542				if(bLogPlayer)26543				{26544					strOutBuf = strBaseString;2654526546					// Name26547					if(GET_PLAYER(eLoopPlayer).isMinorCiv())26548					{26549						strMinorString = "--- ";26550					}2655126552					otherPlayerName = GET_PLAYER(eLoopPlayer).getCivilizationShortDescription();26553					strOutBuf += ", " + strMinorString + otherPlayerName;2655426555					// Approach26556					if(GET_PLAYER(eLoopPlayer).isMinorCiv())26557					{26558						if(GetMinorCivApproach(eLoopPlayer) == MINOR_CIV_APPROACH_CONQUEST)26559						{26560							strOutBuf += ", APP: CONQUEST";26561						}26562						else26563						{26564							strOutBuf += ", APP: o";26565						}26566					}26567					else26568					{26569						if(GetMajorCivApproach(eLoopPlayer, false) == MAJOR_CIV_APPROACH_WAR)26570						{26571							strOutBuf += ", APP: WAR";26572						}26573						else26574						{26575							strOutBuf += ", APP: o";26576						}26577					}2657826579					// Wants to conquer the world?26580					if(IsGoingForWorldConquest())26581					{26582						strOutBuf += ", WC";26583					}26584					else26585					{26586						strOutBuf += ", ";26587					}2658826589					// Wants peace with eLoopPlayer?26590					if(IsWantsPeaceWithPlayer(eLoopPlayer))26591					{26592						strOutBuf += ", Wants Peace!!!";26593					}26594					else26595					{26596						strOutBuf += ", ";26597					}2659826599					LogWarGoal(strOutBuf, eLoopPlayer);26600					LogWarState(strOutBuf, eLoopPlayer);26601					LogWarProjection(strOutBuf, eLoopPlayer);2660226603					LogWarPeaceWillingToOffer(strOutBuf, eLoopPlayer);26604					LogWarPeaceWillingToAccept(strOutBuf, eLoopPlayer);2660526606					// # of turns at War26607					if(GetPlayerNumTurnsAtWar(eLoopPlayer) > 0)26608					{26609						strTemp.Format("%d", GetPlayerNumTurnsAtWar(eLoopPlayer));26610						strOutBuf += ", " + strTemp;26611					}26612					else26613					{26614						strOutBuf += ", ";26615					}2661626617					LogWarDamage(strOutBuf, eLoopPlayer);2661826619					LogMilitaryThreat(strOutBuf, eLoopPlayer);2662026621					LogProximity(strOutBuf, eLoopPlayer);26622					LogTargetValue(strOutBuf, eLoopPlayer);2662326624					LogMilitaryStrength(strOutBuf, eLoopPlayer);26625					LogEconomicStrength(strOutBuf, eLoopPlayer);2662626627					pLog->Msg(strOutBuf);26628				}26629			}26630		}26631	}26632}

Calls

Called by