CvGame::CheckPlayerTurnDeactivate()
- Defined in
- CvGame.cpp, line 1583
- Class
- CvGame
- Hook name
CivHooks::CvGame_CheckPlayerTurnDeactivate
Hooks
static bool BeforeCvGame_CheckPlayerTurnDeactivate(CvGame* self);static void AfterCvGame_CheckPlayerTurnDeactivate(CvGame* self);static void ReplaceCvGame_CheckPlayerTurnDeactivate(void (*original)(CvGame*), CvGame* self);CivRegisterBefore<CivHooks::CvGame_CheckPlayerTurnDeactivate>(host, &BeforeCvGame_CheckPlayerTurnDeactivate);CivRegisterAfter<CivHooks::CvGame_CheckPlayerTurnDeactivate>(host, &AfterCvGame_CheckPlayerTurnDeactivate);CivRegisterReplace<CivHooks::CvGame_CheckPlayerTurnDeactivate>(host, &ReplaceCvGame_CheckPlayerTurnDeactivate);
Code
1580// Check to see if the player's turn should be deactivated.1581// This occurs when the player has set its EndTurn and its AutoMoves to true1582// and all activity has been completed.1583void CvGame::CheckPlayerTurnDeactivate()1584{1585 for(int iI = 0; iI < MAX_PLAYERS; iI++)1586 {1587 CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iI);15881589 if(kPlayer.isAlive() && kPlayer.isTurnActive())1590 {1591 if(kPlayer.isEndTurn() || (!kPlayer.isHuman() && !kPlayer.HasActiveDiplomacyRequests())) // For some reason, AI players don't set EndTurn, why not?1592 {1593 if(kPlayer.hasProcessedAutoMoves())1594 {1595 bool bAutoMovesComplete = false;1596 if(!(kPlayer.hasBusyUnitOrCity()))1597 {1598 bAutoMovesComplete = true;15991600 NET_MESSAGE_DEBUG_OSTR_ALWAYS("CheckPlayerTurnDeactivate() : auto-moves complete for " << kPlayer.getName());1601 }1602 else if(gDLL->HasReceivedTurnComplete(kPlayer.GetID()))1603 {1604 bAutoMovesComplete = true;1605 }16061607 if(bAutoMovesComplete)1608 {1609 kPlayer.setTurnActive(false);16101611 // Activate the next player1612 // This is not done if simultaneous turns is enabled (Networked MP).1613 // In that case, the local human is (should be) the player we just deactivated the turn for1614 // and the AI players will be activated all at once in CvGame::doTurn, once we have received1615 // all the moves from the other human players1616 if(!kPlayer.isSimultaneousTurns())1617 {1618 if((isPbem() || isHotSeat()) && kPlayer.isHuman() && countHumanPlayersAlive() > 1)1619 {1620 setHotPbemBetweenTurns(true);1621 }16221623 if(isSimultaneousTeamTurns())1624 {1625 if(!GET_TEAM(kPlayer.getTeam()).isTurnActive())1626 {1627 for(int iJ = (kPlayer.getTeam() + 1); iJ < MAX_TEAMS; iJ++)1628 {1629 CvTeam& kTeam = GET_TEAM((TeamTypes)iJ);1630 if(kTeam.isAlive() && !kTeam.isSimultaneousTurns())1631 {//this team is alive and also running sequential turns. They're up next!1632 kTeam.setTurnActive(true);1633 resetTurnTimer(false);1634 break;1635 }1636 }1637 }1638 else1639 {1640 CvString logOutput;1641 logOutput.Format("CheckPlayerTurnDeactivate(): Next sequential player not set TurnActive due to player(%i)'s team(%i) being TurnActive.", kPlayer.GetID(), kPlayer.getTeam());1642 gDLL->netMessageDebugLog(logOutput);1643 }1644 }1645 else1646 {1647 if(!GC.GetEngineUserInterface()->isDiploActive())1648 {1649 if(!isHotSeat() || kPlayer.isAlive() || !kPlayer.isHuman()) // If it is a hotseat game and the player is human and is dead, don't advance the player, we want them to get the defeat screen1650 {1651 for(int iJ = (kPlayer.GetID() + 1); iJ < MAX_PLAYERS; iJ++)1652 {1653 CvPlayer& kNextPlayer = GET_PLAYER((PlayerTypes)iJ);1654 if(kNextPlayer.isAlive() && !kNextPlayer.isSimultaneousTurns())1655 {//the player is alive and also running sequential turns. they're up!1656 if(isPbem() && kNextPlayer.isHuman())1657 {1658 if(!getPbemTurnSent())1659 {1660 gDLL->sendPbemTurn((PlayerTypes)iJ);1661 }1662 }1663 else1664 {1665 kNextPlayer.setTurnActive(true);1666 resetTurnTimer(false);1667 }1668 break;1669 }1670 }1671 }1672 }1673 else1674 {1675 // KWG: This doesn't actually do anything other than print to the debug log1676 changeNumGameTurnActive(1, std::string("Because the diplo screen is blocking I am bumping this up for player ") + getName());1677 }1678 }1679 }1680 }1681 }1682 }1683 }1684 }1685}
Calls
- CvGame::changeNumGameTurnActive(int, const std::string &)
- CvGame::countHumanPlayersAlive() const
- CvGame::getName()
- CvGame::getPbemTurnSent() const
- CvGame::isHotSeat() const
- CvGame::isPbem() const
- CvGame::isSimultaneousTeamTurns() const
- CvGame::resetTurnTimer(bool)
- CvGame::setHotPbemBetweenTurns(bool)
- CvGlobals::getDLLIFace()
- CvGlobals::GetEngineUserInterface()
- CvPlayer::GetID() const
- CvPlayer::getName() const
- CvPlayer::getTeam() const
- CvPlayer::HasActiveDiplomacyRequests() const
- CvPlayer::hasBusyUnitOrCity() const
- CvPlayer::hasProcessedAutoMoves() const
- CvPlayer::isAlive() const
- CvPlayer::isEndTurn() const
- CvPlayer::isHuman() const
- CvPlayer::isSimultaneousTurns() const
- CvPlayer::isTurnActive() const
- CvPlayer::setTurnActive(bool, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
CvString::CvStringCvString::Format- CvTeam::getTeam(TeamTypes)
- CvTeam::isAlive() const
- CvTeam::isSimultaneousTurns() const
- CvTeam::isTurnActive() const
- CvTeam::setTurnActive(bool, bool)
ICvEngineUtility1::HasReceivedTurnCompleteICvEngineUtility1::netMessageDebugLogICvEngineUtility1::sendPbemTurnICvUserInterface1::isDiploActivestd::basic_ostringstream::basic_ostringstreamstd::basic_ostringstream::strstd::basic_string::basic_stringstd::operator+std::operator<<