CvGame::updateTestEndTurn()
- Defined in
- CvGame.cpp, line 2009
- Class
- CvGame
- Hook name
CivHooks::CvGame_updateTestEndTurn
Hooks
static bool BeforeCvGame_updateTestEndTurn(CvGame* self);static void AfterCvGame_updateTestEndTurn(CvGame* self);static void ReplaceCvGame_updateTestEndTurn(void (*original)(CvGame*), CvGame* self);CivRegisterBefore<CivHooks::CvGame_updateTestEndTurn>(host, &BeforeCvGame_updateTestEndTurn);CivRegisterAfter<CivHooks::CvGame_updateTestEndTurn>(host, &AfterCvGame_updateTestEndTurn);CivRegisterReplace<CivHooks::CvGame_updateTestEndTurn>(host, &ReplaceCvGame_updateTestEndTurn);
Code
2009void CvGame::updateTestEndTurn()2010{2011 PlayerTypes activePlayerID = getActivePlayer();2012 CvPlayer& activePlayer = GET_PLAYER(activePlayerID);20132014 ICvUserInterface2* pkIface = GC.GetEngineUserInterface();2015 if(pkIface != NULL)2016 {2017 bool automaticallyEndTurns = (isGameMultiPlayer())? pkIface->IsMPAutoEndTurnEnabled() : pkIface->IsSPAutoEndTurnEnabled();2018 if(automaticallyEndTurns && s_unitMoveTurnSlice != 0)2019 automaticallyEndTurns = s_unitMoveTurnSlice + 10 < getTurnSlice();20202021 if(automaticallyEndTurns)2022 {2023 bool hasSelection = false;20242025 auto_ptr<ICvUnit1> pDllHeadSelectedUnit(pkIface->GetHeadSelectedUnit());2026 if(pDllHeadSelectedUnit.get() != NULL)2027 {2028 hasSelection = pDllHeadSelectedUnit->IsSelected();2029 }20302031 if(!hasSelection && !pkIface->waitingForRemotePlayers())2032 {2033 if(m_endTurnTimerSemaphore < 1)2034 {2035 if(pkIface->canEndTurn() && gDLL->allAICivsProcessedThisTurn() && allUnitAIProcessed() && !gDLL->HasSentTurnComplete())2036 {2037#if !defined(NO_ACHIEVEMENTS)2038 activePlayer.GetPlayerAchievements().EndTurn();2039#endif2040 gDLL->sendTurnComplete();2041#if !defined(NO_ACHIEVEMENTS)2042 CvAchievementUnlocker::EndTurn();2043#endif2044 m_endTurnTimer.Start();2045 }2046 }2047 }2048 }2049 }20502051 if(activePlayer.isTurnActive())2052 {2053 // check notifications2054 EndTurnBlockingTypes eEndTurnBlockingType = NO_ENDTURN_BLOCKING_TYPE;2055 int iNotificationIndex = -1;2056 activePlayer.GetNotifications()->GetEndTurnBlockedType(eEndTurnBlockingType, iNotificationIndex);20572058 if(eEndTurnBlockingType == NO_ENDTURN_BLOCKING_TYPE)2059 {2060 // No notifications are blocking, check units/cities2061 if(activePlayer.hasPromotableUnit() && !GC.getGame().isOption(GAMEOPTION_PROMOTION_SAVING))2062 {2063 eEndTurnBlockingType = ENDTURN_BLOCKING_UNIT_PROMOTION;2064 }2065 else if(activePlayer.hasReadyUnit())2066 {2067 const CvUnit* pUnit = activePlayer.GetFirstReadyUnit();2068 CvAssertMsg(pUnit, "GetFirstReadyUnit is returning null");2069 if(pUnit)2070 {2071 if(!pUnit->canHold(pUnit->plot()))2072 {2073 eEndTurnBlockingType = ENDTURN_BLOCKING_STACKED_UNITS;2074 }2075 else2076 {2077 eEndTurnBlockingType = ENDTURN_BLOCKING_UNITS;2078 }2079 }2080 }2081 }20822083 if(eEndTurnBlockingType == NO_ENDTURN_BLOCKING_TYPE)2084 {2085 if(!(activePlayer.hasBusyUnitOrCity()) && !(activePlayer.hasReadyUnit()))2086 {2087 // JAR - Looks like popups are pretty much disabled at this point, this check will break2088 // multiplayer games. Look at revision #27 to resurrect the old popup check code if/when2089 // they are implemented again.2090 if(!isGameMultiPlayer())2091 {2092 if((activePlayer.isOption(PLAYEROPTION_WAIT_END_TURN) && !isGameMultiPlayer()) || !(GC.GetEngineUserInterface()->isHasMovedUnit()) || isHotSeat() || isPbem())2093 {2094 GC.GetEngineUserInterface()->setCanEndTurn(true);2095 }2096 }2097 else2098 {2099 if(activePlayer.hasAutoUnit() && !m_sentAutoMoves)2100 {2101 if(!(gDLL->shiftKey()))2102 {2103 gDLL->sendAutoMoves();2104 m_sentAutoMoves = true;2105 }2106 }2107 else2108 {2109 if((activePlayer.isOption(PLAYEROPTION_WAIT_END_TURN) && !isGameMultiPlayer()) || !(GC.GetEngineUserInterface()->isHasMovedUnit()) || isHotSeat() || isPbem())2110 {2111 GC.GetEngineUserInterface()->setCanEndTurn(true);2112 }2113 else2114 {2115 if(GC.GetEngineUserInterface()->getEndTurnCounter() > 0)2116 {2117 GC.GetEngineUserInterface()->changeEndTurnCounter(-1);2118 }2119 else2120 {2121 if(!gDLL->HasSentTurnComplete() && gDLL->allAICivsProcessedThisTurn() && allUnitAIProcessed() && pkIface && pkIface->IsMPAutoEndTurnEnabled())2122 {2123#if !defined(NO_ACHIEVEMENTS)2124 activePlayer.GetPlayerAchievements().EndTurn();2125#endif2126 gDLL->sendTurnComplete();2127#if !defined(NO_ACHIEVEMENTS)2128 CvAchievementUnlocker::EndTurn();2129#endif2130 }21312132 GC.GetEngineUserInterface()->setEndTurnCounter(3); // XXX2133 if(isGameMultiPlayer())2134 {2135 GC.GetEngineUserInterface()->setCanEndTurn(true);2136 m_endTurnTimer.Start();2137 }2138 }2139 }2140 }2141 }2142 }2143 }21442145 activePlayer.SetEndTurnBlocking(eEndTurnBlockingType, iNotificationIndex);2146 }2147}
Calls
- CvGame::allUnitAIProcessed() const
- CvGame::getActivePlayer() const
- CvGame::getTurnSlice() const
- CvGame::isGameMultiPlayer() const
- CvGame::isHotSeat() const
- CvGame::isOption(GameOptionTypes) const
- CvGame::isPbem() const
- CvGlobals::getDLLIFace()
- CvGlobals::GetEngineUserInterface()
- CvGlobals::getGame()
- CvNotifications::GetEndTurnBlockedType(EndTurnBlockingTypes &, int &)
- CvPlayer::GetFirstReadyUnit() const
- CvPlayer::GetNotifications() const
- CvPlayer::hasAutoUnit() const
- CvPlayer::hasBusyUnitOrCity() const
- CvPlayer::hasPromotableUnit() const
- CvPlayer::hasReadyUnit() const
- CvPlayer::isOption(PlayerOptionTypes) const
- CvPlayer::isTurnActive() const
- CvPlayer::SetEndTurnBlocking(EndTurnBlockingTypes, int)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvUnit::canHold(const CvPlot *) const
- CvUnit::plot() const
FTimer::StartICvEngineUtility1::HasSentTurnCompleteICvEngineUtility1::sendAutoMovesICvEngineUtility1::sendTurnCompleteICvEngineUtility1::shiftKeyICvEngineUtility3::allAICivsProcessedThisTurnICvUnit1::IsSelectedICvUserInterface1::canEndTurnICvUserInterface1::changeEndTurnCounterICvUserInterface1::getEndTurnCounterICvUserInterface1::GetHeadSelectedUnitICvUserInterface1::isHasMovedUnitICvUserInterface1::IsMPAutoEndTurnEnabledICvUserInterface1::IsSPAutoEndTurnEnabledICvUserInterface1::setCanEndTurnICvUserInterface1::setEndTurnCounterICvUserInterface1::waitingForRemotePlayersstd::auto_ptr::auto_ptrstd::auto_ptr::getstd::auto_ptr::operator->