CvPlayer::GetUnhappinessFromCitySpecialists(CvCity *, CvCity *) const
- Defined in
- CvPlayer.cpp, line 12755
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetUnhappinessFromCitySpecialists
Hooks
static bool BeforeCvPlayer_GetUnhappinessFromCitySpecialists(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static void AfterCvPlayer_GetUnhappinessFromCitySpecialists(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static int ReplaceCvPlayer_GetUnhappinessFromCitySpecialists(int (*original)(const CvPlayer*, CvCity*, CvCity*), const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted);CivRegisterBefore<CivHooks::CvPlayer_GetUnhappinessFromCitySpecialists>(host, &BeforeCvPlayer_GetUnhappinessFromCitySpecialists);CivRegisterAfter<CivHooks::CvPlayer_GetUnhappinessFromCitySpecialists>(host, &AfterCvPlayer_GetUnhappinessFromCitySpecialists);CivRegisterReplace<CivHooks::CvPlayer_GetUnhappinessFromCitySpecialists>(host, &ReplaceCvPlayer_GetUnhappinessFromCitySpecialists);
Code
12755int CvPlayer::GetUnhappinessFromCitySpecialists(CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted) const12756{12757 int iUnhappiness = 0;12758 int iUnhappinessFromThisCity;1275912760 int iUnhappinessPerPop = /*1*/ GC.getUNHAPPINESS_PER_POPULATION() * 100;12761 int iPopulation;1276212763 bool bCityValid;1276412765 int iLoop;12766 for(const CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))12767 {12768 bCityValid = false;1276912770 // Assume pLoopCity is Annexed, and does NOT count12771 if(pLoopCity == pAssumeCityAnnexed)12772 bCityValid = false;12773 // Assume that pLoopCity is a Puppet and IS counted here12774 else if(pLoopCity == pAssumeCityPuppeted)12775 bCityValid = true;12776 // Assume city doesn't exist, and does NOT count12777 else if(pLoopCity->IsIgnoreCityForHappiness())12778 bCityValid = false;12779 // Occupied Cities don't get counted here (see the next function)12780 else if(!pLoopCity->IsOccupied() || pLoopCity->IsNoOccupiedUnhappiness())12781 bCityValid = true;1278212783 if(bCityValid)12784 {12785 iPopulation = pLoopCity->GetCityCitizens()->GetTotalSpecialistCount();1278612787 // No Unhappiness from Specialist Pop? (Policies, etc.)12788 if(isHalfSpecialistUnhappiness())12789 {12790 iPopulation++; // Round up12791 iPopulation /= 2;12792 }1279312794 iUnhappinessFromThisCity = iPopulation * iUnhappinessPerPop;1279512796 if(pLoopCity->isCapital() && GetCapitalUnhappinessMod() != 0)12797 {12798 iUnhappinessFromThisCity *= (100 + GetCapitalUnhappinessMod());12799 iUnhappinessFromThisCity /= 100;12800 }1280112802 iUnhappiness += iUnhappinessFromThisCity;12803 }12804 }1280512806 iUnhappiness *= (100 + GetUnhappinessMod());12807 iUnhappiness /= 100;1280812809 iUnhappiness *= 100 + GetPlayerTraits()->GetPopulationUnhappinessModifier();12810 iUnhappiness /= 100;1281112812 // Handicap mod12813 iUnhappiness *= getHandicapInfo().getPopulationUnhappinessMod();12814 iUnhappiness /= 100;1281512816 return iUnhappiness;12817}
Calls
- CvCity::GetCityCitizens() const
- CvCity::isCapital() const
- CvCity::IsIgnoreCityForHappiness() const
- CvCity::IsNoOccupiedUnhappiness() const
- CvCity::IsOccupied() const
- CvCityCitizens::GetTotalSpecialistCount() const
- CvGlobals::getUNHAPPINESS_PER_POPULATION()
- CvHandicapInfo::getPopulationUnhappinessMod() const
- CvPlayer::firstCity(int *, bool) const
- CvPlayer::GetCapitalUnhappinessMod() const
- CvPlayer::getHandicapInfo() const
- CvPlayer::GetPlayerTraits() const
- CvPlayer::GetUnhappinessMod() const
- CvPlayer::isHalfSpecialistUnhappiness() const
- CvPlayer::nextCity(int *, bool) const
- CvPlayerTraits::GetPopulationUnhappinessModifier() const