CvPlayerTechs::GetResearchCost(TechTypes) const
- Defined in
- CvTechClasses.cpp, line 1520
- Class
- CvPlayerTechs
- Hook name
CivHooks::CvPlayerTechs_GetResearchCost
Hooks
static bool BeforeCvPlayerTechs_GetResearchCost(const CvPlayerTechs* self, TechTypes eTech, int& result);static void AfterCvPlayerTechs_GetResearchCost(const CvPlayerTechs* self, TechTypes eTech, int& result);static int ReplaceCvPlayerTechs_GetResearchCost(int (*original)(const CvPlayerTechs*, TechTypes), const CvPlayerTechs* self, TechTypes eTech);CivRegisterBefore<CivHooks::CvPlayerTechs_GetResearchCost>(host, &BeforeCvPlayerTechs_GetResearchCost);CivRegisterAfter<CivHooks::CvPlayerTechs_GetResearchCost>(host, &AfterCvPlayerTechs_GetResearchCost);CivRegisterReplace<CivHooks::CvPlayerTechs_GetResearchCost>(host, &ReplaceCvPlayerTechs_GetResearchCost);
Code
1518/// Return the research cost for a tech for this player. This will be different from the team research cost as it will1519/// include the player's research adjustment1520int CvPlayerTechs::GetResearchCost(TechTypes eTech) const1521{1522 // Get the research cost for the team1523#if defined(MOD_BUGFIX_RESEARCH_NAN)1524 // For late game eras with many cities, *10000 and *(100+iMod) in the code below can overflow a 32-bit int1525 long long iResearchCost = GET_TEAM(m_pPlayer->getTeam()).GetTeamTechs()->GetResearchCost(eTech);1526#else1527 int iResearchCost = GET_TEAM(m_pPlayer->getTeam()).GetTeamTechs()->GetResearchCost(eTech);1528#endif1529 1530 // Adjust to the player's research modifier1531 int iResearchMod = std::max(1, m_pPlayer->calculateResearchModifier(eTech));1532 iResearchCost = ((iResearchCost * 10000) / iResearchMod);15331534 // Mod for City Count1535 int iMod = GC.getMap().getWorldInfo().GetNumCitiesTechCostMod(); // Default is 40, gets smaller on larger maps1536 iMod = iMod * m_pPlayer->GetMaxEffectiveCities(/*bIncludePuppets*/ true);1537 iResearchCost = iResearchCost * (100 + iMod) / 100;15381539 // We're going to round up so that the user wont get confused when the research progress seems to be equal to the research cost, but it is not acutally done.1540 // This is because the 'real' calculations use the GameCore's fixed point math where things are multiplied by 1001541 if((iResearchCost % 100) != 0)1542 iResearchCost = (iResearchCost / 100) + 1;1543 else1544 iResearchCost = (iResearchCost / 100);15451546#if defined(MOD_BUGFIX_RESEARCH_NAN)1547 return (int) iResearchCost;1548#else1549 return iResearchCost;1550#endif1551}
Calls
- CvGlobals::getMap()
- CvMap::getWorldInfo() const
- CvPlayer::calculateResearchModifier(TechTypes)
- CvPlayer::GetMaxEffectiveCities(bool)
- CvPlayer::getTeam() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::GetTeamTechs() const
- CvTeamTechs::GetResearchCost(TechTypes) const
- CvWorldInfo::GetNumCitiesTechCostMod() const
std::max
Called by
- CvEspionageAI::BuildOffenseCityList(EspionageCityList &)
- CvPlayerEspionage::BuildStealableTechList(PlayerTypes)
- CvPlayer::DoUnresearchedTechBonusFromKill(CvUnit *, UnitTypes, int, int, int &)
- CvPlayerTechs::GetMedianTechResearch() const
- CvPlayerTechs::GetResearchTurnsLeftTimes100(TechTypes, bool) const
- CvLuaPlayer::lGetResearchCost(lua_State *)