IsPromotionValidForUnitCombatType(PromotionTypes, UnitTypes)
- Defined in
- CvGameCoreUtils.cpp, line 245
- Hook name
CivHooks::IsPromotionValidForUnitCombatType
Hooks
static bool BeforeIsPromotionValidForUnitCombatType(PromotionTypes ePromotion, UnitTypes eUnit, bool& result);static void AfterIsPromotionValidForUnitCombatType(PromotionTypes ePromotion, UnitTypes eUnit, bool& result);static bool ReplaceIsPromotionValidForUnitCombatType(bool (*original)(PromotionTypes, UnitTypes), PromotionTypes ePromotion, UnitTypes eUnit);CivRegisterBefore<CivHooks::IsPromotionValidForUnitCombatType>(host, &BeforeIsPromotionValidForUnitCombatType);CivRegisterAfter<CivHooks::IsPromotionValidForUnitCombatType>(host, &AfterIsPromotionValidForUnitCombatType);CivRegisterReplace<CivHooks::IsPromotionValidForUnitCombatType>(host, &ReplaceIsPromotionValidForUnitCombatType);
Code
244/// Is this a valid Promotion for the UnitCombatType?245bool IsPromotionValidForUnitCombatType(PromotionTypes ePromotion, UnitTypes eUnit)246{247 CvUnitEntry* unitInfo = GC.getUnitInfo(eUnit);248 CvPromotionEntry* promotionInfo = GC.getPromotionInfo(ePromotion);249250 if(unitInfo == NULL || promotionInfo == NULL)251 return false;252253 // No combat class (civilians)254 if(unitInfo->GetUnitCombatType() == NO_UNITCOMBAT)255 {256 return false;257 }258259 // Combat class not valid for this Promotion260#if defined(MOD_GLOBAL_PROMOTION_CLASSES)261 if(!(promotionInfo->GetUnitCombatClass(unitInfo->GetUnitPromotionType())))262#else263 if(!(promotionInfo->GetUnitCombatClass(unitInfo->GetUnitCombatType())))264#endif265 {266 return false;267 }268269 return true;270}
Calls
Called by
- isPromotionValid(PromotionTypes, UnitTypes, bool, bool)
- CvPlayer::ChangeFreePromotionCount(PromotionTypes, int)
- CvTeam::changeCanEmbarkCount(int)
- CvUnit::convert(CvUnit *, bool)
- CvUnit::initWithNameOffset(int, UnitTypes, int, UnitAITypes, PlayerTypes, int, int, DirectionTypes, bool, bool, int, int)
- CvUnit::setXY(int, int, bool, bool, bool, bool, bool)