Bazaar developer reference

CvPlayerPolicies::SetPolicyBranchBlocked(PolicyBranchTypes, bool)

Defined in
CvPolicyClasses.cpp, line 3992
Class
CvPlayerPolicies
Hook name
CivHooks::CvPlayerPolicies_SetPolicyBranchBlocked

Hooks

static bool BeforeCvPlayerPolicies_SetPolicyBranchBlocked(CvPlayerPolicies* self, PolicyBranchTypes eBranchType, bool bValue);static void AfterCvPlayerPolicies_SetPolicyBranchBlocked(CvPlayerPolicies* self, PolicyBranchTypes eBranchType, bool bValue);static void ReplaceCvPlayerPolicies_SetPolicyBranchBlocked(void (*original)(CvPlayerPolicies*, PolicyBranchTypes, bool), CvPlayerPolicies* self, PolicyBranchTypes eBranchType, bool bValue);CivRegisterBefore<CivHooks::CvPlayerPolicies_SetPolicyBranchBlocked>(host, &BeforeCvPlayerPolicies_SetPolicyBranchBlocked);CivRegisterAfter<CivHooks::CvPlayerPolicies_SetPolicyBranchBlocked>(host, &AfterCvPlayerPolicies_SetPolicyBranchBlocked);CivRegisterReplace<CivHooks::CvPlayerPolicies_SetPolicyBranchBlocked>(host, &ReplaceCvPlayerPolicies_SetPolicyBranchBlocked);

Code

3991/// Accessor: is eBranchType blocked because of branch choices?3992void CvPlayerPolicies::SetPolicyBranchBlocked(PolicyBranchTypes eBranchType, bool bValue)3993{3994	CvAssertMsg(eBranchType >= 0, "eIndex is expected to be non-negative (invalid Index)");3995	CvAssertMsg(eBranchType < m_pPolicies->GetNumPolicyBranches(), "eIndex is expected to be within maximum bounds (invalid Index)");39963997	CvPolicyBranchEntry* pkPolicyBranchEntry = GC.getPolicyBranchInfo(eBranchType);3998	if(pkPolicyBranchEntry)3999	{4000		if(bValue != IsPolicyBranchBlocked(eBranchType))4001		{4002			m_pabPolicyBranchBlocked[eBranchType] = bValue;40034004			int iPolicyEffectChange = bValue ? -1 : 1;40054006			if(iPolicyEffectChange != 0)4007			{4008				// Set Policies in this branch as blocked4009				for(int iPolicyLoop = 0; iPolicyLoop < GetPolicies()->GetNumPolicies(); iPolicyLoop++)4010				{4011					const PolicyTypes ePolicy = static_cast<PolicyTypes>(iPolicyLoop);4012					CvPolicyEntry* pkPolicyInfo = GC.getPolicyInfo(ePolicy);4013					if(pkPolicyInfo)4014					{4015						if(eBranchType == (PolicyBranchTypes) pkPolicyInfo->GetPolicyBranchType() ||	// Branch type matches4016						        pkPolicyBranchEntry->GetFreePolicy() == ePolicy ||		// Free Policy with this branch4017						        pkPolicyBranchEntry->GetFreeFinishingPolicy() == ePolicy)4018						{4019							//ChangePolicyBlockedCount(ePolicy, iPolicyEffectChange);40204021							// Activate/Deactivate Policies4022							if(HasPolicy(ePolicy))4023							{4024								GetPlayer()->processPolicies(ePolicy, iPolicyEffectChange);4025							}4026						}4027					}4028				}4029			}4030		}4031	}4032}

Calls

Called by