Bazaar developer reference

CvCity::GetBuyPlotCost(int, int) const

Defined in
CvCity.cpp, line 12344
Class
CvCity
Hook name
CivHooks::CvCity_GetBuyPlotCost

Hooks

static bool BeforeCvCity_GetBuyPlotCost(const CvCity* self, int iPlotX, int iPlotY, int& result);static void AfterCvCity_GetBuyPlotCost(const CvCity* self, int iPlotX, int iPlotY, int& result);static int ReplaceCvCity_GetBuyPlotCost(int (*original)(const CvCity*, int, int), const CvCity* self, int iPlotX, int iPlotY);CivRegisterBefore<CivHooks::CvCity_GetBuyPlotCost>(host, &BeforeCvCity_GetBuyPlotCost);CivRegisterAfter<CivHooks::CvCity_GetBuyPlotCost>(host, &AfterCvCity_GetBuyPlotCost);CivRegisterReplace<CivHooks::CvCity_GetBuyPlotCost>(host, &ReplaceCvCity_GetBuyPlotCost);

Code

12343/// How much will purchasing this plot cost -- (-1,-1) will return the generic price12344int CvCity::GetBuyPlotCost(int iPlotX, int iPlotY) const12345{12346	VALIDATE_OBJECT12347	if(iPlotX == -1 && iPlotY == -1)12348	{12349		return GET_PLAYER(getOwner()).GetBuyPlotCost();12350	}1235112352	CvPlot* pPlot = GC.getMap().plot(iPlotX, iPlotY);12353	if(!pPlot)12354	{12355		return -1;12356	}1235712358	// Base cost12359	int iCost = GET_PLAYER(getOwner()).GetBuyPlotCost();1236012361	// Influence cost factor (e.g. Hills are more expensive than flat land)12362	CvMap& thisMap = GC.getMap();12363	CvPlot* pThisPlot = plot();12364#if defined(MOD_GLOBAL_CITY_WORKING)12365	const int iMaxRange = getBuyPlotDistance();12366#else12367	const int iMaxRange = /*3*/ GC.getMAXIMUM_BUY_PLOT_DISTANCE();12368#endif12369	if(plotDistance(iPlotX, iPlotY, getX(), getY()) > iMaxRange)12370		return 9999; // Critical hit!1237112372	int iPLOT_INFLUENCE_BASE_MULTIPLIER = /*100*/ GC.getPLOT_INFLUENCE_BASE_MULTIPLIER();12373	int iPLOT_INFLUENCE_DISTANCE_MULTIPLIER = /*100*/ GC.getPLOT_INFLUENCE_DISTANCE_MULTIPLIER();12374	int iPLOT_INFLUENCE_DISTANCE_DIVISOR = /*3*/ GC.getPLOT_INFLUENCE_DISTANCE_DIVISOR();12375	int iPLOT_BUY_RESOURCE_COST = /*-100*/ GC.getPLOT_BUY_RESOURCE_COST();12376	int iDistance = thisMap.calculateInfluenceDistance(pThisPlot, pPlot, iMaxRange, false);12377	iDistance -= GetCheapestPlotInfluence(); // Reduce distance by the cheapest available (so that the costs don't ramp up ridiculously fast)1237812379	int iInfluenceCostFactor = iPLOT_INFLUENCE_BASE_MULTIPLIER;12380	iInfluenceCostFactor += (iDistance * iPLOT_INFLUENCE_DISTANCE_MULTIPLIER) / iPLOT_INFLUENCE_DISTANCE_DIVISOR;12381	if(pPlot->getResourceType(getTeam()) != NO_RESOURCE)12382		iInfluenceCostFactor += iPLOT_BUY_RESOURCE_COST;1238312384	if(iInfluenceCostFactor > 100)12385	{12386		iCost *= iInfluenceCostFactor;12387		iCost /= 100;12388	}1238912390#if defined(MOD_UI_CITY_EXPANSION)12391	if (MOD_UI_CITY_EXPANSION && GET_PLAYER(getOwner()).isHuman()) {12392		// If we have a culture surplus, we get a discount on the tile12393		if (GetJONSCultureStored() >= GetJONSCultureThreshold()) {12394			iCost -= GET_PLAYER(getOwner()).GetBuyPlotCost();12395		}12396	}12397#endif1239812399	// Game Speed Mod12400	iCost *= GC.getGame().getGameSpeedInfo().getGoldPercent();12401	iCost /= 100;1240212403	iCost *= (100 + getPlotBuyCostModifier());12404	iCost /= 100;1240512406	// Now round so the number looks neat12407	int iDivisor = /*5*/ GC.getPLOT_COST_APPEARANCE_DIVISOR();12408	iCost /= iDivisor;12409	iCost *= iDivisor;1241012411	return iCost;12412}

Calls

Called by