CvUnit::CanUpgradeInTerritory(bool) const
- Defined in
- CvUnit.cpp, line 11068
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_CanUpgradeInTerritory
Hooks
static bool BeforeCvUnit_CanUpgradeInTerritory(const CvUnit* self, bool bOnlyTestVisible, bool& result);static void AfterCvUnit_CanUpgradeInTerritory(const CvUnit* self, bool bOnlyTestVisible, bool& result);static bool ReplaceCvUnit_CanUpgradeInTerritory(bool (*original)(const CvUnit*, bool), const CvUnit* self, bool bOnlyTestVisible);CivRegisterBefore<CivHooks::CvUnit_CanUpgradeInTerritory>(host, &BeforeCvUnit_CanUpgradeInTerritory);CivRegisterAfter<CivHooks::CvUnit_CanUpgradeInTerritory>(host, &AfterCvUnit_CanUpgradeInTerritory);CivRegisterReplace<CivHooks::CvUnit_CanUpgradeInTerritory>(host, &ReplaceCvUnit_CanUpgradeInTerritory);
Code
11066#if defined(MOD_GLOBAL_CS_UPGRADES)11067/// Can this Unit upgrade with anything right now?11068bool CvUnit::CanUpgradeInTerritory(bool bOnlyTestVisible) const11069{11070 VALIDATE_OBJECT1107111072 // Show the upgrade, but don't actually allow it11073 if(!bOnlyTestVisible)11074 {11075 CvPlot* pPlot = plot();11076 const PlayerTypes kPlotOwner = pPlot->getOwner();1107711078 // Must be in territory owned by the player or by an allied militaristic City State11079 if (kPlotOwner != getOwner()) {11080 if (MOD_GLOBAL_CS_UPGRADES && kPlotOwner != NO_PLAYER) {11081 const CvPlayer& pPlotOwner = GET_PLAYER(kPlotOwner);11082 if (!(pPlotOwner.isMinorCiv() && 11083 pPlotOwner.GetMinorCivAI()->GetTrait() == MINOR_CIV_TRAIT_MILITARISTIC && 11084 pPlotOwner.GetMinorCivAI()->GetAlly() == getOwner())) {11085 return false;11086 }11087 } else {11088 return false;11089 }11090 }11091 }1109211093 return true;11094}