Bazaar developer reference

CvPlayer::getBuildCost(const CvPlot *, BuildTypes) const

Defined in
CvPlayer.cpp, line 9507
Class
CvPlayer
Hook name
CivHooks::CvPlayer_getBuildCost

Hooks

static bool BeforeCvPlayer_getBuildCost(const CvPlayer* self, const CvPlot* pPlot, BuildTypes eBuild, int& result);static void AfterCvPlayer_getBuildCost(const CvPlayer* self, const CvPlot* pPlot, BuildTypes eBuild, int& result);static int ReplaceCvPlayer_getBuildCost(int (*original)(const CvPlayer*, const CvPlot*, BuildTypes), const CvPlayer* self, const CvPlot* pPlot, BuildTypes eBuild);CivRegisterBefore<CivHooks::CvPlayer_getBuildCost>(host, &BeforeCvPlayer_getBuildCost);CivRegisterAfter<CivHooks::CvPlayer_getBuildCost>(host, &AfterCvPlayer_getBuildCost);CivRegisterReplace<CivHooks::CvPlayer_getBuildCost>(host, &ReplaceCvPlayer_getBuildCost);

Code

9506// Returns the cost9507int CvPlayer::getBuildCost(const CvPlot* pPlot, BuildTypes eBuild) const9508{9509	CvAssert(eBuild >= 0 && eBuild < GC.getNumBuildInfos());951095119512	CvBuildInfo* pkBuildInfo = GC.getBuildInfo(eBuild);9513	if(pkBuildInfo == NULL)9514	{9515		return 0;9516	}95179518	if(pPlot->getBuildProgress(eBuild) > 0)9519	{9520		return 0;9521	}95229523	if(pPlot->getRouteType() != NO_ROUTE && pPlot->getRouteType() == pkBuildInfo->getRoute() && pPlot->IsRoutePillaged())9524	{9525		return 0;9526	}95279528	int iBuildCost = pkBuildInfo->getCost();95299530	// Cost increases as more Improvements are built9531	iBuildCost += (getTotalImprovementsBuilt() * pkBuildInfo->getCostIncreasePerImprovement());95329533	iBuildCost *= (100 + getImprovementCostModifier());9534	iBuildCost /= 100;95359536	if(pPlot->getFeatureType() != NO_FEATURE)9537	{9538		iBuildCost += pkBuildInfo->getFeatureCost(pPlot->getFeatureType());9539	}95409541	iBuildCost *= getHandicapInfo().getImprovementCostPercent();9542	iBuildCost /= 100;95439544	iBuildCost *= GC.getGame().getGameSpeedInfo().getImprovementPercent();9545	iBuildCost /= 100;95469547	return std::max(0, iBuildCost);9548}

Calls

Called by