Bazaar developer reference

CvStartPositioner::StartingPlotRange() const

Defined in
CvStartPositioner.cpp, line 785
Class
CvStartPositioner
Hook name
CivHooks::CvStartPositioner_StartingPlotRange

Hooks

static bool BeforeCvStartPositioner_StartingPlotRange(const CvStartPositioner* self, int& result);static void AfterCvStartPositioner_StartingPlotRange(const CvStartPositioner* self, int& result);static int ReplaceCvStartPositioner_StartingPlotRange(int (*original)(const CvStartPositioner*), const CvStartPositioner* self);CivRegisterBefore<CivHooks::CvStartPositioner_StartingPlotRange>(host, &BeforeCvStartPositioner_StartingPlotRange);CivRegisterAfter<CivHooks::CvStartPositioner_StartingPlotRange>(host, &AfterCvStartPositioner_StartingPlotRange);CivRegisterReplace<CivHooks::CvStartPositioner_StartingPlotRange>(host, &ReplaceCvStartPositioner_StartingPlotRange);

Code

784/// How far apart should our civs start?785int CvStartPositioner::StartingPlotRange() const786{787	int iRange;788	int iNumMinors, iNumMajors;789	int iExpectedCities;790791	// Start with the range as a percentage of the maximum path length across the map792	iRange = (GC.getMap().maxPlotDistance() + 10);793	iRange *= GC.getSTARTING_DISTANCE_PERCENT();794	iRange /= 100;795796	// Now compute how many cities we expect on the map (we'll say just 1 for each minor civ)797	iNumMajors = GC.getGame().countMajorCivsAlive();798	iNumMinors = GC.getGame().countCivPlayersAlive() - iNumMajors;799	iExpectedCities = GC.getMap().getWorldInfo().getTargetNumCities() * iNumMajors;800	iExpectedCities += iNumMinors;801	iExpectedCities = std::max(1,iExpectedCities);802803	// Adjust range compared to how many plots we have per city804	iRange *= GC.getMap().getLandPlots();805#if defined(MOD_GLOBAL_CITY_WORKING)806	iRange /= (AVG_CITY_PLOTS / 2); // Use the average number of plots per city (this is the default 3-ring value)807#else808	iRange /= (NUM_CITY_PLOTS / 2); // NUM_CITY_PLOTS; -- I am assuming that some tiles will be watter or unused809#endif810	iRange /= iExpectedCities;811812	// Used to be a Python hook (minStartingDistanceModifier) here813814	CUSTOMLOG("CvStartPositioner::StartingPlotRange() = %i", std::max(iRange, GC.getMIN_CIV_STARTING_DISTANCE()));815	return std::max(iRange, GC.getMIN_CIV_STARTING_DISTANCE());816}

Calls

Called by