Bazaar developer reference

CvStartPositioner::TooCloseToAnotherCiv(CvPlot *)

Defined in
CvStartPositioner.cpp, line 711
Class
CvStartPositioner
Hook name
CivHooks::CvStartPositioner_TooCloseToAnotherCiv

Hooks

static bool BeforeCvStartPositioner_TooCloseToAnotherCiv(CvStartPositioner* self, CvPlot* pPlot, bool& result);static void AfterCvStartPositioner_TooCloseToAnotherCiv(CvStartPositioner* self, CvPlot* pPlot, bool& result);static bool ReplaceCvStartPositioner_TooCloseToAnotherCiv(bool (*original)(CvStartPositioner*, CvPlot*), CvStartPositioner* self, CvPlot* pPlot);CivRegisterBefore<CivHooks::CvStartPositioner_TooCloseToAnotherCiv>(host, &BeforeCvStartPositioner_TooCloseToAnotherCiv);CivRegisterAfter<CivHooks::CvStartPositioner_TooCloseToAnotherCiv>(host, &AfterCvStartPositioner_TooCloseToAnotherCiv);CivRegisterReplace<CivHooks::CvStartPositioner_TooCloseToAnotherCiv>(host, &ReplaceCvStartPositioner_TooCloseToAnotherCiv);

Code

710/// Returns true if illegal start position711bool CvStartPositioner::TooCloseToAnotherCiv(CvPlot* pPlot)712{713	int iI;714	bool rtnValue = false;715	CvPlot* pStartPlot(NULL);716717	CvAssert(pPlot);718	if(!pPlot)719		return rtnValue;720721	for(iI = 0; iI < MAX_PLAYERS; iI++)722	{723		if(GET_PLAYER((PlayerTypes)iI).isAlive())724		{725			pStartPlot = GET_PLAYER((PlayerTypes)iI).getStartingPlot();726			if(pStartPlot != NULL)727			{728				// If in same area, use full distance729				if(pStartPlot->getArea() == pPlot->getArea())730				{731					if(plotDistance(pPlot->getX(), pPlot->getY(),732					                pStartPlot->getX(), pStartPlot->getY()) < m_iRequiredSeparation)733					{734						return true;735					}736				}737738				// If in another area, use a fraction of full distance739				else740				{741					int iSeparationIfOnAnotherContinent = m_iRequiredSeparation * GC.getMIN_DISTANCE_OTHER_AREA_PERCENT() / 100;742					if(plotDistance(pPlot->getX(), pPlot->getY(),743					                pStartPlot->getX(), pStartPlot->getY()) < iSeparationIfOnAnotherContinent)744					{745						return true;746					}747				}748			}749		}750	}751752	return rtnValue;753}

Calls

Called by