Bazaar developer reference

CvLeague::CalculateStartingVotesForMember(PlayerTypes, bool)

Defined in
CvVotingClasses.cpp, line 3265
Class
CvLeague
Hook name
CivHooks::CvLeague_CalculateStartingVotesForMember

Hooks

static bool BeforeCvLeague_CalculateStartingVotesForMember(CvLeague* self, PlayerTypes ePlayer, bool bForceUpdateSources, int& result);static void AfterCvLeague_CalculateStartingVotesForMember(CvLeague* self, PlayerTypes ePlayer, bool bForceUpdateSources, int& result);static int ReplaceCvLeague_CalculateStartingVotesForMember(int (*original)(CvLeague*, PlayerTypes, bool), CvLeague* self, PlayerTypes ePlayer, bool bForceUpdateSources);CivRegisterBefore<CivHooks::CvLeague_CalculateStartingVotesForMember>(host, &BeforeCvLeague_CalculateStartingVotesForMember);CivRegisterAfter<CivHooks::CvLeague_CalculateStartingVotesForMember>(host, &AfterCvLeague_CalculateStartingVotesForMember);CivRegisterReplace<CivHooks::CvLeague_CalculateStartingVotesForMember>(host, &ReplaceCvLeague_CalculateStartingVotesForMember);

Code

3265int CvLeague::CalculateStartingVotesForMember(PlayerTypes ePlayer, bool bForceUpdateSources)3266{3267	int iVotes = 0;3268	if (CanEverVote(ePlayer))3269	{3270		LeagueSpecialSessionTypes eGoverningSpecialSession = NO_LEAGUE_SPECIAL_SESSION;3271		if (GetCurrentSpecialSession() != NO_LEAGUE_SPECIAL_SESSION)3272		{3273			eGoverningSpecialSession = GetCurrentSpecialSession();3274		}3275		else if (GetLastSpecialSession() != NO_LEAGUE_SPECIAL_SESSION)3276		{3277			eGoverningSpecialSession = GetLastSpecialSession();3278		}3279		3280		CvAssert(eGoverningSpecialSession != NO_LEAGUE_SPECIAL_SESSION);3281		if (eGoverningSpecialSession == NO_LEAGUE_SPECIAL_SESSION) return GC.getLEAGUE_MEMBER_VOTES_BASE();3282		CvLeagueSpecialSessionEntry* pInfo = GC.getLeagueSpecialSessionInfo(eGoverningSpecialSession);3283		CvAssert(pInfo != NULL);3284		if (pInfo == NULL) return GC.getLEAGUE_MEMBER_VOTES_BASE();3285		Member* pMember = GetMember(ePlayer);3286		CvAssert(pMember != NULL);3287		if (pMember == NULL) return GC.getLEAGUE_MEMBER_VOTES_BASE();32883289		// Base votes3290		int iBaseVotes = GetCoreVotesForMember(ePlayer);3291		iVotes += iBaseVotes;32923293		// Extra votes (ie. leading in previous failed Diplo Victory proposals)3294		int iExtraVotes = pMember->iExtraVotes;;3295		iVotes += iExtraVotes;32963297		// Hosting the league3298		int iHostVotes = 0;3299		if (IsHostMember(ePlayer))3300		{3301			iHostVotes += pInfo->GetHostDelegates();3302		}3303		iVotes += iHostVotes;33043305		// City-State allies3306		int iCityStateVotes = 0;3307		for (int i = MAX_MAJOR_CIVS; i < MAX_CIV_PLAYERS; i++)3308		{3309			PlayerTypes eMinor = (PlayerTypes) i;3310			if (GET_PLAYER(eMinor).isAlive() && GET_PLAYER(eMinor).GetMinorCivAI()->IsAllies(ePlayer))3311			{3312				iCityStateVotes += pInfo->GetCityStateDelegates();3313			}3314		}3315		iVotes += iCityStateVotes;33163317		// Diplomats after Globalization tech3318		int iDiplomatVotes = 0;3319		for (int i = 0; i < MAX_MAJOR_CIVS; i++)3320		{3321			PlayerTypes eMajor = (PlayerTypes) i;3322			if (GET_PLAYER(eMajor).isAlive())3323			{3324				if (GET_PLAYER(ePlayer).GetEspionage()->IsMyDiplomatVisitingThem(eMajor))3325				{3326					iDiplomatVotes += GET_PLAYER(ePlayer).GetExtraVotesPerDiplomat();3327				}3328			}3329		}3330		iVotes += iDiplomatVotes;33313332		// Wonders3333		int iWonderVotes = GET_PLAYER(ePlayer).GetExtraLeagueVotes();3334		iVotes += iWonderVotes;33353336		// World Religion3337		int iWorldReligionVotes = GetExtraVotesForFollowingReligion(ePlayer);3338		iVotes += iWorldReligionVotes;33393340		// World Ideology3341		int iWorldIdeologyVotes = GetExtraVotesForFollowingIdeology(ePlayer);3342		iVotes += iWorldIdeologyVotes;33433344		// Vote Sources - Normally this is only updated when we are not in session3345		if (bForceUpdateSources || !IsInSession())3346		{3347			pMember->sVoteSources = "";3348			if (iBaseVotes > 0)3349			{3350				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_BASE_VOTES");3351				sTemp << iBaseVotes;3352				pMember->sVoteSources += sTemp.toUTF8();3353			}3354			if (iExtraVotes > 0)3355			{3356				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_EXTRA_VOTES");3357				sTemp << iExtraVotes;3358				pMember->sVoteSources += sTemp.toUTF8();3359			}3360			if (iHostVotes > 0)3361			{3362				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_HOST_VOTES");3363				sTemp << iHostVotes;3364				pMember->sVoteSources += sTemp.toUTF8();3365			}3366			if (pInfo->GetCityStateDelegates() > 0) // Show even if we have none from this source, to remind players that CS can give Delegates3367			{3368				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_CS_VOTES");3369				sTemp << iCityStateVotes;3370				sTemp << pInfo->GetCityStateDelegates();3371				pMember->sVoteSources += sTemp.toUTF8();3372			}3373			if (iDiplomatVotes > 0)3374			{3375				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_DIPLOMAT_VOTES");3376				sTemp << iDiplomatVotes;3377				sTemp << GET_PLAYER(ePlayer).GetExtraVotesPerDiplomat();3378				pMember->sVoteSources += sTemp.toUTF8();3379			}3380			if (iWonderVotes > 0)3381			{3382				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_WONDER_VOTES");3383				sTemp << iWonderVotes;3384				pMember->sVoteSources += sTemp.toUTF8();3385			}3386			3387			if (iWorldReligionVotes > 0)3388			{3389				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_WORLD_RELIGION_VOTES");3390				sTemp << iWorldReligionVotes;3391				pMember->sVoteSources += sTemp.toUTF8();3392			}3393			if (iWorldIdeologyVotes > 0)3394			{3395				Localization::String sTemp = Localization::Lookup("TXT_KEY_LEAGUE_OVERVIEW_MEMBER_DETAILS_WORLD_IDEOLOGY_VOTES");3396				sTemp << iWorldIdeologyVotes;3397				pMember->sVoteSources += sTemp.toUTF8();3398			}3399		}3400	}3401	return iVotes;3402}

Calls

Called by