CvPlayerCulture::ComputeHypotheticalPublicOpinionUnhappiness(PolicyBranchTypes)
- Defined in
- CvCultureClasses.cpp, line 3771
- Class
- CvPlayerCulture
- Hook name
CivHooks::CvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness
Hooks
static bool BeforeCvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness(CvPlayerCulture* self, PolicyBranchTypes eBranch, int& result);static void AfterCvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness(CvPlayerCulture* self, PolicyBranchTypes eBranch, int& result);static int ReplaceCvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness(int (*original)(CvPlayerCulture*, PolicyBranchTypes), CvPlayerCulture* self, PolicyBranchTypes eBranch);CivRegisterBefore<CivHooks::CvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness>(host, &BeforeCvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness);CivRegisterAfter<CivHooks::CvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness>(host, &AfterCvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness);CivRegisterReplace<CivHooks::CvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness>(host, &ReplaceCvPlayerCulture_ComputeHypotheticalPublicOpinionUnhappiness);
Code
3770/// What would the unhappiness be if we chose this Ideology?3771int CvPlayerCulture::ComputeHypotheticalPublicOpinionUnhappiness(PolicyBranchTypes eBranch)3772{3773 int iDissatisfaction = 0;37743775 PolicyBranchTypes eFreedomBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_FREEDOM();3776 PolicyBranchTypes eAutocracyBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_AUTOCRACY();3777 PolicyBranchTypes eOrderBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_ORDER();37783779 if (eFreedomBranch == NO_POLICY_BRANCH_TYPE || eAutocracyBranch == NO_POLICY_BRANCH_TYPE || eOrderBranch == NO_POLICY_BRANCH_TYPE)3780 {3781 return 0;3782 }37833784 // Start with World Congress3785 int iPressureForFreedom = GC.getGame().GetGameLeagues()->GetPressureForIdeology(m_pPlayer->GetID(), eFreedomBranch);3786 int iPressureForAutocracy = GC.getGame().GetGameLeagues()->GetPressureForIdeology(m_pPlayer->GetID(), eAutocracyBranch);3787 int iPressureForOrder = GC.getGame().GetGameLeagues()->GetPressureForIdeology(m_pPlayer->GetID(), eOrderBranch);37883789 // Look at each civ3790 for (int iLoopPlayer = 0; iLoopPlayer < MAX_MAJOR_CIVS; iLoopPlayer++)3791 {3792 CvPlayer &kPlayer = GET_PLAYER((PlayerTypes)iLoopPlayer);3793 if (iLoopPlayer != m_pPlayer->GetID() && kPlayer.isAlive() && !kPlayer.isMinorCiv())3794 {3795 PolicyBranchTypes eOtherCivIdeology = kPlayer.GetPlayerPolicies()->GetLateGamePolicyTree();3796 if (eOtherCivIdeology != NO_POLICY_BRANCH_TYPE)3797 {3798 int iCulturalDominanceOverUs = kPlayer.GetCulture()->GetInfluenceLevel(m_pPlayer->GetID()) - m_pPlayer->GetCulture()->GetInfluenceLevel((PlayerTypes)iLoopPlayer);3799 if (iCulturalDominanceOverUs > 0)3800 {3801 if (eOtherCivIdeology == eFreedomBranch)3802 {3803 iPressureForFreedom += iCulturalDominanceOverUs;3804 }3805 else if (eOtherCivIdeology == eAutocracyBranch)3806 {3807 iPressureForAutocracy += iCulturalDominanceOverUs;3808 }3809 else3810 {3811 iPressureForOrder += iCulturalDominanceOverUs;3812 }3813 }3814 }3815 }3816 }38173818 if (eBranch == eFreedomBranch)3819 {3820 if (iPressureForFreedom < (iPressureForAutocracy + iPressureForOrder))3821 {3822 if (iPressureForAutocracy > iPressureForOrder)3823 {3824 m_ePreferredIdeology = eAutocracyBranch;3825 }3826 else if (iPressureForOrder >= iPressureForAutocracy)3827 {3828 m_ePreferredIdeology = eOrderBranch;3829 }3830 iDissatisfaction = (iPressureForAutocracy + iPressureForOrder) - iPressureForFreedom;3831 }3832 }3833 else if (eBranch == eAutocracyBranch)3834 {3835 if (iPressureForAutocracy < (iPressureForFreedom + iPressureForOrder))3836 {3837 if (iPressureForFreedom >= iPressureForOrder)3838 {3839 m_ePreferredIdeology = eFreedomBranch;3840 }3841 else if (iPressureForOrder > iPressureForFreedom)3842 {3843 m_ePreferredIdeology = eOrderBranch;3844 }3845 iDissatisfaction = (iPressureForFreedom + iPressureForOrder) - iPressureForAutocracy;3846 }3847 }3848 else3849 {3850 if (iPressureForOrder < (iPressureForFreedom + iPressureForAutocracy))3851 {3852 if (iPressureForFreedom > iPressureForAutocracy)3853 {3854 m_ePreferredIdeology = eFreedomBranch;3855 }3856 else if (iPressureForAutocracy >= iPressureForFreedom)3857 {3858 m_ePreferredIdeology = eAutocracyBranch;3859 }3860 iDissatisfaction = (iPressureForFreedom + iPressureForAutocracy) - iPressureForOrder;3861 }3862 }38633864 int iPerCityUnhappy = 1;3865 int iUnhappyPerXPop = 10;38663867 if (iDissatisfaction == 0)3868 {3869 return 0;3870 }3871 else3872 {3873 return ComputePublicOpinionUnhappiness(iDissatisfaction, iPerCityUnhappy, iUnhappyPerXPop);3874 }3875}
Calls
- CvGame::GetGameLeagues()
- CvGameLeagues::GetPressureForIdeology(PlayerTypes, PolicyBranchTypes)
- CvGlobals::getGame()
- CvGlobals::getPOLICY_BRANCH_AUTOCRACY()
- CvGlobals::getPOLICY_BRANCH_FREEDOM()
- CvGlobals::getPOLICY_BRANCH_ORDER()
- CvPlayer::GetCulture() const
- CvPlayer::GetID() const
- CvPlayer::GetPlayerPolicies() const
- CvPlayer::isAlive() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerCulture::ComputePublicOpinionUnhappiness(int, int &, int &)
- CvPlayerCulture::GetInfluenceLevel(PlayerTypes) const
- CvPlayerPolicies::GetLateGamePolicyTree() const