Bazaar developer reference

CvHomelandAI::EliminateAdjacentHomelandRoads()

Defined in
CvHomelandAI.cpp, line 5333
Class
CvHomelandAI
Hook name
CivHooks::CvHomelandAI_EliminateAdjacentHomelandRoads

Hooks

static bool BeforeCvHomelandAI_EliminateAdjacentHomelandRoads(CvHomelandAI* self);static void AfterCvHomelandAI_EliminateAdjacentHomelandRoads(CvHomelandAI* self);static void ReplaceCvHomelandAI_EliminateAdjacentHomelandRoads(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_EliminateAdjacentHomelandRoads>(host, &BeforeCvHomelandAI_EliminateAdjacentHomelandRoads);CivRegisterAfter<CivHooks::CvHomelandAI_EliminateAdjacentHomelandRoads>(host, &AfterCvHomelandAI_EliminateAdjacentHomelandRoads);CivRegisterReplace<CivHooks::CvHomelandAI_EliminateAdjacentHomelandRoads>(host, &ReplaceCvHomelandAI_EliminateAdjacentHomelandRoads);

Code

5332/// Don't allow adjacent tiles to both be mobile reserve muster points5333void CvHomelandAI::EliminateAdjacentHomelandRoads()5334{5335	// Create temporary copy of list5336	std::vector<CvHomelandTarget> tempPoints;5337	tempPoints = m_TargetedHomelandRoads;53385339	// Clear out main list5340	m_TargetedHomelandRoads.clear();53415342	// Loop through all points in copy5343	std::vector<CvHomelandTarget>::iterator it, it2;5344	for(it = tempPoints.begin(); it != tempPoints.end(); ++it)5345	{5346		bool bFoundAdjacent = false;53475348		// Is it adjacent to a point in the main list?5349		for(it2 = m_TargetedHomelandRoads.begin(); it2 != m_TargetedHomelandRoads.end(); ++it2)5350		{5351			if(plotDistance(it->GetTargetX(), it->GetTargetY(), it2->GetTargetX(), it2->GetTargetY()) == 1)5352			{5353				bFoundAdjacent = true;5354				break;5355			}5356		}53575358		if(!bFoundAdjacent)5359		{5360			m_TargetedHomelandRoads.push_back(*it);5361		}5362	}5363}

Calls

Called by