CvPlot::IsActualAlliedUnit(PlayerTypes, bool) const
- Defined in
- CvPlot.cpp, line 4194
- Class
- CvPlot
- Hook name
CivHooks::CvPlot_IsActualAlliedUnit
Hooks
static bool BeforeCvPlot_IsActualAlliedUnit(const CvPlot* self, PlayerTypes ePlayer, bool bCombatUnitsOnly, bool& result);static void AfterCvPlot_IsActualAlliedUnit(const CvPlot* self, PlayerTypes ePlayer, bool bCombatUnitsOnly, bool& result);static bool ReplaceCvPlot_IsActualAlliedUnit(bool (*original)(const CvPlot*, PlayerTypes, bool), const CvPlot* self, PlayerTypes ePlayer, bool bCombatUnitsOnly);CivRegisterBefore<CivHooks::CvPlot_IsActualAlliedUnit>(host, &BeforeCvPlot_IsActualAlliedUnit);CivRegisterAfter<CivHooks::CvPlot_IsActualAlliedUnit>(host, &AfterCvPlot_IsActualAlliedUnit);CivRegisterReplace<CivHooks::CvPlot_IsActualAlliedUnit>(host, &ReplaceCvPlot_IsActualAlliedUnit);
Code
4193/// Is there an allied Unit on this Plot? (Don't care if we can actually see it or not, so be careful with this)4194bool CvPlot::IsActualAlliedUnit(PlayerTypes ePlayer, bool bCombatUnitsOnly) const4195{4196 CvPlayer& kPlayer = GET_PLAYER(ePlayer);41974198 for (int iUnitLoop = 0; iUnitLoop < getNumUnits(); iUnitLoop++) {4199 CvUnit* pkUnit = getUnitByIndex(iUnitLoop);4200 if (pkUnit) {4201 PlayerTypes eOwner = ((PlayerTypes) pkUnit->getOwner());4202 CvPlayer& kOwner = GET_PLAYER(eOwner);4203 4204 if (ePlayer == eOwner || kPlayer.getTeam() == kOwner.getTeam()) {4205 // It's our unit (or a team member's)4206 return (!bCombatUnitsOnly || pkUnit->IsCombatUnit());4207 } else {4208 // Is it an allied minor or DoF major?4209 if (kOwner.isMinorCiv() && kOwner.GetMinorCivAI()->GetAlly() == ePlayer) {4210 return (!bCombatUnitsOnly || pkUnit->IsCombatUnit());4211 } else if (!kOwner.isBarbarian() && kOwner.GetDiplomacyAI()->IsDoFAccepted(ePlayer)) {4212 return (!bCombatUnitsOnly || pkUnit->IsCombatUnit());4213 }4214 }4215 }4216 }42174218 return false;4219}
Calls
- CvDiplomacyAI::IsDoFAccepted(PlayerTypes) const
- CvMinorCivAI::GetAlly() const
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetMinorCivAI() const
- CvPlayer::getTeam() const
- CvPlayer::isBarbarian() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getNumUnits() const
- CvPlot::getUnitByIndex(int) const
- CvUnit::getOwner() const
- CvUnit::IsCombatUnit() const