Bazaar developer reference

CvGameReligions::CanCreatePantheon(PlayerTypes, bool)

Defined in
CvReligionClasses.cpp, line 645
Class
CvGameReligions
Hook name
CivHooks::CvGameReligions_CanCreatePantheon
Lua events
GameEvents.PlayerCanFoundPantheon

Hooks

static bool BeforeCvGameReligions_CanCreatePantheon(CvGameReligions* self, PlayerTypes ePlayer, bool bCheckFaithTotal, CvGameReligions::FOUNDING_RESULT& result);static void AfterCvGameReligions_CanCreatePantheon(CvGameReligions* self, PlayerTypes ePlayer, bool bCheckFaithTotal, CvGameReligions::FOUNDING_RESULT& result);static CvGameReligions::FOUNDING_RESULT ReplaceCvGameReligions_CanCreatePantheon(CvGameReligions::FOUNDING_RESULT (*original)(CvGameReligions*, PlayerTypes, bool), CvGameReligions* self, PlayerTypes ePlayer, bool bCheckFaithTotal);CivRegisterBefore<CivHooks::CvGameReligions_CanCreatePantheon>(host, &BeforeCvGameReligions_CanCreatePantheon);CivRegisterAfter<CivHooks::CvGameReligions_CanCreatePantheon>(host, &AfterCvGameReligions_CanCreatePantheon);CivRegisterReplace<CivHooks::CvGameReligions_CanCreatePantheon>(host, &ReplaceCvGameReligions_CanCreatePantheon);

Code

644/// Time to create a pantheon?645CvGameReligions::FOUNDING_RESULT CvGameReligions::CanCreatePantheon(PlayerTypes ePlayer, bool bCheckFaithTotal)646{647	if(ePlayer == NO_PLAYER)648		return FOUNDING_INVALID_PLAYER;649650	CvPlayer& kPlayer = GET_PLAYER(ePlayer);651	const int iFaith = kPlayer.GetFaith();652653	if(kPlayer.isMinorCiv())654	{655		return FOUNDING_INVALID_PLAYER;656	}657658	if(HasCreatedPantheon(ePlayer) || HasCreatedReligion(ePlayer))659	{660		return FOUNDING_PLAYER_ALREADY_CREATED_PANTHEON;661	}662663	if(bCheckFaithTotal && iFaith < GetMinimumFaithNextPantheon())664	{665		return FOUNDING_NOT_ENOUGH_FAITH;666	}667668	// Has a religion been enhanced yet (and total number of religions/pantheons is equal to number of religions allowed)?669	ReligionList::const_iterator it;670	for(it = m_CurrentReligions.begin(); it != m_CurrentReligions.end(); it++)671	{672		if(it->m_bEnhanced)673		{674			if (GetNumPantheonsCreated() >= GC.getMap().getWorldInfo().getMaxActiveReligions())675			{676				return FOUNDING_RELIGION_ENHANCED;677			}678		}679	}680681#if defined(MOD_EVENTS_FOUND_RELIGION)682		if (MOD_EVENTS_FOUND_RELIGION) {683			if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundPantheon, ePlayer) == GAMEEVENTRETURN_FALSE) {684				return FOUNDING_INVALID_PLAYER;685			}686		} else {687#endif688			ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();689			if(pkScriptSystem) 690			{691				CvLuaArgsHandle args;692				args->Push(ePlayer);693694				// Attempt to execute the game events.695				// Will return false if there are no registered listeners.696				bool bResult = false;697				if (LuaSupport::CallTestAll(pkScriptSystem, "PlayerCanFoundPantheon", args.get(), bResult))698				{699					if (bResult == false) 700					{701						return FOUNDING_INVALID_PLAYER;702					}703				}704			}705#if defined(MOD_EVENTS_FOUND_RELIGION)706		}707#endif708709#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)710	if (GetAvailablePantheonBeliefs(ePlayer).size() == 0)711#else712	if (GetAvailablePantheonBeliefs().size() == 0)713#endif714		return FOUNDING_NO_BELIEFS_AVAILABLE;715716	return FOUNDING_OK;717}

Calls

Called by