CvPlayer::GetUnhappinessFromCityPopulation(CvCity *, CvCity *) const
- Defined in
- CvPlayer.cpp, line 12626
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetUnhappinessFromCityPopulation
Hooks
static bool BeforeCvPlayer_GetUnhappinessFromCityPopulation(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static void AfterCvPlayer_GetUnhappinessFromCityPopulation(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static int ReplaceCvPlayer_GetUnhappinessFromCityPopulation(int (*original)(const CvPlayer*, CvCity*, CvCity*), const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted);CivRegisterBefore<CivHooks::CvPlayer_GetUnhappinessFromCityPopulation>(host, &BeforeCvPlayer_GetUnhappinessFromCityPopulation);CivRegisterAfter<CivHooks::CvPlayer_GetUnhappinessFromCityPopulation>(host, &AfterCvPlayer_GetUnhappinessFromCityPopulation);CivRegisterReplace<CivHooks::CvPlayer_GetUnhappinessFromCityPopulation>(host, &ReplaceCvPlayer_GetUnhappinessFromCityPopulation);
Code
12625/// Unhappiness from City Population12626int CvPlayer::GetUnhappinessFromCityPopulation(CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted) const12627{12628 int iUnhappiness = 0;12629 int iUnhappinessFromThisCity;1263012631 int iUnhappinessPerPop = /*1*/ GC.getUNHAPPINESS_PER_POPULATION() * 100;12632 int iPopulation;12633 int iSpecialistCount;1263412635 bool bCityValid;1263612637 int iLoop;12638 for(const CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))12639 {12640 bCityValid = false;1264112642 // Assume pLoopCity is Annexed, and does NOT count12643 if(pLoopCity == pAssumeCityAnnexed)12644 bCityValid = false;12645 // Assume that pLoopCity is a Puppet and IS counted here12646 else if(pLoopCity == pAssumeCityPuppeted)12647 bCityValid = true;12648 // Assume city doesn't exist, and does NOT count12649 else if(pLoopCity->IsIgnoreCityForHappiness())12650 bCityValid = false;12651 // Occupied Cities don't get counted here (see the next function)12652 else if(!pLoopCity->IsOccupied() || pLoopCity->IsNoOccupiedUnhappiness())12653 bCityValid = true;1265412655 if(bCityValid)12656 {12657 iPopulation = pLoopCity->getPopulation();1265812659 // No Unhappiness from Specialist Pop? (Policies, etc.)12660 if(isHalfSpecialistUnhappiness())12661 {12662 iSpecialistCount = pLoopCity->GetCityCitizens()->GetTotalSpecialistCount();12663 iSpecialistCount++; // Round up12664 iPopulation -= (iSpecialistCount / 2);12665 }1266612667 iUnhappinessFromThisCity = iPopulation * iUnhappinessPerPop;1266812669 if(pLoopCity->isCapital() && GetCapitalUnhappinessMod() != 0)12670 {12671 iUnhappinessFromThisCity *= (100 + GetCapitalUnhappinessMod());12672 iUnhappinessFromThisCity /= 100;12673 }1267412675 iUnhappiness += iUnhappinessFromThisCity;12676 }12677 }1267812679 iUnhappiness *= (100 + GetUnhappinessMod());12680 iUnhappiness /= 100;1268112682 iUnhappiness *= 100 + GetPlayerTraits()->GetPopulationUnhappinessModifier();12683 iUnhappiness /= 100;1268412685 // Handicap mod12686 iUnhappiness *= getHandicapInfo().getPopulationUnhappinessMod();12687 iUnhappiness /= 100;1268812689 return iUnhappiness;12690}
Calls
- CvCity::GetCityCitizens() const
- CvCity::getPopulation(bool) 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