Bazaar developer reference

CvGameTrade::MoveUnit(int)

Defined in
CvTradeClasses.cpp, line 1448
Class
CvGameTrade
Hook name
CivHooks::CvGameTrade_MoveUnit

Hooks

static bool BeforeCvGameTrade_MoveUnit(CvGameTrade* self, int iIndex, bool& result);static void AfterCvGameTrade_MoveUnit(CvGameTrade* self, int iIndex, bool& result);static bool ReplaceCvGameTrade_MoveUnit(bool (*original)(CvGameTrade*, int), CvGameTrade* self, int iIndex);CivRegisterBefore<CivHooks::CvGameTrade_MoveUnit>(host, &BeforeCvGameTrade_MoveUnit);CivRegisterAfter<CivHooks::CvGameTrade_MoveUnit>(host, &AfterCvGameTrade_MoveUnit);CivRegisterReplace<CivHooks::CvGameTrade_MoveUnit>(host, &ReplaceCvGameTrade_MoveUnit);

Code

1447/// move a trade unit along its path for all its movement points1448bool CvGameTrade::MoveUnit (int iIndex) 1449{1450	CvAssertMsg(iIndex >= 0 && iIndex < (int)m_aTradeConnections.size(), "iIndex out of bounds");1451	if (iIndex < 0 || iIndex >= (int)m_aTradeConnections.size())1452	{1453		return false;1454	}14551456	TradeConnection &kTradeConnection = m_aTradeConnections[iIndex];1457	int iMoves = GET_PLAYER(kTradeConnection.m_eOriginOwner).GetTrade()->GetTradeRouteSpeed(kTradeConnection.m_eDomain);1458	for (int i = 0; i < iMoves; i++)1459	{1460		if (kTradeConnection.m_iCircuitsCompleted >= kTradeConnection.m_iCircuitsToComplete)1461		{1462			break;1463		}14641465		bool bAbleToStep = StepUnit(iIndex);1466		if (!bAbleToStep)1467		{1468			break;1469		}1470	}14711472	gDLL->TradeVisuals_UpdateRouteDirection(iIndex, kTradeConnection.m_bTradeUnitMovingForward);14731474	// Send a NULL plot move to say we are complete to the vis unit.1475	CvUnit *pkUnit = GetVis(iIndex);1476	if (pkUnit)1477	{1478		pkUnit->UnitMove(NULL, false, NULL);1479		pkUnit->setMoves(0);1480	}14811482	return true;1483}

Calls

Called by