Bazaar developer reference

CvAIOperation::LogOperationStatus()

Defined in
CvAIOperation.cpp, line 1274
Class
CvAIOperation
Hook name
CivHooks::CvAIOperation_LogOperationStatus

Hooks

static bool BeforeCvAIOperation_LogOperationStatus(CvAIOperation* self);static void AfterCvAIOperation_LogOperationStatus(CvAIOperation* self);static void ReplaceCvAIOperation_LogOperationStatus(void (*original)(CvAIOperation*), CvAIOperation* self);CivRegisterBefore<CivHooks::CvAIOperation_LogOperationStatus>(host, &BeforeCvAIOperation_LogOperationStatus);CivRegisterAfter<CivHooks::CvAIOperation_LogOperationStatus>(host, &AfterCvAIOperation_LogOperationStatus);CivRegisterReplace<CivHooks::CvAIOperation_LogOperationStatus>(host, &ReplaceCvAIOperation_LogOperationStatus);

Code

1273/// Log current status of the operation1274void CvAIOperation::LogOperationStatus()1275{1276	if(GC.getLogging() && GC.getAILogging())1277	{1278		CvString strOutBuf;1279		CvString strBaseString;1280		CvString strTemp, szTemp2, szTemp3;1281		CvString strPlayerName;1282		FILogFile* pLog;12831284		strPlayerName = GET_PLAYER(m_eOwner).getCivilizationShortDescription();1285		pLog = LOGFILEMGR.GetLog(GetLogFileName(strPlayerName), FILogFile::kDontTimeStamp);12861287		// Get the leading info for this line1288		strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());1289		strBaseString += strPlayerName + ", " + GetOperationName() + ", ";12901291		switch(m_eCurrentState)1292		{1293		case AI_OPERATION_STATE_ABORTED:1294			strTemp = "Aborted";1295			break;1296		case AI_OPERATION_STATE_RECRUITING_UNITS:1297			strTemp = "";1298			for(unsigned int uiI = 0; uiI < m_viArmyIDs.size(); uiI++)1299			{1300				CvArmyAI* pThisArmy = GET_PLAYER(m_eOwner).getArmyAI(m_viArmyIDs[uiI]);1301				szTemp2.Format("Recruiting Units, Army: %d, Muster Turn: %d, SLOT DETAIL:, ", pThisArmy->GetID(), pThisArmy->GetTurnAtNextCheckpoint());1302				strTemp += szTemp2;13031304				for(int iI = 0; iI < pThisArmy->GetNumFormationEntries(); iI++)1305				{1306					CvArmyFormationSlot* pSlot = pThisArmy->GetFormationSlot(iI);1307					if(pSlot->GetTurnAtCheckpoint() == ARMYSLOT_UNKNOWN_TURN_AT_CHECKPOINT)1308					{1309						szTemp2 = "No Info, ";1310					}1311					else if(pSlot->GetTurnAtCheckpoint() == ARMYSLOT_NOT_INCLUDING_IN_OPERATION)1312					{1313						szTemp2 = "Skipping, ";1314					}1315					else if(pSlot->GetUnitID() == NO_UNIT)1316					{1317						szTemp3.Format("Turn %d, ", pSlot->GetTurnAtCheckpoint());1318						szTemp2 = "Training - " + szTemp3;1319					}1320					else if(pSlot->HasStartedOnOperation())1321					{1322						UnitHandle pThisUnit = GET_PLAYER(m_eOwner).getUnit(pSlot->GetUnitID());1323						if(pThisUnit)1324						{1325							szTemp2.Format("Gathering at (%d-%d), ", pThisUnit->getX(), pThisUnit->getY());1326						}1327					}1328					else1329					{1330						UnitHandle pThisUnit = GET_PLAYER(m_eOwner).getUnit(pSlot->GetUnitID());1331						if(pThisUnit)1332						{1333							szTemp2.Format("%s - Turn %d, ", pThisUnit->getName().GetCString(), pSlot->GetTurnAtCheckpoint());1334						}1335					}1336					strTemp += szTemp2;1337				}1338			}1339			break;1340		case AI_OPERATION_STATE_GATHERING_FORCES:1341			strTemp = "";1342			for(unsigned int uiI = 0; uiI < m_viArmyIDs.size(); uiI++)1343			{1344				CvArmyAI* pThisArmy = GET_PLAYER(m_eOwner).getArmyAI(m_viArmyIDs[uiI]);1345				szTemp2.Format("Gathering Forces, Army: %d, Gather X: %d, Gather Y: %d, ", pThisArmy->GetID(), pThisArmy->GetX(), pThisArmy->GetY());1346				strTemp += szTemp2;1347				int iUnitID;1348				iUnitID = pThisArmy->GetFirstUnitID();1349				while(iUnitID != ARMY_NO_UNIT)1350				{1351					// do something with each entry1352					UnitHandle pThisUnit = GET_PLAYER(m_eOwner).getUnit(iUnitID);1353					if(pThisUnit)1354					{1355						szTemp2.Format("%s at (%d-%d),", pThisUnit->getName().GetCString(), pThisUnit->getX(), pThisUnit->getY());1356						strTemp += szTemp2;1357					}1358					iUnitID = pThisArmy->GetNextUnitID();1359				}1360			}1361			break;1362		case AI_OPERATION_STATE_MOVING_TO_TARGET:1363			strTemp = "";1364			for(unsigned int uiI = 0; uiI < m_viArmyIDs.size(); uiI++)1365			{1366				CvArmyAI* pThisArmy = GET_PLAYER(m_eOwner).getArmyAI(m_viArmyIDs[uiI]);1367				szTemp2.Format("Moving To Target, Army: %d, At X: %d, At Y: %d, To X: %d, To Y: %d, ", pThisArmy->GetID(), pThisArmy->GetX(), pThisArmy->GetY(), m_iTargetX, m_iTargetY);1368				strTemp += szTemp2;1369				int iUnitID;1370				iUnitID = pThisArmy->GetFirstUnitID();1371				while(iUnitID != ARMY_NO_UNIT)1372				{1373					// do something with each entry1374					UnitHandle pThisUnit = GET_PLAYER(m_eOwner).getUnit(iUnitID);1375					if(pThisUnit)1376					{1377						szTemp2.Format("%s at (%d-%d),", pThisUnit->getName().GetCString(), pThisUnit->getX(), pThisUnit->getY());1378						strTemp += szTemp2;1379					}1380					iUnitID = pThisArmy->GetNextUnitID();1381				}1382			}1383			break;1384		case AI_OPERATION_STATE_AT_TARGET:1385			strTemp = "At Target";1386			break;1387		case AI_OPERATION_STATE_SUCCESSFUL_FINISH:1388			strTemp = "Completed";1389			break;1390		};13911392		strOutBuf = strBaseString + strTemp;1393		pLog->Msg(strOutBuf);1394	}1395}

Calls

Called by