CvMinorCivAI::GetBuyoutCost(PlayerTypes)
- Defined in
- CvMinorCivAI.cpp, line 8789
- Class
- CvMinorCivAI
- Hook name
CivHooks::CvMinorCivAI_GetBuyoutCost
Hooks
static bool BeforeCvMinorCivAI_GetBuyoutCost(CvMinorCivAI* self, PlayerTypes eMajor, int& result);static void AfterCvMinorCivAI_GetBuyoutCost(CvMinorCivAI* self, PlayerTypes eMajor, int& result);static int ReplaceCvMinorCivAI_GetBuyoutCost(int (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes eMajor);CivRegisterBefore<CivHooks::CvMinorCivAI_GetBuyoutCost>(host, &BeforeCvMinorCivAI_GetBuyoutCost);CivRegisterAfter<CivHooks::CvMinorCivAI_GetBuyoutCost>(host, &AfterCvMinorCivAI_GetBuyoutCost);CivRegisterReplace<CivHooks::CvMinorCivAI_GetBuyoutCost>(host, &ReplaceCvMinorCivAI_GetBuyoutCost);
Code
8789int CvMinorCivAI::GetBuyoutCost(PlayerTypes eMajor)8790{8791 CvAssertMsg(eMajor >= 0, "eMajor is expected to be non-negative (invalid Index)");8792 CvAssertMsg(eMajor < MAX_MAJOR_CIVS, "eMajor is expected to be within maximum bounds (invalid Index)");8793 if(eMajor < 0 || eMajor >= MAX_MAJOR_CIVS) return -1;87948795 int iGold = GC.getMINOR_CIV_BUYOUT_COST();87968797 // Game Speed Mod8798 iGold *= GC.getGame().getGameSpeedInfo().getGoldPercent();8799 iGold /= 100;88008801 // Add in the scrap cost of all this minor's units8802 int iScrapCost = 0;8803 int iUnitLoop;8804 CvUnit *pLoopUnit;8805 for (pLoopUnit = m_pPlayer->firstUnit(&iUnitLoop); pLoopUnit != NULL; pLoopUnit = m_pPlayer->nextUnit(&iUnitLoop))8806 {8807 iScrapCost += pLoopUnit->GetScrapGold();8808 }8809 iGold += iScrapCost;88108811 // Rounding8812 int iVisibleDivisor = /*5*/ GC.getMINOR_CIV_GOLD_GIFT_VISIBLE_DIVISOR();8813 iGold /= iVisibleDivisor;8814 iGold *= iVisibleDivisor;88158816 return iGold;8817}