Bazaar developer reference

CvTradeAI::ScoreWonderTR(const TradeConnection &, std::vector<CvCity *>)

Defined in
CvTradeClasses.cpp, line 4661
Class
CvTradeAI
Hook name
CivHooks::CvTradeAI_ScoreWonderTR

Hooks

static bool BeforeCvTradeAI_ScoreWonderTR(CvTradeAI* self, const TradeConnection& kTradeConnection, std::vector<CvCity*> aTargetCityList, int& result);static void AfterCvTradeAI_ScoreWonderTR(CvTradeAI* self, const TradeConnection& kTradeConnection, std::vector<CvCity*> aTargetCityList, int& result);static int ReplaceCvTradeAI_ScoreWonderTR(int (*original)(CvTradeAI*, const TradeConnection&, std::vector<CvCity*>), CvTradeAI* self, const TradeConnection& kTradeConnection, std::vector<CvCity*> aTargetCityList);CivRegisterBefore<CivHooks::CvTradeAI_ScoreWonderTR>(host, &BeforeCvTradeAI_ScoreWonderTR);CivRegisterAfter<CivHooks::CvTradeAI_ScoreWonderTR>(host, &AfterCvTradeAI_ScoreWonderTR);CivRegisterReplace<CivHooks::CvTradeAI_ScoreWonderTR>(host, &ReplaceCvTradeAI_ScoreWonderTR);

Code

4659#if defined(MOD_TRADE_WONDER_RESOURCE_ROUTES)4660/// Score Wonder TR4661int CvTradeAI::ScoreWonderTR (const TradeConnection& kTradeConnection, std::vector<CvCity*> aTargetCityList)4662{4663	// If it wasn't for this test, this method would be the same as ScoreProductionTR()4664	// only consider wonder trades4665	if (kTradeConnection.m_eConnectionType != TRADE_CONNECTION_WONDER_RESOURCE)4666	{4667		return 0;4668	}46694670	// if this was recently plundered, 0 the score4671	if (m_pPlayer->GetTrade()->CheckTradeConnectionWasPlundered(kTradeConnection))4672	{4673		return 0;4674	}46754676	// if we're not going to a target wonder city, ignore4677	bool bValidTarget = false;4678	for (uint ui = 0; ui < aTargetCityList.size(); ui++)4679	{4680		if (kTradeConnection.m_iDestX == aTargetCityList[ui]->getX() && kTradeConnection.m_iDestY == aTargetCityList[ui]->getY())4681		{4682			bValidTarget = true;4683			break;4684		}4685	}46864687	if (!bValidTarget)4688	{4689		return 0;4690	}46914692	int iMaxDistance = 60;4693	int iDistance = kTradeConnection.m_aPlotList.size();4694	int iDistanceScore = iMaxDistance - iDistance;4695	if (kTradeConnection.m_eDomain == DOMAIN_SEA)4696	{4697		iDistanceScore = iDistanceScore * 2;4698	}46994700	//CvPlayerTrade* pPlayerTrade = m_pPlayer->GetTrade();4701	int iDangerSum = 1; // can't be zero because we divide by zero!4702	for (uint uiPlotList = 0; uiPlotList < kTradeConnection.m_aPlotList.size(); uiPlotList++)4703	{4704		CvPlot* pPlot = GC.getMap().plot(kTradeConnection.m_aPlotList[uiPlotList].m_iX, kTradeConnection.m_aPlotList[uiPlotList].m_iY);4705		CvAssertMsg(pPlot, "pPlot is null when trying to evaluate the list");4706		if (pPlot == NULL)4707		{4708			break;4709		}4710		int iDangerValue = m_pPlayer->GetPlotDanger(*pPlot);4711		if (iDangerValue == 0)4712		{4713			if (!pPlot->isVisible(m_pPlayer->getTeam()))4714			{4715				iDangerValue += 1;4716			}47174718			if (pPlot->getTeam() != NO_TEAM && GET_TEAM(m_pPlayer->getTeam()).isAtWar(pPlot->getTeam()))4719			{4720				iDangerValue += 1000;4721			}4722		}4723		iDangerSum += iDangerValue;4724	}47254726	return iDistanceScore - iDangerSum;4727}

Calls

Called by