CvUnit::canPlunderTradeRoute(const CvPlot *, bool) const
- Defined in
- CvUnit.cpp, line 7047
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canPlunderTradeRoute
Hooks
static bool BeforeCvUnit_canPlunderTradeRoute(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static void AfterCvUnit_canPlunderTradeRoute(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static bool ReplaceCvUnit_canPlunderTradeRoute(bool (*original)(const CvUnit*, const CvPlot*, bool), const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility);CivRegisterBefore<CivHooks::CvUnit_canPlunderTradeRoute>(host, &BeforeCvUnit_canPlunderTradeRoute);CivRegisterAfter<CivHooks::CvUnit_canPlunderTradeRoute>(host, &AfterCvUnit_canPlunderTradeRoute);CivRegisterReplace<CivHooks::CvUnit_canPlunderTradeRoute>(host, &ReplaceCvUnit_canPlunderTradeRoute);
Code
7047bool CvUnit::canPlunderTradeRoute(const CvPlot* pPlot, bool bOnlyTestVisibility) const7048{7049 if (!IsCombatUnit())7050 {7051 return false;7052 }70537054 if (pPlot == NULL)7055 {7056 return false;7057 }70587059 if (isEmbarked())7060 {7061 return false;7062 }7063 7064#if defined(MOD_GLOBAL_NO_OCEAN_PLUNDERING)7065 if (MOD_GLOBAL_NO_OCEAN_PLUNDERING && pPlot->isWater() && !pPlot->isShallowWater())7066 {7067 return false;7068 }7069#endif70707071#if defined(MOD_BUGFIX_USE_GETTERS)7072 if (GET_MY_PLAYER().GetTrade()->ContainsOpposingPlayerTradeUnit(pPlot))7073#else7074 if (GET_PLAYER(m_eOwner).GetTrade()->ContainsOpposingPlayerTradeUnit(pPlot))7075#endif7076 {7077 if (!bOnlyTestVisibility)7078 {7079 std::vector<int> aiTradeUnitsAtPlot;7080 aiTradeUnitsAtPlot = GET_MY_PLAYER().GetTrade()->GetOpposingTradeUnitsAtPlot(pPlot, true);7081 if (aiTradeUnitsAtPlot.size() <= 0)7082 {7083 return false;7084 }70857086 PlayerTypes eTradeUnitOwner = GC.getGame().GetGameTrade()->GetOwnerFromID(aiTradeUnitsAtPlot[0]);7087 if (eTradeUnitOwner == NO_PLAYER)7088 {7089 // invalid TradeUnit7090 return false;7091 }70927093 TeamTypes eTeam = GET_PLAYER(eTradeUnitOwner).getTeam();7094#if defined(MOD_BUGFIX_USE_GETTERS)7095 if (!GET_TEAM(GET_MY_PLAYER().getTeam()).isAtWar(eTeam))7096#else7097 if (!GET_TEAM(GET_PLAYER(m_eOwner).getTeam()).isAtWar(eTeam))7098#endif7099 {7100 return false;7101 }7102 }71037104 return true;7105 }7106 else7107 {7108 return false;7109 }7110}
Calls
- CustomMods::isGLOBAL_NO_OCEAN_PLUNDERING()
- CvGame::GetGameTrade()
- CvGameTrade::GetOwnerFromID(int)
- CvGlobals::getGame()
- CvPlayer::getTeam() const
- CvPlayer::GetTrade() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerTrade::ContainsOpposingPlayerTradeUnit(const CvPlot *)
- CvPlayerTrade::GetOpposingTradeUnitsAtPlot(const CvPlot *, bool)
- CvPlot::isShallowWater() const
- CvPlot::isWater() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAtWar(TeamTypes) const
- CvUnit::getOwner() const
- CvUnit::IsCombatUnit() const
- CvUnit::isEmbarked() const
std::vector::operator=std::vector::operator[]std::vector::sizestd::vector::vector