CvTeam::enhanceBuilding(BuildingTypes, int)
- Defined in
- CvTeam.cpp, line 4976
- Class
- CvTeam
- Hook name
CivHooks::CvTeam_enhanceBuilding
Hooks
static bool BeforeCvTeam_enhanceBuilding(CvTeam* self, BuildingTypes eIndex, int iChange);static void AfterCvTeam_enhanceBuilding(CvTeam* self, BuildingTypes eIndex, int iChange);static void ReplaceCvTeam_enhanceBuilding(void (*original)(CvTeam*, BuildingTypes, int), CvTeam* self, BuildingTypes eIndex, int iChange);CivRegisterBefore<CivHooks::CvTeam_enhanceBuilding>(host, &BeforeCvTeam_enhanceBuilding);CivRegisterAfter<CivHooks::CvTeam_enhanceBuilding>(host, &AfterCvTeam_enhanceBuilding);CivRegisterReplace<CivHooks::CvTeam_enhanceBuilding>(host, &ReplaceCvTeam_enhanceBuilding);
Code
4976void CvTeam::enhanceBuilding(BuildingTypes eIndex, int iChange)4977{4978 CvCity* pLoopCity;4979 int iLoop;49804981 CvAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");4982 CvAssertMsg(eIndex < GC.getNumBuildingInfos(), "eIndex is expected to be within maximum bounds (invalid Index)");49834984 CvBuildingEntry* thisBuildingEntry = GC.getBuildingInfo(eIndex);4985 if(thisBuildingEntry == NULL)4986 return;49874988 if(iChange != 0)4989 {4990 for(int i = 0; i < MAX_PLAYERS; i++)4991 {4992 CvPlayerAI& kPlayer = GET_PLAYER(static_cast<PlayerTypes>(i));49934994 if(kPlayer.isAlive())4995 {4996 if(kPlayer.getTeam() == GetID())4997 {4998 for(pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop))4999 {5000 if(pLoopCity->GetCityBuildings()->GetNumBuilding(eIndex) > 0)5001 {5002 for(int k = 0; k < NUM_YIELD_TYPES; k++)5003 {5004 if((YieldTypes)k == YIELD_CULTURE)5005 {5006#if defined(MOD_BUGFIX_MINOR)5007 int iEnhancedYield = thisBuildingEntry->GetTechEnhancedYieldChange(k) * pLoopCity->GetCityBuildings()->GetNumBuilding(eIndex);5008 pLoopCity->ChangeJONSCulturePerTurnFromBuildings(iEnhancedYield * iChange);5009#else5010 pLoopCity->ChangeJONSCulturePerTurnFromBuildings(thisBuildingEntry->GetTechEnhancedYieldChange(k) * iChange);5011#endif5012 }5013 else if((YieldTypes)k == YIELD_FAITH)5014 {5015#if defined(MOD_BUGFIX_MINOR)5016 int iEnhancedYield = thisBuildingEntry->GetTechEnhancedYieldChange(k) * pLoopCity->GetCityBuildings()->GetNumBuilding(eIndex);5017 pLoopCity->ChangeFaithPerTurnFromBuildings(iEnhancedYield * iChange);5018#else5019 pLoopCity->ChangeFaithPerTurnFromBuildings(thisBuildingEntry->GetTechEnhancedYieldChange(k) * iChange);5020#endif5021 }5022 else5023 {5024#if defined(MOD_BUGFIX_MINOR)5025 int iEnhancedYield = thisBuildingEntry->GetTechEnhancedYieldChange(k) * pLoopCity->GetCityBuildings()->GetNumBuilding(eIndex);5026 pLoopCity->ChangeBaseYieldRateFromBuildings(((YieldTypes)k), iEnhancedYield * iChange);5027#else5028 pLoopCity->ChangeBaseYieldRateFromBuildings(((YieldTypes)k), thisBuildingEntry->GetTechEnhancedYieldChange(k) * iChange);5029#endif5030 }5031 }5032 }5033 }5034 }5035 }5036 }5037 }5038}
Calls
- CvBuildingEntry::GetTechEnhancedYieldChange(int) const
- CvCity::ChangeBaseYieldRateFromBuildings(YieldTypes, int)
- CvCity::ChangeFaithPerTurnFromBuildings(int)
- CvCity::ChangeJONSCulturePerTurnFromBuildings(int)
- CvCity::GetCityBuildings() const
- CvCityBuildings::GetNumBuilding(BuildingTypes) const
- CvGlobals::getBuildingInfo(BuildingTypes)
- CvPlayer::firstCity(int *, bool)
- CvPlayer::getTeam() const
- CvPlayer::isAlive() const
- CvPlayer::nextCity(int *, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::GetID() const