Bazaar developer reference

CvUnit::canSellExoticGoods(const CvPlot *, bool) const

Defined in
CvUnit.cpp, line 7327
Class
CvUnit
Hook name
CivHooks::CvUnit_canSellExoticGoods

Hooks

static bool BeforeCvUnit_canSellExoticGoods(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static void AfterCvUnit_canSellExoticGoods(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static bool ReplaceCvUnit_canSellExoticGoods(bool (*original)(const CvUnit*, const CvPlot*, bool), const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility);CivRegisterBefore<CivHooks::CvUnit_canSellExoticGoods>(host, &BeforeCvUnit_canSellExoticGoods);CivRegisterAfter<CivHooks::CvUnit_canSellExoticGoods>(host, &AfterCvUnit_canSellExoticGoods);CivRegisterReplace<CivHooks::CvUnit_canSellExoticGoods>(host, &ReplaceCvUnit_canSellExoticGoods);

Code

7327bool CvUnit::canSellExoticGoods(const CvPlot* pPlot, bool bOnlyTestVisibility) const7328{7329	if (pPlot == NULL)7330	{7331		return false;7332	}73337334	if (getNumExoticGoods() <= 0)7335	{7336		return false;7337	}73387339	if (!bOnlyTestVisibility)7340	{7341		int iNumValidPlots = 0;7342		for (int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)7343		{7344			CvPlot* pLoopPlot = plotDirection(pPlot->getX(), pPlot->getY(), ((DirectionTypes)iI));7345			if (pLoopPlot != NULL)7346			{7347				PlayerTypes eLoopPlotOwner = pLoopPlot->getOwner();7348				if (eLoopPlotOwner != getOwner() && eLoopPlotOwner != NO_PLAYER)7349				{7350					if (!GET_TEAM(getTeam()).isAtWar(GET_PLAYER(eLoopPlotOwner).getTeam()))7351					{7352						iNumValidPlots++;7353					}7354				}7355			}7356		}73577358		if (iNumValidPlots <= 0)7359		{7360			return false;7361		}7362	}73637364	return true;7365}

Calls

Called by