CvPlayer::getProductionNeeded(UnitTypes) const
- Defined in
- CvPlayer.cpp, line 8589
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_getProductionNeeded
Hooks
static bool BeforeCvPlayer_getProductionNeeded(const CvPlayer* self, UnitTypes eUnit, int& result);static void AfterCvPlayer_getProductionNeeded(const CvPlayer* self, UnitTypes eUnit, int& result);static int ReplaceCvPlayer_getProductionNeeded(int (*original)(const CvPlayer*, UnitTypes), const CvPlayer* self, UnitTypes eUnit);CivRegisterBefore<CivHooks::CvPlayer_getProductionNeeded>(host, &BeforeCvPlayer_getProductionNeeded);CivRegisterAfter<CivHooks::CvPlayer_getProductionNeeded>(host, &AfterCvPlayer_getProductionNeeded);CivRegisterReplace<CivHooks::CvPlayer_getProductionNeeded>(host, &ReplaceCvPlayer_getProductionNeeded);
Code
8589int CvPlayer::getProductionNeeded(UnitTypes eUnit) const8590{8591 CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eUnit);85928593 CvAssertMsg(pkUnitEntry, "This should never be hit");8594 if(pkUnitEntry == NULL)8595 return 0;85968597 UnitClassTypes eUnitClass = (UnitClassTypes)pkUnitEntry->GetUnitClassType();8598 CvAssert(NO_UNITCLASS != eUnitClass);85998600 CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass);8601 CvAssert(pkUnitClassInfo);8602 if(pkUnitClassInfo == NULL)8603 return 0;86048605 int iProductionNeeded = pkUnitEntry->GetProductionCost();8606 iProductionNeeded *= 100 + getUnitClassCount(eUnitClass) * pkUnitClassInfo->getInstanceCostModifier();8607 iProductionNeeded /= 100;86088609 if(isMinorCiv())8610 {8611 iProductionNeeded *= GC.getMINOR_CIV_PRODUCTION_PERCENT();8612 iProductionNeeded /= 100;8613 }86148615 iProductionNeeded *= GC.getUNIT_PRODUCTION_PERCENT();8616 iProductionNeeded /= 100;86178618 iProductionNeeded *= GC.getGame().getGameSpeedInfo().getTrainPercent();8619 iProductionNeeded /= 100;86208621 iProductionNeeded *= GC.getGame().getStartEraInfo().getTrainPercent();8622 iProductionNeeded /= 100;86238624 if(!isHuman() && !IsAITeammateOfHuman() && !isBarbarian())8625 {8626 if(isWorldUnitClass(eUnitClass))8627 {8628 iProductionNeeded *= GC.getGame().getHandicapInfo().getAIWorldTrainPercent();8629 iProductionNeeded /= 100;8630 }8631 else8632 {8633 iProductionNeeded *= GC.getGame().getHandicapInfo().getAITrainPercent();8634 iProductionNeeded /= 100;8635 }86368637 iProductionNeeded *= std::max(0, ((GC.getGame().getHandicapInfo().getAIPerEraModifier() * GetCurrentEra()) + 100));8638 iProductionNeeded /= 100;8639 }86408641 iProductionNeeded += getUnitExtraCost(eUnitClass);86428643 return std::max(1, iProductionNeeded);8644}
Calls
- CvEraInfo::getTrainPercent() const
- CvGame::getGameSpeedInfo() const
- CvGame::getHandicapInfo() const
- CvGame::getStartEraInfo() const
- CvGameSpeedInfo::getTrainPercent() const
- CvGlobals::getGame()
- CvGlobals::getMINOR_CIV_PRODUCTION_PERCENT()
- CvGlobals::getUNIT_PRODUCTION_PERCENT()
- CvGlobals::getUnitClassInfo(UnitClassTypes)
- CvGlobals::getUnitInfo(UnitTypes)
- CvHandicapInfo::getAIPerEraModifier() const
- CvHandicapInfo::getAITrainPercent() const
- CvHandicapInfo::getAIWorldTrainPercent() const
- CvPlayer::GetCurrentEra() const
- CvPlayer::getUnitClassCount(UnitClassTypes) const
- CvPlayer::getUnitExtraCost(UnitClassTypes) const
- CvPlayer::IsAITeammateOfHuman() const
- CvPlayer::isBarbarian() const
- CvPlayer::isHuman() const
- CvPlayer::isMinorCiv() const
- CvUnitClassInfo::getInstanceCostModifier() const
- CvUnitEntry::GetProductionCost() const
- CvUnitEntry::GetUnitClassType() const
- isWorldUnitClass(UnitClassTypes)
std::max