Bazaar developer reference

CvMilitaryAI::LogChosenTarget(AIOperationTypes, PlayerTypes, CvMilitaryTarget &)

Defined in
CvMilitaryAI.cpp, line 1785
Class
CvMilitaryAI
Hook name
CivHooks::CvMilitaryAI_LogChosenTarget

Hooks

static bool BeforeCvMilitaryAI_LogChosenTarget(CvMilitaryAI* self, AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvMilitaryTarget& target);static void AfterCvMilitaryAI_LogChosenTarget(CvMilitaryAI* self, AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvMilitaryTarget& target);static void ReplaceCvMilitaryAI_LogChosenTarget(void (*original)(CvMilitaryAI*, AIOperationTypes, PlayerTypes, CvMilitaryTarget&), CvMilitaryAI* self, AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvMilitaryTarget& target);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvMilitaryAI_LogChosenTarget::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvMilitaryAI_LogChosenTarget);host->RegisterHook(host->pluginIndex, CivHooks::CvMilitaryAI_LogChosenTarget::ID, CIV_HOOK_AFTER, (void*)&AfterCvMilitaryAI_LogChosenTarget);host->RegisterHook(host->pluginIndex, CivHooks::CvMilitaryAI_LogChosenTarget::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvMilitaryAI_LogChosenTarget);

Code

1784/// Log chosen attack1785void CvMilitaryAI::LogChosenTarget(AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvMilitaryTarget& target)1786{1787	if(GC.getLogging() && GC.getAILogging())1788	{1789		CvString strOutBuf;1790		CvString strBaseString;1791		CvString strTemp;1792		CvString playerName;1793		CvString strLogName;17941795		// Find the name of this civ and city1796		playerName = m_pPlayer->getCivilizationShortDescription();17971798		// Open the log file1799		FILogFile* pLog;1800		if(GC.getPlayerAndCityAILogSplit())1801		{1802			strLogName = "OperationalAILog_" + playerName + ".csv";1803		}1804		else1805		{1806			strLogName = "OperationalAILog.csv";1807		}1808		pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);18091810		// Get the leading info for this line1811		strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());1812		strBaseString += playerName + ", ";1813		if(eAIOperationType == AI_OPERATION_BASIC_CITY_ATTACK)1814		{1815			strBaseString += "Basic Attack, ";1816		}1817		else if(eAIOperationType == AI_OPERATION_SNEAK_CITY_ATTACK)1818		{1819			strBaseString += "Sneak Attack, ";1820		}1821		else if(eAIOperationType == AI_OPERATION_PURE_NAVAL_CITY_ATTACK)1822		{1823			strBaseString += "Pure Naval Attack, ";1824		}1825		else1826		{1827			strBaseString += "City State Attack, ";1828		}1829		strBaseString += GET_PLAYER(eEnemy).getCivilizationShortDescription();1830		strBaseString += ", ";18311832		strTemp.Format("CHOSEN: %s, Muster: %s", target.m_pTargetCity->getName().GetCString(), target.m_pMusterCity->getName().GetCString());1833		strOutBuf = strBaseString + strTemp;1834		if(target.m_bAttackBySea)1835		{1836			strOutBuf += ", Sea";1837		}1838		else1839		{1840			strOutBuf += ", Land";1841		}1842		pLog->Msg(strOutBuf);1843	}1844}

Calls

Called by