CvUnit::canSleep(const CvPlot *) const
- Defined in
- CvUnit.cpp, line 4602
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canSleep
Hooks
static bool BeforeCvUnit_canSleep(const CvUnit* self, const CvPlot* pPlot, bool& result);static void AfterCvUnit_canSleep(const CvUnit* self, const CvPlot* pPlot, bool& result);static bool ReplaceCvUnit_canSleep(bool (*original)(const CvUnit*, const CvPlot*), const CvUnit* self, const CvPlot* pPlot);CivRegisterBefore<CivHooks::CvUnit_canSleep>(host, &BeforeCvUnit_canSleep);CivRegisterAfter<CivHooks::CvUnit_canSleep>(host, &AfterCvUnit_canSleep);CivRegisterReplace<CivHooks::CvUnit_canSleep>(host, &ReplaceCvUnit_canSleep);
Code
4602bool CvUnit::canSleep(const CvPlot* pPlot) const4603{4604 VALIDATE_OBJECT4605 // Can't sleep if we're a Unit that can normally fortify4606 if(!noDefensiveBonus() && IsCombatUnit())4607 {4608 return false;4609 }46104611 if(isHuman() && !getFortifyTurns()) // we aren't fortified4612 {4613#if defined(MOD_GLOBAL_STACKING_RULES)4614 if(pPlot->getNumFriendlyUnitsOfType(this) > pPlot->getUnitLimit())4615#else4616 if(pPlot->getNumFriendlyUnitsOfType(this) > GC.getPLOT_UNIT_LIMIT())4617#endif4618 {4619 return false;4620 }4621 }46224623 if(isFortifyable())4624 {4625 return false;4626 }46274628 if(isWaiting())4629 {4630 return false;4631 }46324633 return true;4634}