Bazaar developer reference

CvPlayerPolicies::WillFinishBranchIfAdopted(PolicyTypes) const

Defined in
CvPolicyClasses.cpp, line 4225
Class
CvPlayerPolicies
Hook name
CivHooks::CvPlayerPolicies_WillFinishBranchIfAdopted

Hooks

static bool BeforeCvPlayerPolicies_WillFinishBranchIfAdopted(const CvPlayerPolicies* self, PolicyTypes eType, bool& result);static void AfterCvPlayerPolicies_WillFinishBranchIfAdopted(const CvPlayerPolicies* self, PolicyTypes eType, bool& result);static bool ReplaceCvPlayerPolicies_WillFinishBranchIfAdopted(bool (*original)(const CvPlayerPolicies*, PolicyTypes), const CvPlayerPolicies* self, PolicyTypes eType);CivRegisterBefore<CivHooks::CvPlayerPolicies_WillFinishBranchIfAdopted>(host, &BeforeCvPlayerPolicies_WillFinishBranchIfAdopted);CivRegisterAfter<CivHooks::CvPlayerPolicies_WillFinishBranchIfAdopted>(host, &AfterCvPlayerPolicies_WillFinishBranchIfAdopted);CivRegisterReplace<CivHooks::CvPlayerPolicies_WillFinishBranchIfAdopted>(host, &ReplaceCvPlayerPolicies_WillFinishBranchIfAdopted);

Code

4224/// Is this the last policy needed to finish this branch?4225bool CvPlayerPolicies::WillFinishBranchIfAdopted(PolicyTypes eType) const4226{4227	PolicyBranchTypes eBranchType = (PolicyBranchTypes)m_pPolicies->GetPolicyEntry(eType)->GetPolicyBranchType();42284229	if(eBranchType != NO_POLICY_BRANCH_TYPE)4230	{4231		// Is the branch this policy is in finished?4232		for(int iPolicyLoop = 0; iPolicyLoop < GetPolicies()->GetNumPolicies(); iPolicyLoop++)4233		{4234			const PolicyTypes eLoopPolicy = static_cast<PolicyTypes>(iPolicyLoop);42354236			CvPolicyEntry* pkLoopPolicyInfo = GC.getPolicyInfo(eLoopPolicy);4237			if(pkLoopPolicyInfo)4238			{4239				// This policy belongs to our branch4240				if(pkLoopPolicyInfo->GetPolicyBranchType() == eBranchType)4241				{4242					// We don't have this policy!4243					if(!HasPolicy(eLoopPolicy))4244					{4245						// Is it this policy passed in?4246						if(eLoopPolicy != eType)4247						{4248							// No, so this one won't finish branch4249							return false;4250						}4251					}4252				}4253			}4254		}42554256		// Didn't find any policy in this branch that we didn't have covered.  This will finish it4257		return true;4258	}42594260	return false;4261}

Calls

Called by