Bazaar developer reference

CvTacticalAI::RemoveChosenUnits(int)

Defined in
CvTacticalAI.cpp, line 10947
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_RemoveChosenUnits

Hooks

static bool BeforeCvTacticalAI_RemoveChosenUnits(CvTacticalAI* self, int iStartIndex);static void AfterCvTacticalAI_RemoveChosenUnits(CvTacticalAI* self, int iStartIndex);static void ReplaceCvTacticalAI_RemoveChosenUnits(void (*original)(CvTacticalAI*, int), CvTacticalAI* self, int iStartIndex);CivRegisterBefore<CivHooks::CvTacticalAI_RemoveChosenUnits>(host, &BeforeCvTacticalAI_RemoveChosenUnits);CivRegisterAfter<CivHooks::CvTacticalAI_RemoveChosenUnits>(host, &AfterCvTacticalAI_RemoveChosenUnits);CivRegisterReplace<CivHooks::CvTacticalAI_RemoveChosenUnits>(host, &ReplaceCvTacticalAI_RemoveChosenUnits);

Code

10946/// Pull the units we just assigned out of the list of potential assignments10947void CvTacticalAI::RemoveChosenUnits(int iStartIndex)10948{10949	m_TemporaryBlocks.clear();10950	m_TemporaryBlocks = m_PotentialBlocks;10951	m_PotentialBlocks.clear();1095210953	for(unsigned int iI = iStartIndex; iI < m_TemporaryBlocks.size(); iI++)10954	{10955		bool bCopyIt = true;1095610957		CvBlockingUnit block = m_TemporaryBlocks[iI];1095810959		// Loop through chosen array looking for occurrences of this unit10960		for(unsigned int jJ = 0; jJ < m_NewlyChosen.size() && bCopyIt; jJ++)10961		{10962			if(block.GetUnitID() == m_NewlyChosen[jJ].GetUnitID())10963			{10964				bCopyIt = false;10965			}10966		}1096710968		if(bCopyIt)10969		{10970			m_PotentialBlocks.push_back(block);10971		}10972	}1097310974	// Rebuild number of choices10975	for(unsigned int iI = 0; iI < m_PotentialBlocks.size(); iI++)10976	{10977		int iNumFound = 0;10978		CvPlot* pPlot = m_PotentialBlocks[iI].GetPlot();1097910980		for(unsigned int jJ = 0; jJ < m_PotentialBlocks.size(); jJ++)10981		{10982			if(pPlot == m_PotentialBlocks[jJ].GetPlot())10983			{10984				iNumFound++;10985			}10986		}10987		m_PotentialBlocks[iI].SetNumChoices(iNumFound);10988	}10989}

Calls

Called by