Bazaar developer reference

CvPlayer::canBuild(const CvPlot *, BuildTypes, bool, bool, bool, bool) const

Defined in
CvPlayer.cpp, line 9419
Class
CvPlayer
Hook name
CivHooks::CvPlayer_canBuild

Hooks

static bool BeforeCvPlayer_canBuild(const CvPlayer* self, const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, bool bTestVisible, bool bTestGold, bool bTestPlotOwner, bool& result);static void AfterCvPlayer_canBuild(const CvPlayer* self, const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, bool bTestVisible, bool bTestGold, bool bTestPlotOwner, bool& result);static bool ReplaceCvPlayer_canBuild(bool (*original)(const CvPlayer*, const CvPlot*, BuildTypes, bool, bool, bool, bool), const CvPlayer* self, const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, bool bTestVisible, bool bTestGold, bool bTestPlotOwner);CivRegisterBefore<CivHooks::CvPlayer_canBuild>(host, &BeforeCvPlayer_canBuild);CivRegisterAfter<CivHooks::CvPlayer_canBuild>(host, &AfterCvPlayer_canBuild);CivRegisterReplace<CivHooks::CvPlayer_canBuild>(host, &ReplaceCvPlayer_canBuild);

Code

9418/// Can we eBuild on pPlot?9419bool CvPlayer::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, bool bTestVisible, bool bTestGold, bool bTestPlotOwner) const9420{9421	if(!(pPlot->canBuild(eBuild, GetID(), bTestVisible, bTestPlotOwner)))9422	{9423		return false;9424	}94259426	if(GC.getBuildInfo(eBuild)->getTechPrereq() != NO_TECH)9427	{9428		if(!(GET_TEAM(getTeam()).GetTeamTechs()->HasTech((TechTypes)GC.getBuildInfo(eBuild)->getTechPrereq())))9429		{9430			if((!bTestEra && !bTestVisible) || ((GetCurrentEra() + 1) < GC.getTechInfo((TechTypes) GC.getBuildInfo(eBuild)->getTechPrereq())->GetEra()))9431			{9432				return false;9433			}9434		}9435	}94369437	// Is this an improvement that is only useable by a specific civ?9438	ImprovementTypes eImprovement = (ImprovementTypes)GC.getBuildInfo(eBuild)->getImprovement();9439	if(eImprovement != NO_IMPROVEMENT)9440	{9441		CvImprovementEntry* pkEntry = GC.getImprovementInfo(eImprovement);9442		if(pkEntry->IsSpecificCivRequired())9443		{9444			CivilizationTypes eCiv = pkEntry->GetRequiredCivilization();9445			if(eCiv != getCivilizationType())9446			{9447				return false;9448			}9449		}9450	}94519452	if(!bTestVisible)9453	{9454		if(IsBuildBlockedByFeature(eBuild, pPlot->getFeatureType()))9455		{9456			return false;9457		}94589459		if(bTestGold)9460		{9461			if(std::max(0, GetTreasury()->GetGold()) < getBuildCost(pPlot, eBuild))9462			{9463				return false;9464			}9465		}9466	}94679468	return true;9469}

Calls

Called by