CvUnit::IsHasNoValidMove() const
- Defined in
- CvUnit.cpp, line 15457
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_IsHasNoValidMove
Hooks
static bool BeforeCvUnit_IsHasNoValidMove(const CvUnit* self, bool& result);static void AfterCvUnit_IsHasNoValidMove(const CvUnit* self, bool& result);static bool ReplaceCvUnit_IsHasNoValidMove(bool (*original)(const CvUnit*), const CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_IsHasNoValidMove>(host, &BeforeCvUnit_IsHasNoValidMove);CivRegisterAfter<CivHooks::CvUnit_IsHasNoValidMove>(host, &AfterCvUnit_IsHasNoValidMove);CivRegisterReplace<CivHooks::CvUnit_IsHasNoValidMove>(host, &ReplaceCvUnit_IsHasNoValidMove);
Code
15457bool CvUnit::IsHasNoValidMove() const15458{15459#if defined(MOD_GLOBAL_STACKING_RULES)15460 if(plot()->getNumFriendlyUnitsOfType(this) <= plot()->getUnitLimit())15461#else15462 if(plot()->getNumFriendlyUnitsOfType(this) <= GC.getPLOT_UNIT_LIMIT())15463#endif15464 {15465 return false;15466 }1546715468 CvTwoLayerPathFinder& thePathfinder = GC.getPathFinder();1546915470 // change the unit pathfinder to use these funcs instead15471 thePathfinder.SetDestValidFunc(NULL);15472 thePathfinder.SetIsPathDestFunc(FindValidDestinationDest);15473 thePathfinder.SetValidFunc(FindValidDestinationPathValid);1547415475 // call the pathfinder15476 bool bCanFindPath = thePathfinder.GenerateUnitPath(this, getX(), getY(), -1, -1, 0, false);1547715478 // change the unit pathfinder back15479 thePathfinder.SetDestValidFunc(PathDestValid);15480 thePathfinder.SetIsPathDestFunc(PathDest);15481 thePathfinder.SetValidFunc(PathValid);15482 thePathfinder.ForceReset();1548315484 return !bCanFindPath;15485}
Calls
- CvAStar::ForceReset()
- CvAStar::SetDestValidFunc(CvAPointFunc)
- CvAStar::SetIsPathDestFunc(CvAPointFunc)
- CvAStar::SetValidFunc(CvAStarFunc)
- CvGlobals::getPathFinder()
- CvPlot::getNumFriendlyUnitsOfType(const CvUnit *, bool) const
- CvPlot::getUnitLimit() const
- CvTwoLayerPathFinder::GenerateUnitPath(const CvUnit *, int, int, int, int, int, bool)
- CvUnit::getX() const
- CvUnit::getY() const
- CvUnit::plot() const
- FindValidDestinationDest(int, int, const void *, CvAStar *)
- FindValidDestinationPathValid(CvAStarNode *, CvAStarNode *, int, const void *, CvAStar *)
- PathDest(int, int, const void *, CvAStar *)
- PathDestValid(int, int, const void *, CvAStar *)
- PathValid(CvAStarNode *, CvAStarNode *, int, const void *, CvAStar *)