Bazaar developer reference

CvPlayerTrade::GetTradePlotsAtPlot(const CvPlot *, bool, bool, bool)

Defined in
CvTradeClasses.cpp, line 3172
Class
CvPlayerTrade
Hook name
CivHooks::CvPlayerTrade_GetTradePlotsAtPlot

Hooks

static bool BeforeCvPlayerTrade_GetTradePlotsAtPlot(CvPlayerTrade* self, const CvPlot* pPlot, bool bFailAtFirstFound, bool bExcludingMe, bool bOnlyWar, std::vector<int>& result);static void AfterCvPlayerTrade_GetTradePlotsAtPlot(CvPlayerTrade* self, const CvPlot* pPlot, bool bFailAtFirstFound, bool bExcludingMe, bool bOnlyWar, std::vector<int>& result);static std::vector<int> ReplaceCvPlayerTrade_GetTradePlotsAtPlot(std::vector<int> (*original)(CvPlayerTrade*, const CvPlot*, bool, bool, bool), CvPlayerTrade* self, const CvPlot* pPlot, bool bFailAtFirstFound, bool bExcludingMe, bool bOnlyWar);CivRegisterBefore<CivHooks::CvPlayerTrade_GetTradePlotsAtPlot>(host, &BeforeCvPlayerTrade_GetTradePlotsAtPlot);CivRegisterAfter<CivHooks::CvPlayerTrade_GetTradePlotsAtPlot>(host, &AfterCvPlayerTrade_GetTradePlotsAtPlot);CivRegisterReplace<CivHooks::CvPlayerTrade_GetTradePlotsAtPlot>(host, &ReplaceCvPlayerTrade_GetTradePlotsAtPlot);

Code

3172std::vector<int> CvPlayerTrade::GetTradePlotsAtPlot(const CvPlot* pPlot, bool bFailAtFirstFound, bool bExcludingMe, bool bOnlyWar)3173{3174	std::vector<int> aiTradeConnectionIDs;31753176	if (pPlot == NULL)3177	{3178		return aiTradeConnectionIDs;3179	}31803181	int iX = pPlot->getX();3182	int iY = pPlot->getY();31833184	TeamTypes eMyTeam = m_pPlayer->getTeam();31853186	CvGameTrade* pTrade = GC.getGame().GetGameTrade();3187	for (uint uiConnection = 0; uiConnection < pTrade->m_aTradeConnections.size(); uiConnection++)3188	{3189		TradeConnection* pConnection = &(pTrade->m_aTradeConnections[uiConnection]);3190		if (pTrade->IsTradeRouteIndexEmpty(uiConnection))3191		{3192			continue;3193		}31943195		TeamTypes eOtherTeam = GET_PLAYER(pConnection->m_eOriginOwner).getTeam();31963197		bool bIgnore = false;3198		if (bExcludingMe && eOtherTeam == eMyTeam)3199		{3200			bIgnore = true;3201		}32023203		if (bOnlyWar && !GET_TEAM(eMyTeam).isAtWar(eOtherTeam))3204		{3205			bIgnore = true;3206		}32073208		if (bIgnore)3209		{3210			continue;3211		}32123213		for (uint ui = 0; ui < pConnection->m_aPlotList.size(); ui++)3214		{3215			if (pConnection->m_aPlotList[ui].m_iX == iX && pConnection->m_aPlotList[ui].m_iY == iY)3216			{3217				aiTradeConnectionIDs.push_back(pConnection->m_iID);3218				if (bFailAtFirstFound)3219				{3220					break;3221				}3222			}3223		}32243225		if (bFailAtFirstFound && aiTradeConnectionIDs.size() > 0)3226		{3227			break;3228		}3229	}32303231	return aiTradeConnectionIDs;	3232}

Calls

Called by