CvPlayer::GetUnhappinessFromOccupiedCities(CvCity *, CvCity *) const
- Defined in
- CvPlayer.cpp, line 12821
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetUnhappinessFromOccupiedCities
Hooks
static bool BeforeCvPlayer_GetUnhappinessFromOccupiedCities(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static void AfterCvPlayer_GetUnhappinessFromOccupiedCities(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static int ReplaceCvPlayer_GetUnhappinessFromOccupiedCities(int (*original)(const CvPlayer*, CvCity*, CvCity*), const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted);CivRegisterBefore<CivHooks::CvPlayer_GetUnhappinessFromOccupiedCities>(host, &BeforeCvPlayer_GetUnhappinessFromOccupiedCities);CivRegisterAfter<CivHooks::CvPlayer_GetUnhappinessFromOccupiedCities>(host, &AfterCvPlayer_GetUnhappinessFromOccupiedCities);CivRegisterReplace<CivHooks::CvPlayer_GetUnhappinessFromOccupiedCities>(host, &ReplaceCvPlayer_GetUnhappinessFromOccupiedCities);
Code
12820/// Unhappiness from City Population in Occupied Cities12821int CvPlayer::GetUnhappinessFromOccupiedCities(CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted) const12822{12823 int iUnhappiness = 0;12824 int iUnhappinessFromThisCity;1282512826 double fUnhappinessPerPop = /*1.34f*/ GC.getUNHAPPINESS_PER_OCCUPIED_POPULATION() * 100;12827 int iPopulation;12828 int iSpecialistCount;1282912830 bool bCityValid;1283112832 int iLoop;12833 for(const CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))12834 {12835 bCityValid = false;1283612837 // Assume pLoopCity is Annexed, and counts12838 if(pLoopCity == pAssumeCityAnnexed)12839 bCityValid = true;12840 // Assume that pLoopCity is a Puppet and does NOT count12841 else if(pLoopCity == pAssumeCityPuppeted)12842 bCityValid = false;12843 // Assume city doesn't exist, and does NOT count12844 else if(pLoopCity->IsIgnoreCityForHappiness())12845 bCityValid = false;12846 // Occupied Cities12847 else if(pLoopCity->IsOccupied() && !pLoopCity->IsNoOccupiedUnhappiness())12848 bCityValid = true;1284912850 if(bCityValid)12851 {12852 iPopulation = pLoopCity->getPopulation();1285312854 // No Unhappiness from Specialist Pop? (Policies, etc.)12855 if(isHalfSpecialistUnhappiness())12856 {12857 iSpecialistCount = pLoopCity->GetCityCitizens()->GetTotalSpecialistCount();12858 iSpecialistCount++; // Round up12859 iPopulation -= (iSpecialistCount / 2);12860 }1286112862 iUnhappinessFromThisCity = int(double(iPopulation) * fUnhappinessPerPop);1286312864 // Mod (Policies, etc.)12865 if(GetOccupiedPopulationUnhappinessMod() != 0)12866 {12867 iUnhappinessFromThisCity *= (100 + GetOccupiedPopulationUnhappinessMod());12868 iUnhappinessFromThisCity /= 100;12869 }1287012871 iUnhappiness += iUnhappinessFromThisCity;12872 }12873 }1287412875 // Handicap mod12876 iUnhappiness *= getHandicapInfo().getPopulationUnhappinessMod();12877 iUnhappiness /= 100;1287812879 return iUnhappiness;12880}
Calls
- CvCity::GetCityCitizens() const
- CvCity::getPopulation(bool) const
- CvCity::IsIgnoreCityForHappiness() const
- CvCity::IsNoOccupiedUnhappiness() const
- CvCity::IsOccupied() const
- CvCityCitizens::GetTotalSpecialistCount() const
- CvGlobals::getUNHAPPINESS_PER_OCCUPIED_POPULATION()
- CvHandicapInfo::getPopulationUnhappinessMod() const
- CvPlayer::firstCity(int *, bool) const
- CvPlayer::getHandicapInfo() const
- CvPlayer::GetOccupiedPopulationUnhappinessMod() const
- CvPlayer::isHalfSpecialistUnhappiness() const
- CvPlayer::nextCity(int *, bool) const