Bazaar developer reference

CvTacticalAI::ExtractTargetsForZone(CvTacticalDominanceZone *)

Defined in
CvTacticalAI.cpp, line 6093
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_ExtractTargetsForZone

Hooks

static bool BeforeCvTacticalAI_ExtractTargetsForZone(CvTacticalAI* self, CvTacticalDominanceZone* pZone);static void AfterCvTacticalAI_ExtractTargetsForZone(CvTacticalAI* self, CvTacticalDominanceZone* pZone);static void ReplaceCvTacticalAI_ExtractTargetsForZone(void (*original)(CvTacticalAI*, CvTacticalDominanceZone*), CvTacticalAI* self, CvTacticalDominanceZone* pZone);CivRegisterBefore<CivHooks::CvTacticalAI_ExtractTargetsForZone>(host, &BeforeCvTacticalAI_ExtractTargetsForZone);CivRegisterAfter<CivHooks::CvTacticalAI_ExtractTargetsForZone>(host, &AfterCvTacticalAI_ExtractTargetsForZone);CivRegisterReplace<CivHooks::CvTacticalAI_ExtractTargetsForZone>(host, &ReplaceCvTacticalAI_ExtractTargetsForZone);

Code

6092/// Sift through the target list and find just those that apply to the dominance zone we are currently looking at6093void CvTacticalAI::ExtractTargetsForZone(CvTacticalDominanceZone* pZone /* Pass in NULL for all zones */)6094{6095	TacticalList::iterator it;60966097	m_ZoneTargets.clear();6098	for(it = m_AllTargets.begin(); it != m_AllTargets.end(); ++it)6099	{6100		bool bValid = false;61016102		if(pZone == NULL)6103		{6104			bValid = true;6105		}6106		else6107		{6108			DomainTypes eDomain = DOMAIN_LAND;6109			if(pZone->IsWater())6110			{6111				eDomain = DOMAIN_SEA;6112			}6113			bValid = it->IsTargetValidInThisDomain(eDomain);6114		}6115		if(bValid)6116		{6117			if(pZone == NULL || it->GetDominanceZone() == pZone->GetDominanceZoneID())6118			{6119				m_ZoneTargets.push_back(*it);6120			}61216122			// Not obviously in this zone, but if within 2 of city we want them anyway6123			else6124			{6125				CvCity* pCity;6126				pCity = pZone->GetClosestCity();6127				if(pCity)6128				{6129					if(plotDistance(pCity->getX(), pCity->getY(), it->GetTargetX(), it->GetTargetY()) <= 2)6130					{6131						m_ZoneTargets.push_back(*it);6132					}6133				}6134			}6135		}6136	}6137}

Calls

Called by