CvCity::GetPurchaseCost(UnitTypes)
- Defined in
- CvCity.cpp, line 4989
- Class
- CvCity
- Hook name
CivHooks::CvCity_GetPurchaseCost
Hooks
static bool BeforeCvCity_GetPurchaseCost(CvCity* self, UnitTypes eUnit, int& result);static void AfterCvCity_GetPurchaseCost(CvCity* self, UnitTypes eUnit, int& result);static int ReplaceCvCity_GetPurchaseCost(int (*original)(CvCity*, UnitTypes), CvCity* self, UnitTypes eUnit);CivRegisterBefore<CivHooks::CvCity_GetPurchaseCost>(host, &BeforeCvCity_GetPurchaseCost);CivRegisterAfter<CivHooks::CvCity_GetPurchaseCost>(host, &AfterCvCity_GetPurchaseCost);CivRegisterReplace<CivHooks::CvCity_GetPurchaseCost>(host, &ReplaceCvCity_GetPurchaseCost);
Code
4989int CvCity::GetPurchaseCost(UnitTypes eUnit)4990{4991 VALIDATE_OBJECT49924993 CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit);4994 if(pkUnitInfo == NULL)4995 {4996 //Should never happen4997 return 0;4998 }49995000 int iModifier = pkUnitInfo->GetHurryCostModifier();50015002 bool bIsSpaceshipPart = pkUnitInfo->GetSpaceshipProject() != NO_PROJECT;50035004 if (iModifier == -1 && (!bIsSpaceshipPart || !GET_PLAYER(getOwner()).IsEnablesSSPartPurchase()))5005 {5006 return -1;5007 }50085009 int iCost = GetPurchaseCostFromProduction(getProductionNeeded(eUnit));5010 iCost *= (100 + iModifier);5011 iCost /= 100;50125013 // Cost of purchasing units modified?5014 iCost *= (100 + GET_PLAYER(getOwner()).GetUnitPurchaseCostModifier());5015 iCost /= 100;50165017 // Make the number not be funky5018 int iDivisor = /*10*/ GC.getGOLD_PURCHASE_VISIBLE_DIVISOR();5019 iCost /= iDivisor;5020 iCost *= iDivisor;50215022 return iCost;5023}
Calls
- CvCity::getOwner() const
- CvCity::getProductionNeeded(UnitTypes) const
- CvCity::GetPurchaseCostFromProduction(int)
- CvGlobals::getGOLD_PURCHASE_VISIBLE_DIVISOR()
- CvGlobals::getUnitInfo(UnitTypes)
- CvPlayer::GetUnitPurchaseCostModifier() const
- CvPlayer::IsEnablesSSPartPurchase() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvUnitEntry::GetHurryCostModifier() const
- CvUnitEntry::GetSpaceshipProject() const