CvEnactProposal::IsPassed(int)
- Defined in
- CvVotingClasses.cpp, line 1123
- Class
- CvEnactProposal
- Hook name
CivHooks::CvEnactProposal_IsPassed- Overrides
- CvProposal::IsPassed(int)
Hooks
static bool BeforeCvEnactProposal_IsPassed(CvEnactProposal* self, int iTotalSessionVotes, bool& result);static void AfterCvEnactProposal_IsPassed(CvEnactProposal* self, int iTotalSessionVotes, bool& result);static bool ReplaceCvEnactProposal_IsPassed(bool (*original)(CvEnactProposal*, int), CvEnactProposal* self, int iTotalSessionVotes);CivRegisterBefore<CivHooks::CvEnactProposal_IsPassed>(host, &BeforeCvEnactProposal_IsPassed);CivRegisterAfter<CivHooks::CvEnactProposal_IsPassed>(host, &AfterCvEnactProposal_IsPassed);CivRegisterReplace<CivHooks::CvEnactProposal_IsPassed>(host, &ReplaceCvEnactProposal_IsPassed);
Code
1123bool CvEnactProposal::IsPassed(int iTotalSessionVotes)1124{1125 CvResolutionEntry* pInfo = GC.getResolutionInfo(GetType());1126 CvAssert(pInfo);1127 if (!pInfo)1128 {1129 return false;1130 }11311132 int iQuorumPercent = pInfo->GetQuorumPercent();1133 bool bQuorum = ((float)GetVoterDecision()->GetVotesCast() / (float)iTotalSessionVotes) >= ((float)iQuorumPercent / 100.0f);1134 if (!bQuorum)1135 {1136 return false;1137 }11381139 int iDecision = GetVoterDecision()->GetDecision();11401141 if (GetEffects()->bDiplomaticVictory)1142 {1143 // World Leader only passes if there is no tie and someone has enough votes cast for them1144 if (!GetVoterDecision()->IsTie())1145 {1146 int iVotesForTop = GetVoterDecision()->GetVotesCastForChoice(iDecision);1147 int iVotesNeededToWin = GC.getGame().GetVotesNeededForDiploVictory();1148 if (iVotesForTop >= iVotesNeededToWin)1149 {1150 return true;1151 }1152 }1153 return false;1154 }1155 else if (GetEffects()->bChangeLeagueHost)1156 {1157 // Choose Host always passes, it's just a matter of who won1158 return true;1159 }1160 else if (GetVoterDecision()->GetType() == RESOLUTION_DECISION_YES_OR_NO)1161 {1162 // Normal resolutions only pass on YES, not NO or NONE1163 return (iDecision == LeagueHelpers::CHOICE_YES);1164 }11651166 CvAssertMsg(false, "Unexpected case when determining whether an enact proposal has passed. Please send Anton your save file and version.");1167 return false;1168}
Calls
- CvGame::GetVotesNeededForDiploVictory() const
- CvGlobals::getGame()
- CvGlobals::getResolutionInfo(ResolutionTypes)
- CvResolution::GetEffects()
- CvResolution::GetType() const
- CvResolution::GetVoterDecision()
- CvResolutionDecision::GetType() const
- CvResolutionEntry::GetQuorumPercent() const
- CvVoterDecision::GetDecision()
- CvVoterDecision::GetVotesCast()
- CvVoterDecision::GetVotesCastForChoice(int)
- CvVoterDecision::IsTie()