Bazaar developer reference

CvCityConnections::ShouldConnectToOtherPlayer(PlayerTypes)

Defined in
CvCityConnections.cpp, line 575
Class
CvCityConnections
Hook name
CivHooks::CvCityConnections_ShouldConnectToOtherPlayer

Hooks

static bool BeforeCvCityConnections_ShouldConnectToOtherPlayer(CvCityConnections* self, PlayerTypes eOtherPlayer, bool& result);static void AfterCvCityConnections_ShouldConnectToOtherPlayer(CvCityConnections* self, PlayerTypes eOtherPlayer, bool& result);static bool ReplaceCvCityConnections_ShouldConnectToOtherPlayer(bool (*original)(CvCityConnections*, PlayerTypes), CvCityConnections* self, PlayerTypes eOtherPlayer);CivRegisterBefore<CivHooks::CvCityConnections_ShouldConnectToOtherPlayer>(host, &BeforeCvCityConnections_ShouldConnectToOtherPlayer);CivRegisterAfter<CivHooks::CvCityConnections_ShouldConnectToOtherPlayer>(host, &AfterCvCityConnections_ShouldConnectToOtherPlayer);CivRegisterReplace<CivHooks::CvCityConnections_ShouldConnectToOtherPlayer>(host, &ReplaceCvCityConnections_ShouldConnectToOtherPlayer);

Code

575bool CvCityConnections::ShouldConnectToOtherPlayer(PlayerTypes eOtherPlayer)576{577	bool result = false;578579	// shouldn't be able to connect to yourself580	if(m_pPlayer->GetID() == eOtherPlayer)581	{582		return false;583	}584585	if(!GET_PLAYER(eOtherPlayer).isAlive())586	{587		return false;588	}589590	if(GET_PLAYER(eOtherPlayer).isBarbarian())591	{592		return false;593	}594595	CvPlayer* pOtherPlayer = &(GET_PLAYER(eOtherPlayer));596597	// only majors and minors should connect to each other at this point.598	bool bMajorMinor = m_pPlayer->isMinorCiv() != pOtherPlayer->isMinorCiv();599	if(!bMajorMinor)600	{601		return false;602	}603604	if(m_pPlayer->isMinorCiv())605	{606		CvPlayer* pMajorCiv = pOtherPlayer;607608		// If the major is a human, don't decide a connection to a minor is desirable on their behalf609		if(pMajorCiv->isHuman())610		{611			return false;612		}613614		if(!m_pPlayer->GetMinorCivAI()->IsActiveQuestForPlayer(pMajorCiv->GetID(), MINOR_CIV_QUEST_ROUTE))615		{616			return false;617		}618619		result = true;620	}621	else // player is a major622	{623		CvPlayer* pMinorPlayer = pOtherPlayer;624		if(!pMinorPlayer->isAlive())625		{626			return false;627		}628629		// If the major is a human, don't decide a connection to a minor is desirable on their behalf630		if(m_pPlayer->isHuman())631		{632			return false;633		}634635		if(!m_pPlayer->GetDiplomacyAI()->IsWantToRouteConnectToMinor(pMinorPlayer->GetID()))636		{637			return false;638		}639640		if(!pMinorPlayer->GetMinorCivAI()->IsActiveQuestForPlayer(m_pPlayer->GetID(), MINOR_CIV_QUEST_ROUTE))641		{642			return false;643		}644645		result = true;646	}647648	return result;649}

Calls

Called by