CvPlayer::GetUnhappiness(CvCity *, CvCity *) const
- Defined in
- CvPlayer.cpp, line 12419
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetUnhappiness
Hooks
static bool BeforeCvPlayer_GetUnhappiness(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static void AfterCvPlayer_GetUnhappiness(const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted, int& result);static int ReplaceCvPlayer_GetUnhappiness(int (*original)(const CvPlayer*, CvCity*, CvCity*), const CvPlayer* self, CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted);CivRegisterBefore<CivHooks::CvPlayer_GetUnhappiness>(host, &BeforeCvPlayer_GetUnhappiness);CivRegisterAfter<CivHooks::CvPlayer_GetUnhappiness>(host, &AfterCvPlayer_GetUnhappiness);CivRegisterReplace<CivHooks::CvPlayer_GetUnhappiness>(host, &ReplaceCvPlayer_GetUnhappiness);
Code
12418/// How much of our Happiness is being used up? (Population + Units)12419int CvPlayer::GetUnhappiness(CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted) const12420{12421 int iUnhappiness = 0;1242212423 // City Count Unhappiness12424 iUnhappiness += GetUnhappinessFromCityCount(pAssumeCityAnnexed, pAssumeCityPuppeted);1242512426 // Occupied City Count Unhappiness12427 iUnhappiness += GetUnhappinessFromCapturedCityCount(pAssumeCityAnnexed, pAssumeCityPuppeted);1242812429 // City Population Unhappiness12430 iUnhappiness += GetUnhappinessFromCityPopulation(pAssumeCityAnnexed, pAssumeCityPuppeted);1243112432 // Occupied City Population Unhappiness12433 iUnhappiness += GetUnhappinessFromOccupiedCities(pAssumeCityAnnexed, pAssumeCityPuppeted);1243412435 // Unit Unhappiness (Builders)12436 iUnhappiness += GetUnhappinessFromUnits();1243712438 iUnhappiness /= 100;1243912440 iUnhappiness += GetCulture()->GetPublicOpinionUnhappiness();1244112442 // AI gets reduced Unhappiness on higher levels12443 if(!isHuman() && !IsAITeammateOfHuman())12444 {12445 iUnhappiness *= GC.getGame().getHandicapInfo().getAIUnhappinessPercent();12446 iUnhappiness /= 100;12447 }1244812449 return iUnhappiness;12450}
Calls
- CvGame::getHandicapInfo() const
- CvGlobals::getGame()
- CvHandicapInfo::getAIUnhappinessPercent() const
- CvPlayer::GetCulture() const
- CvPlayer::GetUnhappinessFromCapturedCityCount(CvCity *, CvCity *) const
- CvPlayer::GetUnhappinessFromCityCount(CvCity *, CvCity *) const
- CvPlayer::GetUnhappinessFromCityPopulation(CvCity *, CvCity *) const
- CvPlayer::GetUnhappinessFromOccupiedCities(CvCity *, CvCity *) const
- CvPlayer::GetUnhappinessFromUnits() const
- CvPlayer::IsAITeammateOfHuman() const
- CvPlayer::isHuman() const
- CvPlayerCulture::GetPublicOpinionUnhappiness() const
Called by
- CvEconomicAI::LogMonitor()
- EconomicAIHelpers::IsTestStrategy_NeedHappiness(EconomicAIStrategyTypes, CvPlayer *)
- EconomicAIHelpers::IsTestStrategy_NeedHappinessCritical(EconomicAIStrategyTypes, CvPlayer *)
- CvPlayer::GatherPerTurnReplayStats(int)
- CvPlayer::GetExcessHappiness() const
- CvPlayerPolicies::AddFlavorAsStrategies(int)
- CvLuaPlayer::lGetUnhappiness(lua_State *)
- CvLuaPlayer::lGetUnhappinessForecast(lua_State *)