Bazaar developer reference

CvDllGame::CanMoveUnitTo(ICvUnit1 *, ICvPlot1 *) const

Defined in
CvDllGame.cpp, line 524
Class
CvDllGame
Hook name
CivHooks::CvDllGame_CanMoveUnitTo

Hooks

static bool BeforeCvDllGame_CanMoveUnitTo(const CvDllGame* self, ICvUnit1* pUnit, ICvPlot1* pPlot, bool& result);static void AfterCvDllGame_CanMoveUnitTo(const CvDllGame* self, ICvUnit1* pUnit, ICvPlot1* pPlot, bool& result);static bool ReplaceCvDllGame_CanMoveUnitTo(bool (*original)(const CvDllGame*, ICvUnit1*, ICvPlot1*), const CvDllGame* self, ICvUnit1* pUnit, ICvPlot1* pPlot);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvDllGame_CanMoveUnitTo::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvDllGame_CanMoveUnitTo);host->RegisterHook(host->pluginIndex, CivHooks::CvDllGame_CanMoveUnitTo::ID, CIV_HOOK_AFTER, (void*)&AfterCvDllGame_CanMoveUnitTo);host->RegisterHook(host->pluginIndex, CivHooks::CvDllGame_CanMoveUnitTo::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvDllGame_CanMoveUnitTo);

Code

524bool CvDllGame::CanMoveUnitTo(ICvUnit1* pUnit, ICvPlot1* pPlot) const525{526	if(pUnit == NULL || pPlot == NULL)527	{528		return false;529	}530531	CvUnit* pkUnit = GC.UnwrapUnitPointer(pUnit);532	CvPlot* pkPlot = GC.UnwrapPlotPointer(pPlot);533534	GC.getInterfacePathFinder().SetData(pkUnit);535536	// can the unit actually walk there537	bool bCanFindPath = GC.getInterfacePathFinder().GeneratePath(pkUnit->getX(), pkUnit->getY(), pkPlot->getX(), pkPlot->getY(), MOVE_UNITS_IGNORE_DANGER | MOVE_UNITS_THROUGH_ENEMY /*iFlags*/, true/*bReuse*/);538	if(!bCanFindPath)539	{540		return false;541	}542543	CvAStarNode* pNode = GC.getInterfacePathFinder().GetLastNode();544	FAssertMsg(pNode, "Invalid node. What?");545	if(!pNode)546	{547		return false;548	}549550	// move is too far away551	if(pNode->m_iData2 >= 2)552	{553		return false;554	}555556	return true;557}

Calls