Bazaar developer reference

CvLeague::FinishSession()

Defined in
CvVotingClasses.cpp, line 5411
Class
CvLeague
Hook name
CivHooks::CvLeague_FinishSession

Hooks

static bool BeforeCvLeague_FinishSession(CvLeague* self);static void AfterCvLeague_FinishSession(CvLeague* self);static void ReplaceCvLeague_FinishSession(void (*original)(CvLeague*), CvLeague* self);CivRegisterBefore<CivHooks::CvLeague_FinishSession>(host, &BeforeCvLeague_FinishSession);CivRegisterAfter<CivHooks::CvLeague_FinishSession>(host, &AfterCvLeague_FinishSession);CivRegisterReplace<CivHooks::CvLeague_FinishSession>(host, &ReplaceCvLeague_FinishSession);

Code

5411void CvLeague::FinishSession()5412{5413	PlayerTypes eOldHost = GetHostMember();5414	LeagueHelpers::PlayerList vSupportedNewHost;5415	int iTotalSessionVotes = GetVotesSpentThisSession();54165417	// Find out if we have a recurring proposal5418	ResolutionTypes eRecurringProposal = NO_RESOLUTION;5419	bool bRecurringProposalThisSession = false;5420	if (GetLastSpecialSession() != NO_LEAGUE_SPECIAL_SESSION)5421	{5422		CvLeagueSpecialSessionEntry* pInfo = GC.getLeagueSpecialSessionInfo(GetLastSpecialSession());5423		CvAssert(pInfo != NULL);5424		if (pInfo != NULL)5425		{5426			eRecurringProposal = pInfo->GetRecurringProposal();5427		}5428	}54295430	// Notify players of vote results5431	NotifySessionDone();54325433	// Resolve Proposals on table5434	for (RepealProposalList::iterator it = m_vRepealProposals.begin(); it != m_vRepealProposals.end(); it++)5435	{5436		if (eRecurringProposal != NO_RESOLUTION && eRecurringProposal == it->GetType())5437		{5438			bRecurringProposalThisSession = true;5439		}54405441		PlayerTypes eProposer = it->GetProposalPlayer();5442		LeagueHelpers::PlayerList vHelpedOutcome = it->GetRepealDecision()->GetPlayersVotingForChoice(it->GetRepealDecision()->GetDecision());5443		if (it->IsPassed(iTotalSessionVotes))5444		{5445			// Proposer is grateful to people who helped it pass5446			if (eProposer != NO_PLAYER)5447			{5448				for (LeagueHelpers::PlayerList::iterator playerIt = vHelpedOutcome.begin(); playerIt != vHelpedOutcome.end(); ++playerIt)5449				{5450					GET_PLAYER(eProposer).GetDiplomacyAI()->SetTurnsSinceTheySupportedOurProposal(*playerIt, 0);5451				}5452			}54535454			DoRepealResolution(it);5455		}5456		else5457		{5458			// Proposer is angry at people who helped it fail5459			if (eProposer != NO_PLAYER)5460			{5461				for (LeagueHelpers::PlayerList::iterator playerIt = vHelpedOutcome.begin(); playerIt != vHelpedOutcome.end(); ++playerIt)5462				{5463					GET_PLAYER(eProposer).GetDiplomacyAI()->SetTurnsSinceTheyFoiledOurProposal(*playerIt, 0);5464				}5465			}5466		}54675468		LogProposalResolved(it);5469	}5470	for (EnactProposalList::iterator it = m_vEnactProposals.begin(); it != m_vEnactProposals.end(); it++)5471	{5472		if (eRecurringProposal != NO_RESOLUTION && eRecurringProposal == it->GetType())5473		{5474			bRecurringProposalThisSession = true;5475		}54765477		PlayerTypes eProposer = it->GetProposalPlayer();5478		LeagueHelpers::PlayerList vHelpedOutcome = it->GetVoterDecision()->GetPlayersVotingForChoice(it->GetVoterDecision()->GetDecision());5479		if (it->IsPassed(iTotalSessionVotes))5480		{5481			// Proposer is grateful to people who helped it pass5482			if (eProposer != NO_PLAYER)5483			{5484				for (LeagueHelpers::PlayerList::iterator playerIt = vHelpedOutcome.begin(); playerIt != vHelpedOutcome.end(); ++playerIt)5485				{5486					GET_PLAYER(eProposer).GetDiplomacyAI()->SetTurnsSinceTheySupportedOurProposal(*playerIt, 0);5487				}5488			}54895490			if (it->GetEffects()->bChangeLeagueHost)5491			{5492				vSupportedNewHost.clear();5493				vSupportedNewHost = it->GetVoterDecision()->GetPlayersVotingForChoice(it->GetVoterDecision()->GetDecision());5494			}54955496			DoEnactResolution(it);5497		}5498		else5499		{5500			// Proposer is angry at people who helped it fail5501			if (eProposer != NO_PLAYER)5502			{5503				for (LeagueHelpers::PlayerList::iterator playerIt = vHelpedOutcome.begin(); playerIt != vHelpedOutcome.end(); ++playerIt)5504				{5505					GET_PLAYER(eProposer).GetDiplomacyAI()->SetTurnsSinceTheyFoiledOurProposal(*playerIt, 0);5506				}5507			}55085509			// Since it failed, it may provide members with extra votes5510			CvResolutionEntry* pInfo = GC.getResolutionInfo(it->GetType());5511			CvAssert(pInfo != NULL);5512			if (pInfo != NULL)5513			{5514				if (pInfo->GetLeadersVoteBonusOnFail() > 0)5515				{5516					bool bChoicesArePlayers = (pInfo->GetVoterDecision() == RESOLUTION_DECISION_MAJOR_CIV_MEMBER || pInfo->GetVoterDecision() == RESOLUTION_DECISION_OTHER_MAJOR_CIV_MEMBER);5517					CvAssertMsg(bChoicesArePlayers, "Trying to give bonus delegates since a resolution failed, but voter decision is unexpected type. Please send Anton your save file and version.");5518					if (bChoicesArePlayers)5519					{5520						std::vector<int> vBonusVotePlayers = it->GetVoterDecision()->GetTopVotedChoices(LeagueHelpers::NUM_LEADERS_FOR_EXTRA_VOTES);5521						for (uint i = 0; i < vBonusVotePlayers.size(); i++)5522						{5523							Member* pMember = GetMember((PlayerTypes)vBonusVotePlayers[i]);5524							CvAssert(pMember != NULL);5525							if (pMember != NULL)5526							{5527								pMember->iExtraVotes = pMember->iExtraVotes + pInfo->GetLeadersVoteBonusOnFail();5528							}5529						}5530					}5531				}5532			}5533		}55345535		LogProposalResolved(it);5536	}5537	PlayerTypes eNewHost = GetHostMember();55385539	// A new host is grateful to people who helped him5540	if (!vSupportedNewHost.empty() && eNewHost != NO_PLAYER)5541	{5542		for (LeagueHelpers::PlayerList::iterator playerIt = vSupportedNewHost.begin(); playerIt != vSupportedNewHost.end(); ++playerIt)5543		{5544			GET_PLAYER(eNewHost).GetDiplomacyAI()->SetTurnsSinceTheySupportedOurHosting(*playerIt, 0);5545		}5546	}55475548	// Update number of sessions held by consecutively by host5549	if (eNewHost == eOldHost)5550	{5551		ChangeConsecutiveHostedSessions(1);5552	}5553	else5554	{5555		SetConsecutiveHostedSessions(0);5556	}55575558	// Clear processed proposals, and bring back any that were on hold5559	DoClearProposals();55605561	// Clear existing proposal privileges5562	ClearProposalPrivileges();55635564	bool bRegularSession = (GetCurrentSpecialSession() == NO_LEAGUE_SPECIAL_SESSION);5565	if (bRegularSession)5566	{5567		// Prepare next proposals5568		if (eRecurringProposal != NO_RESOLUTION && !bRecurringProposalThisSession && IsResolutionEffectsValid(eRecurringProposal, LeagueHelpers::CHOICE_NONE))5569		{5570			// We have a recurring proposal that was not proposed this time, so auto propose it for next time5571			DoProposeEnact(eRecurringProposal, NO_PLAYER, LeagueHelpers::CHOICE_NONE);5572		}5573		else5574		{5575			// Players get to make the proposals for next session5576			CvAssertMsg(!IsAnythingProposed(), "Assigning proposal privileges to players when something is already proposed. Please send Anton your save file and version.");5577			AssignProposalPrivileges();5578		}55795580		// Reset counter5581		ResetTurnsUntilSession();5582	}55835584	SetInSession(false);5585}

Calls

Called by