Hooks
static bool BeforeCvPlayerPolicies_DoSwitchIdeologies(CvPlayerPolicies* self, PolicyBranchTypes eNewBranchType);static void AfterCvPlayerPolicies_DoSwitchIdeologies(CvPlayerPolicies* self, PolicyBranchTypes eNewBranchType);static void ReplaceCvPlayerPolicies_DoSwitchIdeologies(void (*original)(CvPlayerPolicies*, PolicyBranchTypes), CvPlayerPolicies* self, PolicyBranchTypes eNewBranchType);CivRegisterBefore<CivHooks::CvPlayerPolicies_DoSwitchIdeologies>(host, &BeforeCvPlayerPolicies_DoSwitchIdeologies);CivRegisterAfter<CivHooks::CvPlayerPolicies_DoSwitchIdeologies>(host, &AfterCvPlayerPolicies_DoSwitchIdeologies);CivRegisterReplace<CivHooks::CvPlayerPolicies_DoSwitchIdeologies>(host, &ReplaceCvPlayerPolicies_DoSwitchIdeologies);
Code
4076/// Implement a switch of ideologies4077void CvPlayerPolicies::DoSwitchIdeologies(PolicyBranchTypes eNewBranchType)4078{4079 PolicyBranchTypes eOldBranchType = GetLateGamePolicyTree();4080 CvAssertMsg (eOldBranchType != eNewBranchType && eNewBranchType != NO_POLICY_BRANCH_TYPE && eOldBranchType != NO_POLICY_BRANCH_TYPE, "Illegal time for Ideology change");40814082 int iOldBranchTenets = GetNumPoliciesOwnedInBranch(eOldBranchType);4083 int iNewBranchTenets = max(0, iOldBranchTenets - GC.getSWITCH_POLICY_BRANCHES_TENETS_LOST());40844085 ClearPolicyBranch(eOldBranchType);4086 SetPolicyBranchUnlocked(eOldBranchType, false, false);40874088 SetPolicyBranchUnlocked(eNewBranchType, true, true /*bRevolution*/);4089 m_pPlayer->GetCulture()->DoPublicOpinion();4090 m_pPlayer->GetCulture()->SetTurnIdeologySwitch(GC.getGame().getGameTurn());4091 m_pPlayer->setJONSCulture(0);4092 m_pPlayer->ChangeNumFreeTenets(iNewBranchTenets, false /*bCountAsFreePolicies*/);40934094#if defined(MOD_BUGFIX_MISSING_POLICY_EVENTS)4095 if (MOD_BUGFIX_MISSING_POLICY_EVENTS)4096 {4097 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();4098 if(pkScriptSystem)4099 {4100 CvLuaArgsHandle args;4101 args->Push(m_pPlayer->GetID());4102 args->Push(eNewBranchType);41034104 bool bResult = false;4105 LuaSupport::CallHook(pkScriptSystem, "PlayerAdoptPolicyBranch", args.get(), bResult);4106 }4107 }4108#endif41094110 if (GC.getGame().getActivePlayer() == m_pPlayer->GetID())4111 {4112 DLLUI->setDirty(Policies_DIRTY_BIT, true);4113 }4114}