Bazaar developer reference

CvGame::setActivePlayer(PlayerTypes, bool, bool)

Defined in
CvGame.cpp, line 5680
Class
CvGame
Hook name
CivHooks::CvGame_setActivePlayer

Hooks

static bool BeforeCvGame_setActivePlayer(CvGame* self, PlayerTypes eNewValue, bool bForceHotSeat, bool bAutoplaySwitch);static void AfterCvGame_setActivePlayer(CvGame* self, PlayerTypes eNewValue, bool bForceHotSeat, bool bAutoplaySwitch);static void ReplaceCvGame_setActivePlayer(void (*original)(CvGame*, PlayerTypes, bool, bool), CvGame* self, PlayerTypes eNewValue, bool bForceHotSeat, bool bAutoplaySwitch);CivRegisterBefore<CivHooks::CvGame_setActivePlayer>(host, &BeforeCvGame_setActivePlayer);CivRegisterAfter<CivHooks::CvGame_setActivePlayer>(host, &AfterCvGame_setActivePlayer);CivRegisterReplace<CivHooks::CvGame_setActivePlayer>(host, &ReplaceCvGame_setActivePlayer);

Code

5680void CvGame::setActivePlayer(PlayerTypes eNewValue, bool bForceHotSeat, bool bAutoplaySwitch)5681{5682	PlayerTypes eOldActivePlayer = getActivePlayer();5683	if(eOldActivePlayer != eNewValue)5684	{5685		int iActiveNetId = ((NO_PLAYER != eOldActivePlayer) ? GET_PLAYER(eOldActivePlayer).getNetID() : -1);5686		CvPreGame::setActivePlayer(eNewValue);5687		gDLL->GameplayActivePlayerChanged(eNewValue);56885689		if(GET_PLAYER(eNewValue).isHuman() && (isHotSeat() || isPbem() || bForceHotSeat))5690		{5691			if(isHotSeat())5692			{5693				GC.GetEngineUserInterface()->setDirty(TurnTimer_DIRTY_BIT, true);5694				GC.GetEngineUserInterface()->setDirty(GameData_DIRTY_BIT, true);5695				m_sentAutoMoves = false;5696				resetTurnTimer();5697				endTurnTimerReset();5698			}56995700			gDLL->getPassword(eNewValue);5701			setHotPbemBetweenTurns(false);57025703			if(NO_PLAYER != eOldActivePlayer)5704			{5705				int iInactiveNetId = GET_PLAYER(eNewValue).getNetID();5706				GET_PLAYER(eNewValue).setNetID(iActiveNetId);5707				GET_PLAYER(eOldActivePlayer).setNetID(iInactiveNetId);5708			}57095710			if(countHumanPlayersAlive() == 1 && isPbem())5711			{5712				// Nobody else left alive5713				CvPreGame::setGameType(GAME_HOTSEAT_MULTIPLAYER);5714			}5715		}57165717		if(isHotSeat() || bForceHotSeat || bAutoplaySwitch)5718		{5719			sendPlayerOptions(true);5720		}57215722		if(GC.IsGraphicsInitialized())5723		{5724			// Publish the player change first5725			// Messages will be sent out by the updating of the fog and they do not indicate5726			// the player the update is for, so listeners will want to get the player change message first5727			gDLL->PublishActivePlayer(eNewValue, eOldActivePlayer);57285729			CvMap& theMap = GC.getMap();5730			theMap.updateFog();5731			theMap.updateVisibility();57325733			ICvUserInterface2* theUI = GC.GetEngineUserInterface();5734			theUI->setCanEndTurn(false);57355736			theUI->clearSelectedCities();5737			theUI->ClearSelectionList();57385739			theUI->setDirty(PercentButtons_DIRTY_BIT, true);5740			theUI->setDirty(ResearchButtons_DIRTY_BIT, true);5741			theUI->setDirty(GameData_DIRTY_BIT, true);5742			theUI->setDirty(MinimapSection_DIRTY_BIT, true);5743			theUI->setDirty(CityInfo_DIRTY_BIT, true);5744			theUI->setDirty(UnitInfo_DIRTY_BIT, true);57455746			//theUI->setDirty(NationalBorders_DIRTY_BIT, true);5747			theUI->setDirty(BlockadedPlots_DIRTY_BIT, true);5748		}5749	}5750}

Calls

Called by