Bazaar developer reference

CvPlayerPolicies::DoNewPolicyPickedForHistory(PolicyTypes)

Defined in
CvPolicyClasses.cpp, line 4359
Class
CvPlayerPolicies
Hook name
CivHooks::CvPlayerPolicies_DoNewPolicyPickedForHistory

Hooks

static bool BeforeCvPlayerPolicies_DoNewPolicyPickedForHistory(CvPlayerPolicies* self, PolicyTypes ePolicy);static void AfterCvPlayerPolicies_DoNewPolicyPickedForHistory(CvPlayerPolicies* self, PolicyTypes ePolicy);static void ReplaceCvPlayerPolicies_DoNewPolicyPickedForHistory(void (*original)(CvPlayerPolicies*, PolicyTypes), CvPlayerPolicies* self, PolicyTypes ePolicy);CivRegisterBefore<CivHooks::CvPlayerPolicies_DoNewPolicyPickedForHistory>(host, &BeforeCvPlayerPolicies_DoNewPolicyPickedForHistory);CivRegisterAfter<CivHooks::CvPlayerPolicies_DoNewPolicyPickedForHistory>(host, &AfterCvPlayerPolicies_DoNewPolicyPickedForHistory);CivRegisterReplace<CivHooks::CvPlayerPolicies_DoNewPolicyPickedForHistory>(host, &ReplaceCvPlayerPolicies_DoNewPolicyPickedForHistory);

Code

4358/// New Policy picked... figure how what that means for history. This isn't the greatest example of programming ever, but oh well, it'll do4359void CvPlayerPolicies::DoNewPolicyPickedForHistory(PolicyTypes ePolicy)4360{4361	CvPolicyEntry* pkPolicyInfo = GC.getPolicyInfo(ePolicy);4362	if(pkPolicyInfo == NULL)4363		return;43644365	PolicyBranchTypes eNewBranch = (PolicyBranchTypes) pkPolicyInfo->GetPolicyBranchType();43664367	// Are we a free branch policy?4368	if(eNewBranch == NO_POLICY_BRANCH_TYPE)4369	{4370		for(int iBranchLoop = 0; iBranchLoop < m_pPolicies->GetNumPolicyBranches(); iBranchLoop++)4371		{4372			const PolicyBranchTypes eLoopBranch = static_cast<PolicyBranchTypes>(iBranchLoop);4373			CvPolicyBranchEntry* pkPolicyBranchInfo = GC.getPolicyBranchInfo(eLoopBranch);4374			if(pkPolicyBranchInfo)4375			{4376				// Yes, it's a freebie4377				if(pkPolicyBranchInfo->GetFreePolicy() == ePolicy)4378				{4379					eNewBranch = eLoopBranch;4380					break;4381				}4382			}4383		}4384	}43854386	// Have we filled up the slots yet?4387	if(GetBranchPicked1() == NO_POLICY_BRANCH_TYPE)4388	{4389		SetBranchPicked1(eNewBranch);4390	}4391	else if(GetBranchPicked2() == NO_POLICY_BRANCH_TYPE)4392	{4393		SetBranchPicked2(eNewBranch);4394	}4395	else if(GetBranchPicked3() == NO_POLICY_BRANCH_TYPE)4396	{4397		SetBranchPicked3(eNewBranch);4398	}43994400	// if we've gotten here it means that all the slots are filled already, so we gotta bump some stuff4401	else4402	{4403		SetBranchPicked3(GetBranchPicked2());4404		SetBranchPicked2(GetBranchPicked1());4405		SetBranchPicked1(eNewBranch);4406	}4407}

Calls

Called by