Bazaar developer reference

CvPlayerPolicies::IsTimeToChooseIdeology() const

Defined in
CvPolicyClasses.cpp, line 4550
Class
CvPlayerPolicies
Hook name
CivHooks::CvPlayerPolicies_IsTimeToChooseIdeology

Hooks

static bool BeforeCvPlayerPolicies_IsTimeToChooseIdeology(const CvPlayerPolicies* self, bool& result);static void AfterCvPlayerPolicies_IsTimeToChooseIdeology(const CvPlayerPolicies* self, bool& result);static bool ReplaceCvPlayerPolicies_IsTimeToChooseIdeology(bool (*original)(const CvPlayerPolicies*), const CvPlayerPolicies* self);CivRegisterBefore<CivHooks::CvPlayerPolicies_IsTimeToChooseIdeology>(host, &BeforeCvPlayerPolicies_IsTimeToChooseIdeology);CivRegisterAfter<CivHooks::CvPlayerPolicies_IsTimeToChooseIdeology>(host, &AfterCvPlayerPolicies_IsTimeToChooseIdeology);CivRegisterReplace<CivHooks::CvPlayerPolicies_IsTimeToChooseIdeology>(host, &ReplaceCvPlayerPolicies_IsTimeToChooseIdeology);

Code

4549/// Is the player far enough into Industrialization that they need to choose an Ideology?4550bool CvPlayerPolicies::IsTimeToChooseIdeology() const4551{4552	PolicyBranchTypes eFreedomBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_FREEDOM();4553	PolicyBranchTypes eAutocracyBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_AUTOCRACY();4554	PolicyBranchTypes eOrderBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_ORDER();4555	if (eFreedomBranch == NO_POLICY_BRANCH_TYPE || eAutocracyBranch == NO_POLICY_BRANCH_TYPE || eOrderBranch == NO_POLICY_BRANCH_TYPE)4556	{4557		return false;4558	}45594560#if defined(MOD_CONFIG_GAME_IN_XML)4561	if (m_pPlayer->GetCurrentEra() > GD_INT_GET(IDEOLOGY_START_ERA))4562#else4563	if (m_pPlayer->GetCurrentEra() > GC.getInfoTypeForString("ERA_INDUSTRIAL"))4564#endif4565	{4566		return true;4567	}45684569	// Check for the right number of buildings of a certain type (3 factories)4570	else4571	{4572		CvBuildingXMLEntries* pkGameBuildings = GC.GetGameBuildings();4573		CvCivilizationInfo* pkInfo = GC.getCivilizationInfo(m_pPlayer->getCivilizationType());4574		if(pkInfo)4575		{4576			// Find a building that triggers an ideology4577			// Loop through all building classes4578			for(int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)4579			{4580				const BuildingTypes eBuilding = static_cast<BuildingTypes>(pkInfo->getCivilizationBuildings(iI));4581				CvBuildingEntry* pkBuildingInfo = NULL;4582				if(eBuilding != -1)4583				{4584					pkBuildingInfo = pkGameBuildings->GetEntry(eBuilding);4585					if (pkBuildingInfo)4586					{4587						int iIdeologyTriggerCount = pkBuildingInfo->GetXBuiltTriggersIdeologyChoice();4588						if (iIdeologyTriggerCount > 0)4589						{4590							if (m_pPlayer->getBuildingClassCount((BuildingClassTypes)iI) >= iIdeologyTriggerCount)4591							{4592								return true;4593							}4594						}4595					}4596				}4597			}4598		}4599	}46004601	return false;4602}

Calls

Called by