Bazaar developer reference

CvPlayer::GetUnhappinessFromPuppetCityPopulation() const

Defined in
CvPlayer.cpp, line 12694
Class
CvPlayer
Hook name
CivHooks::CvPlayer_GetUnhappinessFromPuppetCityPopulation

Hooks

static bool BeforeCvPlayer_GetUnhappinessFromPuppetCityPopulation(const CvPlayer* self, int& result);static void AfterCvPlayer_GetUnhappinessFromPuppetCityPopulation(const CvPlayer* self, int& result);static int ReplaceCvPlayer_GetUnhappinessFromPuppetCityPopulation(int (*original)(const CvPlayer*), const CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_GetUnhappinessFromPuppetCityPopulation>(host, &BeforeCvPlayer_GetUnhappinessFromPuppetCityPopulation);CivRegisterAfter<CivHooks::CvPlayer_GetUnhappinessFromPuppetCityPopulation>(host, &AfterCvPlayer_GetUnhappinessFromPuppetCityPopulation);CivRegisterReplace<CivHooks::CvPlayer_GetUnhappinessFromPuppetCityPopulation>(host, &ReplaceCvPlayer_GetUnhappinessFromPuppetCityPopulation);

Code

12693/// Unhappiness from Puppet City Population12694int CvPlayer::GetUnhappinessFromPuppetCityPopulation() const12695{12696	int iUnhappiness = 0;12697	int iUnhappinessPerPop = GC.getUNHAPPINESS_PER_POPULATION() * 100;1269812699	int iLoop = 0;12700	for(const CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))12701	{12702		bool bCityValid = false;1270312704		if(pLoopCity->IsPuppet())12705			bCityValid = true;1270612707		// Assume city doesn't exist, and does NOT count12708		if(pLoopCity->IsIgnoreCityForHappiness())12709			bCityValid = false;1271012711		if(bCityValid)12712		{12713			int iPopulation = pLoopCity->getPopulation();1271412715			// No Unhappiness from Specialist Pop? (Policies, etc.)12716			// slewis - 2013.5.7 12717			// This function, along with GetUnhappinessFromCitySpecialists, is only called through the UI to reflect 12718			// to the player what's going on with their happiness. So I removed the effect that specialists have on 12719			// puppeted cities and let the GetUnhappinessFromCitySpecialists correct that problem.1272012721			/*if(isHalfSpecialistUnhappiness())12722			{12723				int iSpecialistCount = pLoopCity->GetCityCitizens()->GetTotalSpecialistCount();12724				iSpecialistCount++; // Round up12725				iPopulation -= (iSpecialistCount / 2);12726			}*/12727			iPopulation -= pLoopCity->GetCityCitizens()->GetTotalSpecialistCount();1272812729			int iUnhappinessFromThisCity = iPopulation * iUnhappinessPerPop;1273012731			if(pLoopCity->isCapital() && GetCapitalUnhappinessMod() != 0)12732			{12733				iUnhappinessFromThisCity *= (100 + GetCapitalUnhappinessMod());12734				iUnhappinessFromThisCity /= 100;12735			}1273612737			iUnhappiness += iUnhappinessFromThisCity;12738		}12739	}1274012741	iUnhappiness *= (100 + GetUnhappinessMod());12742	iUnhappiness /= 100;1274312744	iUnhappiness *= 100 + GetPlayerTraits()->GetPopulationUnhappinessModifier();12745	iUnhappiness /= 100;1274612747	// Handicap mod12748	iUnhappiness *= getHandicapInfo().getPopulationUnhappinessMod();12749	iUnhappiness /= 100;1275012751	return iUnhappiness;12752}

Calls

Called by