CvGameLeagues::DoTurn()
- Defined in
- CvVotingClasses.cpp, line 6758
- Class
- CvGameLeagues
- Hook name
CivHooks::CvGameLeagues_DoTurn
Hooks
static bool BeforeCvGameLeagues_DoTurn(CvGameLeagues* self);static void AfterCvGameLeagues_DoTurn(CvGameLeagues* self);static void ReplaceCvGameLeagues_DoTurn(void (*original)(CvGameLeagues*), CvGameLeagues* self);CivRegisterBefore<CivHooks::CvGameLeagues_DoTurn>(host, &BeforeCvGameLeagues_DoTurn);CivRegisterAfter<CivHooks::CvGameLeagues_DoTurn>(host, &AfterCvGameLeagues_DoTurn);CivRegisterReplace<CivHooks::CvGameLeagues_DoTurn>(host, &ReplaceCvGameLeagues_DoTurn);
Code
6758void CvGameLeagues::DoTurn()6759{6760 if (!GC.getGame().isOption(GAMEOPTION_NO_LEAGUES))6761 {6762 GC.getGame().DoUpdateDiploVictory();67636764 // Not yet founded - is it time to start?6765 if (GetNumActiveLeagues() == 0)6766 {6767 // Has any living major civ met every other living major civ?6768 for (int iCiv = 0; iCiv < MAX_MAJOR_CIVS; iCiv++)6769 {6770 PlayerTypes eCiv = (PlayerTypes) iCiv;6771 if (GET_PLAYER(eCiv).isAlive())6772 {6773 // Has the unlock from tech?6774 if (GET_TEAM(GET_PLAYER(eCiv).getTeam()).HasTechForWorldCongress())6775 {6776 // Met every other civ?6777 bool bMetEveryone = true;6778 for (int iOtherCiv = 0; iOtherCiv < MAX_MAJOR_CIVS; iOtherCiv++)6779 {6780 PlayerTypes eOtherCiv = (PlayerTypes) iOtherCiv;6781 if (eCiv != eOtherCiv && GET_PLAYER(eOtherCiv).isAlive())6782 {6783 if (!GET_TEAM(GET_PLAYER(eCiv).getTeam()).isHasMet(GET_PLAYER(eOtherCiv).getTeam()))6784 {6785 bMetEveryone = false;6786 break;6787 }6788 }6789 }67906791 if (bMetEveryone && GC.getGame().countMajorCivsAlive() > 1)6792 {6793 FoundLeague(eCiv);6794 break;6795 }6796 }6797 }6798 }6799 }6800 // Already founded - do we want to trigger a special session, or just a normal turn?6801 else6802 {6803 EraTypes eGameEra = LeagueHelpers::GetGameEraForTrigger();6804 LeagueSpecialSessionTypes eSpecialSession = NO_LEAGUE_SPECIAL_SESSION;6805 if (eGameEra > GetLastEraTrigger())6806 {6807 for (int i = 0; i < GC.getNumLeagueSpecialSessionInfos(); i++)6808 {6809 CvLeagueSpecialSessionEntry* pInfo = GC.getLeagueSpecialSessionInfo((LeagueSpecialSessionTypes)i);6810 if (pInfo != NULL)6811 {6812 EraTypes eSessionTrigger = pInfo->GetEraTrigger();6813 if (eSessionTrigger <= eGameEra && eSessionTrigger > GetLastEraTrigger())6814 {6815 eSpecialSession = (LeagueSpecialSessionTypes)i;6816 }6817 }6818 }6819 }68206821 CvLeague* pLeague = GetActiveLeague();6822 CvAssert(pLeague != NULL);6823 if (pLeague != NULL)6824 {6825 // We want to trigger a special session6826 if (eSpecialSession != NO_LEAGUE_SPECIAL_SESSION)6827 {6828 // And we can6829 if (pLeague->CanStartSpecialSession(eSpecialSession))6830 {6831 pLeague->DoTurn(eSpecialSession);68326833 // Flag this era as the last era we did a special session6834 CvLeagueSpecialSessionEntry* pInfo = GC.getLeagueSpecialSessionInfo(eSpecialSession);6835 CvAssert(pInfo != NULL);6836 if (pInfo != NULL)6837 {6838 SetLastEraTrigger(pInfo->GetEraTrigger());6839 }68406841 LogSpecialSession(eSpecialSession);6842 }6843 // Have to wait6844 else6845 {6846 pLeague->DoTurn();6847 }6848 }6849 // Just a normal turn6850 else6851 {6852 pLeague->DoTurn();6853 }6854 }6855 }6856 }6857 else6858 {6859 VictoryTypes eDiploVictory = (VictoryTypes) GC.getInfoTypeForString("VICTORY_DIPLOMATIC", true);6860 if (eDiploVictory != NO_VICTORY)6861 {6862 CvAssertMsg(!GC.getGame().isVictoryValid(eDiploVictory), "Diplomacy victory is valid, but leagues are disabled. Please send Anton your save file and version.");6863 }6864 }6865}
Calls
- CvGame::countMajorCivsAlive() const
- CvGame::DoUpdateDiploVictory()
- CvGame::isOption(const char *) const
- CvGameLeagues::FoundLeague(PlayerTypes)
- CvGameLeagues::GetActiveLeague()
- CvGameLeagues::GetLastEraTrigger() const
- CvGameLeagues::GetNumActiveLeagues()
- CvGameLeagues::LogSpecialSession(LeagueSpecialSessionTypes)
- CvGameLeagues::SetLastEraTrigger(EraTypes)
- CvGlobals::getGame()
- CvGlobals::getInfoTypeForString(const char *, bool) const
- CvGlobals::getLeagueSpecialSessionInfo(LeagueSpecialSessionTypes)
- CvGlobals::getNumLeagueSpecialSessionInfos()
- CvLeague::CanStartSpecialSession(LeagueSpecialSessionTypes)
- CvLeague::DoTurn(LeagueSpecialSessionTypes)
- CvLeagueSpecialSessionEntry::GetEraTrigger() const
- CvPlayer::getTeam() const
- CvPlayer::isAlive() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::getTeam(TeamTypes)
- CvTeam::HasTechForWorldCongress() const
- CvTeam::isHasMet(TeamTypes) const
- LeagueHelpers::GetGameEraForTrigger()