Hooks
static bool BeforeCvPlayer_processPolicies(CvPlayer* self, PolicyTypes ePolicy, int iChange);static void AfterCvPlayer_processPolicies(CvPlayer* self, PolicyTypes ePolicy, int iChange);static void ReplaceCvPlayer_processPolicies(void (*original)(CvPlayer*, PolicyTypes, int), CvPlayer* self, PolicyTypes ePolicy, int iChange);CivRegisterBefore<CivHooks::CvPlayer_processPolicies>(host, &BeforeCvPlayer_processPolicies);CivRegisterAfter<CivHooks::CvPlayer_processPolicies>(host, &AfterCvPlayer_processPolicies);CivRegisterReplace<CivHooks::CvPlayer_processPolicies>(host, &ReplaceCvPlayer_processPolicies);
Code
23630void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange)23631{23632 int iI, iJ;2363323634 CvPolicyEntry* pPolicy = GC.getPolicyInfo(ePolicy);23635 if(pPolicy == NULL)23636 return;2363723638#if defined(MOD_TRAITS_OTHER_PREREQS)23639 if (MOD_TRAITS_OTHER_PREREQS) {23640 // Update our traits (some may have become obsolete)23641 GetPlayerTraits()->Reset();23642 GetPlayerTraits()->InitPlayerTraits();23643 recomputePolicyCostModifier();23644 }23645#endif2364623647 const CvPolicyEntry& kPolicy = (*pPolicy);2364823649 ChangeCulturePerWonder(pPolicy->GetCulturePerWonder() * iChange);23650 ChangeCultureWonderMultiplier(pPolicy->GetCultureWonderMultiplier() * iChange);23651 ChangeCulturePerTechResearched(pPolicy->GetCulturePerTechResearched() * iChange);23652 ChangeGoldenAgeMeterMod(pPolicy->GetGoldenAgeMeterMod() * iChange);23653 changeGoldenAgeModifier(pPolicy->GetGoldenAgeDurationMod() * iChange);23654 changeWorkerSpeedModifier(pPolicy->GetWorkerSpeedModifier() * iChange);23655 changeImprovementCostModifier(pPolicy->GetImprovementCostModifier() * iChange);23656 changeImprovementUpgradeRateModifier(pPolicy->GetImprovementUpgradeRateModifier() * iChange);23657 changeSpecialistProductionModifier(pPolicy->GetSpecialistProductionModifier() * iChange);23658 changeMilitaryProductionModifier(pPolicy->GetMilitaryProductionModifier() * iChange);23659 changeBaseFreeUnits(pPolicy->GetBaseFreeUnits() * iChange);23660 ChangeHappinessPerGarrisonedUnit(pPolicy->GetHappinessPerGarrisonedUnit() * iChange);23661 ChangeHappinessPerTradeRoute(pPolicy->GetHappinessPerTradeRoute() * iChange);23662 ChangeHappinessPerXPopulation(pPolicy->GetHappinessPerXPopulation() * iChange);23663 ChangeExtraHappinessPerLuxury(pPolicy->GetExtraHappinessPerLuxury() * iChange);23664 ChangeUnhappinessFromUnitsMod(pPolicy->GetUnhappinessFromUnitsMod() * iChange);23665 ChangeUnhappinessMod(pPolicy->GetUnhappinessMod() * iChange);23666 ChangeCityCountUnhappinessMod(pPolicy->GetCityCountUnhappinessMod() * iChange);23667 ChangeOccupiedPopulationUnhappinessMod(pPolicy->GetOccupiedPopulationUnhappinessMod() * iChange);23668 ChangeCapitalUnhappinessMod(pPolicy->GetCapitalUnhappinessMod() * iChange);23669 ChangeWoundedUnitDamageMod(pPolicy->GetWoundedUnitDamageMod() * iChange);23670 ChangeUnitUpgradeCostMod(pPolicy->GetUnitUpgradeCostMod() * iChange);23671 ChangeBarbarianCombatBonus(pPolicy->GetBarbarianCombatBonus() * iChange);23672 ChangeAlwaysSeeBarbCampsCount(pPolicy->IsAlwaysSeeBarbCamps() * iChange);23673 ChangeMaxNumBuilders(pPolicy->GetNumExtraBuilders() * iChange);23674 ChangePlotGoldCostMod(pPolicy->GetPlotGoldCostMod() * iChange);23675#if defined(MOD_POLICIES_CITY_WORKING)23676 ChangeCityWorkingChange(pPolicy->GetCityWorkingChange() * iChange);23677#endif23678#if defined(MOD_POLICIES_CITY_AUTOMATON_WORKERS)23679 ChangeCityAutomatonWorkersChange(pPolicy->GetCityAutomatonWorkersChange() * iChange);23680#endif23681 ChangePlotCultureCostModifier(pPolicy->GetPlotCultureCostModifier() * iChange);23682 ChangePlotCultureExponentModifier(pPolicy->GetPlotCultureExponentModifier() * iChange);23683 ChangeNumCitiesPolicyCostDiscount(pPolicy->GetNumCitiesPolicyCostDiscount() * iChange);23684 ChangeGarrisonFreeMaintenanceCount(pPolicy->IsGarrisonFreeMaintenance() * iChange);23685 ChangeGarrisonedCityRangeStrikeModifier(pPolicy->GetGarrisonedCityRangeStrikeModifier() * iChange);23686 ChangeUnitPurchaseCostModifier(pPolicy->GetUnitPurchaseCostModifier() * iChange);23687 GetTreasury()->ChangeCityConnectionTradeRouteGoldModifier(pPolicy->GetCityConnectionTradeRouteGoldModifier() * iChange);23688 changeGoldPerUnit(pPolicy->GetGoldPerUnit() * iChange);23689 changeGoldPerMilitaryUnit(pPolicy->GetGoldPerMilitaryUnit() * iChange);23690 ChangeCityStrengthMod(pPolicy->GetCityStrengthMod() * iChange);23691 ChangeCityGrowthMod(pPolicy->GetCityGrowthMod() * iChange);23692 ChangeCapitalGrowthMod(pPolicy->GetCapitalGrowthMod() * iChange);23693 changeSettlerProductionModifier(pPolicy->GetSettlerProductionModifier() * iChange);23694 changeCapitalSettlerProductionModifier(pPolicy->GetCapitalSettlerProductionModifier() * iChange);23695 ChangeRouteGoldMaintenanceMod(pPolicy->GetRouteGoldMaintenanceMod() * iChange);23696 ChangeBuildingGoldMaintenanceMod(pPolicy->GetBuildingGoldMaintenanceMod() * iChange);23697 ChangeUnitGoldMaintenanceMod(pPolicy->GetUnitGoldMaintenanceMod() * iChange);23698 ChangeUnitSupplyMod(pPolicy->GetUnitSupplyMod() * iChange);23699 changeHappyPerMilitaryUnit(pPolicy->GetHappyPerMilitaryUnit() * iChange);23700 changeHappinessToCulture(pPolicy->GetHappinessToCulture() * iChange);23701 changeHappinessToScience(pPolicy->GetHappinessToScience() * iChange);23702 changeHalfSpecialistUnhappinessCount((pPolicy->IsHalfSpecialistUnhappiness()) ? iChange : 0);23703 changeHalfSpecialistFoodCount((pPolicy->IsHalfSpecialistFood()) ? iChange : 0);23704 changeMilitaryFoodProductionCount((pPolicy->IsMilitaryFoodProduction()) ? iChange : 0);23705 ChangeGoldenAgeCultureBonusDisabledCount((pPolicy->IsGoldenAgeCultureBonusDisabled()) ? iChange : 0);23706 ChangeSecondReligionPantheonCount((pPolicy->IsSecondReligionPantheon()) ? iChange : 0);23707 ChangeEnablesSSPartHurryCount((pPolicy->IsEnablesSSPartHurry()) ? iChange : 0);23708 ChangeEnablesSSPartPurchaseCount((pPolicy->IsEnablesSSPartPurchase()) ? iChange : 0);23709 changeMaxConscript(getWorldSizeMaxConscript(kPolicy) * iChange);23710 changeExpModifier(pPolicy->GetExpModifier() * iChange);23711 changeExpInBorderModifier(pPolicy->GetExpInBorderModifier() * iChange);23712 changeMinorQuestFriendshipMod(pPolicy->GetMinorQuestFriendshipMod() * iChange);23713 changeMinorGoldFriendshipMod(pPolicy->GetMinorGoldFriendshipMod() * iChange);23714 ChangeMinorFriendshipAnchorMod(pPolicy->GetMinorFriendshipMinimum() * iChange);23715 changeGetMinorFriendshipDecayMod(pPolicy->GetMinorFriendshipDecayMod() * iChange);23716 ChangeMinorScienceAlliesCount(pPolicy->IsMinorScienceAllies() * iChange);23717 ChangeMinorResourceBonusCount(pPolicy->IsMinorResourceBonus() * iChange);23718 ChangeNewCityExtraPopulation(pPolicy->GetNewCityExtraPopulation() * iChange);23719 ChangeFreeFoodBox(pPolicy->GetFreeFoodBox() * iChange);23720 ChangeStrategicResourceMod(pPolicy->GetStrategicResourceMod() * iChange);23721 ChangeAbleToAnnexCityStatesCount((pPolicy->IsAbleToAnnexCityStates()) ? iChange : 0);2372223723 if(pPolicy->IsOneShot())23724 {23725 if(m_pPlayerPolicies->HasOneShotPolicyFired(ePolicy))23726 {23727 return;23728 }23729 else23730 {23731 m_pPlayerPolicies->SetOneShotPolicyFired(ePolicy,true);23732 }23733 }2373423735 GetPlayerPolicies()->ChangeNumExtraBranches(pPolicy->GetNumExtraBranches() * iChange);2373623737 ChangeAllFeatureProduction(pPolicy->GetAllFeatureProduction());2373823739 int iMod;23740 YieldTypes eYield;2374123742 for(iI = 0; iI < NUM_YIELD_TYPES; iI++)23743 {23744 eYield = (YieldTypes) iI;2374523746 iMod = pPolicy->GetYieldModifier(iI) * iChange;23747 if(iMod != 0)23748 changeYieldRateModifier(eYield, iMod);2374923750 iMod = pPolicy->GetCityYieldChange(iI) * iChange;23751 if(iMod != 0)23752#if defined(MOD_BUGFIX_MINOR)23753 ChangeCityYieldChangeTimes100(eYield, iMod * 100);23754#else23755 ChangeCityYieldChange(eYield, iMod * 100);23756#endif2375723758 iMod = pPolicy->GetCoastalCityYieldChange(iI) * iChange;23759 if(iMod != 0)23760 ChangeCoastalCityYieldChange(eYield, iMod);2376123762 iMod = pPolicy->GetCapitalYieldChange(iI) * iChange;23763 if(iMod != 0)23764#if defined(MOD_BUGFIX_MINOR)23765 ChangeCapitalYieldChangeTimes100(eYield, iMod * 100);23766#else23767 ChangeCapitalYieldChange(eYield, iMod * 100);23768#endif2376923770 iMod = pPolicy->GetCapitalYieldPerPopChange(iI) * iChange;23771 if(iMod != 0)23772 ChangeCapitalYieldPerPopChange(eYield, iMod);2377323774 iMod = pPolicy->GetCapitalYieldModifier(iI) * iChange;23775 if(iMod != 0)23776 changeCapitalYieldRateModifier(eYield, iMod);2377723778 iMod = pPolicy->GetGreatWorkYieldChange(iI) * iChange;23779 if(iMod != 0)23780 ChangeGreatWorkYieldChange(eYield, iMod);2378123782 iMod = pPolicy->GetSpecialistExtraYield(iI) * iChange;23783 if(iMod != 0)23784 changeSpecialistExtraYield(eYield, iMod);2378523786#if defined(MOD_API_UNIFIED_YIELDS)23787 iMod = pPolicy->GetYieldFromKills(iI) * iChange;23788 if(iMod != 0)23789 changeYieldFromKills(eYield, iMod);2379023791 iMod = pPolicy->GetYieldFromBarbarianKills(iI) * iChange;23792 if(iMod != 0)23793 changeYieldFromBarbarianKills(eYield, iMod);2379423795 iMod = pPolicy->GetYieldChangeTradeRoute(iI) * iChange;23796 if(iMod != 0)23797 ChangeYieldChangeTradeRoute(eYield, iMod);2379823799 iMod = pPolicy->GetYieldChangesNaturalWonder(iI) * iChange;23800 if(iMod != 0)23801 ChangeYieldChangesNaturalWonder(eYield, iMod);2380223803 iMod = pPolicy->GetYieldChangeWorldWonder(iI) * iChange;23804 if(iMod != 0)23805 ChangeYieldChangeWorldWonder(eYield, iMod);23806#endif23807 }2380823809 for(iI = 0; iI < GC.getNumUnitCombatClassInfos(); iI++)23810 {23811 changeUnitCombatProductionModifiers((UnitCombatTypes)iI, (pPolicy->GetUnitCombatProductionModifiers(iI) * iChange));23812 changeUnitCombatFreeExperiences((UnitCombatTypes)iI, (pPolicy->GetUnitCombatFreeExperiences(iI) * iChange));23813 }2381423815 for(iI = 0; iI < GC.getNumHurryInfos(); iI++)23816 {23817 if(GC.getHurryInfo((HurryTypes) iI)->getPolicyPrereq() == ePolicy)23818 {23819 changeHurryCount(((HurryTypes)iI), iChange);23820 }23821 {23822 changeHurryModifier((HurryTypes) iI, (pPolicy->GetHurryModifier(iI) * iChange));23823 }23824 }2382523826#if defined(MOD_API_UNIFIED_YIELDS) && defined(MOD_API_PLOT_YIELDS)23827 for(iI = 0; iI < GC.getNumPlotInfos(); iI++)23828 {23829 for(iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)23830 {23831 changePlotYieldChange(((PlotTypes)iI), ((YieldTypes)iJ), (pPolicy->GetPlotYieldChanges(iI, iJ) * iChange));23832 }23833 }23834#endif2383523836#if defined(MOD_API_UNIFIED_YIELDS)23837 for(iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)23838 {23839 for(iI = 0; iI < GC.getNumFeatureInfos(); iI++)23840 {23841 changeFeatureYieldChange(((FeatureTypes)iI), ((YieldTypes)iJ), (pPolicy->GetFeatureYieldChanges(iI, iJ) * iChange));23842 }2384323844 for(iI = 0; iI < GC.getNumFeatureInfos(); iI++)23845 {23846 changeCityYieldFromUnimprovedFeature(((FeatureTypes)iI), ((YieldTypes)iJ), (pPolicy->GetCityYieldFromUnimprovedFeature(iI, iJ) * iChange));23847 changeUnimprovedFeatureYieldChange(((FeatureTypes)iI), ((YieldTypes)iJ), (pPolicy->GetUnimprovedFeatureYieldChanges(iI, iJ) * iChange));23848 }2384923850 for(iI = 0; iI < GC.getNumResourceInfos(); iI++)23851 {23852 changeResourceYieldChange(((ResourceTypes)iI), ((YieldTypes)iJ), (pPolicy->GetResourceYieldChanges(iI, iJ) * iChange));23853 }2385423855 for(iI = 0; iI < GC.getNumTerrainInfos(); iI++)23856 {23857 changeTerrainYieldChange(((TerrainTypes)iI), ((YieldTypes)iJ), (pPolicy->GetTerrainYieldChanges(iI, iJ) * iChange));23858 }2385923860 for(iI = 0; iI < NUM_DOMAIN_TYPES; iI++)23861 {23862 changeTradeRouteYieldChange(((DomainTypes)iI), ((YieldTypes)iJ), (pPolicy->GetTradeRouteYieldChange(iI, iJ) * iChange));23863 }2386423865 for(iI = 0; iI < GC.getNumSpecialistInfos(); iI++)23866 {23867 changeSpecialistYieldChange(((SpecialistTypes)iI), ((YieldTypes)iJ), (pPolicy->GetSpecialistYieldChanges(iI, iJ) * iChange));23868 }2386923870 for(iI = 0; iI < GC.getNumGreatPersonInfos(); iI++)23871 {23872 changeGreatPersonExpendedYield(((GreatPersonTypes)iI), ((YieldTypes)iJ), (pPolicy->GetGreatPersonExpendedYield(iI, iJ) * iChange));23873 }23874 }2387523876 for(iI = 0; iI < GC.getNumGreatPersonInfos(); iI++)23877 {23878 iMod = pPolicy->GetGoldenAgeGreatPersonRateModifier(iI) * iChange;23879 if(iMod != 0)23880 changeGoldenAgeGreatPersonRateModifier((GreatPersonTypes)iI, iMod);23881 }23882#endif2388323884 for(iI = 0; iI < GC.getNumImprovementInfos(); iI++)23885 {23886 for(iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)23887 {23888 changeImprovementYieldChange(((ImprovementTypes)iI), ((YieldTypes)iJ), (pPolicy->GetImprovementYieldChanges(iI, iJ) * iChange));23889 }23890 }2389123892 // Free Promotions23893 PromotionTypes ePromotion;23894 for(iI = 0; iI < GC.getNumPromotionInfos(); iI++)23895 {23896 ePromotion = (PromotionTypes) iI;2389723898 if(pPolicy->IsFreePromotion(ePromotion))23899 ChangeFreePromotionCount(ePromotion, iChange);23900 }2390123902 CvCity* pLoopCity;23903 PlayerTypes ePlayer;2390423905 // All player Capital Locations Revealed23906 if(pPolicy->IsRevealAllCapitals())23907 {23908 for(iI = 0; iI < MAX_CIV_PLAYERS; iI++)23909 {23910 ePlayer = (PlayerTypes) iI;2391123912 if(GET_PLAYER(ePlayer).isAlive())23913 {23914 pLoopCity = GET_PLAYER(ePlayer).getCapitalCity();2391523916 if(pLoopCity != NULL)23917 {23918 pLoopCity->plot()->setRevealed(getTeam(), true);23919 }23920 }23921 }23922 }2392323924 // Friendship Decay for OTHER PLAYERS23925 CvNotifications* pNotifications;23926 Localization::String locString;23927 Localization::String locSummary;2392823929 int iOtherPlayersDecay = pPolicy->GetOtherPlayersMinorFriendshipDecayMod();23930 if(iOtherPlayersDecay != 0)23931 {23932 for(iI = 0; iI < MAX_MAJOR_CIVS; iI++)23933 {23934 ePlayer = (PlayerTypes) iI;2393523936 if(GET_PLAYER(ePlayer).isEverAlive())23937 {23938 // Don't hurt us or teammates23939 if(GET_PLAYER(ePlayer).getTeam() != getTeam())23940 {23941 GET_PLAYER(ePlayer).changeGetMinorFriendshipDecayMod(iOtherPlayersDecay * iChange);2394223943 // Send notification to affected players23944 locString = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_FRIENDSHIP_DECAY");23945 locString << getNameKey();23946 locSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_MINOR_FRIENDSHIP_DECAY");2394723948 pNotifications = GET_PLAYER(ePlayer).GetNotifications();23949 if(pNotifications)23950 {23951 pNotifications->Add(NOTIFICATION_DIPLOMACY_DECLARATION, locString.toUTF8(), locSummary.toUTF8(), -1, -1, -1);23952 }23953 }23954 }23955 }23956 }2395723958 BuildingClassTypes eBuildingClass;23959 BuildingTypes eBuilding;23960 int iBuildingCount;23961 int iYieldMod;23962 int iYieldChange;2396323964 // How many cities get free culture buildings?23965 int iNumCitiesFreeCultureBuilding = pPolicy->GetNumCitiesFreeCultureBuilding();23966 int iNumCitiesFreeFoodBuilding = pPolicy->GetNumCitiesFreeFoodBuilding();2396723968 // Loop through Cities23969 int iLoop;23970 for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))23971 {23972 if(iNumCitiesFreeCultureBuilding > 0)23973 {23974 BuildingTypes eCultureBuilding = pLoopCity->ChooseFreeCultureBuilding();23975 if(eCultureBuilding != NO_BUILDING)23976 {23977 pLoopCity->GetCityBuildings()->SetNumFreeBuilding(eCultureBuilding, 1);2397823979 if(pLoopCity->getFirstBuildingOrder(eCultureBuilding) == 0)23980 {23981 pLoopCity->clearOrderQueue();23982 pLoopCity->chooseProduction(); // Send a notification to the user that what they were building was given to them, and they need to produce something else.23983 }23984 }23985 else23986 {23987 pLoopCity->SetOwedCultureBuilding(true);23988 }2398923990 // Decrement cities left to get free culture building (at end of loop we'll set the remainder)23991 iNumCitiesFreeCultureBuilding--;23992 }2399323994 if(iNumCitiesFreeFoodBuilding > 0)23995 {23996 BuildingTypes eFoodBuilding = pLoopCity->ChooseFreeFoodBuilding();23997 if(eFoodBuilding != NO_BUILDING)23998 {23999 pLoopCity->GetCityBuildings()->SetNumFreeBuilding(eFoodBuilding, 1);2400024001 if(pLoopCity->getFirstBuildingOrder(eFoodBuilding) == 0)24002 {24003 pLoopCity->clearOrderQueue();24004 pLoopCity->chooseProduction(); // Send a notification to the user that what they were building was given to them, and they need to produce something else.24005 }24006 }24007#if defined(MOD_BUGFIX_FREE_FOOD_BUILDING)24008 else24009 {24010 pLoopCity->SetOwedFoodBuilding(true);24011 }24012#endif2401324014 // Decrement cities left to get free food building (at end of loop we'll set the remainder)24015 iNumCitiesFreeFoodBuilding--;24016 }2401724018 // Free Culture-per-turn in every City24019 int iCityCultureChange = pPolicy->GetCulturePerCity() * iChange;24020 if(pLoopCity->GetGarrisonedUnit() != NULL)24021 {24022 iCityCultureChange += (pPolicy->GetCulturePerGarrisonedUnit() * iChange);24023 }24024 pLoopCity->ChangeJONSCulturePerTurnFromPolicies(iCityCultureChange);24025 24026#if defined(MOD_API_UNIFIED_YIELDS)24027 int iTotalWonders = 0;24028#endif2402924030 // Building modifiers24031 for(iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)24032 {24033 eBuildingClass = (BuildingClassTypes) iI;2403424035 CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass);24036 if(!pkBuildingClassInfo)24037 {24038 continue;24039 }2404024041 eBuilding = (BuildingTypes) getCivilizationInfo().getCivilizationBuildings(eBuildingClass);2404224043 if(eBuilding != NO_BUILDING)24044 {24045 CvBuildingEntry* pkBuilding = GC.getBuildingInfo(eBuilding);24046 if(pkBuilding)24047 {24048 iBuildingCount = pLoopCity->GetCityBuildings()->GetNumBuilding(eBuilding);2404924050 if(iBuildingCount > 0)24051 {24052#if defined(MOD_API_UNIFIED_YIELDS)24053 if (isWorldWonderClass(pkBuilding->GetBuildingClassInfo())) {24054 iTotalWonders += iBuildingCount;24055 }24056#endif24057 24058#if defined(MOD_API_UNIFIED_YIELDS)24059 iYieldMod = pPolicy->GetBuildingClassYieldModifiers(eBuildingClass, YIELD_CULTURE);24060 if (iYieldMod > 0)24061 {24062 pLoopCity->changeYieldRateModifier(YIELD_CULTURE, iYieldMod * iBuildingCount * iChange);24063 }24064 iYieldChange = pPolicy->GetBuildingClassCultureChange(eBuildingClass);24065 iYieldChange += pPolicy->GetBuildingClassYieldChanges(eBuildingClass, YIELD_CULTURE);24066 if (iYieldChange != 0)24067 {24068 pLoopCity->ChangeJONSCulturePerTurnFromPolicies(iYieldChange * iBuildingCount * iChange);24069 }24070#else24071 pLoopCity->ChangeJONSCulturePerTurnFromPolicies(pPolicy->GetBuildingClassCultureChange(eBuildingClass) * iBuildingCount * iChange);24072#endif2407324074 // Building Class Yield Stuff24075 for(iJ = 0; iJ < NUM_YIELD_TYPES; iJ++)24076 {24077 switch(iJ)24078 {24079 case YIELD_CULTURE:24080 // Skip, handled above24081 break;24082 case YIELD_FAITH:24083#if defined(MOD_API_UNIFIED_YIELDS)24084 {24085 eYield = (YieldTypes) iJ;24086 iYieldMod = pPolicy->GetBuildingClassYieldModifiers(eBuildingClass, eYield);24087 if (iYieldMod > 0)24088 {24089 pLoopCity->changeYieldRateModifier(eYield, iYieldMod * iBuildingCount * iChange);24090 }24091 iYieldChange = pPolicy->GetBuildingClassYieldChanges(eBuildingClass, eYield);24092 if (iYieldChange != 0)24093 {24094 pLoopCity->ChangeFaithPerTurnFromPolicies(iYieldChange * iBuildingCount * iChange);24095 }24096 }24097#else24098 pLoopCity->ChangeFaithPerTurnFromPolicies(pPolicy->GetBuildingClassYieldChanges(eBuildingClass, iJ) * iBuildingCount * iChange);24099#endif24100 break;24101 default:24102 {24103 eYield = (YieldTypes) iJ;24104 iYieldMod = pPolicy->GetBuildingClassYieldModifiers(eBuildingClass, eYield);24105 if (iYieldMod > 0)24106 {24107 pLoopCity->changeYieldRateModifier(eYield, iYieldMod * iBuildingCount * iChange);24108 }24109 iYieldChange = pPolicy->GetBuildingClassYieldChanges(eBuildingClass, eYield);24110 if (iYieldChange != 0)24111 {24112 pLoopCity->ChangeBaseYieldRateFromBuildings(eYield, iYieldChange * iBuildingCount * iChange);24113 }24114 }24115 }24116 }24117 }24118 }24119 }24120 }2412124122#if defined(MOD_API_UNIFIED_YIELDS)24123 if (iTotalWonders > 0) {24124 for (int iI = 0; iI < NUM_YIELD_TYPES; iI++)24125 {24126 YieldTypes eYield = (YieldTypes) iI;24127 int iYield = pPolicy->GetYieldChangeWorldWonder(iI);2412824129 if (eYield == YIELD_CULTURE)24130 {24131 pLoopCity->ChangeJONSCulturePerTurnFromBuildings(iYield * iTotalWonders * iChange);24132 }24133 else if (eYield == YIELD_FAITH)24134 {24135 pLoopCity->ChangeFaithPerTurnFromBuildings(iYield * iTotalWonders * iChange);24136 }24137 else24138 {24139 pLoopCity->ChangeBaseYieldRateFromBuildings(eYield, iYield * iTotalWonders * iChange);24140 }24141 }24142 }24143#endif24144 }2414524146 // Store off number of newly built cities that will get a free building24147 ChangeNumCitiesFreeCultureBuilding(iNumCitiesFreeCultureBuilding);24148 ChangeNumCitiesFreeFoodBuilding(iNumCitiesFreeFoodBuilding);2414924150 // Not really techs but this is what we use (for now)24151 for(iI = 0; iI < GC.getNUM_AND_TECH_PREREQS(); iI++)24152 {24153 if(pPolicy->GetPolicyDisables(iI) != NO_POLICY)24154 {24155 if(m_pPlayerPolicies->HasPolicy((PolicyTypes) pPolicy->GetPolicyDisables(iI)))24156 {24157 setHasPolicy((PolicyTypes) pPolicy->GetPolicyDisables(iI), false);24158 }24159 }24160 }2416124162 // Attack bonus for a period of time24163 int iTurns = pPolicy->GetAttackBonusTurns() * iChange;24164 if(iTurns > 0)24165 {24166 ChangeAttackBonusTurns(iTurns);24167 }2416824169 // Golden Age!24170 int iGoldenAgeTurns = pPolicy->GetGoldenAgeTurns() * iChange;24171 if(iGoldenAgeTurns > 0)24172 {24173 // Player modifier24174 int iLengthModifier = getGoldenAgeModifier();2417524176 // Trait modifier24177 iLengthModifier += GetPlayerTraits()->GetGoldenAgeDurationModifier();2417824179 if(iLengthModifier > 0)24180 {24181 iGoldenAgeTurns = iGoldenAgeTurns * (100 + iLengthModifier) / 100;24182 }2418324184 // Game Speed mod24185 iGoldenAgeTurns *= GC.getGame().getGameSpeedInfo().getGoldenAgePercent();24186 iGoldenAgeTurns /= 100;2418724188 changeGoldenAgeTurns(iGoldenAgeTurns);24189 }2419024191 // Free Techs24192 int iNumFreeTechs = pPolicy->GetNumFreeTechs() * iChange;24193 if(iNumFreeTechs > 0)24194 {24195 if(!isHuman())24196 {24197 for(iI = 0; iI < iNumFreeTechs; iI++)24198 {24199 AI_chooseFreeTech();24200 }24201 }24202 else24203 {24204 CvString strBuffer = GetLocalizedText("TXT_KEY_MISC_COMPLETED_WONDER_CHOOSE_TECH", pPolicy->GetTextKey());24205 chooseTech(iNumFreeTechs, strBuffer.GetCString());24206 }24207 }2420824209 ChangeMedianTechPercentage(pPolicy->GetMedianTechPercentChange());2421024211 // Free Policies24212 int iNumFreePolicies = pPolicy->GetNumFreePolicies() * iChange;24213 if(iNumFreePolicies > 0)24214 {24215 ChangeNumFreePolicies(iNumFreePolicies);24216 }2421724218 if(pPolicy->IncludesOneShotFreeUnits())24219 {24220 if(!m_pPlayerPolicies->HaveOneShotFreeUnitsFired(ePolicy))24221 {24222 m_pPlayerPolicies->SetOneShotFreeUnitsFired(ePolicy,true);2422324224 int iNumFreeGreatPeople = pPolicy->GetNumFreeGreatPeople() * iChange;24225 if(iNumFreeGreatPeople > 0)24226 {24227 ChangeNumFreeGreatPeople(iNumFreeGreatPeople);24228 }2422924230 if(getCapitalCity() != NULL)24231 {24232 int iX = getCapitalCity()->getX();24233 int iY = getCapitalCity()->getY();2423424235 for(iI = 0; iI < GC.getNumUnitClassInfos(); iI++)24236 {24237 const UnitClassTypes eUnitClass = static_cast<UnitClassTypes>(iI);24238 CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass);24239 if(pkUnitClassInfo)24240 {24241 int iNumFreeUnits = pPolicy->GetNumFreeUnitsByClass(eUnitClass);24242 if(iNumFreeUnits > 0)24243 {24244 const UnitTypes eUnit = (UnitTypes) getCivilizationInfo().getCivilizationUnits(eUnitClass);24245 CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit);24246 if(GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE) && isHuman() && pUnitEntry != NULL && pUnitEntry->IsFound())24247 {24248 continue;24249 }2425024251 for(int iUnitLoop = 0; iUnitLoop < iNumFreeUnits; iUnitLoop++)24252 {24253 CvUnit* pNewUnit = NULL;2425424255 // slewis24256 // for venice24257 if (pUnitEntry->IsFound() && GetPlayerTraits()->IsNoAnnexing())24258 {24259 // drop a merchant of venice instead24260 // find the eUnit replacement that's the merchant of venice24261 for(int iVeniceSearch = 0; iVeniceSearch < GC.getNumUnitClassInfos(); iVeniceSearch++)24262 {24263 const UnitClassTypes eVeniceUnitClass = static_cast<UnitClassTypes>(iVeniceSearch);24264 CvUnitClassInfo* pkVeniceUnitClassInfo = GC.getUnitClassInfo(eVeniceUnitClass);24265 if(pkVeniceUnitClassInfo)24266 {24267 const UnitTypes eMerchantOfVeniceUnit = (UnitTypes) getCivilizationInfo().getCivilizationUnits(eVeniceUnitClass);24268 if (eMerchantOfVeniceUnit != NO_UNIT)24269 {24270 CvUnitEntry* pVeniceUnitEntry = GC.getUnitInfo(eMerchantOfVeniceUnit);24271 if (pVeniceUnitEntry->IsCanBuyCityState())24272 {24273 pNewUnit = initUnit(eMerchantOfVeniceUnit, iX, iY); 24274 break;24275 }24276 }24277 }24278 }24279 }24280 else24281 {24282 pNewUnit = initUnit(eUnit, iX, iY);24283 }2428424285 CvAssert(pNewUnit);2428624287 if (pNewUnit)24288 {24289 if(pNewUnit->IsGreatGeneral())24290 {24291#if defined(MOD_GLOBAL_TRULY_FREE_GP)24292 incrementGreatGeneralsCreated(MOD_GLOBAL_TRULY_FREE_GP);24293#else24294 incrementGreatGeneralsCreated();24295#endif24296 pNewUnit->jumpToNearestValidPlot();24297 }24298 else if(pNewUnit->IsGreatAdmiral())24299 {24300#if defined(MOD_GLOBAL_TRULY_FREE_GP)24301 incrementGreatAdmiralsCreated(MOD_GLOBAL_TRULY_FREE_GP);24302#else24303 incrementGreatAdmiralsCreated();24304#endif24305 CvPlot *pSpawnPlot = GetGreatAdmiralSpawnPlot(pNewUnit);24306 if (pNewUnit->plot() != pSpawnPlot)24307 {24308 pNewUnit->setXY(pSpawnPlot->getX(), pSpawnPlot->getY());24309 }24310 }24311 else if(pNewUnit->getUnitInfo().IsFoundReligion())24312 {24313 ReligionTypes eReligion = GetReligions()->GetReligionCreatedByPlayer();24314 int iReligionSpreads = pNewUnit->getUnitInfo().GetReligionSpreads();24315 int iReligiousStrength = pNewUnit->getUnitInfo().GetReligiousStrength();24316 if(iReligionSpreads > 0 && eReligion > RELIGION_PANTHEON)24317 {24318 pNewUnit->GetReligionData()->SetSpreadsLeft(iReligionSpreads);24319 pNewUnit->GetReligionData()->SetReligiousStrength(iReligiousStrength);24320 pNewUnit->GetReligionData()->SetReligion(eReligion);24321 }24322 }24323 else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_WRITER"))24324 {24325#if defined(MOD_GLOBAL_TRULY_FREE_GP)24326 incrementGreatWritersCreated(MOD_GLOBAL_TRULY_FREE_GP);24327#else24328 incrementGreatWritersCreated();24329#endif2433024331 if (pNewUnit->getUnitInfo().GetOneShotTourism() > 0)24332 {24333 pNewUnit->SetTourismBlastStrength(GetCulture()->GetTourismBlastStrength(pNewUnit->getUnitInfo().GetOneShotTourism()));24334 }2433524336 pNewUnit->jumpToNearestValidPlot();24337 } 24338 else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_ARTIST"))24339 {24340#if defined(MOD_GLOBAL_TRULY_FREE_GP)24341 incrementGreatArtistsCreated(MOD_GLOBAL_TRULY_FREE_GP);24342#else24343 incrementGreatArtistsCreated();24344#endif24345 pNewUnit->jumpToNearestValidPlot();24346 } 24347 else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MUSICIAN"))24348 {24349#if defined(MOD_GLOBAL_TRULY_FREE_GP)24350 incrementGreatMusiciansCreated(MOD_GLOBAL_TRULY_FREE_GP);24351#else24352 incrementGreatMusiciansCreated();24353#endif24354 pNewUnit->jumpToNearestValidPlot();24355 }24356 else if(pNewUnit->IsGreatPerson())24357 {24358#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS)24359 if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) {24360 if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MERCHANT")) {24361#if defined(MOD_GLOBAL_TRULY_FREE_GP)24362 incrementGreatMerchantsCreated(MOD_GLOBAL_TRULY_FREE_GP);24363#else24364 incrementGreatMerchantsCreated();24365#endif24366 } else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_SCIENTIST")) {24367#if defined(MOD_GLOBAL_TRULY_FREE_GP)24368 incrementGreatScientistsCreated(MOD_GLOBAL_TRULY_FREE_GP);24369#else24370 incrementGreatScientistsCreated();24371#endif24372 } else {24373#if defined(MOD_GLOBAL_TRULY_FREE_GP)24374 incrementGreatEngineersCreated(MOD_GLOBAL_TRULY_FREE_GP);24375#else24376 incrementGreatEngineersCreated();24377#endif24378 }24379 } else24380#endif24381#if defined(MOD_GLOBAL_TRULY_FREE_GP)24382 incrementGreatPeopleCreated(MOD_GLOBAL_TRULY_FREE_GP);24383#else24384 incrementGreatPeopleCreated();24385#endif24386 pNewUnit->jumpToNearestValidPlot();24387 }24388 else24389 {24390 pNewUnit->jumpToNearestValidPlot();24391 }24392 }24393 }24394 }24395 }24396 }24397 }24398 }24399 }2440024401 // Great People bonus from Allied city-states24402 if(pPolicy->IsMinorGreatPeopleAllies())24403 {24404 DoAdoptedGreatPersonCityStatePolicy();24405 }2440624407 // Add a Reformation belief if eligible24408#if defined(MOD_RELIGION_LOCAL_RELIGIONS)24409 if (isHuman() && pPolicy->IsAddReformationBelief() && GetReligions()->HasCreatedReligion(true) && !GetReligions()->HasAddedReformationBelief())24410#else24411 if (isHuman() && pPolicy->IsAddReformationBelief() && GetReligions()->HasCreatedReligion() && !GetReligions()->HasAddedReformationBelief())24412#endif24413 {24414 pNotifications = GetNotifications();24415 if(pNotifications)24416 {24417 CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_ADD_REFORMATION_BELIEF");24418 CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_SUMMARY_ADD_REFORMATION_BELIEF");24419 pNotifications->Add(NOTIFICATION_ADD_REFORMATION_BELIEF, strBuffer, strSummary, -1, -1, -1);24420 }24421 }2442224423 // if the steal tech faster amount is modified, then update the progress of all spies24424 if (pPolicy->GetStealTechFasterModifier() != 0)24425 {24426 GetEspionage()->UpdateSpies();24427 }2442824429 CvPlot *pLoopPlot;24430 ResourceTypes eResource;24431 for(iI = 0; iI < GC.getMap().numPlots(); iI++)24432 {24433 pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);24434 eResource = pLoopPlot->getResourceType();24435 if(eResource != NO_RESOURCE)24436 {24437 if(GC.getResourceInfo(eResource)->getPolicyReveal() == (int)ePolicy)24438 {24439 pLoopPlot->updateYield();24440 if (pLoopPlot->isRevealed(getTeam()))24441 {24442 pLoopPlot->setLayoutDirty(true);24443 }24444 }24445 }24446 }2444724448 DoUpdateHappiness();24449 GetTrade()->UpdateTradeConnectionValues();24450 recomputeGreatPeopleModifiers();24451 recomputePolicyCostModifier();24452 recomputeFreeExperience();2445324454 doUpdateBarbarianCampVisibility();2445524456 GC.GetEngineUserInterface()->setDirty(CityInfo_DIRTY_BIT, true);24457 GC.GetEngineUserInterface()->setDirty(GameData_DIRTY_BIT, true);24458}