Bazaar developer reference

CvMilitaryAI::LogMilitaryStatus()

Defined in
CvMilitaryAI.cpp, line 4197
Class
CvMilitaryAI
Hook name
CivHooks::CvMilitaryAI_LogMilitaryStatus

Hooks

static bool BeforeCvMilitaryAI_LogMilitaryStatus(CvMilitaryAI* self);static void AfterCvMilitaryAI_LogMilitaryStatus(CvMilitaryAI* self);static void ReplaceCvMilitaryAI_LogMilitaryStatus(void (*original)(CvMilitaryAI*), CvMilitaryAI* self);CivRegisterBefore<CivHooks::CvMilitaryAI_LogMilitaryStatus>(host, &BeforeCvMilitaryAI_LogMilitaryStatus);CivRegisterAfter<CivHooks::CvMilitaryAI_LogMilitaryStatus>(host, &AfterCvMilitaryAI_LogMilitaryStatus);CivRegisterReplace<CivHooks::CvMilitaryAI_LogMilitaryStatus>(host, &ReplaceCvMilitaryAI_LogMilitaryStatus);

Code

4196/// Log some military status info each turn4197void CvMilitaryAI::LogMilitaryStatus()4198{4199	if(GC.getLogging() && GC.getAILogging())4200	{4201		CvString strOutBuf;4202		CvString strBaseString;4203		CvString strTemp;4204		CvString playerName;4205		CvCity* pCity;4206		CvString cityName;4207		FILogFile* pLog;42084209		// Open the right file4210		playerName = GetPlayer()->getCivilizationShortDescription();4211		pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);42124213		// Very first update (to write header row?)4214		if(GC.getGame().getGameTurn() == 1 && m_pPlayer->GetID() == 0)4215		{4216			strTemp.Format("Turn, Player, Cities, Settlers, Civ Threat, Barb Threat, Land Units, Land In Armies, Rec Land Size, Land Reserve, Naval Units, Naval In Armies, Rec Naval Size, Most Threatened, Danger");4217			pLog->Msg(strTemp);4218		}42194220		// Get the leading info for this line4221		strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());4222		strBaseString += playerName + ", ";42234224		// City info4225		strTemp.Format("%d, %d, ", m_pPlayer->getNumCities(), m_pPlayer->GetNumUnitsWithUnitAI(UNITAI_SETTLE, true));4226		strOutBuf = strBaseString + strTemp;42274228		//Threat Info4229		strTemp.Format("%d, %d, ", m_iTotalThreatWeight, GetBarbarianThreatTotal());4230		strOutBuf += strTemp;42314232		// Military size Info4233		int iNavalSize = MilitaryAIHelpers::ComputeRecommendedNavySize(m_pPlayer);4234		strTemp.Format("%d, %d, %d, %d, %d, %d, %d, ", m_iNumLandUnits, m_iNumLandUnitsInArmies, m_iRecommendedMilitarySize, m_iMandatoryReserveSize, m_iNumNavalUnits, m_iNumNavalUnitsInArmies, iNavalSize);4235		strOutBuf += strTemp;42364237		// Most threatened city4238		pCity = GetMostThreatenedCity();4239		if(pCity != NULL)4240		{4241			cityName = pCity->getName();4242			strOutBuf += cityName;4243			strTemp.Format(", %d", pCity->getThreatValue());4244			strOutBuf += strTemp;4245		}42464247		pLog->Msg(strOutBuf);4248	}4249}

Calls

Called by