Hooks
static bool BeforeCvMilitaryAI_LogAttackTargets(CvMilitaryAI* self, AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvWeightedVector<CvMilitaryTarget, SAFE_ESTIMATE_NUM_CITIES* 10, true>& weightedTargetList);static void AfterCvMilitaryAI_LogAttackTargets(CvMilitaryAI* self, AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvWeightedVector<CvMilitaryTarget, SAFE_ESTIMATE_NUM_CITIES* 10, true>& weightedTargetList);static void ReplaceCvMilitaryAI_LogAttackTargets(void (*original)(CvMilitaryAI*, AIOperationTypes, PlayerTypes, CvWeightedVector<CvMilitaryTarget, SAFE_ESTIMATE_NUM_CITIES* 10, true>&), CvMilitaryAI* self, AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvWeightedVector<CvMilitaryTarget, SAFE_ESTIMATE_NUM_CITIES* 10, true>& weightedTargetList);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvMilitaryAI_LogAttackTargets::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvMilitaryAI_LogAttackTargets);host->RegisterHook(host->pluginIndex, CivHooks::CvMilitaryAI_LogAttackTargets::ID, CIV_HOOK_AFTER, (void*)&AfterCvMilitaryAI_LogAttackTargets);host->RegisterHook(host->pluginIndex, CivHooks::CvMilitaryAI_LogAttackTargets::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvMilitaryAI_LogAttackTargets);
Code
1716/// Log all potential attacks1717void CvMilitaryAI::LogAttackTargets(AIOperationTypes eAIOperationType, PlayerTypes eEnemy, CvWeightedVector<CvMilitaryTarget, SAFE_ESTIMATE_NUM_CITIES* 10, true>& weightedTargetList)1718{1719 if(GC.getLogging() && GC.getAILogging())1720 {1721 CvString strOutBuf;1722 CvString strBaseString;1723 CvString strTemp;1724 CvString playerName;1725 CvString strLogName;17261727 // Find the name of this civ1728 playerName = m_pPlayer->getCivilizationShortDescription();17291730 // Open the log file1731 FILogFile* pLog;1732 if(GC.getPlayerAndCityAILogSplit())1733 {1734 strLogName = "OperationalAILog_" + playerName + ".csv";1735 }1736 else1737 {1738 strLogName = "OperationalAILog.csv";1739 }1740 pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);17411742 // Get the leading info for this line1743 strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());1744 strBaseString += playerName + ", ";1745 if(eAIOperationType == AI_OPERATION_BASIC_CITY_ATTACK)1746 {1747 strBaseString += "Basic Attack, ";1748 }1749 else if(eAIOperationType == AI_OPERATION_SNEAK_CITY_ATTACK)1750 {1751 strBaseString += "Sneak Attack, ";1752 }1753 else if(eAIOperationType == AI_OPERATION_PURE_NAVAL_CITY_ATTACK)1754 {1755 strBaseString += "Pure Naval Attack, ";1756 }1757 else1758 {1759 strBaseString += "City State Attack, ";1760 }1761 strBaseString += GET_PLAYER(eEnemy).getCivilizationShortDescription();1762 strBaseString += ", ";17631764 // Dump out the weight of each buildable item1765 for(int iI = 0; iI < weightedTargetList.size(); iI++)1766 {1767 CvMilitaryTarget target = weightedTargetList.GetElement(iI);1768 int iWeight = weightedTargetList.GetWeight(iI);1769 strTemp.Format("Target: %s, Muster: %s, %d, Distance: %d", target.m_pTargetCity->getName().GetCString(), target.m_pMusterCity->getName().GetCString(), iWeight, target.m_iPathLength);1770 strOutBuf = strBaseString + strTemp;1771 if(target.m_bAttackBySea)1772 {1773 strOutBuf += ", Sea";1774 }1775 else1776 {1777 strOutBuf += ", Land";1778 }1779 pLog->Msg(strOutBuf);1780 }1781 }1782}