CvPlayerPolicies::DoUnlockPolicyBranch(PolicyBranchTypes)
- Defined in
- CvPolicyClasses.cpp, line 3648
- Class
- CvPlayerPolicies
- Hook name
CivHooks::CvPlayerPolicies_DoUnlockPolicyBranch- Lua events
GameEvents.PlayerAdoptPolicyBranch
Hooks
static bool BeforeCvPlayerPolicies_DoUnlockPolicyBranch(CvPlayerPolicies* self, PolicyBranchTypes eBranchType);static void AfterCvPlayerPolicies_DoUnlockPolicyBranch(CvPlayerPolicies* self, PolicyBranchTypes eBranchType);static void ReplaceCvPlayerPolicies_DoUnlockPolicyBranch(void (*original)(CvPlayerPolicies*, PolicyBranchTypes), CvPlayerPolicies* self, PolicyBranchTypes eBranchType);CivRegisterBefore<CivHooks::CvPlayerPolicies_DoUnlockPolicyBranch>(host, &BeforeCvPlayerPolicies_DoUnlockPolicyBranch);CivRegisterAfter<CivHooks::CvPlayerPolicies_DoUnlockPolicyBranch>(host, &AfterCvPlayerPolicies_DoUnlockPolicyBranch);CivRegisterReplace<CivHooks::CvPlayerPolicies_DoUnlockPolicyBranch>(host, &ReplaceCvPlayerPolicies_DoUnlockPolicyBranch);
Code
3647/// Player gets a new Policy Branch!3648void CvPlayerPolicies::DoUnlockPolicyBranch(PolicyBranchTypes eBranchType)3649{3650 CvPolicyBranchEntry* pkPolicyBranchInfo = GC.getPolicyBranchInfo(eBranchType);3651 if(pkPolicyBranchInfo == NULL)3652 {3653 return;3654 }36553656 // Can we actually do this?3657 if(!CanUnlockPolicyBranch(eBranchType))3658 {3659 return;3660 }36613662 // Set that we now have it3663 SetPolicyBranchUnlocked(eBranchType, true, false);36643665 // Are we blocked? If so, unblock us3666 DoSwitchToPolicyBranch(eBranchType);36673668 // Free Policy with this Branch?3669 PolicyTypes eFreePolicy = (PolicyTypes) pkPolicyBranchInfo->GetFreePolicy();3670 if(eFreePolicy != NO_POLICY)3671 {3672 GetPlayer()->setHasPolicy(eFreePolicy, true);3673 }36743675 // Pay Culture cost - if applicable3676 if(GetPlayer()->GetNumFreePolicies() == 0)3677 {3678 GetPlayer()->changeJONSCulture(-GetPlayer()->getNextPolicyCost());3679 }3680 else3681 {3682 GetPlayer()->ChangeNumFreePolicies(-1);3683 }36843685 // Update cost if trying to buy another policy this turn3686 GetPlayer()->DoUpdateNextPolicyCost();36873688 GC.GetEngineUserInterface()->setDirty(GameData_DIRTY_BIT, true);36893690 // This Dirty bit must only be set when changing something for the active player3691 if(GC.getGame().getActivePlayer() == GetPlayer()->GetID())3692 {3693 GC.GetEngineUserInterface()->setDirty(Policies_DIRTY_BIT, true);3694 }36953696 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();3697 if(pkScriptSystem)3698 {3699 CvLuaArgsHandle args;3700 args->Push(m_pPlayer->GetID());3701 args->Push(eBranchType);37023703 // Attempt to execute the game events.3704 // Will return false if there are no registered listeners.3705 bool bResult = false;3706 LuaSupport::CallHook(pkScriptSystem, "PlayerAdoptPolicyBranch", args.get(), bResult);3707 }3708}
Calls
- CvGame::getActivePlayer() const
- CvGlobals::getDLLIFace()
- CvGlobals::GetEngineUserInterface()
- CvGlobals::getGame()
- CvGlobals::getPolicyBranchInfo(PolicyBranchTypes)
- CvLuaArgsHandle::CvLuaArgsHandle()
- CvLuaArgsHandle::get() const
- CvLuaArgsHandle::operator->() const
- CvPlayer::changeJONSCulture(int)
- CvPlayer::ChangeNumFreePolicies(int)
- CvPlayer::DoUpdateNextPolicyCost()
- CvPlayer::GetID() const
- CvPlayer::getNextPolicyCost() const
- CvPlayer::GetNumFreePolicies() const
- CvPlayer::setHasPolicy(PolicyTypes, bool, bool)
- CvPlayerPolicies::CanUnlockPolicyBranch(PolicyBranchTypes)
- CvPlayerPolicies::DoSwitchToPolicyBranch(PolicyBranchTypes)
- CvPlayerPolicies::GetPlayer()
- CvPlayerPolicies::SetPolicyBranchUnlocked(PolicyBranchTypes, bool, bool)
- CvPolicyBranchEntry::GetFreePolicy() const
ICvEngineScriptSystemArgs1::PushICvEngineUtility1::GetScriptSystemICvUserInterface1::setDirty- LuaSupport::CallHook(ICvEngineScriptSystem1 *, const char *, ICvEngineScriptSystemArgs1 *, bool &)