CvPlayer::GetMostUnhappyCityRecipient()
- Defined in
- CvPlayer.cpp, line 11985
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetMostUnhappyCityRecipient
Hooks
static bool BeforeCvPlayer_GetMostUnhappyCityRecipient(CvPlayer* self, PlayerTypes& result);static void AfterCvPlayer_GetMostUnhappyCityRecipient(CvPlayer* self, PlayerTypes& result);static PlayerTypes ReplaceCvPlayer_GetMostUnhappyCityRecipient(PlayerTypes (*original)(CvPlayer*), CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_GetMostUnhappyCityRecipient>(host, &BeforeCvPlayer_GetMostUnhappyCityRecipient);CivRegisterAfter<CivHooks::CvPlayer_GetMostUnhappyCityRecipient>(host, &AfterCvPlayer_GetMostUnhappyCityRecipient);CivRegisterReplace<CivHooks::CvPlayer_GetMostUnhappyCityRecipient>(host, &ReplaceCvPlayer_GetMostUnhappyCityRecipient);
Code
11984// Calculate player that will receive city if it revolts11985PlayerTypes CvPlayer::GetMostUnhappyCityRecipient()11986{11987 PlayerTypes eRtnValue = NO_PLAYER;11988 CvCity *pMostUnhappyCity = GetMostUnhappyCity();11989 int iClosestCapital = MAX_INT;1199011991 if (pMostUnhappyCity)11992 {11993 PolicyBranchTypes ePreferredIdeology = GetCulture()->GetPublicOpinionPreferredIdeology();1199411995 // Look at each civ11996 for (int iLoopPlayer = 0; iLoopPlayer < MAX_MAJOR_CIVS; iLoopPlayer++)11997 {11998 CvPlayer &kPlayer = GET_PLAYER((PlayerTypes)iLoopPlayer);11999 if (iLoopPlayer != GetID() && kPlayer.isAlive() && !kPlayer.isMinorCiv())12000 {12001 PolicyBranchTypes eOtherCivIdeology = kPlayer.GetPlayerPolicies()->GetLateGamePolicyTree();12002 if (eOtherCivIdeology == ePreferredIdeology)12003 {12004 int iCulturalDominanceOverUs = kPlayer.GetCulture()->GetInfluenceLevel(GetID()) - GetCulture()->GetInfluenceLevel((PlayerTypes)iLoopPlayer);12005 if (iCulturalDominanceOverUs > 0 && kPlayer.getCapitalCity() != NULL)12006 {12007 // Find how far their capital is from this city12008 int iCapitalDistance = plotDistance(pMostUnhappyCity->getX(), pMostUnhappyCity->getY(), kPlayer.getCapitalCity()->getX(), kPlayer.getCapitalCity()->getY());1200912010 if (iCapitalDistance < iClosestCapital)12011 {12012 iClosestCapital = iCapitalDistance;12013 eRtnValue = (PlayerTypes)iLoopPlayer;12014 }12015 }12016 }12017 }12018 }12019 }1202012021 return eRtnValue;12022}
Calls
- CvCity::getX() const
- CvCity::getY() const
- CvPlayer::getCapitalCity()
- CvPlayer::GetCulture() const
- CvPlayer::GetID() const
- CvPlayer::GetMostUnhappyCity()
- CvPlayer::GetPlayerPolicies() const
- CvPlayer::isAlive() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerCulture::GetInfluenceLevel(PlayerTypes) const
- CvPlayerCulture::GetPublicOpinionPreferredIdeology() const
- CvPlayerPolicies::GetLateGamePolicyTree() const
- plotDistance(int, int, int, int)