CvUnit::canChangeTradeUnitHomeCityAt(const CvPlot *, int, int) const
- Defined in
- CvUnit.cpp, line 6857
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canChangeTradeUnitHomeCityAt
Hooks
static bool BeforeCvUnit_canChangeTradeUnitHomeCityAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, bool& result);static void AfterCvUnit_canChangeTradeUnitHomeCityAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, bool& result);static bool ReplaceCvUnit_canChangeTradeUnitHomeCityAt(bool (*original)(const CvUnit*, const CvPlot*, int, int), const CvUnit* self, const CvPlot* pPlot, int iX, int iY);CivRegisterBefore<CivHooks::CvUnit_canChangeTradeUnitHomeCityAt>(host, &BeforeCvUnit_canChangeTradeUnitHomeCityAt);CivRegisterAfter<CivHooks::CvUnit_canChangeTradeUnitHomeCityAt>(host, &AfterCvUnit_canChangeTradeUnitHomeCityAt);CivRegisterReplace<CivHooks::CvUnit_canChangeTradeUnitHomeCityAt>(host, &ReplaceCvUnit_canChangeTradeUnitHomeCityAt);
Code
6857bool CvUnit::canChangeTradeUnitHomeCityAt(const CvPlot* pPlot, int iX, int iY) const6858{6859 if (!canChangeTradeUnitHomeCity(pPlot))6860 {6861 return false;6862 }68636864 if (pPlot == NULL)6865 {6866 return false;6867 }68686869 CvCity* pFromCity = pPlot->getPlotCity();6870 if (pFromCity == NULL)6871 {6872 return false;6873 }68746875 // you must launch a trade mission from one of your own cities6876 if (pFromCity->getOwner() != getOwner())6877 {6878 return false;6879 }68806881 CvPlot* pToPlot = GC.getMap().plot(iX, iY);68826883 // Null plot...6884 if(pToPlot == NULL)6885 {6886 return false;6887 }68886889 // Same plot...6890 if(pToPlot == pPlot)6891 {6892 return false;6893 }68946895 CvCity* pToCity = pToPlot->getPlotCity();6896 if (pToCity == NULL)6897 {6898 return false;6899 }69006901 // can't change cities with a city you don't own6902 if (pToCity->getOwner() != getOwner())6903 {6904 return false;6905 }69066907 if (getDomainType() == DOMAIN_SEA)6908 {6909#if defined(MOD_BUGFIX_MINOR)6910 // The path finder permits routes between cities on lakes,6911 // so we'd better allow cargo ships to be relocated there!6912 if (!pToCity->isCoastal(0))6913#else6914 if (!pToCity->isCoastal())6915#endif6916 {6917 return false;6918 }6919 }69206921 return true;6922}