Bazaar developer reference

CvHomelandAI::PlotSentryMoves()

Defined in
CvHomelandAI.cpp, line 1146
Class
CvHomelandAI
Hook name
CivHooks::CvHomelandAI_PlotSentryMoves

Hooks

static bool BeforeCvHomelandAI_PlotSentryMoves(CvHomelandAI* self);static void AfterCvHomelandAI_PlotSentryMoves(CvHomelandAI* self);static void ReplaceCvHomelandAI_PlotSentryMoves(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_PlotSentryMoves>(host, &BeforeCvHomelandAI_PlotSentryMoves);CivRegisterAfter<CivHooks::CvHomelandAI_PlotSentryMoves>(host, &AfterCvHomelandAI_PlotSentryMoves);CivRegisterReplace<CivHooks::CvHomelandAI_PlotSentryMoves>(host, &ReplaceCvHomelandAI_PlotSentryMoves);

Code

1145/// Send units to sentry points around borders1146void CvHomelandAI::PlotSentryMoves()1147{1148#if defined(MOD_AI_SECONDARY_WORKERS)1149	if (MOD_AI_SECONDARY_WORKERS && !m_pPlayer->isMinorCiv()) {1150		// Find any units with a secondary role of worker and see if there is anything close to build1151		PlotWorkerMoves(true);1152	}1153#endif1154	1155	// Do we have any targets of this type?1156	if(!m_TargetedSentryPoints.empty())1157	{1158		// Prioritize them (LATER)11591160		// See how many moves of this type we can execute1161		for(unsigned int iI = 0; iI < m_TargetedSentryPoints.size(); iI++)1162		{1163			AI_PERF_FORMAT("Homeland-perf.csv", ("PlotSentryMoves, Turn %03d, %s", GC.getGame().getElapsedGameTurns(), m_pPlayer->getCivilizationShortDescription()) );11641165			CvPlot* pTarget = GC.getMap().plot(m_TargetedSentryPoints[iI].GetTargetX(), m_TargetedSentryPoints[iI].GetTargetY());11661167			FindUnitsForThisMove(AI_HOMELAND_MOVE_SENTRY, (iI == 0)/*bFirstTime*/);11681169			if(m_CurrentMoveHighPriorityUnits.size() + m_CurrentMoveUnits.size() > 0)1170			{1171				if(GetBestUnitToReachTarget(pTarget, MAX_INT))1172				{1173					ExecuteMoveToTarget(pTarget);11741175					if(GC.getLogging() && GC.getAILogging())1176					{1177						CvString strLogString;1178						strLogString.Format("Moving to sentry point, X: %d, Y: %d, Priority: %d", m_TargetedSentryPoints[iI].GetTargetX(), m_TargetedSentryPoints[iI].GetTargetY(), m_TargetedSentryPoints[iI].GetAuxIntData());1179						LogHomelandMessage(strLogString);1180					}1181				}1182			}1183		}1184	}1185}

Calls

Called by