Bazaar developer reference

CvGame::addPlayer(PlayerTypes, LeaderHeadTypes, CivilizationTypes)

Defined in
CvGame.cpp, line 9982
Class
CvGame
Hook name
CivHooks::CvGame_addPlayer

Hooks

static bool BeforeCvGame_addPlayer(CvGame* self, PlayerTypes eNewPlayer, LeaderHeadTypes eLeader, CivilizationTypes eCiv);static void AfterCvGame_addPlayer(CvGame* self, PlayerTypes eNewPlayer, LeaderHeadTypes eLeader, CivilizationTypes eCiv);static void ReplaceCvGame_addPlayer(void (*original)(CvGame*, PlayerTypes, LeaderHeadTypes, CivilizationTypes), CvGame* self, PlayerTypes eNewPlayer, LeaderHeadTypes eLeader, CivilizationTypes eCiv);CivRegisterBefore<CivHooks::CvGame_addPlayer>(host, &BeforeCvGame_addPlayer);CivRegisterAfter<CivHooks::CvGame_addPlayer>(host, &AfterCvGame_addPlayer);CivRegisterReplace<CivHooks::CvGame_addPlayer>(host, &ReplaceCvGame_addPlayer);

Code

9982void CvGame::addPlayer(PlayerTypes eNewPlayer, LeaderHeadTypes eLeader, CivilizationTypes eCiv)9983{9984	CvCivilizationInfo* pkCivilizationInfo = GC.getCivilizationInfo(eCiv);9985	CvCivilizationInfo* pkBarbarianCivInfo = GC.getCivilizationInfo(static_cast<CivilizationTypes>(GC.getBARBARIAN_CIVILIZATION()));99869987	if(pkCivilizationInfo == NULL || pkBarbarianCivInfo == NULL)9988	{9989		//Should never happen.9990		CvAssert(false);9991		return;9992	}99939994	PlayerColorTypes eColor = (PlayerColorTypes)pkCivilizationInfo->getDefaultPlayerColor();99959996	for(int iI = 0; iI < MAX_CIV_PLAYERS; iI++)9997	{9998		if(eColor == NO_PLAYERCOLOR || GET_PLAYER((PlayerTypes)iI).getPlayerColor() == eColor)9999		{10000			for(int iK = 0; iK < GC.GetNumPlayerColorInfos(); iK++)10001			{10002				const PlayerColorTypes ePlayerColor = static_cast<PlayerColorTypes>(iK);10003				CvPlayerColorInfo* pkPlayerColorInfo = GC.GetPlayerColorInfo(ePlayerColor);10004				if(pkPlayerColorInfo)10005				{10006					if(iK != pkBarbarianCivInfo->getDefaultPlayerColor())10007					{10008						bool bValid = true;1000910010						for(int iL = 0; iL < MAX_CIV_PLAYERS; iL++)10011						{10012							if(GET_PLAYER((PlayerTypes)iL).getPlayerColor() == ePlayerColor)10013							{10014								bValid = false;10015								break;10016							}10017						}1001810019						if(bValid)10020						{10021							eColor = ePlayerColor;10022							iI = MAX_CIV_PLAYERS;10023							break;10024						}10025					}10026				}10027			}10028		}10029	}1003010031	CvPreGame::setLeaderHead(eNewPlayer, eLeader);10032	CvPreGame::setCivilization(eNewPlayer, eCiv);10033	CvPreGame::setSlotStatus(eNewPlayer, SS_COMPUTER);10034	CvPreGame::setPlayerColor(eNewPlayer, eColor);10035	GET_PLAYER(eNewPlayer).init(eNewPlayer);10036}

Calls

Called by