Bazaar developer reference

CvPlot::IsActualEnemyUnit(PlayerTypes, bool, bool) const

Defined in
CvPlot.cpp, line 4158
Class
CvPlot
Hook name
CivHooks::CvPlot_IsActualEnemyUnit

Hooks

static bool BeforeCvPlot_IsActualEnemyUnit(const CvPlot* self, PlayerTypes ePlayer, bool bCombatUnitsOnly, bool bNavalUnitsOnly, bool& result);static void AfterCvPlot_IsActualEnemyUnit(const CvPlot* self, PlayerTypes ePlayer, bool bCombatUnitsOnly, bool bNavalUnitsOnly, bool& result);static bool ReplaceCvPlot_IsActualEnemyUnit(bool (*original)(const CvPlot*, PlayerTypes, bool, bool), const CvPlot* self, PlayerTypes ePlayer, bool bCombatUnitsOnly, bool bNavalUnitsOnly);CivRegisterBefore<CivHooks::CvPlot_IsActualEnemyUnit>(host, &BeforeCvPlot_IsActualEnemyUnit);CivRegisterAfter<CivHooks::CvPlot_IsActualEnemyUnit>(host, &AfterCvPlot_IsActualEnemyUnit);CivRegisterReplace<CivHooks::CvPlot_IsActualEnemyUnit>(host, &ReplaceCvPlot_IsActualEnemyUnit);

Code

4156/// Is there an enemy Unit on this Plot?  (Don't care if we can actually see it or not, so be careful with this)4157#if defined(MOD_GLOBAL_SHORT_EMBARKED_BLOCKADES)4158bool CvPlot::IsActualEnemyUnit(PlayerTypes ePlayer, bool bCombatUnitsOnly, bool bNavalUnitsOnly) const4159#else4160bool CvPlot::IsActualEnemyUnit(PlayerTypes ePlayer, bool bCombatUnitsOnly) const4161#endif4162{4163	TeamTypes eTeam = GET_PLAYER(ePlayer).getTeam();4164	CvTeam& kTeam = GET_TEAM(eTeam);41654166	for(int iUnitLoop = 0; iUnitLoop < getNumUnits(); iUnitLoop++)4167	{4168		CvUnit* pkUnit = getUnitByIndex(iUnitLoop);4169		if(pkUnit)4170		{4171			if(kTeam.isAtWar(pkUnit->getTeam()))4172			{4173				if(!bCombatUnitsOnly || pkUnit->IsCombatUnit())4174				{4175#if defined(MOD_GLOBAL_SHORT_EMBARKED_BLOCKADES)4176					if (!bNavalUnitsOnly || pkUnit->getDomainType() == DOMAIN_SEA)4177					{4178#endif4179						return true;4180#if defined(MOD_GLOBAL_SHORT_EMBARKED_BLOCKADES)4181					}4182#endif4183				}4184			}4185		}4186	}41874188	return false;4189}

Calls

Called by