CvPlot::getNumDefenders(PlayerTypes) const
- Defined in
- CvPlot.cpp, line 3981
- Class
- CvPlot
- Hook name
CivHooks::CvPlot_getNumDefenders
Hooks
static bool BeforeCvPlot_getNumDefenders(const CvPlot* self, PlayerTypes ePlayer, int& result);static void AfterCvPlot_getNumDefenders(const CvPlot* self, PlayerTypes ePlayer, int& result);static int ReplaceCvPlot_getNumDefenders(int (*original)(const CvPlot*, PlayerTypes), const CvPlot* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvPlot_getNumDefenders>(host, &BeforeCvPlot_getNumDefenders);CivRegisterAfter<CivHooks::CvPlot_getNumDefenders>(host, &AfterCvPlot_getNumDefenders);CivRegisterReplace<CivHooks::CvPlot_getNumDefenders>(host, &ReplaceCvPlot_getNumDefenders);
Code
3981int CvPlot::getNumDefenders(PlayerTypes ePlayer) const3982{3983 const IDInfo* pUnitNode = m_units.head();3984 if(pUnitNode != NULL)3985 {3986 CvAssertMsg(ePlayer != NO_PLAYER, "Player must be valid");3987 int iCount = 0;39883989 do3990 {3991 const CvUnit* pLoopUnit = GetPlayerUnit(*pUnitNode);3992 pUnitNode = m_units.next(pUnitNode);39933994 if(pLoopUnit)3995 {3996 if(pLoopUnit->getOwner() == ePlayer && pLoopUnit->IsCanDefend())3997 {3998 ++iCount;3999 }4000 }4001 }4002 while(pUnitNode != NULL);4003 return iCount;4004 }40054006 return 0;4007}
Calls
- CvUnit::getOwner() const
- CvUnit::IsCanDefend(const CvPlot *) const
FFastSmallFixedList::headFFastSmallFixedList::next- GetPlayerUnit(const IDInfo &)
Called by
- CvEconomicAI::UpdatePlots()
- CvHomelandAI::ExecuteMovesToSafestPlot()
- CvHomelandAI::FindHomelandTargets()
- CvTacticalAI::ExecuteAttack(CvTacticalTarget *, CvPlot *, bool, bool)
- CvTacticalAI::ExecuteMovesToSafestPlot()
- CvTacticalAI::PlotEmergencyPurchases()
- CvTacticalAI::PlotMovesToSafety(bool)
- CvUnitCombat::GenerateMeleeCombatInfo(CvUnit &, CvUnit *, CvPlot &, CvCombatInfo *)
- CvUnitMission::AutoMission(UnitHandle)
- CvUnitMission::PushMission(UnitHandle, MissionTypes, int, int, int, bool, bool, MissionAITypes, CvPlot *, CvUnit *)
- CvLuaPlot::lGetNumDefenders(lua_State *)