CvUnit::canPromote(PromotionTypes, int) const
- Defined in
- CvUnit.cpp, line 10628
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canPromote
Hooks
static bool BeforeCvUnit_canPromote(const CvUnit* self, PromotionTypes ePromotion, int iLeaderUnitId, bool& result);static void AfterCvUnit_canPromote(const CvUnit* self, PromotionTypes ePromotion, int iLeaderUnitId, bool& result);static bool ReplaceCvUnit_canPromote(bool (*original)(const CvUnit*, PromotionTypes, int), const CvUnit* self, PromotionTypes ePromotion, int iLeaderUnitId);CivRegisterBefore<CivHooks::CvUnit_canPromote>(host, &BeforeCvUnit_canPromote);CivRegisterAfter<CivHooks::CvUnit_canPromote>(host, &AfterCvUnit_canPromote);CivRegisterReplace<CivHooks::CvUnit_canPromote>(host, &ReplaceCvUnit_canPromote);
Code
10628bool CvUnit::canPromote(PromotionTypes ePromotion, int iLeaderUnitId) const10629{10630 VALIDATE_OBJECT10631 if(iLeaderUnitId >= 0)10632 {10633 if(iLeaderUnitId == GetID())10634 {10635 return false;10636 }1063710638 // The command is always possible if it's coming from a Warlord unit that gives just experience points10639 UnitHandle pWarlord = GET_PLAYER(getOwner()).getUnit(iLeaderUnitId);10640 if(pWarlord &&10641 NO_UNIT != pWarlord->getUnitType() &&10642 pWarlord->getUnitInfo().GetLeaderExperience() > 0 &&10643 NO_PROMOTION == pWarlord->getUnitInfo().GetLeaderPromotion() &&10644 canAcquirePromotionAny())10645 {10646 return true;10647 }10648 }1064910650 if(ePromotion == NO_PROMOTION)10651 {10652 return false;10653 }1065410655 CvPromotionEntry* pkPromotionInfo = GC.getPromotionInfo(ePromotion);10656 if(pkPromotionInfo == NULL)10657 {10658 return false;10659 }1066010661 if(!canAcquirePromotion(ePromotion))10662 {10663 return false;10664 }1066510666 if(pkPromotionInfo->IsLeader())10667 {10668 if(iLeaderUnitId >= 0)10669 {10670 UnitHandle pWarlord = GET_PLAYER(getOwner()).getUnit(iLeaderUnitId);10671 if(pWarlord && NO_UNIT != pWarlord->getUnitType())10672 {10673 return (pWarlord->getUnitInfo().GetLeaderPromotion() == ePromotion);10674 }10675 }10676 return false;10677 }10678 else10679 {10680 if(!isPromotionReady())10681 {10682 return false;10683 }10684 }1068510686 return true;10687}
Calls
- CvGlobals::getPromotionInfo(PromotionTypes)
- CvPlayer::getUnit(int)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPromotionEntry::IsLeader() const
- CvUnit::canAcquirePromotion(PromotionTypes) const
- CvUnit::canAcquirePromotionAny() const
- CvUnit::GetID() const
- CvUnit::getOwner() const
- CvUnit::getUnitInfo() const
- CvUnit::getUnitType() const
- CvUnit::isPromotionReady() const
- CvUnitEntry::GetLeaderExperience() const
- CvUnitEntry::GetLeaderPromotion() const
FObjectHandle::FObjectHandleFObjectHandle::operator boolFObjectHandle::operator->