Bazaar developer reference

CvPlayer::setEndTurn(bool)

Defined in
CvPlayer.cpp, line 18111
Class
CvPlayer
Hook name
CivHooks::CvPlayer_setEndTurn

Hooks

static bool BeforeCvPlayer_setEndTurn(CvPlayer* self, bool bNewValue);static void AfterCvPlayer_setEndTurn(CvPlayer* self, bool bNewValue);static void ReplaceCvPlayer_setEndTurn(void (*original)(CvPlayer*, bool), CvPlayer* self, bool bNewValue);CivRegisterBefore<CivHooks::CvPlayer_setEndTurn>(host, &BeforeCvPlayer_setEndTurn);CivRegisterAfter<CivHooks::CvPlayer_setEndTurn>(host, &AfterCvPlayer_setEndTurn);CivRegisterReplace<CivHooks::CvPlayer_setEndTurn>(host, &ReplaceCvPlayer_setEndTurn);

Code

18111void CvPlayer::setEndTurn(bool bNewValue)18112{18113	CvGame& game = GC.getGame();1811418115	if(isSimultaneousTurns()18116		&& bNewValue 18117		&& game.isNetworkMultiPlayer() 18118		&& !gDLL->HasReceivedTurnAllCompleteFromAllPlayers())18119	{//When doing simultaneous turns in multiplayer, we don't want anyone to end their turn until everyone has signalled TurnAllComplete.18120		// No setting end turn to true until all the players have sent the TurnComplete network message18121		return;18122	}1812318124	// If this is a remote player in an MP match, don't18125	// honor the end of turn request if the player still18126	// has units to run the simulation for the turn18127	if(!isEndTurn() && isHuman() && GetID() != game.getActivePlayer())18128	{18129		if(hasBusyUnitOrCity() || (!gDLL->HasReceivedTurnComplete(GetID()) && hasReadyUnit()))18130		{18131			return;18132		}18133	}18134	else if(!isHuman())18135	{18136		if(hasBusyUnitOrCity())18137		{18138			return;18139		}18140	}1814118142	if(isEndTurn() != bNewValue)18143	{18144		//  If the game isn't MP and the player has queued popups force him to deal with them first18145		if(!GC.getGame().isGameMultiPlayer())18146		{18147			//if (GC.GetEngineUserInterface()->isPopupQueued())18148			//{18149			//	GC.GetEngineUserInterface()->setForcePopup(true);18150			//	return;18151			//}18152			//if (GC.GetEngineUserInterface()->isDiploOrPopupWaiting())18153			//{18154			//	return;18155			//}18156		}1815718158		CvAssertMsg(isTurnActive(), "isTurnActive is expected to be true");1815918160		m_bEndTurn = bNewValue;1816118162		if(isEndTurn())18163		{18164			if(!GC.getGame().isOption(GAMEOPTION_DYNAMIC_TURNS) && GC.getGame().isOption(GAMEOPTION_SIMULTANEOUS_TURNS))18165			{//fully simultaneous turns only run automoves after every human has moved.18166				checkRunAutoMovesForEveryone();18167			}18168			else18169			{18170				setAutoMoves(true);18171			}18172		}18173		else18174			setAutoMoves(false);18175	}18176	else18177	{18178		// This check is here for the AI.  Currently, the setEndTurn(true) never seems to get called for AI players, the automoves are just set directly18179		// Why is this?  It would be great if all players were processed the same.18180		if(!bNewValue && isAutoMoves())18181			setAutoMoves(false);18182	}18183}

Calls

Called by