CvPlot::isVisibleEnemyDefender(const CvUnit *) const
- Defined in
- CvPlot.cpp, line 3926
- Class
- CvPlot
- Hook name
CivHooks::CvPlot_isVisibleEnemyDefender
Hooks
static bool BeforeCvPlot_isVisibleEnemyDefender(const CvPlot* self, const CvUnit* pUnit, bool& result);static void AfterCvPlot_isVisibleEnemyDefender(const CvPlot* self, const CvUnit* pUnit, bool& result);static bool ReplaceCvPlot_isVisibleEnemyDefender(bool (*original)(const CvPlot*, const CvUnit*), const CvPlot* self, const CvUnit* pUnit);CivRegisterBefore<CivHooks::CvPlot_isVisibleEnemyDefender>(host, &BeforeCvPlot_isVisibleEnemyDefender);CivRegisterAfter<CivHooks::CvPlot_isVisibleEnemyDefender>(host, &AfterCvPlot_isVisibleEnemyDefender);CivRegisterReplace<CivHooks::CvPlot_isVisibleEnemyDefender>(host, &ReplaceCvPlot_isVisibleEnemyDefender);
Code
3926bool CvPlot::isVisibleEnemyDefender(const CvUnit* pUnit) const3927{3928 CvAssertMsg(pUnit, "Source unit must be valid");3929 const IDInfo* pUnitNode = m_units.head();3930 if(pUnit && pUnitNode)3931 {3932 TeamTypes eTeam = GET_PLAYER(pUnit->getOwner()).getTeam();3933 bool bAlwaysHostile = pUnit->isAlwaysHostile(*this);39343935 do3936 {3937 const CvUnit* pLoopUnit = GetPlayerUnit(*pUnitNode);3938 pUnitNode = m_units.next(pUnitNode);39393940 if(pLoopUnit)3941 {3942 if(pLoopUnit->IsCanDefend() && isEnemy(pLoopUnit, eTeam, bAlwaysHostile))3943 {3944 return true;3945 }3946 }3947 }3948 while(pUnitNode != NULL);3949 }39503951 return false;3952}