Bazaar developer reference

FindValidDestinationDest(int, int, const void *, CvAStar *)

Defined in
CvAStar.cpp, line 3735
Hook name
CivHooks::FindValidDestinationDest

Hooks

static bool BeforeFindValidDestinationDest(int iToX, int iToY, const void* pointer, CvAStar* finder, int& result);static void AfterFindValidDestinationDest(int iToX, int iToY, const void* pointer, CvAStar* finder, int& result);static int ReplaceFindValidDestinationDest(int (*original)(int, int, const void*, CvAStar*), int iToX, int iToY, const void* pointer, CvAStar* finder);CivRegisterBefore<CivHooks::FindValidDestinationDest>(host, &BeforeFindValidDestinationDest);CivRegisterAfter<CivHooks::FindValidDestinationDest>(host, &AfterFindValidDestinationDest);CivRegisterReplace<CivHooks::FindValidDestinationDest>(host, &ReplaceFindValidDestinationDest);

Code

3735int FindValidDestinationDest(int iToX, int iToY, const void* pointer, CvAStar* finder)3736{3737	CvUnit* pUnit = ((CvUnit*)pointer);3738	CvPlot* pToPlot = GC.getMap().plotUnchecked(iToX, iToY);37393740#if defined(MOD_GLOBAL_STACKING_RULES)3741	if(pToPlot->getNumFriendlyUnitsOfType(pUnit) >= pToPlot->getUnitLimit())3742#else3743	if(pToPlot->getNumFriendlyUnitsOfType(pUnit) >= GC.getPLOT_UNIT_LIMIT())3744#endif3745	{3746		return false;3747	}37483749	if(pToPlot->getNumVisibleEnemyDefenders(pUnit) > 0)3750	{3751		return false;3752	}37533754	// can't capture the unit with a non-combat unit3755	if(!pUnit->IsCombatUnit() && pToPlot->isVisibleEnemyUnit(pUnit))3756	{3757		return false;3758	}37593760	return true;3761}

Calls

Called by