Bazaar developer reference

AttackPathDestEval(int, int, const void *, CvAStar *, bool, bool)

Defined in
CvAStar.cpp, line 3337
Hook name
CivHooks::AttackPathDestEval

Hooks

static bool BeforeAttackPathDestEval(int iToX, int iToY, const void* pointer, CvAStar* finder, bool bOnlyFortified, bool bOnlyCity, int& result);static void AfterAttackPathDestEval(int iToX, int iToY, const void* pointer, CvAStar* finder, bool bOnlyFortified, bool bOnlyCity, int& result);static int ReplaceAttackPathDestEval(int (*original)(int, int, const void*, CvAStar*, bool, bool), int iToX, int iToY, const void* pointer, CvAStar* finder, bool bOnlyFortified, bool bOnlyCity);CivRegisterBefore<CivHooks::AttackPathDestEval>(host, &BeforeAttackPathDestEval);CivRegisterAfter<CivHooks::AttackPathDestEval>(host, &AfterAttackPathDestEval);CivRegisterReplace<CivHooks::AttackPathDestEval>(host, &ReplaceAttackPathDestEval);

Code

3337int AttackPathDestEval(int iToX, int iToY, const void* pointer, CvAStar* finder, bool bOnlyFortified, bool bOnlyCity)3338{3339	CvUnit* pUnit = ((CvUnit*)pointer);3340	CvAssertMsg(pUnit, "pUnit should be a value");3341	CvPlot* pPlot = GC.getMap().plot(iToX, iToY);3342	CvAStarNode* pNode = finder->GetLastNode();33433344	if(pPlot->isVisible(pUnit->getTeam()) && (pPlot->isVisibleEnemyUnit(pUnit) || pPlot->isEnemyCity(*pUnit)) && pNode && pNode->m_iData2 < 2)3345	{3346		if (pUnit->canMoveInto(*pPlot, CvUnit::MOVEFLAG_ATTACK))3347		{3348			if(bOnlyFortified)3349			{3350				CvUnit* pEnemyUnit = pPlot->getVisibleEnemyDefender(pUnit->getOwner());3351				if(pEnemyUnit && pEnemyUnit->IsFortifiedThisTurn())3352				{3353					return TRUE;3354				}3355			}3356			else if(bOnlyCity)3357			{3358				if(pPlot->isEnemyCity(*pUnit))3359				{3360					return TRUE;3361				}3362			}3363			else3364			{3365				return TRUE;3366			}3367		}3368	}33693370	return FALSE;3371}

Calls

Called by