CvPlot::getNumVisiblePotentialEnemyDefenders(const CvUnit *) const
- Defined in
- CvPlot.cpp, line 4040
- Class
- CvPlot
- Hook name
CivHooks::CvPlot_getNumVisiblePotentialEnemyDefenders
Hooks
static bool BeforeCvPlot_getNumVisiblePotentialEnemyDefenders(const CvPlot* self, const CvUnit* pUnit, int& result);static void AfterCvPlot_getNumVisiblePotentialEnemyDefenders(const CvPlot* self, const CvUnit* pUnit, int& result);static int ReplaceCvPlot_getNumVisiblePotentialEnemyDefenders(int (*original)(const CvPlot*, const CvUnit*), const CvPlot* self, const CvUnit* pUnit);CivRegisterBefore<CivHooks::CvPlot_getNumVisiblePotentialEnemyDefenders>(host, &BeforeCvPlot_getNumVisiblePotentialEnemyDefenders);CivRegisterAfter<CivHooks::CvPlot_getNumVisiblePotentialEnemyDefenders>(host, &AfterCvPlot_getNumVisiblePotentialEnemyDefenders);CivRegisterReplace<CivHooks::CvPlot_getNumVisiblePotentialEnemyDefenders>(host, &ReplaceCvPlot_getNumVisiblePotentialEnemyDefenders);
Code
4040int CvPlot::getNumVisiblePotentialEnemyDefenders(const CvUnit* pUnit) const4041{4042 CvAssertMsg(pUnit, "Source unit must be valid");4043 const IDInfo* pUnitNode = m_units.head();4044 if(pUnit && pUnitNode)4045 {4046 int iCount = 0;4047 TeamTypes eTeam = GET_PLAYER(pUnit->getOwner()).getTeam();4048 bool bAlwaysHostile = pUnit->isAlwaysHostile(*this);40494050 do4051 {4052 const CvUnit* pLoopUnit = GetPlayerUnit(*pUnitNode);4053 pUnitNode = m_units.next(pUnitNode);40544055 if(pLoopUnit && !pLoopUnit->isInvisible(eTeam, false))4056 {4057 if(pLoopUnit->IsCanDefend() && isPotentialEnemy(pLoopUnit, eTeam, bAlwaysHostile))4058 {4059 ++iCount;4060 }4061 }4062 }4063 while(pUnitNode != NULL);4064 return iCount;4065 }40664067 return 0;4068}
Calls
- CvPlayer::getTeam() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvUnit::getOwner() const
- CvUnit::isAlwaysHostile(const CvPlot &) const
- CvUnit::IsCanDefend(const CvPlot *) const
- CvUnit::isInvisible(TeamTypes, bool, bool) const
FFastSmallFixedList::headFFastSmallFixedList::next- GetPlayerUnit(const IDInfo &)
- isPotentialEnemy(const CvUnit *, TeamTypes, bool)