CvPlayer::GetUnhappinessFromCapturedCityCount(CvCity *, CvCity *) const
- Defined in
- CvPlayer.cpp, line 12575
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetUnhappinessFromCapturedCityCount
Hooks
static bool BeforeCvPlayer_GetUnhappinessFromCapturedCityCount(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static void AfterCvPlayer_GetUnhappinessFromCapturedCityCount(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static int ReplaceCvPlayer_GetUnhappinessFromCapturedCityCount(int (*original)(const CvPlayer*, CvCity*, CvCity*), const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted);CivRegisterBefore<CivHooks::CvPlayer_GetUnhappinessFromCapturedCityCount>(host, &BeforeCvPlayer_GetUnhappinessFromCapturedCityCount);CivRegisterAfter<CivHooks::CvPlayer_GetUnhappinessFromCapturedCityCount>(host, &AfterCvPlayer_GetUnhappinessFromCapturedCityCount);CivRegisterReplace<CivHooks::CvPlayer_GetUnhappinessFromCapturedCityCount>(host, &ReplaceCvPlayer_GetUnhappinessFromCapturedCityCount);
Code
12574/// Unhappiness from number of Captured Cities12575int CvPlayer::GetUnhappinessFromCapturedCityCount(CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted) const12576{12577 int iUnhappiness = 0;12578 int iUnhappinessPerCapturedCity = /*5*/ GC.getUNHAPPINESS_PER_CAPTURED_CITY() * 100;1257912580 bool bCityValid;1258112582 int iLoop;12583 for(const CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))12584 {12585 bCityValid = false;1258612587 // Assume city is puppeted, and does NOT count12588 if(pLoopCity == pAssumeCityPuppeted)12589 bCityValid = false;12590 // Assume city is annexed, and counts12591 else if(pLoopCity == pAssumeCityAnnexed)12592 bCityValid = true;12593 // Assume city doesn't exist, and does NOT count12594 else if(pLoopCity->IsIgnoreCityForHappiness())12595 bCityValid = false;12596 // Occupied city12597 else if(pLoopCity->IsOccupied() && !pLoopCity->IsNoOccupiedUnhappiness())12598 bCityValid = true;1259912600 // Extra Unhappiness from Occupied Cities12601 if(bCityValid)12602 iUnhappiness += iUnhappinessPerCapturedCity;12603 }1260412605 // Player count mod12606 int iMod = 0;12607 iMod += GetCityCountUnhappinessMod();12608 iMod += GetPlayerTraits()->GetCityUnhappinessModifier();1260912610 iUnhappiness *= (100 + iMod);12611 iUnhappiness /= 100;1261212613 // Handicap mod12614 iUnhappiness *= getHandicapInfo().getNumCitiesUnhappinessMod();12615 iUnhappiness /= 100;1261612617 // Map size mod12618 iUnhappiness *= GC.getMap().getWorldInfo().getNumCitiesUnhappinessPercent();12619 iUnhappiness /= 100;1262012621 return iUnhappiness;12622}
Calls
- CvCity::IsIgnoreCityForHappiness() const
- CvCity::IsNoOccupiedUnhappiness() const
- CvCity::IsOccupied() const
- CvGlobals::getMap()
- CvGlobals::getUNHAPPINESS_PER_CAPTURED_CITY()
- CvHandicapInfo::getNumCitiesUnhappinessMod() const
- CvMap::getWorldInfo() const
- CvPlayer::firstCity(int *, bool) const
- CvPlayer::GetCityCountUnhappinessMod() const
- CvPlayer::getHandicapInfo() const
- CvPlayer::GetPlayerTraits() const
- CvPlayer::nextCity(int *, bool) const
- CvPlayerTraits::GetCityUnhappinessModifier() const
- CvWorldInfo::getNumCitiesUnhappinessPercent() const