CvGame::DoTestConquestVictory()
- Defined in
- CvGame.cpp, line 10654
- Class
- CvGame
- Hook name
CivHooks::CvGame_DoTestConquestVictory
Hooks
static bool BeforeCvGame_DoTestConquestVictory(CvGame* self);static void AfterCvGame_DoTestConquestVictory(CvGame* self);static void ReplaceCvGame_DoTestConquestVictory(void (*original)(CvGame*), CvGame* self);CivRegisterBefore<CivHooks::CvGame_DoTestConquestVictory>(host, &BeforeCvGame_DoTestConquestVictory);CivRegisterAfter<CivHooks::CvGame_DoTestConquestVictory>(host, &AfterCvGame_DoTestConquestVictory);CivRegisterReplace<CivHooks::CvGame_DoTestConquestVictory>(host, &ReplaceCvGame_DoTestConquestVictory);
Code
10652/// See if someone has won a conquest Victory10653/// slewis, 10.1.12 - changing conquest so that a player has to hold all capitals10654void CvGame::DoTestConquestVictory()10655{10656 TeamTypes eTeamWhoWon = NO_TEAM;1065710658 PlayerTypes eLoopPlayer;1065910660 // find out how many original capitals there are10661 int iNumOriginalCapitals = 0;1066210663 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)10664 {10665 eLoopPlayer = (PlayerTypes) iPlayerLoop;10666 if(GET_PLAYER(eLoopPlayer).isAlive())10667 {10668 int iCityLoop;10669 CvCity* pLoopCity = NULL;10670 for(pLoopCity = GET_PLAYER(eLoopPlayer).firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(eLoopPlayer).nextCity(&iCityLoop))10671 {10672 if (pLoopCity->getOriginalOwner() < MAX_MAJOR_CIVS && pLoopCity->IsOriginalCapital())10673 {10674 iNumOriginalCapitals += 1;10675 }10676 }10677 }10678 }1067910680 CvAssertMsg(iNumOriginalCapitals > 0, "No one controls an original capital. This is wrong.");1068110682 // find out if any team controls all the capitals10683 for(int iTeamLoop = 0; iTeamLoop < MAX_CIV_TEAMS; iTeamLoop++)10684 {10685 int iNumCapitalsControlled = 0;10686 if(GET_TEAM((TeamTypes)iTeamLoop).isAlive())10687 {10688 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)10689 {10690 eLoopPlayer = (PlayerTypes) iPlayerLoop;1069110692 if(GET_PLAYER(eLoopPlayer).isAlive() && GET_PLAYER(eLoopPlayer).getTeam() == (TeamTypes)iTeamLoop)10693 {10694 int iCityLoop;10695 CvCity* pLoopCity = NULL;10696 for(pLoopCity = GET_PLAYER(eLoopPlayer).firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(eLoopPlayer).nextCity(&iCityLoop))10697 {10698 if (pLoopCity->getOriginalOwner() < MAX_MAJOR_CIVS && pLoopCity->IsOriginalCapital())10699 {10700 iNumCapitalsControlled += 1;10701 }10702 }10703 }10704 }1070510706 if (iNumCapitalsControlled == iNumOriginalCapitals)10707 {10708 eTeamWhoWon = (TeamTypes)iTeamLoop;10709 break;10710 }10711 }10712 }1071310714 // If we got here then only one player remains alive!10715 if (eTeamWhoWon != NO_TEAM)10716 {10717 for(int iVictoryLoop = 0; iVictoryLoop < GC.getNumVictoryInfos(); iVictoryLoop++)10718 {10719 VictoryTypes eVictory = static_cast<VictoryTypes>(iVictoryLoop);10720 CvVictoryInfo* pkVictoryInfo = GC.getVictoryInfo(eVictory);10721 if(pkVictoryInfo)10722 {10723 if(pkVictoryInfo->isConquest() && isVictoryValid(eVictory))10724 {10725 CUSTOMLOG("Calling setWinner from DoTestConquestVictory: %i, %i", eTeamWhoWon, eVictory);10726 setWinner(eTeamWhoWon, eVictory);10727 }10728 }10729 }10730 }10731}
Calls
- CvCity::getOriginalOwner() const
- CvCity::IsOriginalCapital() const
- CvGame::isVictoryValid(VictoryTypes) const
- CvGame::setWinner(TeamTypes, VictoryTypes)
- CvGlobals::getNumVictoryInfos()
- CvGlobals::getVictoryInfo(VictoryTypes)
- CvPlayer::firstCity(int *, bool)
- CvPlayer::getTeam() const
- CvPlayer::isAlive() const
- CvPlayer::nextCity(int *, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
CvString::CvStringCvString::format- CvTeam::getTeam(TeamTypes)
- CvTeam::isAlive() const
- CvVictoryInfo::isConquest() const
FILogFile::MsgFILogFileMgr::GetInstanceFILogFileMgr::GetLogstd::basic_string::c_str