Bazaar developer reference

CvUnit::plunderTradeRoute()

Defined in
CvUnit.cpp, line 7113
Class
CvUnit
Hook name
CivHooks::CvUnit_plunderTradeRoute

Hooks

static bool BeforeCvUnit_plunderTradeRoute(CvUnit* self, bool& result);static void AfterCvUnit_plunderTradeRoute(CvUnit* self, bool& result);static bool ReplaceCvUnit_plunderTradeRoute(bool (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_plunderTradeRoute>(host, &BeforeCvUnit_plunderTradeRoute);CivRegisterAfter<CivHooks::CvUnit_plunderTradeRoute>(host, &AfterCvUnit_plunderTradeRoute);CivRegisterReplace<CivHooks::CvUnit_plunderTradeRoute>(host, &ReplaceCvUnit_plunderTradeRoute);

Code

7113bool CvUnit::plunderTradeRoute()7114{7115	CvPlot* pPlot = plot();7116	if (!canPlunderTradeRoute(pPlot, false))7117	{7118		return false;7119	}71207121	std::vector<int> aiTradeUnitsAtPlot;7122#if defined(MOD_BUGFIX_USE_GETTERS)7123	CvPlayerTrade* pTrade = GET_MY_PLAYER().GetTrade();7124#else7125	CvPlayerTrade* pTrade = GET_PLAYER(m_eOwner).GetTrade();7126#endif7127	aiTradeUnitsAtPlot = pTrade->GetOpposingTradeUnitsAtPlot(pPlot, false);7128	CvAssertMsg(aiTradeUnitsAtPlot.size() > 0, "aiTradeUnitsAtPlot is empty. Earlier check should have verified that this can't be the case");7129	if (aiTradeUnitsAtPlot.size() <= 0)7130	{7131		return false;7132	}71337134	// right now, plunder the first unit7135#if defined(MOD_API_EXTENSIONS)7136	pTrade->PlunderTradeRoute(aiTradeUnitsAtPlot[0], this);7137#else7138	pTrade->PlunderTradeRoute(aiTradeUnitsAtPlot[0]);7139#endif7140	return true;7141}

Calls

Called by