CvHomelandAI::EliminateAdjacentSentryPoints()
- Defined in
- CvHomelandAI.cpp, line 5297
- Class
- CvHomelandAI
- Hook name
CivHooks::CvHomelandAI_EliminateAdjacentSentryPoints
Hooks
static bool BeforeCvHomelandAI_EliminateAdjacentSentryPoints(CvHomelandAI* self);static void AfterCvHomelandAI_EliminateAdjacentSentryPoints(CvHomelandAI* self);static void ReplaceCvHomelandAI_EliminateAdjacentSentryPoints(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_EliminateAdjacentSentryPoints>(host, &BeforeCvHomelandAI_EliminateAdjacentSentryPoints);CivRegisterAfter<CivHooks::CvHomelandAI_EliminateAdjacentSentryPoints>(host, &AfterCvHomelandAI_EliminateAdjacentSentryPoints);CivRegisterReplace<CivHooks::CvHomelandAI_EliminateAdjacentSentryPoints>(host, &ReplaceCvHomelandAI_EliminateAdjacentSentryPoints);
Code
5296/// Don't allow adjacent tiles to both be sentry points5297void CvHomelandAI::EliminateAdjacentSentryPoints()5298{5299 // First, sort the sentry points by priority5300 std::stable_sort(m_TargetedSentryPoints.begin(), m_TargetedSentryPoints.end());53015302 // Create temporary copy of list5303 std::vector<CvHomelandTarget> tempPoints;5304 tempPoints = m_TargetedSentryPoints;53055306 // Clear out main list5307 m_TargetedSentryPoints.clear();53085309 // Loop through all points in copy5310 std::vector<CvHomelandTarget>::iterator it, it2;5311 for(it = tempPoints.begin(); it != tempPoints.end(); ++it)5312 {5313 bool bFoundAdjacent = false;53145315 // Is it adjacent to a point in the main list?5316 for(it2 = m_TargetedSentryPoints.begin(); it2 != m_TargetedSentryPoints.end(); ++it2)5317 {5318 if(plotDistance(it->GetTargetX(), it->GetTargetY(), it2->GetTargetX(), it2->GetTargetY()) == 1)5319 {5320 bFoundAdjacent = true;5321 break;5322 }5323 }53245325 if(!bFoundAdjacent)5326 {5327 m_TargetedSentryPoints.push_back(*it);5328 }5329 }5330}
Calls
- CvHomelandTarget::GetTargetX()
- CvHomelandTarget::GetTargetY()
- plotDistance(int, int, int, int)
std::_Vector_const_iterator::operator!=std::_Vector_iterator::_Vector_iteratorstd::_Vector_iterator::operator*std::_Vector_iterator::operator++std::_Vector_iterator::operator->std::_Vector_iterator::operator=std::stable_sortstd::vector::beginstd::vector::clearstd::vector::endstd::vector::operator=std::vector::push_backstd::vector::vector