CvUnit::canEnterTerritory(TeamTypes, bool, bool, bool) const
- Defined in
- CvUnit.cpp, line 2550
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canEnterTerritory
Hooks
static bool BeforeCvUnit_canEnterTerritory(const CvUnit* self, TeamTypes eTeam, bool bIgnoreRightOfPassage, bool bIsCity, bool bIsDeclareWarMove, bool& result);static void AfterCvUnit_canEnterTerritory(const CvUnit* self, TeamTypes eTeam, bool bIgnoreRightOfPassage, bool bIsCity, bool bIsDeclareWarMove, bool& result);static bool ReplaceCvUnit_canEnterTerritory(bool (*original)(const CvUnit*, TeamTypes, bool, bool, bool), const CvUnit* self, TeamTypes eTeam, bool bIgnoreRightOfPassage, bool bIsCity, bool bIsDeclareWarMove);CivRegisterBefore<CivHooks::CvUnit_canEnterTerritory>(host, &BeforeCvUnit_canEnterTerritory);CivRegisterAfter<CivHooks::CvUnit_canEnterTerritory>(host, &AfterCvUnit_canEnterTerritory);CivRegisterReplace<CivHooks::CvUnit_canEnterTerritory>(host, &ReplaceCvUnit_canEnterTerritory);
Code
2550bool CvUnit::canEnterTerritory(TeamTypes eTeam, bool bIgnoreRightOfPassage, bool bIsCity, bool bIsDeclareWarMove) const2551{2552 VALIDATE_OBJECT25532554 if(eTeam == NO_TEAM)2555 {2556 return true;2557 }25582559 TeamTypes eMyTeam = GET_PLAYER(getOwner()).getTeam();25602561 CvTeam& kMyTeam = GET_TEAM(eMyTeam);2562 CvTeam& kTheirTeam = GET_TEAM(eTeam);25632564#if defined(MOD_GLOBAL_CS_OVERSEAS_TERRITORY)2565 CvTeam* pTheirTeam = &kTheirTeam;2566#endif25672568 if(kMyTeam.isFriendlyTerritory(eTeam))2569 {2570 return true;2571 }25722573 if(isEnemy(eTeam))2574 {2575 return true;2576 }25772578 if(isRivalTerritory())2579 {2580 return true;2581 }25822583 if(kTheirTeam.isMinorCiv())2584 {2585 // Minors can't intrude into one another's territory2586 if(!kMyTeam.isMinorCiv())2587 {2588 // If we haven't yet met the Minor we can move in2589 // Do we need to do anything special here for human VS AI civs? AIs might get confused2590 if(!kMyTeam.isHasMet(eTeam))2591 {2592 return true;2593 }25942595 if(bIsCity && bIsDeclareWarMove)2596 {2597 return false;2598 }25992600#if defined(MOD_GLOBAL_CS_OVERSEAS_TERRITORY)2601 CvMinorCivAI* pMinorAI = GET_PLAYER(kTheirTeam.getLeaderID()).GetMinorCivAI();2602 PlayerTypes eMinorAlly = pMinorAI->GetAlly();26032604 // If the minor is allied, treat the plot as being owned by their ally2605 if (MOD_GLOBAL_CS_OVERSEAS_TERRITORY && eMinorAlly != NO_PLAYER) {2606 if (eMinorAlly == getOwner()) {2607 return true;2608 }26092610 pTheirTeam = &GET_TEAM(GET_PLAYER(eMinorAlly).getTeam());2611 } else {2612#endif2613 // The remaining checks are only for AI major vs. AI Minor, humans can always enter a minor's territory.2614 if (isHuman())2615 return true;26162617#if !defined(MOD_GLOBAL_CS_OVERSEAS_TERRITORY)2618 CvMinorCivAI* pMinorAI = GET_PLAYER(kTheirTeam.getLeaderID()).GetMinorCivAI();2619#endif26202621 // Is this an excluded unit that doesn't cause anger?2622 bool bAngerFreeUnit = IsAngerFreeUnit();2623 // Player can earn Open Borders with enough Friendship2624 bool bHasOpenBorders = pMinorAI->IsPlayerHasOpenBorders(getOwner());2625 // If already intruding on this minor, okay to do it some more2626 bool bIntruding = pMinorAI->IsMajorIntruding(getOwner());26272628 if(bAngerFreeUnit || bHasOpenBorders || bIntruding)2629 {2630 return true;2631 }2632#if defined(MOD_GLOBAL_CS_OVERSEAS_TERRITORY)2633 }2634#endif2635 }2636 }26372638 if(!bIgnoreRightOfPassage)2639 {2640#if defined(MOD_GLOBAL_CS_OVERSEAS_TERRITORY)2641 if(pTheirTeam->IsAllowsOpenBordersToTeam(eMyTeam))2642#else2643 if(kTheirTeam.IsAllowsOpenBordersToTeam(eMyTeam))2644#endif2645 {2646 return true;2647 }2648 }26492650 return false;2651}
Calls
- CustomMods::isGLOBAL_CS_OVERSEAS_TERRITORY()
- CvMinorCivAI::GetAlly() const
- CvMinorCivAI::IsMajorIntruding(PlayerTypes) const
- CvMinorCivAI::IsPlayerHasOpenBorders(PlayerTypes)
- CvPlayer::GetMinorCivAI() const
- CvPlayer::getTeam() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::getLeaderID() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::IsAllowsOpenBordersToTeam(TeamTypes) const
- CvTeam::isFriendlyTerritory(TeamTypes) const
- CvTeam::isHasMet(TeamTypes) const
- CvTeam::isMinorCiv() const
- CvUnit::getOwner() const
- CvUnit::IsAngerFreeUnit() const
- CvUnit::isEnemy(TeamTypes, const CvPlot *) const
- CvUnit::isHuman() const
- CvUnit::isRivalTerritory() const
Called by
- IgnoreUnitsDestValid(int, int, const void *, CvAStar *)
- IgnoreUnitsValid(CvAStarNode *, CvAStarNode *, int, const void *, CvAStar *)
- CvPlayer::receiveGoody(CvPlot *, GoodyTypes, CvUnit *)
- CvPlot::verifyUnitValidPlot()
- CvTacticalAI::PlotSingleHexOperationMoves(CvAIEscortedOperation *)
- CvUnit::GetBullyMinorMove(const CvPlot *) const
- CvUnit::GetDeclareWarMove(const CvPlot &) const
- CvUnit::canEnterTerrain(const CvPlot &, byte) const
- CvUnit::canMoveInto(const CvPlot &, byte) const
- CvUnit::jumpToNearestValidPlot()
- CvUnit::jumpToNearestValidPlotWithinRange(int)
- CvLuaUnit::lCanEnterTerritory(lua_State *)