CvGame::DoUpdateDiploVictory()
- Defined in
- CvGame.cpp, line 5152
- Class
- CvGame
- Hook name
CivHooks::CvGame_DoUpdateDiploVictory
Hooks
static bool BeforeCvGame_DoUpdateDiploVictory(CvGame* self);static void AfterCvGame_DoUpdateDiploVictory(CvGame* self);static void ReplaceCvGame_DoUpdateDiploVictory(void (*original)(CvGame*), CvGame* self);CivRegisterBefore<CivHooks::CvGame_DoUpdateDiploVictory>(host, &BeforeCvGame_DoUpdateDiploVictory);CivRegisterAfter<CivHooks::CvGame_DoUpdateDiploVictory>(host, &AfterCvGame_DoUpdateDiploVictory);CivRegisterReplace<CivHooks::CvGame_DoUpdateDiploVictory>(host, &ReplaceCvGame_DoUpdateDiploVictory);
Code
5151/// Update diplo victory parameters, such as how many votes are needed to win5152void CvGame::DoUpdateDiploVictory()5153{5154 int iVotesForHost = 1;5155 int iVotesPerCiv = 1;5156 int iVotesPerCityState = 1;5157 for (int i = 0; i < GC.getNumLeagueSpecialSessionInfos(); i++)5158 {5159 LeagueSpecialSessionTypes e = (LeagueSpecialSessionTypes)i;5160 CvLeagueSpecialSessionEntry* pInfo = GC.getLeagueSpecialSessionInfo(e);5161 CvAssert(pInfo != NULL);5162 if (pInfo != NULL)5163 {5164 if (pInfo->IsUnitedNations())5165 {5166 iVotesForHost = pInfo->GetHostDelegates();5167 iVotesPerCiv = pInfo->GetCivDelegates();5168 iVotesPerCityState = pInfo->GetCityStateDelegates();5169 }5170 }5171 }51725173 float fCivsToCount = 0.0f;5174 float fCityStatesToCount = 0.0f;5175 for (uint i = 0; i < MAX_CIV_PLAYERS; i++)5176 {5177 PlayerTypes e = (PlayerTypes)i;5178 CvPlayer* pPlayer = &GET_PLAYER(e);5179 if (pPlayer != NULL && pPlayer->isEverAlive())5180 {5181 // Minor civ5182 if (pPlayer->isMinorCiv())5183 {5184 // Bought out does not count (they are no longer in the pool of teams, cannot be liberated, etc.)5185 if (!pPlayer->GetMinorCivAI()->IsBoughtOut())5186 {5187 if (pPlayer->isAlive())5188 {5189 fCityStatesToCount += 1.0f;5190 }5191 else5192 {5193 fCityStatesToCount += 0.5f;5194 }5195 }5196 }5197 // Major civ5198 else5199 {5200 if (pPlayer->isAlive())5201 {5202 fCivsToCount += 1.0f;5203 }5204 else5205 {5206 fCivsToCount += 0.5f;5207 }5208 }5209 }5210 }52115212 // Number of delegates needed to win increases the more civs and city-states there are in the game,5213 // but these two scale differently since civs' delegates are harder to secure. These functions 5214 // are based on a logarithmic regression.5215 float fCivVotesPortion = (GC.getDIPLO_VICTORY_CIV_DELEGATES_COEFFICIENT() * (float)log(fCivsToCount)) + GC.getDIPLO_VICTORY_CIV_DELEGATES_CONSTANT();5216 if (fCivVotesPortion < 0.0f)5217 {5218 fCivVotesPortion = 0.0f;5219 }5220 float fCityStateVotesPortion = (GC.getDIPLO_VICTORY_CS_DELEGATES_COEFFICIENT() * (float)log(fCityStatesToCount)) + GC.getDIPLO_VICTORY_CS_DELEGATES_CONSTANT();5221 if (fCityStateVotesPortion < 0.0f)5222 {5223 fCityStateVotesPortion = 0.0f;5224 }52255226 int iVotesToWin = (int)floor(fCivVotesPortion + fCityStateVotesPortion);5227 iVotesToWin = MAX(iVotesForHost + iVotesPerCiv + 1, iVotesToWin);5228 iVotesToWin = MIN(iVotesForHost + (iVotesPerCiv * (int)fCivsToCount) + (iVotesPerCityState * (int)fCityStatesToCount), iVotesToWin);52295230 SetVotesNeededForDiploVictory(iVotesToWin);5231 GC.GetEngineUserInterface()->setDirty(LeagueScreen_DIRTY_BIT, true);5232}
Calls
- CvGame::SetVotesNeededForDiploVictory(int)
- CvGlobals::getDIPLO_VICTORY_CIV_DELEGATES_COEFFICIENT()
- CvGlobals::getDIPLO_VICTORY_CIV_DELEGATES_CONSTANT()
- CvGlobals::getDIPLO_VICTORY_CS_DELEGATES_COEFFICIENT()
- CvGlobals::getDIPLO_VICTORY_CS_DELEGATES_CONSTANT()
- CvGlobals::GetEngineUserInterface()
- CvGlobals::getLeagueSpecialSessionInfo(LeagueSpecialSessionTypes)
- CvGlobals::getNumLeagueSpecialSessionInfos()
- CvLeagueSpecialSessionEntry::GetCityStateDelegates() const
- CvLeagueSpecialSessionEntry::GetCivDelegates() const
- CvLeagueSpecialSessionEntry::GetHostDelegates() const
- CvLeagueSpecialSessionEntry::IsUnitedNations() const
- CvMinorCivAI::IsBoughtOut() const
- CvPlayer::GetMinorCivAI() const
- CvPlayer::isAlive() const
- CvPlayer::isEverAlive() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
floorICvUserInterface1::setDirtylogstd::maxstd::min