Hooks
static bool BeforeCvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const(const CvPlot* self, PlayerTypes ePlayer, bool arg1, const CvUnit* pUnit, bool& result);static void AfterCvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const(const CvPlot* self, PlayerTypes ePlayer, bool arg1, const CvUnit* pUnit, bool& result);static bool ReplaceCvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const(bool (*original)(const CvPlot*, PlayerTypes, bool, const CvUnit*), const CvPlot* self, PlayerTypes ePlayer, bool arg1, const CvUnit* pUnit);CivRegisterBefore<CivHooks::CvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const>(host, &BeforeCvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const);CivRegisterAfter<CivHooks::CvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const>(host, &AfterCvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const);CivRegisterReplace<CivHooks::CvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const>(host, &ReplaceCvPlot_isFriendlyCityOrPassableImprovement_with_PlayerTypes_bool_const_CvUnit_const);
Code
3763bool CvPlot::isFriendlyCityOrPassableImprovement(PlayerTypes ePlayer, bool, const CvUnit* pUnit) const3764{3765 CvCity* pPlotCity = getPlotCity();37663767 if (!(pPlotCity || isPassableImprovement())) {3768 // Not a city or a fort3769 return false;3770 }3771 3772 if (IsFriendlyTerritory(ePlayer)) {3773 // In friendly lands (ours, an allied CS or a major with open borders)37743775#if defined(MOD_EVENTS_MINORS_INTERACTION)3776 if (MOD_EVENTS_MINORS_INTERACTION && GET_PLAYER(pPlotCity->getOwner()).isMinorCiv()) {3777 if (pUnit) {3778 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_UnitCanTransitMinorCity, ePlayer, pUnit->GetID(), pPlotCity->getOwner(), pPlotCity->GetID(), getX(), getY()) == GAMEEVENTRETURN_FALSE) {3779 return false;3780 }3781 } else {3782 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanTransitMinorCity, ePlayer, pPlotCity->getOwner(), pPlotCity->GetID(), getX(), getY()) == GAMEEVENTRETURN_FALSE) {3783 return false;3784 }3785 }3786 }3787#endif37883789 return true;3790 }37913792 if (getTeam() == NO_TEAM) {3793 TeamTypes eTeam = GET_PLAYER(ePlayer).getTeam();37943795 // In no-mans land ...3796 if (getNumUnits() == 0) {3797 return true;3798 }37993800 // ... make sure there are only friendly units here3801 const IDInfo* pUnitNode = headUnitNode();3802 while (pUnitNode != NULL) {3803 if ((pUnitNode->eOwner >= 0) && pUnitNode->eOwner < MAX_PLAYERS) {3804 CvUnit* pLoopUnit = (GET_PLAYER(pUnitNode->eOwner).getUnit(pUnitNode->iID));38053806 if (pLoopUnit && (eTeam == pLoopUnit->getTeam())) {3807 // Any friendly unit will do3808 return true;3809 }3810 }38113812 pUnitNode = nextUnitNode(pUnitNode);3813 }3814 }38153816 return false;3817}