CvUnit::canMakeTradeRouteAt(const CvPlot *, int, int, TradeConnectionType) const
- Defined in
- CvUnit.cpp, line 6749
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canMakeTradeRouteAt
Hooks
static bool BeforeCvUnit_canMakeTradeRouteAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, TradeConnectionType eConnectionType, bool& result);static void AfterCvUnit_canMakeTradeRouteAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, TradeConnectionType eConnectionType, bool& result);static bool ReplaceCvUnit_canMakeTradeRouteAt(bool (*original)(const CvUnit*, const CvPlot*, int, int, TradeConnectionType), const CvUnit* self, const CvPlot* pPlot, int iX, int iY, TradeConnectionType eConnectionType);CivRegisterBefore<CivHooks::CvUnit_canMakeTradeRouteAt>(host, &BeforeCvUnit_canMakeTradeRouteAt);CivRegisterAfter<CivHooks::CvUnit_canMakeTradeRouteAt>(host, &AfterCvUnit_canMakeTradeRouteAt);CivRegisterReplace<CivHooks::CvUnit_canMakeTradeRouteAt>(host, &ReplaceCvUnit_canMakeTradeRouteAt);
Code
6749bool CvUnit::canMakeTradeRouteAt(const CvPlot* pPlot, int iX, int iY, TradeConnectionType eConnectionType) const6750{6751 if (!canMakeTradeRoute(pPlot))6752 {6753 return false;6754 }67556756 if (pPlot == NULL)6757 {6758 return false;6759 }67606761 CvCity* pFromCity = pPlot->getPlotCity();6762 if (pFromCity == NULL)6763 {6764 return false;6765 }67666767 // you must launch a trade mission from one of your own cities6768 if (pFromCity->getOwner() != getOwner())6769 {6770 return false;6771 }67726773 CvPlot* pToPlot = GC.getMap().plot(iX, iY);67746775 // Null plot...6776 if(pToPlot == NULL)6777 {6778 return false;6779 }67806781 // Same plot...6782 if(pToPlot == pPlot)6783 {6784 return false;6785 }67866787 CvCity* pToCity = pToPlot->getPlotCity();6788 if (pToCity == NULL)6789 {6790 return false;6791 }67926793 if (!GET_PLAYER(getOwner()).GetTrade()->CanCreateTradeRoute(pFromCity, pToCity, getDomainType(), eConnectionType, false))6794 {6795 return false;6796 }67976798 return true;6799}
Calls
- CvCity::getOwner() const
- CvGlobals::getMap()
- CvMap::plot(int, int) const
- CvPlayer::GetTrade() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerTrade::CanCreateTradeRoute(CvCity *, CvCity *, DomainTypes, TradeConnectionType, bool, bool)
- CvPlot::getPlotCity() const
- CvUnit::canMakeTradeRoute(const CvPlot *) const
- CvUnit::getDomainType() const
- CvUnit::getOwner() const
Called by
- CvTradeAI::ChooseTradeUnitTargetPlot(CvUnit *, int &, int &, TradeConnectionType &, bool &, const TradeConnectionList &)
- CvUnit::makeTradeRoute(int, int, TradeConnectionType)
- CvLuaPlayer::GetPotentialInternationalTradeRouteDestinationsHelper(lua_State *, CvPlayerAI *, CvUnit *, CvPlot *)
- CvLuaUnit::lCanMakeTradeRouteAt(lua_State *)