From e632da69db6c78288e6b3f907c03bea3e64d123d Mon Sep 17 00:00:00 2001 From: azum4roll Date: Sun, 9 Jun 2024 22:46:01 +0800 Subject: [PATCH] Massive code cleanup fix CP-only having resilient pantheons fix experience being added twice for free units from buildings fix submarines under ice being immune to ranged attacks even though GLOBAL_SUBS_UNDER_ICE_IMMUNITY is off fix CP-only ranged ships can't shoot inland targets (#10940) fix resource requirement tooltip still showing on buildings even when fulfilled fix Honor conscription not happening when gaining multiple citizens to skip over the threshold - still won't get the correct amount (only 1 conscript) when skipping over multiple thresholds in one go, but that's an extreme case fix Honor giving only one conscript when taken while city has 20+ population fix City-States never asking for ranged units stop OCC Venice from getting a free Merchant of Venice from Pyramids - they already don't get one from Imperium, it's more consistent that way don't clear production queue if free unit happens to be the first thing in queue also did a LOT of cleanup on repetitive code removed some null checks that shouldn't happen (let it crash!) removed many useless #if defines - especially those with #else or affecting code structure - it's not completed; DON'T remove any #defines for now! it definitely won't build -- to be fair, it won't build either if you remove #defines BEFORE this commit moved some CvGame functions to other fitting classes - all references updated - does not affect the Lua API standardized most free unit pickers like conscripts and partisans - can pick whether to include ranged, ships, recon, UUs, units that require resources, etc. - can specify a list of UnitCombats that the free unit must be - can either return best unit or randomly pick from top 5 - see CvPlayer::GetCompetitiveSpawnUnitType() for details converted some hardcoded defines into mod options - CORE_DELAYED_VISIBILITY: default on - CORE_HOVERING_UNITS: default off - CORE_RESILIENT_PANTHEONS: default on in VP only - CORE_TWO_PASS_DANGER: default off - UNIT_KILL_STATS: default off --- .../Core Tables/CustomModOptions.xml | 16 +- .../CustomModOptionChanges.sql | 2 + CvGameCoreDLLUtil/include/CvEnums.h | 2 - CvGameCoreDLL_Expansion2/CustomMods.cpp | 7 + CvGameCoreDLL_Expansion2/CustomMods.h | 22 +- CvGameCoreDLL_Expansion2/CvAdvisorCounsel.cpp | 4 +- CvGameCoreDLL_Expansion2/CvBeliefClasses.cpp | 168 +- CvGameCoreDLL_Expansion2/CvBeliefClasses.h | 2 - .../CvBuildingClasses.cpp | 68 +- CvGameCoreDLL_Expansion2/CvBuildingClasses.h | 23 +- .../CvBuildingProductionAI.cpp | 4 +- CvGameCoreDLL_Expansion2/CvCity.cpp | 1717 ++------ CvGameCoreDLL_Expansion2/CvCity.h | 48 +- CvGameCoreDLL_Expansion2/CvCityAI.cpp | 6 +- CvGameCoreDLL_Expansion2/CvCityCitizens.cpp | 433 +- CvGameCoreDLL_Expansion2/CvCityCitizens.h | 7 +- .../CvCitySpecializationAI.cpp | 37 +- CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp | 21 +- CvGameCoreDLL_Expansion2/CvCultureClasses.cpp | 414 +- CvGameCoreDLL_Expansion2/CvCultureClasses.h | 31 +- CvGameCoreDLL_Expansion2/CvDangerPlots.cpp | 56 +- CvGameCoreDLL_Expansion2/CvDealAI.cpp | 109 +- CvGameCoreDLL_Expansion2/CvDealClasses.cpp | 84 +- CvGameCoreDLL_Expansion2/CvDealClasses.h | 8 +- CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp | 373 +- .../CvDiplomacyRequests.cpp | 61 +- CvGameCoreDLL_Expansion2/CvDllGameDeals.cpp | 25 +- CvGameCoreDLL_Expansion2/CvDllNetInitInfo.cpp | 42 - CvGameCoreDLL_Expansion2/CvDllNetInitInfo.h | 4 - .../CvDllNetMessageHandler.cpp | 161 +- CvGameCoreDLL_Expansion2/CvDllPlot.cpp | 16 +- CvGameCoreDLL_Expansion2/CvEconomicAI.cpp | 98 +- CvGameCoreDLL_Expansion2/CvEconomicAI.h | 2 +- .../CvEmphasisClasses.cpp | 8 +- CvGameCoreDLL_Expansion2/CvGame.cpp | 752 +--- CvGameCoreDLL_Expansion2/CvGame.h | 6 - .../CvGameCoreStructs.cpp | 55 +- CvGameCoreDLL_Expansion2/CvGameCoreUtils.cpp | 56 +- CvGameCoreDLL_Expansion2/CvGlobals.cpp | 27 +- CvGameCoreDLL_Expansion2/CvHomelandAI.cpp | 51 +- CvGameCoreDLL_Expansion2/CvHomelandAI.h | 6 +- .../CvImprovementClasses.cpp | 6 +- CvGameCoreDLL_Expansion2/CvInfos.cpp | 11 +- CvGameCoreDLL_Expansion2/CvInfos.h | 5 +- CvGameCoreDLL_Expansion2/CvMap.cpp | 12 +- CvGameCoreDLL_Expansion2/CvMap.h | 4 - CvGameCoreDLL_Expansion2/CvMilitaryAI.cpp | 50 +- CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp | 148 +- CvGameCoreDLL_Expansion2/CvMinorCivAI.h | 4 - CvGameCoreDLL_Expansion2/CvPlayer.cpp | 3924 ++++++----------- CvGameCoreDLL_Expansion2/CvPlayer.h | 131 +- CvGameCoreDLL_Expansion2/CvPlayerAI.cpp | 78 +- CvGameCoreDLL_Expansion2/CvPlayerAI.h | 2 +- CvGameCoreDLL_Expansion2/CvPlot.cpp | 218 +- CvGameCoreDLL_Expansion2/CvPlot.h | 36 +- CvGameCoreDLL_Expansion2/CvPolicyAI.cpp | 106 +- CvGameCoreDLL_Expansion2/CvPreGame.cpp | 43 +- CvGameCoreDLL_Expansion2/CvPreGame.h | 4 - .../CvProcessProductionAI.cpp | 19 +- .../CvReligionClasses.cpp | 591 +-- CvGameCoreDLL_Expansion2/CvReligionClasses.h | 61 +- CvGameCoreDLL_Expansion2/CvTeam.cpp | 206 +- CvGameCoreDLL_Expansion2/CvTradeClasses.cpp | 4 +- CvGameCoreDLL_Expansion2/CvTraitClasses.cpp | 172 +- CvGameCoreDLL_Expansion2/CvUnit.cpp | 1379 ++---- CvGameCoreDLL_Expansion2/CvUnit.h | 30 +- CvGameCoreDLL_Expansion2/CvUnitClasses.cpp | 16 +- CvGameCoreDLL_Expansion2/CvUnitClasses.h | 8 +- CvGameCoreDLL_Expansion2/CvUnitCombat.cpp | 4 - CvGameCoreDLL_Expansion2/CvVotingClasses.cpp | 94 +- CvGameCoreDLL_Expansion2/Lua/CvLuaGame.cpp | 5 +- CvGameCoreDLL_Expansion2/Lua/CvLuaGame.h | 3 - CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp | 57 +- CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp | 5 - CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.h | 3 - 75 files changed, 2960 insertions(+), 9511 deletions(-) diff --git a/(1) Community Patch/Core Files/Core Tables/CustomModOptions.xml b/(1) Community Patch/Core Files/Core Tables/CustomModOptions.xml index 4661210006..5c469496c2 100644 --- a/(1) Community Patch/Core Files/Core Tables/CustomModOptions.xml +++ b/(1) Community Patch/Core Files/Core Tables/CustomModOptions.xml @@ -954,8 +954,8 @@ - - + + @@ -970,13 +970,23 @@ - + + + + + + + + + + + diff --git a/(2) Vox Populi/Database Changes/CustomModOptionChanges.sql b/(2) Vox Populi/Database Changes/CustomModOptionChanges.sql index 56b5bd73d9..9b6b21b850 100644 --- a/(2) Vox Populi/Database Changes/CustomModOptionChanges.sql +++ b/(2) Vox Populi/Database Changes/CustomModOptionChanges.sql @@ -267,3 +267,5 @@ UPDATE CustomModOptions SET Value = 1 WHERE Name = 'BALANCE_CORE_GOODY_RECON_ONL -- No longer needed now that Helicopter Gunship doesn't embark anywhere UPDATE CustomModOptions SET Value = 0 WHERE Name = 'PROMOTIONS_DEEP_WATER_EMBARKATION'; + +UPDATE CustomModOptions SET Value = 1 WHERE Name = 'CORE_RESILIENT_PANTHEONS'; diff --git a/CvGameCoreDLLUtil/include/CvEnums.h b/CvGameCoreDLLUtil/include/CvEnums.h index d370ffd65f..ae4ca9cdb7 100644 --- a/CvGameCoreDLLUtil/include/CvEnums.h +++ b/CvGameCoreDLLUtil/include/CvEnums.h @@ -1347,9 +1347,7 @@ enum CLOSED_ENUM GameOptionTypes #define GAMEOPTION_RANDOM_VICTORY "GAMEOPTION_RANDOM_VICTORY" #endif -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) #define GAMEOPTION_KEEP_UNMET_PLAYERS_UNKNOWN "GAMEOPTION_KEEP_UNMET_PLAYERS_UNKNOWN" -#endif enum CLOSED_ENUM MultiplayerOptionTypes { diff --git a/CvGameCoreDLL_Expansion2/CustomMods.cpp b/CvGameCoreDLL_Expansion2/CustomMods.cpp index 6d670adb83..fa167ccf82 100644 --- a/CvGameCoreDLL_Expansion2/CustomMods.cpp +++ b/CvGameCoreDLL_Expansion2/CustomMods.cpp @@ -558,6 +558,13 @@ int CustomMods::getOption(const string& sOption, int defValue) { MOD_OPT_CACHE(BATTLE_ROYALE); + MOD_OPT_CACHE(CORE_TWO_PASS_DANGER); + MOD_OPT_CACHE(CORE_DELAYED_VISIBILITY); + MOD_OPT_CACHE(CORE_HOVERING_UNITS); + MOD_OPT_CACHE(CORE_RESILIENT_PANTHEONS); + + MOD_OPT_CACHE(UNIT_KILL_STATS); + MOD_OPT_CACHE(AI_UNIT_PRODUCTION); MOD_OPT_CACHE(ADJACENT_BLOCKADE); MOD_OPT_CACHE(ATTRITION); diff --git a/CvGameCoreDLL_Expansion2/CustomMods.h b/CvGameCoreDLL_Expansion2/CustomMods.h index 9aeda43739..ea43abfe88 100644 --- a/CvGameCoreDLL_Expansion2/CustomMods.h +++ b/CvGameCoreDLL_Expansion2/CustomMods.h @@ -61,16 +61,16 @@ #define MOD_BALANCE_RANGED_ATTACK_ONLY_IN_NATIVE_DOMAIN // for debugging only -//#define MOD_UNIT_KILL_STATS +#define MOD_UNIT_KILL_STATS gCustomMods.isUNIT_KILL_STATS() /// visible tiles stay visible until the end of the turn -#define MOD_CORE_DELAYED_VISIBILITY +#define MOD_CORE_DELAYED_VISIBILITY gCustomMods.isCORE_DELAYED_VISIBILITY() /// ignore ZOC for those units which are likely to be killed by the enemy (alternatively ignore ZOC for all owned units) -//#define MOD_CORE_TWO_PASS_DANGER +#define MOD_CORE_TWO_PASS_DANGER gCustomMods.isCORE_TWO_PASS_DANGER() -/// define this if you need hovercraft support, but it costs performance -//#define MOD_CORE_HOVERING_UNITS +/// set this to true if you need hovercraft support, but it costs performance +#define MOD_CORE_HOVERING_UNITS gCustomMods.isCORE_HOVERING_UNITS() /// unrevealed plots are impassable instead of passable by default #define MOD_CORE_UNREVEALED_IMPASSABLE @@ -78,14 +78,11 @@ /// for better multiplayer experience #define MOD_CORE_REDUCE_RANDOMNESS -#define MOD_CORE_RESILIENT_PANTHEONS +#define MOD_CORE_RESILIENT_PANTHEONS gCustomMods.isCORE_RESILIENT_PANTHEONS() // track how much damage a unit takes per turn in order to better predict whether it might die #define MOD_CORE_PER_TURN_DAMAGE -// Comment out this line to include all the tutorials code -#define NO_TUTORIALS - // Comment out this line to switch off all custom mod logging #define CUSTOMLOGDEBUG "CustomMods.log" // Define to include the file name and line number in the log @@ -1558,6 +1555,13 @@ class CustomMods { MOD_OPT_DECL(BATTLE_ROYALE); + MOD_OPT_DECL(UNIT_KILL_STATS); + + MOD_OPT_DECL(CORE_TWO_PASS_DANGER); + MOD_OPT_DECL(CORE_DELAYED_VISIBILITY); + MOD_OPT_DECL(CORE_HOVERING_UNITS); + MOD_OPT_DECL(CORE_RESILIENT_PANTHEONS); + MOD_OPT_DECL(AI_UNIT_PRODUCTION); MOD_OPT_DECL(ADJACENT_BLOCKADE); MOD_OPT_DECL(ATTRITION); diff --git a/CvGameCoreDLL_Expansion2/CvAdvisorCounsel.cpp b/CvGameCoreDLL_Expansion2/CvAdvisorCounsel.cpp index b41e1bcf32..5981b7a4b0 100644 --- a/CvGameCoreDLL_Expansion2/CvAdvisorCounsel.cpp +++ b/CvGameCoreDLL_Expansion2/CvAdvisorCounsel.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -384,7 +384,7 @@ void CvAdvisorCounsel::BuildCounselList(PlayerTypes ePlayer) { if(pUnitEntry->GetPrereqAndTech() == eTech && pUnitEntry->GetUnitCombatType() != NO_UNITCOMBAT) { - UnitTypes eCivUnit = ((GET_PLAYER(ePlayer).GetSpecificUnitType((UnitClassTypes)pUnitEntry->GetUnitClassType()))); + UnitTypes eCivUnit = GET_PLAYER(ePlayer).GetSpecificUnitType((UnitClassTypes)pUnitEntry->GetUnitClassType()); if(eUnitType != eCivUnit) { continue; diff --git a/CvGameCoreDLL_Expansion2/CvBeliefClasses.cpp b/CvGameCoreDLL_Expansion2/CvBeliefClasses.cpp index 1120e4d014..5d8c79b5bb 100644 --- a/CvGameCoreDLL_Expansion2/CvBeliefClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvBeliefClasses.cpp @@ -1856,11 +1856,7 @@ void CvBeliefXMLEntries::DeleteArray() /// Get a specific entry CvBeliefEntry* CvBeliefXMLEntries::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_BELIEF) ? m_paBeliefEntries[index] : NULL; -#else - return m_paBeliefEntries[index]; -#endif + return (index != NO_BELIEF) ? m_paBeliefEntries[index] : NULL; } //===================================== @@ -1868,118 +1864,29 @@ CvBeliefEntry* CvBeliefXMLEntries::GetEntry(int index) //===================================== /// Constructor CvReligionBeliefs::CvReligionBeliefs() : -#if !defined(MOD_BALANCE_CORE_BELIEFS) -m_paiBuildingClassEnabled(NULL) -#else m_ReligionBeliefs(), m_BeliefLookup(), m_eReligion(NO_RELIGION) -#endif { Reset(); } -/// Destructor -CvReligionBeliefs::~CvReligionBeliefs(void) -{ - Uninit(); -} - /// Copy Constructor with typical parameters CvReligionBeliefs::CvReligionBeliefs(const CvReligionBeliefs& source) { m_ReligionBeliefs = source.m_ReligionBeliefs; -#if defined(MOD_BALANCE_CORE) m_BeliefLookup = source.m_BeliefLookup; m_eReligion = source.m_eReligion; -#endif -#if !defined(MOD_BALANCE_CORE_BELIEFS) - m_paiBuildingClassEnabled = FNEW(int[GC.getNumBuildingClassInfos()], c_eCiv5GameplayDLL, 0); - for(int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++) - { - CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo((BuildingClassTypes)iI); - if(!pkBuildingClassInfo) - { - continue; - } - - m_paiBuildingClassEnabled[iI] = source.m_paiBuildingClassEnabled[iI]; - } -#endif -} - -/// Deallocate memory created in initialize -void CvReligionBeliefs::Uninit() -{ -#if !defined(MOD_BALANCE_CORE_BELIEFS) - SAFE_DELETE_ARRAY(m_paiBuildingClassEnabled); -#endif } /// Reset data members void CvReligionBeliefs::Reset() { -#if !defined(MOD_BALANCE_CORE_BELIEFS) - m_iFaithFromDyingUnits = 0; - m_iRiverHappiness = 0; - m_iPlotCultureCostModifier = 0; - m_iCityRangeStrikeModifier = 0; - m_iCombatModifierEnemyCities = 0; - m_iCombatModifierFriendlyCities = 0; - m_iFriendlyHealChange = 0; - m_iCityStateFriendshipModifier = 0; - m_iLandBarbarianConversionPercent = 0; - m_iSpreadDistanceModifier = 0; - m_iSpreadStrengthModifier = 0; - m_iProphetStrengthModifier = 0; - m_iProphetCostModifier = 0; - m_iMissionaryStrengthModifier = 0; - m_iMissionaryCostModifier = 0; - m_iFriendlyCityStateSpreadModifier = 0; - m_iGreatPersonExpendedFaith = 0; - m_iCityStateMinimumInfluence = 0; - m_iCityStateInfluenceModifier = 0; - m_iOtherReligionPressureErosion = 0; - m_iSpyPressure = 0; - m_iInquisitorPressureRetention = 0; - m_iFaithBuildingTourism = 0; - -#if defined(MOD_BALANCE_CORE_BELIEFS) - m_iCombatVersusOtherReligionOwnLands = 0; - m_iCombatVersusOtherReligionTheirLands = 0; - m_iMissionaryInfluenceCS = 0; - m_iHappinessPerPantheon = 0; - m_iExtraVotes = 0; -#endif -#if defined(MOD_BALANCE_CORE) - m_eRequiredCivilization = NO_CIVILIZATION; -#endif - - m_eObsoleteEra = NO_ERA; - m_eResourceRevealed = NO_RESOURCE; - m_eSpreadModifierDoublingTech = NO_TECH; -#endif - m_ReligionBeliefs.clear(); -#if defined(MOD_BALANCE_CORE) m_eReligion = NO_RELIGION; m_BeliefLookup = std::vector(GC.GetGameBeliefs()->GetNumBeliefs(),0); -#endif -#if !defined(MOD_BALANCE_CORE_BELIEFS) - m_paiBuildingClassEnabled = FNEW(int[GC.getNumBuildingClassInfos()], c_eCiv5GameplayDLL, 0); - for(int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++) - { - CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo((BuildingClassTypes)iI); - if(!pkBuildingClassInfo) - { - continue; - } - - m_paiBuildingClassEnabled[iI] = 0; - } -#endif } -#if defined(MOD_BALANCE_CORE) + void CvReligionBeliefs::SetReligion(ReligionTypes eReligion) { m_eReligion = eReligion; @@ -1988,83 +1895,30 @@ ReligionTypes CvReligionBeliefs::GetReligion() const { return m_eReligion; } -#endif + /// Store off data on bonuses from beliefs void CvReligionBeliefs::AddBelief(BeliefTypes eBelief) { CvAssert(eBelief != NO_BELIEF); - if(eBelief == NO_BELIEF) + if (eBelief == NO_BELIEF) return; CvBeliefEntry* belief = GC.GetGameBeliefs()->GetEntry(eBelief); - CvAssert(belief != NULL); - if(belief == NULL) + CvAssert(belief); + if (!belief) return; -#if !defined(MOD_BALANCE_CORE_BELIEFS) - m_iFaithFromDyingUnits += belief->GetFaithFromDyingUnits(); - m_iRiverHappiness += belief->GetRiverHappiness(); - m_iPlotCultureCostModifier += belief->GetPlotCultureCostModifier(); - m_iCityRangeStrikeModifier += belief->GetCityRangeStrikeModifier(); - m_iCombatModifierEnemyCities += belief->GetCombatModifierEnemyCities(); - m_iCombatModifierFriendlyCities += belief->GetCombatModifierFriendlyCities(); - m_iFriendlyHealChange += belief->GetFriendlyHealChange(); - m_iCityStateFriendshipModifier += belief->GetCityStateFriendshipModifier(); - m_iLandBarbarianConversionPercent += belief->GetLandBarbarianConversionPercent(); - m_iSpreadDistanceModifier += belief->GetSpreadDistanceModifier(); - m_iSpreadStrengthModifier += belief->GetSpreadStrengthModifier(); - m_iProphetStrengthModifier += belief->GetProphetStrengthModifier(); - m_iProphetCostModifier += belief->GetProphetCostModifier(); - m_iMissionaryStrengthModifier += belief->GetMissionaryStrengthModifier(); - m_iMissionaryCostModifier += belief->GetMissionaryCostModifier(); - m_iFriendlyCityStateSpreadModifier += belief->GetFriendlyCityStateSpreadModifier(); - m_iGreatPersonExpendedFaith += belief->GetGreatPersonExpendedFaith(); - m_iCityStateMinimumInfluence += belief->GetCityStateMinimumInfluence(); - m_iCityStateInfluenceModifier += belief->GetCityStateInfluenceModifier(); - m_iOtherReligionPressureErosion += belief->GetOtherReligionPressureErosion(); - m_iSpyPressure += belief->GetSpyPressure(); - m_iInquisitorPressureRetention += belief->GetInquisitorPressureRetention(); - m_iFaithBuildingTourism += belief->GetFaithBuildingTourism(); -#if defined(MOD_BALANCE_CORE_BELIEFS) - m_iCombatVersusOtherReligionOwnLands += belief->GetCombatVersusOtherReligionOwnLands(); - m_iCombatVersusOtherReligionTheirLands += belief->GetCombatVersusOtherReligionTheirLands(); - m_iMissionaryInfluenceCS += belief->GetMissionaryInfluenceCS(); - m_iHappinessPerPantheon += belief->GetHappinessPerPantheon(); - m_iExtraVotes += belief->GetExtraVotes(); -#endif -#if defined(MOD_BALANCE_CORE) - m_eRequiredCivilization = belief->GetRequiredCivilization(); -#endif - - m_eObsoleteEra = belief->GetObsoleteEra(); - m_eResourceRevealed = belief->GetResourceRevealed(); - for (int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++) - { - if (belief->IsBuildingClassEnabled(iI)) - { - m_paiBuildingClassEnabled[iI]++; - } - } - if(belief->GetSpreadModifierDoublingTech() != NO_TECH) - { - m_eSpreadModifierDoublingTech = belief->GetSpreadModifierDoublingTech(); - } -#endif - m_ReligionBeliefs.push_back((int)eBelief); - m_BeliefLookup[(int)(eBelief)] = 1; + m_ReligionBeliefs.push_back(eBelief); + m_BeliefLookup[eBelief] = 1; } /// Does this religion possess a specific belief? bool CvReligionBeliefs::HasBelief(BeliefTypes eBelief) const { -#if defined(MOD_BALANCE_CORE) - if (eBelief==NO_BELIEF) + if (eBelief == NO_BELIEF) return m_ReligionBeliefs.empty(); - return m_BeliefLookup[(int)(eBelief)]==1; -#else - return (find(m_ReligionBeliefs.begin(), m_ReligionBeliefs.end(), (int)eBelief) != m_ReligionBeliefs.end()); -#endif + return (m_BeliefLookup[eBelief] == 1); } /// Does this religion possess a specific belief? @@ -3758,7 +3612,6 @@ int CvReligionBeliefs::GetPlotYieldChange(PlotTypes ePlot, YieldTypes eYieldType return rtnValue; } -#if defined(MOD_RELIGION_EXTENSIONS) /// Get free promotions from beliefs std::vector CvReligionBeliefs::GetFreePromotions(PlayerTypes ePlayer, const CvCity* pCity, bool bHolyCityOnly) const { @@ -3827,7 +3680,6 @@ int CvReligionBeliefs::GetYieldFromPillageGlobal(YieldTypes eYield, bool bEraSca return rtnValue; } -#endif // Get happiness boost from a resource int CvReligionBeliefs::GetResourceHappiness(ResourceTypes eResource, PlayerTypes ePlayer, bool bHolyCityOnly) const diff --git a/CvGameCoreDLL_Expansion2/CvBeliefClasses.h b/CvGameCoreDLL_Expansion2/CvBeliefClasses.h index 6ec0eec313..57b42fdb27 100644 --- a/CvGameCoreDLL_Expansion2/CvBeliefClasses.h +++ b/CvGameCoreDLL_Expansion2/CvBeliefClasses.h @@ -417,9 +417,7 @@ class CvReligionBeliefs { public: CvReligionBeliefs(void); - ~CvReligionBeliefs(void); CvReligionBeliefs(const CvReligionBeliefs& source); - void Uninit(); void Reset(); void AddBelief(BeliefTypes eBelief); diff --git a/CvGameCoreDLL_Expansion2/CvBuildingClasses.cpp b/CvGameCoreDLL_Expansion2/CvBuildingClasses.cpp index ef4b07b9be..325d384bc2 100644 --- a/CvGameCoreDLL_Expansion2/CvBuildingClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvBuildingClasses.cpp @@ -4544,17 +4544,10 @@ void CvBuildingXMLEntries::DeleteArray() } /// Get a specific entry -#if defined(MOD_BALANCE_CORE) CvBuildingEntry* CvBuildingXMLEntries::GetEntry(int index) const { return (index!=NO_BUILDING) ? m_paBuildingEntries[index] : NULL; } -#else -CvBuildingEntry* CvBuildingXMLEntries::GetEntry(int index) -{ - return m_paBuildingEntries[index]; -} -#endif //===================================== // CvCityBuildings @@ -5203,25 +5196,13 @@ int CvCityBuildings::GetNumRealBuilding(BuildingTypes eIndex) const } /// Accessor: Set number of these buildings that have been constructed in the city - -#if defined(MOD_BALANCE_CORE) void CvCityBuildings::SetNumRealBuilding(BuildingTypes eIndex, int iNewValue, bool bNoBonus) { SetNumRealBuildingTimed(eIndex, iNewValue, true, m_pCity->getOwner(), GC.getGame().getGameTurnYear(), bNoBonus); } -#else -void CvCityBuildings::SetNumRealBuilding(BuildingTypes eIndex, int iNewValue) -{ - SetNumRealBuildingTimed(eIndex, iNewValue, true, m_pCity->getOwner(), GC.getGame().getGameTurnYear()); -} -#endif /// Accessor: Set number of these buildings that have been constructed in the city (with date) -#if defined(MOD_BALANCE_CORE) void CvCityBuildings::SetNumRealBuildingTimed(BuildingTypes eIndex, int iNewValue, bool bFirst, PlayerTypes eOriginalOwner, int iOriginalTime, bool bNoBonus) -#else -void CvCityBuildings::SetNumRealBuildingTimed(BuildingTypes eIndex, int iNewValue, bool bFirst, PlayerTypes eOriginalOwner, int iOriginalTime) -#endif { CvPlayer* pPlayer = &GET_PLAYER(m_pCity->getOwner()); @@ -5277,11 +5258,7 @@ void CvCityBuildings::SetNumRealBuildingTimed(BuildingTypes eIndex, int iNewValu // Process building effects if(iOldNumBuilding != GetNumBuilding(eIndex)) { -#if defined(MOD_BALANCE_CORE) m_pCity->processBuilding(eIndex, iChangeNumRealBuilding, bFirst, false, false, bNoBonus); -#else - m_pCity->processBuilding(eIndex, iChangeNumRealBuilding, bFirst); -#endif } // Maintenance cost @@ -6016,13 +5993,8 @@ int CvCityBuildings::GetYieldFromGreatWorks(YieldTypes eYield) const int iRtnValue = (iStandardWorkCount * iBaseYield); iRtnValue += (iRealWorkCount * iSecondaryYield); //Then theming bonuses for the yield. -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) iRtnValue += GetCurrentThemingBonuses(eYield); -#else - if (eYield == YIELD_CULTURE) { - iRtnValue += GetCurrentThemingBonuses(); - } -#endif + //Next add in any UA or extra theming bonuses. iRtnValue += (iTypeBonuses + iThemingBonusTotal); @@ -6036,13 +6008,8 @@ int CvCityBuildings::GetCultureFromGreatWorks() const } /// Accessor: How many Great Works of specific slot type present in this city? -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) int CvCityBuildings::GetNumGreatWorks(bool bIgnoreYield) const -#else -int CvCityBuildings::GetNumGreatWorks() const -#endif { -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) int iRtnValue = 0; CvCivilizationInfo *pkCivInfo = GC.getCivilizationInfo(m_pCity->getCivilizationType()); @@ -6077,27 +6044,17 @@ int CvCityBuildings::GetNumGreatWorks() const } } return iRtnValue; -#else - // Simple if want total of all types - return m_aBuildingGreatWork.size(); -#endif } /// Accessor: How many Great Works of specific slot type present in this city? -#if defined(MOD_BALANCE_CORE) int CvCityBuildings::GetNumGreatWorks(GreatWorkSlotType eGreatWorkSlot, bool bArtifact, bool bArt) const -#else -int CvCityBuildings::GetNumGreatWorks(GreatWorkSlotType eGreatWorkSlot) const -#endif { if (eGreatWorkSlot == NO_GREAT_WORK_SLOT) return 0; int iRtnValue = 0; -#if defined(MOD_BALANCE_CORE) GreatWorkClass eArtifactsClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_ARTIFACT"); GreatWorkClass eArtClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_ART"); -#endif CvCivilizationInfo *pkCivInfo = GC.getCivilizationInfo(m_pCity->getCivilizationType()); if (pkCivInfo) { @@ -6111,19 +6068,18 @@ int CvCityBuildings::GetNumGreatWorks(GreatWorkSlotType eGreatWorkSlot) const if (MOD_BUILDINGS_THOROUGH_PREREQUISITES) { - eBuilding = GetBuildingTypeFromClass(eBldgClass); } else { eBuilding = (BuildingTypes)pkCivInfo->getCivilizationBuildings(eBldgClass); } + CvBuildingEntry *pkInfo = GC.getBuildingInfo(eBuilding); if (pkInfo) { -#if defined(MOD_BALANCE_CORE) //Art/Artifact need distinction here, because they occupy the same slot! - if(bArtifact) + if (bArtifact) { CvGreatWork work = GC.getGame().GetGameCulture()->m_CurrentGreatWorks[(*it).iGreatWorkIndex]; @@ -6133,7 +6089,7 @@ int CvCityBuildings::GetNumGreatWorks(GreatWorkSlotType eGreatWorkSlot) const iRtnValue++; } } - else if(bArt) + else if (bArt) { CvGreatWork work = GC.getGame().GetGameCulture()->m_CurrentGreatWorks[(*it).iGreatWorkIndex]; @@ -6143,9 +6099,7 @@ int CvCityBuildings::GetNumGreatWorks(GreatWorkSlotType eGreatWorkSlot) const iRtnValue++; } } - else -#endif - if (pkInfo->GetGreatWorkSlotType() == eGreatWorkSlot) + else if (pkInfo->GetGreatWorkSlotType() == eGreatWorkSlot) { iRtnValue++; } @@ -6155,7 +6109,7 @@ int CvCityBuildings::GetNumGreatWorks(GreatWorkSlotType eGreatWorkSlot) const } return iRtnValue; } -#if defined(MOD_BALANCE_CORE) + int CvCityBuildings::GetThemingBonusIndex(BuildingTypes eBuilding) const { return m_paiThemingBonusIndex[eBuilding]; @@ -6169,7 +6123,7 @@ void CvCityBuildings::SetThemingBonusIndex(BuildingTypes eBuilding, int iIndex) m_paiThemingBonusIndex[eBuilding] = iIndex; } } -#endif + /// Accessor: Get tourism converted from culture from Improvements and Wonders int CvCityBuildings::GetLandmarksTourismPercent() const { @@ -6203,16 +6157,11 @@ void CvCityBuildings::ChangeGreatWorksTourismModifier(int iChange) } /// Accessor: Total theming bonus from all buildings in the city -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) int CvCityBuildings::GetCurrentThemingBonuses(YieldTypes eYield) const -#else -int CvCityBuildings::GetCurrentThemingBonuses() const -#endif { int iTotal = 0; for(std::vector::const_iterator iI=m_buildingsThatExistAtLeastOnce.begin(); iI!=m_buildingsThatExistAtLeastOnce.end(); ++iI) { -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) CvBuildingEntry *pkBuilding = GC.getBuildingInfo(*iI); if (pkBuilding) { @@ -6236,9 +6185,6 @@ int CvCityBuildings::GetCurrentThemingBonuses() const iTotal += iBonus; } } -#else - iTotal += m_pCity->GetCityCulture()->GetThemingBonus( (BuildingClassTypes)pkInfo->GetBuildingClassType() ); -#endif } return iTotal; diff --git a/CvGameCoreDLL_Expansion2/CvBuildingClasses.h b/CvGameCoreDLL_Expansion2/CvBuildingClasses.h index 70ba30500a..ecec8b9754 100644 --- a/CvGameCoreDLL_Expansion2/CvBuildingClasses.h +++ b/CvGameCoreDLL_Expansion2/CvBuildingClasses.h @@ -1193,19 +1193,15 @@ class CvCityBuildings void SetBuildingOriginalTime(BuildingTypes eIndex, int iNewValue); int GetNumRealBuilding(BuildingTypes eIndex) const; -#if defined(MOD_BALANCE_CORE) void SetNumRealBuilding(BuildingTypes eIndex, int iNewValue, bool bNoBonus = false); void SetNumRealBuildingTimed(BuildingTypes eIndex, int iNewValue, bool bFirst, PlayerTypes eOriginalOwner, int iOriginalTime, bool bNoBonus = false); -#else - void SetNumRealBuilding(BuildingTypes eIndex, int iNewValue); - void SetNumRealBuildingTimed(BuildingTypes eIndex, int iNewValue, bool bFirst, PlayerTypes eOriginalOwner, int iOriginalTime); -#endif + int GetNumFreeBuilding(BuildingTypes eIndex) const; void SetNumFreeBuilding(BuildingTypes eIndex, int iNewValue); -#if defined(MOD_BALANCE_CORE) + int IsFirstTimeBuilding(BuildingTypes eBuilding); void SetFirstTimeBuilding(BuildingTypes eBuilding, int iValue); -#endif + int GetBuildingYieldChange(BuildingClassTypes eBuildingClass, YieldTypes eYield) const; void SetBuildingYieldChange(BuildingClassTypes eBuildingClass, YieldTypes eYield, int iChange); void ChangeBuildingYieldChange(BuildingClassTypes eBuildingClass, YieldTypes eYield, int iChange); @@ -1224,27 +1220,20 @@ class CvCityBuildings int GetYieldFromGreatWorks(YieldTypes eYield) const; int GetCultureFromGreatWorks() const; -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) + int GetNumGreatWorks(bool bIgnoreYield = true) const; -#else - int GetNumGreatWorks() const; -#endif int GetNumGreatWorks(GreatWorkSlotType eGreatWorkSlot, bool bArtifact = false, bool bArt = false) const; -#if defined(MOD_BALANCE_CORE) + int GetThemingBonusIndex(BuildingTypes eBuilding) const; void SetThemingBonusIndex(BuildingTypes eBuilding, int iIndex); -#endif int GetLandmarksTourismPercent() const; void ChangeLandmarksTourismPercent(int iChange); int GetGreatWorksTourismModifier() const; void ChangeGreatWorksTourismModifier(int iChange); -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) int GetCurrentThemingBonuses(YieldTypes eYield) const; -#else - int GetCurrentThemingBonuses() const; -#endif + int GetTotalNumThemedBuildings() const; int GetNumBuildingsFromFaith() const; diff --git a/CvGameCoreDLL_Expansion2/CvBuildingProductionAI.cpp b/CvGameCoreDLL_Expansion2/CvBuildingProductionAI.cpp index 207e954e65..4969fe3b98 100644 --- a/CvGameCoreDLL_Expansion2/CvBuildingProductionAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvBuildingProductionAI.cpp @@ -480,8 +480,8 @@ int CvBuildingProductionAI::CheckBuildingBuildSanity(BuildingTypes eBuilding, in // the building needs aluminum? check if we'd still have enough for the spaceship if (eResource == eAluminum && pkBuildingInfo->GetResourceQuantityRequirement(eResource) > 0) { - vector vCitiesForSpaceshipParts = kPlayer.GetCoreCitiesForSpaceshipProduction(); - if (std::find(vCitiesForSpaceshipParts.begin(), vCitiesForSpaceshipParts.end(), m_pCity) == vCitiesForSpaceshipParts.end()) + const vector& vCitiesForSpaceshipParts = kPlayer.GetCoreCitiesForSpaceshipProduction(); + if (std::find(vCitiesForSpaceshipParts.begin(), vCitiesForSpaceshipParts.end(), m_pCity->GetID()) == vCitiesForSpaceshipParts.end()) { // this is not one of the core cities for spaceship parts. only build something if we'd still have enough aluminum for spaceship parts and for buildings in the core cities int iNumAluminumWeCanUse = kPlayer.getNumResourceAvailable(eResource, false) - kPlayer.GetNumAluminumStillNeededForSpaceship() - kPlayer.GetNumAluminumStillNeededForCoreCities(); diff --git a/CvGameCoreDLL_Expansion2/CvCity.cpp b/CvGameCoreDLL_Expansion2/CvCity.cpp index 65f2923ed5..ed7c0d8cff 100644 --- a/CvGameCoreDLL_Expansion2/CvCity.cpp +++ b/CvGameCoreDLL_Expansion2/CvCity.cpp @@ -594,13 +594,8 @@ void CvCity::init(int iID, PlayerTypes eOwner, int iX, int iY, bool bBumpUnits, //only after the owner is set! pPlot->setIsCity(true, m_iID, getWorkPlotDistance()); -#if defined(MOD_EVENTS_TILE_IMPROVEMENTS) pPlot->SetImprovementPillaged(false, false); pPlot->SetRoutePillaged(false, false); -#else - pPlot->SetImprovementPillaged(false); - pPlot->SetRoutePillaged(false); -#endif //clear the first ring int iRange = min(1, /*1*/ GD_INT_GET(CITY_STARTING_RINGS)); @@ -741,11 +736,6 @@ void CvCity::init(int iID, PlayerTypes eOwner, int iX, int iY, bool bBumpUnits, for (int iUnitClassLoop = 0; iUnitClassLoop < GC.getNumUnitClassInfos(); iUnitClassLoop++) { const UnitClassTypes eUnitClass = static_cast(iUnitClassLoop); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (!pkUnitClassInfo) - { - continue; - } if (GET_PLAYER(getOwner()).IsFreeUnitNewFoundCity(eUnitClass)) { UnitTypes eUnit = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); @@ -1774,7 +1764,7 @@ void CvCity::reset(int iID, PlayerTypes eOwner, int iX, int iY, bool bConstructo } int iNumSpecialistInfos = GC.getNumSpecialistInfos(); - for (iI = 0; iI < GC.getNumSpecialistInfos(); iI++) + for (iI = 0; iI < iNumSpecialistInfos; iI++) { m_aiSpecialistRateModifier[iI] = 0; } @@ -7414,34 +7404,30 @@ void CvCity::DoEventChoice(CityEventChoiceTypes eEventChoice, CityEventTypes eCi for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo) - { - if (pkEventChoiceInfo->getNumFreeUnits((UnitClassTypes)iI) <= 0) - continue; + if (pkEventChoiceInfo->getNumFreeUnits((UnitClassTypes)iI) <= 0) + continue; - const UnitTypes eLoopUnit = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); - if (eLoopUnit != NO_UNIT) + const UnitTypes eLoopUnit = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); + if (eLoopUnit != NO_UNIT) + { + CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eLoopUnit); + if (pkUnitEntry) { - CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eLoopUnit); - if (pkUnitEntry) + for (int iJ = 0; iJ < pkEventChoiceInfo->getNumFreeUnits((UnitClassTypes)iI); iJ++) { - for (int iJ = 0; iJ < pkEventChoiceInfo->getNumFreeUnits((UnitClassTypes)iI); iJ++) + UnitAITypes eUnitAI = pkUnitEntry->GetDefaultUnitAIType(); + CvUnit* pUnit = CreateUnit(eLoopUnit, eUnitAI, REASON_GIFT); + if (pUnit) { - UnitAITypes eUnitAI = pkUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = CreateUnit(eLoopUnit, eUnitAI, REASON_GIFT); - if (pUnit) + if (!pUnit->IsCivilianUnit() && !pUnit->jumpToNearestValidPlot()) { - if (!pUnit->IsCivilianUnit() && !pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - else - { - pUnit->finishMoves(); - //Lua Hook - GAMEEVENTINVOKE_HOOK(GAMEEVENT_EventUnitCreated, getOwner(), eEventChoice, pUnit); - } + pUnit->kill(false); // Could not find a valid spot! + } + else + { + pUnit->finishMoves(); + //Lua Hook + GAMEEVENTINVOKE_HOOK(GAMEEVENT_EventUnitCreated, getOwner(), eEventChoice, pUnit); } } } @@ -7566,7 +7552,7 @@ void CvCity::DoEventChoice(CityEventChoiceTypes eEventChoice, CityEventTypes eCi // In hundreds int iNumRecruits = pkEventChoiceInfo->getFreeScaledUnits(); - GC.getGame().DoSpawnUnitsAroundTargetCity(getOwner(), this, iNumRecruits, false, isCoastal(), false, false); + SpawnPlayerUnitsNearby(getOwner(), iNumRecruits, false, isCoastal()); } if (pkEventChoiceInfo->getSpecialistsGreatPersonPointsPerTurn() != 0) { @@ -7817,33 +7803,17 @@ bool CvCity::IsRouteToCapitalConnected(void) const // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void CvCity::createGreatGeneral(UnitTypes eGreatPersonUnit, bool bIsFree) -#else -void CvCity::createGreatGeneral(UnitTypes eGreatPersonUnit) -#endif { VALIDATE_OBJECT -#if defined(MOD_GLOBAL_TRULY_FREE_GP) GET_PLAYER(getOwner()).createGreatGeneral(eGreatPersonUnit, getX(), getY(), bIsFree); -#else - GET_PLAYER(getOwner()).createGreatGeneral(eGreatPersonUnit, getX(), getY()); -#endif } // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void CvCity::createGreatAdmiral(UnitTypes eGreatPersonUnit, bool bIsFree) -#else -void CvCity::createGreatAdmiral(UnitTypes eGreatPersonUnit) -#endif { VALIDATE_OBJECT -#if defined(MOD_GLOBAL_TRULY_FREE_GP) GET_PLAYER(getOwner()).createGreatAdmiral(eGreatPersonUnit, getX(), getY(), bIsFree); -#else - GET_PLAYER(getOwner()).createGreatAdmiral(eGreatPersonUnit, getX(), getY()); -#endif } // -------------------------------------------------------------------------------- @@ -8496,49 +8466,46 @@ UnitTypes CvCity::allUpgradesAvailable(UnitTypes eUnit, int iUpgradeCount) const for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo) + if (pkUnitInfo->GetUpgradeUnitClass(iI)) { - if (pkUnitInfo->GetUpgradeUnitClass(iI)) - { - const UnitTypes eLoopUnit = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); + const UnitTypes eLoopUnit = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); - if (eLoopUnit != NO_UNIT) - { - bUpgradeFound = true; + if (eLoopUnit != NO_UNIT) + { + bUpgradeFound = true; - const UnitTypes eTempUnit = allUpgradesAvailable(eLoopUnit, (iUpgradeCount + 1)); + const UnitTypes eTempUnit = allUpgradesAvailable(eLoopUnit, (iUpgradeCount + 1)); - if (eTempUnit != NO_UNIT) - { - eUpgradeUnit = eTempUnit; - bUpgradeAvailable = true; - } - else - { - bUpgradeUnavailable = true; - } + if (eTempUnit != NO_UNIT) + { + eUpgradeUnit = eTempUnit; + bUpgradeAvailable = true; + } + else + { + bUpgradeUnavailable = true; } } - if (GET_PLAYER(getOwner()).GetPlayerTraits()->HasSpecialUnitUpgrade(eUnitClass, eUnit)) - { - const UnitTypes eLoopUnit = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); + } - if (eLoopUnit != NO_UNIT) - { - bUpgradeFound = true; + if (GET_PLAYER(getOwner()).GetPlayerTraits()->HasSpecialUnitUpgrade(eUnitClass, eUnit)) + { + const UnitTypes eLoopUnit = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); - const UnitTypes eTempUnit = allUpgradesAvailable(eLoopUnit, (iUpgradeCount + 1)); + if (eLoopUnit != NO_UNIT) + { + bUpgradeFound = true; - if (eTempUnit != NO_UNIT) - { - eUpgradeUnit = eTempUnit; - bUpgradeAvailable = true; - } - else - { - bUpgradeUnavailable = true; - } + const UnitTypes eTempUnit = allUpgradesAvailable(eLoopUnit, (iUpgradeCount + 1)); + + if (eTempUnit != NO_UNIT) + { + eUpgradeUnit = eTempUnit; + bUpgradeAvailable = true; + } + else + { + bUpgradeUnavailable = true; } } } @@ -9143,11 +9110,7 @@ bool CvCity::canConstruct(BuildingTypes eBuilding, const std::vector& vPreE int iNumBuildingClassInfos = GC.getNumBuildingClassInfos(); // Can't construct a building to reduce occupied unhappiness if the city isn't occupied -#if defined(MOD_BALANCE_CORE) if (pkBuildingInfo->IsNoOccupiedUnhappiness() && !IsOccupied() && !pkBuildingInfo->IsBuildAnywhere()) -#else - if (pkBuildingInfo->IsNoOccupiedUnhappiness() && !IsOccupied()) -#endif return false; // Does this city have prereq buildings? @@ -9178,11 +9141,7 @@ bool CvCity::canConstruct(BuildingTypes eBuilding, const std::vector& vPreE { if (!bContinue) { -#if defined(MOD_BALANCE_CORE_BUILDING_INVESTMENTS) if (!MOD_BALANCE_CORE_BUILDING_INVESTMENTS && getFirstBuildingOrder(eBuilding) != -1) -#else - if (getFirstBuildingOrder(eBuilding) != -1) -#endif { return false; } @@ -9919,59 +9878,57 @@ void CvCity::ChangeNumResourceLocal(ResourceTypes eResource, int iChange, bool b bool CvCity::IsBuildingLocalResourceValid(BuildingTypes eBuilding, bool bTestVisible, CvString* toolTipSink) const { VALIDATE_OBJECT - CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eBuilding); - if (pkBuildingInfo == NULL) + CvBuildingEntry* pBuildingInfo = GC.getBuildingInfo(eBuilding); + if (!pBuildingInfo) return false; - // ANDs: City must have ALL of these nearby + bool bHasAllAnd = true; + bool bHasAnyOr = false; + bool bNeedAnyOr = false; + CvString tempTooltip; for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) { - ResourceTypes eResource = (ResourceTypes)pkBuildingInfo->GetLocalResourceAnd(iResourceLoop); + ResourceTypes eAndResource = static_cast(pBuildingInfo->GetLocalResourceAnd(iResourceLoop)); + ResourceTypes eOrResource = static_cast(pBuildingInfo->GetLocalResourceOr(iResourceLoop)); - // Doesn't require a resource in this AND slot - if (eResource == NO_RESOURCE) - continue; + // Both lists have run out; terminate early + if (eAndResource == NO_RESOURCE && eOrResource == NO_RESOURCE) + break; - CvResourceInfo* pkResource = GC.getResourceInfo(eResource); - if (pkResource == NULL) - continue; + CvResourceInfo* pAndResource = GC.getResourceInfo(eAndResource); + CvResourceInfo* pOrResource = GC.getResourceInfo(eOrResource); - // City doesn't have resource locally - return false immediately - if (!IsHasResourceLocal(eResource, bTestVisible)) + // City doesn't have resource locally + if (pAndResource && !IsHasResourceLocal(eAndResource, bTestVisible)) { - GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_NO_ACTION_BUILDING_LOCAL_RESOURCE", pkResource->GetTextKey(), pkResource->GetIconString()); - return false; + GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_NO_ACTION_BUILDING_LOCAL_RESOURCE", pAndResource->GetTextKey(), pAndResource->GetIconString()); + bHasAllAnd = false; } - } - int iOrResources = 0; - - // ORs: City must have ONE of these nearby - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - ResourceTypes eResource = (ResourceTypes)pkBuildingInfo->GetLocalResourceOr(iResourceLoop); - - // Doesn't require a resource in this AND slot - if (eResource == NO_RESOURCE) - continue; - - CvResourceInfo* pkResource = GC.getResourceInfo(eResource); - if (pkResource == NULL) - continue; + if (pOrResource) + { + bNeedAnyOr = true; - // City has resource locally - return true immediately - if (IsHasResourceLocal(eResource, bTestVisible)) - return true; + // City has resource locally + if (!IsHasResourceLocal(eOrResource, bTestVisible)) + { + bHasAnyOr = true; + continue; + } - // If we get here it means we passed the AND tests but not one of the OR tests - GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_NO_ACTION_BUILDING_LOCAL_RESOURCE", pkResource->GetTextKey(), pkResource->GetIconString()); + // Otherwise, prepare the temp tooltip + GC.getGame().BuildCannotPerformActionHelpText(&tempTooltip, "TXT_KEY_NO_ACTION_BUILDING_LOCAL_RESOURCE", pOrResource->GetTextKey(), pOrResource->GetIconString()); + } + } - // Increment counter for OR we don't have - iOrResources++; + if (!bHasAllAnd || (bNeedAnyOr && !bHasAnyOr)) + { + // Hope nobody puts both AND and OR requirements onto the same building... + *toolTipSink += tempTooltip; + return false; } - // No OR resource requirements (and passed the AND test above) - return iOrResources == 0; + return true; } // -------------------------------------------------------------------------------- @@ -10860,7 +10817,7 @@ bool CvCity::canContinueProduction(OrderData order) // -------------------------------------------------------------------------------- -int CvCity::getProductionExperience(UnitTypes eUnit) +int CvCity::getProductionExperience(UnitTypes eUnit) const { VALIDATE_OBJECT CvPlayerAI& kOwner = GET_PLAYER(getOwner()); @@ -10904,7 +10861,7 @@ int CvCity::getProductionExperience(UnitTypes eUnit) // -------------------------------------------------------------------------------- -void CvCity::addProductionExperience(CvUnit* pUnit, bool bHalveXP, bool bGoldPurchase) +void CvCity::addProductionExperience(CvUnit* pUnit, bool bHalveXP, bool bGoldPurchase) const { VALIDATE_OBJECT bHalveXP = (bHalveXP || (bGoldPurchase && MOD_BALANCE_CORE_HALF_XP_PURCHASE && GET_PLAYER(getOwner()).GetNoXPLossUnitPurchase() <= 0 && !pUnit->getUnitInfo().CanMoveAfterPurchase())); @@ -11183,11 +11140,7 @@ int CvCity::getGeneralProductionTurnsLeft() const break; case ORDER_MAINTAIN: -#if defined(MOD_PROCESS_STOCKPILE) return getProductionTurnsLeft((ProcessTypes)pOrderNode->iData1, 0); -#else - return 0; -#endif break; default: @@ -12137,11 +12090,7 @@ int CvCity::GetFaithPurchaseCost(UnitTypes eUnit, bool bIncludeBeliefDiscounts) } else { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iCost = kPlayer.GetReligions()->GetCostNextProphet(true /*bIncludeBeliefDiscounts*/, false /*bAdjustForSpeedDifficulty*/, MOD_GLOBAL_TRULY_FREE_GP); -#else - iCost = kPlayer.GetReligions()->GetCostNextProphet(true /*bIncludeBeliefDiscounts*/, false /*bAdjustForSpeedDifficulty*/); -#endif } } else if (eThisPlayersUnitType == eUnit) @@ -12477,7 +12426,6 @@ int CvCity::GetPurchaseCost(BuildingTypes eBuilding) if (iModifier == -1) return -1; -#if defined(MOD_BALANCE_CORE_BUILDING_INVESTMENTS) if (MOD_BALANCE_CORE_BUILDING_INVESTMENTS && (NO_BUILDING != eBuilding)) { //Have we already invested here? @@ -12487,20 +12435,17 @@ int CvCity::GetPurchaseCost(BuildingTypes eBuilding) return -1; } } -#endif -#if defined(MOD_BUILDINGS_PRO_RATA_PURCHASE) + int iProductionNeeded = getProductionNeeded(eBuilding); - if (MOD_BUILDINGS_PRO_RATA_PURCHASE) { + if (MOD_BUILDINGS_PRO_RATA_PURCHASE) + { // Deduct any current production towards this building int iProductionToDate = m_pCityBuildings->GetBuildingProduction(eBuilding); iProductionNeeded -= (iProductionToDate * gCustomMods.getOption("BUILDINGS_PRO_RATA_PURCHASE_DEPRECIATION", 80)) / 100; } int iCost = GetPurchaseCostFromProduction(iProductionNeeded); -#else - int iCost = GetPurchaseCostFromProduction(getProductionNeeded(eBuilding)); -#endif iCost *= (100 + iModifier); iCost /= 100; @@ -13184,11 +13129,7 @@ int CvCity::getProductionModifier(UnitTypes eUnit, CvString* toolTipSink, bool b { for (int iResource = 0; iResource < GC.getNumResourceInfos(); iResource++) { -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) if (pkUnitInfo->GetResourceQuantityRequirement(iResource) > 0 || (MOD_UNITS_RESOURCE_QUANTITY_TOTALS && pkUnitInfo->GetResourceQuantityTotal(iResource) > 0)) -#else - if (pkUnitInfo->GetResourceQuantityRequirement(iResource) > 0) -#endif { iTempMod = pkCorporationInfo->GetUnitResourceProductionModifier(iResource); iMultiplier += iTempMod; @@ -13979,11 +13920,7 @@ void CvCity::processResource(ResourceTypes eResource, int iChange) // -------------------------------------------------------------------------------- -#if defined(MOD_BALANCE_CORE) void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, bool bObsolete, bool /*bApplyingAllCitiesBonus*/, bool bNoBonus) -#else -void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, bool bObsolete, bool /*bApplyingAllCitiesBonus*/) -#endif { VALIDATE_OBJECT @@ -14026,7 +13963,7 @@ void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, // Capital if (pBuildingInfo->IsCapital()) owningPlayer.setCapitalCity(this); -#if defined(MOD_BALANCE_CORE) + bool bIsWonder = ::isWorldWonderClass(pBuildingInfo->GetBuildingClassInfo()); if (bIsWonder) { @@ -14061,675 +13998,67 @@ void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, } } } -#endif - // Free Units - CvUnit* pFreeUnit = NULL; + // Free Units int iFreeUnitLoop = 0; int iFreeSpecUnitLoop = 0; for (int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) { const UnitTypes eUnit = static_cast(iUnitLoop); - CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit); - if (pkUnitInfo) + const CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnit); + if (pUnitInfo) { - for (iFreeUnitLoop = 0; iFreeUnitLoop < pBuildingInfo->GetNumFreeUnits(iUnitLoop); iFreeUnitLoop++) + // No settling units for One City Challenge + if (isHuman() && pUnitInfo->IsFound() && GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE)) + continue; + + int iNumFreeUnits = pBuildingInfo->GetNumFreeUnits(iUnitLoop); + int iNumFreeSpecUnits = pBuildingInfo->GetNumFreeSpecialUnits(iUnitLoop); + + if (iNumFreeUnits > 0 || iNumFreeSpecUnits > 0) { - // Get the right unit of this class for this civ - const UnitTypes eFreeUnitType = owningPlayer.GetSpecificUnitType((UnitClassTypes)pkUnitInfo->GetUnitClassType()); -#if defined(MOD_BALANCE_CORE) - //Test for forbidden or locked units. - if (eFreeUnitType == NO_UNIT) + for (iFreeSpecUnitLoop = 0; iFreeSpecUnitLoop < iNumFreeSpecUnits; iFreeSpecUnitLoop++) { - // Great prophet? - if (GC.GetGameUnits()->GetEntry(eUnit)->IsFoundReligion()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, MOD_GLOBAL_TRULY_FREE_GP); -#else - GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true); -#endif - } - else - { -#if defined(MOD_BALANCE_CORE) - // for venice - pFreeUnit = NULL; - if (pkUnitInfo->IsFound() && owningPlayer.GetPlayerTraits()->IsNoAnnexing()) - { - // drop a merchant of venice instead - // find the eUnit replacement that's the merchant of venice - for (int iVeniceSearch = 0; iVeniceSearch < GC.getNumUnitClassInfos(); iVeniceSearch++) - { - const UnitClassTypes eVeniceUnitClass = static_cast(iVeniceSearch); - CvUnitClassInfo* pkVeniceUnitClassInfo = GC.getUnitClassInfo(eVeniceUnitClass); - if (pkVeniceUnitClassInfo) - { - const UnitTypes eMerchantOfVeniceUnit = owningPlayer.GetSpecificUnitType(eVeniceUnitClass); - if (eMerchantOfVeniceUnit != NO_UNIT) - { - CvUnitEntry* pVeniceUnitEntry = GC.getUnitInfo(eMerchantOfVeniceUnit); - if (pVeniceUnitEntry->IsCanBuyCityState()) - { - pFreeUnit = owningPlayer.initUnit(eMerchantOfVeniceUnit, getX(), getY()); - break; - } - } - } - } - } - else - { -#endif - pFreeUnit = owningPlayer.initUnit(eUnit, getX(), getY()); - bool bJumpSuccess = pFreeUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - addProductionExperience(pFreeUnit); - if (getFirstUnitOrder(eUnit) == 0) - { - clearOrderQueue(); - chooseProduction(); - } - } - else - { - pFreeUnit->kill(false); - } -#if defined(MOD_BALANCE_CORE) - } - if (pFreeUnit->IsGreatPerson()) - { - if (owningPlayer.GetPlayerTraits()->IsGPWLTKD()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - this->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = owningPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); - strText << pFreeUnit->getNameKey() << this->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); - strSummary << this->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), this->getX(), this->getY(), -1); - } - } - } - if (pFreeUnit->isWLKTKDOnBirth()) - { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for (pLoopCity = owningPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = owningPlayer.nextCity(&iLoop)) - { - if (pLoopCity != NULL && pLoopCity->getOwner() == owningPlayer.GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; + SpawnFreeUnit(eUnit); + } - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = owningPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << pFreeUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - } - if (pFreeUnit->isGoldenAgeOnBirth()) - { - owningPlayer.changeGoldenAgeTurns(owningPlayer.getGoldenAgeLength()); - } - if (pFreeUnit->isCultureBoost()) - { - int iValue = owningPlayer.GetTotalJONSCulturePerTurn() * 4; - owningPlayer.changeJONSCulture(iValue); - if (owningPlayer.getCapitalCity() != NULL) - owningPlayer.getCapitalCity()->ChangeJONSCultureStored(iValue); + // Get the right unit of this class for this civ + const UnitClassTypes eFreeUnitClass = static_cast(pUnitInfo->GetUnitClassType()); + UnitTypes eFreeUnit = owningPlayer.GetSpecificUnitType(eFreeUnitClass); - CvNotifications* pNotifications = owningPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << pFreeUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << pFreeUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pFreeUnit->getX(), pFreeUnit->getY(), -1); - } - } - } -#endif - // Bump up the count - if (pFreeUnit->IsGreatGeneral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatGeneralsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatGeneralsCreated(); -#endif - bool bJumpSuccess = pFreeUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - addProductionExperience(pFreeUnit); - } - else - { - pFreeUnit->kill(false); - } - } - else if (pFreeUnit->IsGreatAdmiral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatAdmiralsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatAdmiralsCreated(); -#endif - CvPlot* pSpawnPlot = owningPlayer.GetBestCoastalSpawnPlot(pFreeUnit); - if (pFreeUnit->plot() != pSpawnPlot) - { - pFreeUnit->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); - addProductionExperience(pFreeUnit); - } - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_WRITER")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatWritersCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatWritersCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_ARTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatArtistsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatArtistsCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MUSICIAN")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatMusiciansCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatMusiciansCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (MOD_BALANCE_VP && pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatDiplomatsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatDiplomatsCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } -#if defined(MOD_BALANCE_CORE) - else if (pkUnitInfo->IsGPExtra() == 1) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra1Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra1Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 2) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra2Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra2Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 3) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra3Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra3Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 4) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra4Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra4Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 5) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra5Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra5Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } -#endif - else if (pFreeUnit->IsGreatPerson()) - { -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) - if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) - { - if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MERCHANT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatMerchantsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatMerchantsCreated(); -#endif - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_SCIENTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatScientistsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatScientistsCreated(); -#endif - } - else - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatEngineersCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatEngineersCreated(); -#endif - } - } - else -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatPeopleCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatPeopleCreated(); -#endif - bool bJumpSuccess = pFreeUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - addProductionExperience(pFreeUnit); - } - else - { - pFreeUnit->kill(false); - } - } - } - } -#endif -#if defined(MOD_BALANCE_CORE) - //Test for forbidden or locked units. - if (eFreeUnitType != NO_UNIT) + // For Venice, replace any spawned settling unit with Merchant of Venice + if (pUnitInfo->IsFound() && owningPlayer.GetPlayerTraits()->IsNoAnnexing()) { -#endif - // Great prophet? - if (GC.GetGameUnits()->GetEntry(eFreeUnitType)->IsFoundReligion()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - GetCityCitizens()->DoSpawnGreatPerson(eFreeUnitType, true /*bIncrementCount*/, true, MOD_GLOBAL_TRULY_FREE_GP); -#else - GetCityCitizens()->DoSpawnGreatPerson(eFreeUnitType, true /*bIncrementCount*/, true); -#endif - } - else + bool bFound = false; + for (int iVeniceSearch = 0; iVeniceSearch < GC.getNumUnitClassInfos(); iVeniceSearch++) { -#if defined(MOD_BALANCE_CORE) - // for venice - pFreeUnit = NULL; - if (pkUnitInfo->IsFound() && owningPlayer.GetPlayerTraits()->IsNoAnnexing()) - { - // drop a merchant of venice instead - // find the eUnit replacement that's the merchant of venice - for (int iVeniceSearch = 0; iVeniceSearch < GC.getNumUnitClassInfos(); iVeniceSearch++) - { - const UnitClassTypes eVeniceUnitClass = static_cast(iVeniceSearch); - CvUnitClassInfo* pkVeniceUnitClassInfo = GC.getUnitClassInfo(eVeniceUnitClass); - if (pkVeniceUnitClassInfo) - { - const UnitTypes eMerchantOfVeniceUnit = owningPlayer.GetSpecificUnitType(eVeniceUnitClass); - if (eMerchantOfVeniceUnit != NO_UNIT) - { - CvUnitEntry* pVeniceUnitEntry = GC.getUnitInfo(eMerchantOfVeniceUnit); - if (pVeniceUnitEntry->IsCanBuyCityState()) - { - pFreeUnit = owningPlayer.initUnit(eMerchantOfVeniceUnit, getX(), getY()); - break; - } - } - } - } - } - else - { -#endif - pFreeUnit = owningPlayer.initUnit(eFreeUnitType, getX(), getY()); -#if defined(MOD_BALANCE_CORE) - if (pFreeUnit) - { - if (pFreeUnit->isTrade()) - { - if (GC.getLogging() && GC.getAILogging()) - { - CvString strCiv = GET_PLAYER(getOwner()).getCivilizationAdjective(); - CvString strLogString; - strLogString.Format("FREE TRADE UNIT CREATED: %s %s at %d,d", strCiv.c_str(), pFreeUnit->getName().c_str(), pFreeUnit->getX(), pFreeUnit->getY()); - GET_PLAYER(getOwner()).GetHomelandAI()->LogHomelandMessage(strLogString); - } - } - bool bJumpSuccess = pFreeUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - addProductionExperience(pFreeUnit); - } - else - { - pFreeUnit->kill(false); - } - } -#endif -#if defined(MOD_BALANCE_CORE) - } - if (pFreeUnit->IsGreatPerson()) - { - if (owningPlayer.GetPlayerTraits()->IsGPWLTKD()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - this->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = owningPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); - strText << pFreeUnit->getNameKey() << this->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); - strSummary << this->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), this->getX(), this->getY(), -1); - } - } - } - if (pFreeUnit->isWLKTKDOnBirth()) - { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for (pLoopCity = owningPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = owningPlayer.nextCity(&iLoop)) - { - if (pLoopCity != NULL && pLoopCity->getOwner() == owningPlayer.GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = owningPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << pFreeUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - } - if (pFreeUnit->isGoldenAgeOnBirth()) - { - owningPlayer.changeGoldenAgeTurns(owningPlayer.getGoldenAgeLength()); - } - if (pFreeUnit->isCultureBoost()) - { - int iValue = owningPlayer.GetTotalJONSCulturePerTurn() * 4; - owningPlayer.changeJONSCulture(iValue); - if (owningPlayer.getCapitalCity() != NULL) - owningPlayer.getCapitalCity()->ChangeJONSCultureStored(iValue); - - CvNotifications* pNotifications = owningPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << pFreeUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << pFreeUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pFreeUnit->getX(), pFreeUnit->getY(), -1); - } - } - } -#endif - // Bump up the count - if (pFreeUnit->IsGreatGeneral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatGeneralsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatGeneralsCreated(); -#endif - bool bJumpSuccess = pFreeUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - addProductionExperience(pFreeUnit); - } - else - { - pFreeUnit->kill(false); - } - } - else if (pFreeUnit->IsGreatAdmiral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatAdmiralsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatAdmiralsCreated(); -#endif - CvPlot* pSpawnPlot = owningPlayer.GetBestCoastalSpawnPlot(pFreeUnit); - if (pFreeUnit->plot() != pSpawnPlot) - { - pFreeUnit->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); - addProductionExperience(pFreeUnit); - } - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_WRITER")) + const UnitClassTypes eVeniceUnitClass = static_cast(iVeniceSearch); + const UnitTypes eMerchantOfVeniceUnit = owningPlayer.GetSpecificUnitType(eVeniceUnitClass); + if (eMerchantOfVeniceUnit != NO_UNIT) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatWritersCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatWritersCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_ARTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatArtistsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatArtistsCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MUSICIAN")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatMusiciansCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatMusiciansCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (MOD_BALANCE_VP && pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatDiplomatsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatDiplomatsCreated(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } -#if defined(MOD_BALANCE_CORE) - else if (pkUnitInfo->IsGPExtra() == 1) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra1Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra1Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 2) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra2Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra2Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 3) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra3Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra3Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 4) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra4Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra4Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } - else if (pkUnitInfo->IsGPExtra() == 5) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGPExtra5Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGPExtra5Created(); -#endif - if (!pFreeUnit->jumpToNearestValidPlot()) - pFreeUnit->kill(false); // Could not find a valid spot! - } -#endif - else if (pFreeUnit->IsGreatPerson()) - { -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) - if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) - { - if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MERCHANT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatMerchantsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatMerchantsCreated(); -#endif - } - else if (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_SCIENTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatScientistsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatScientistsCreated(); -#endif - } - else - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatEngineersCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatEngineersCreated(); -#endif - } - } - else -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - owningPlayer.incrementGreatPeopleCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - owningPlayer.incrementGreatPeopleCreated(); -#endif - bool bJumpSuccess = pFreeUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - addProductionExperience(pFreeUnit); - } - else + CvUnitEntry* pVeniceUnitEntry = GC.getUnitInfo(eMerchantOfVeniceUnit); + if (pVeniceUnitEntry->IsCanBuyCityState()) { - pFreeUnit->kill(false); + eFreeUnit = eMerchantOfVeniceUnit; + bFound = true; + break; } } -#if defined(MOD_BALANCE_CORE) } -#endif - } - } -#if defined(MOD_BALANCE_CORE) - for (iFreeSpecUnitLoop = 0; iFreeSpecUnitLoop < pBuildingInfo->GetNumFreeSpecialUnits(iUnitLoop); iFreeSpecUnitLoop++) - { - pFreeUnit = NULL; - const UnitTypes eFreeSpecUnitType = (UnitTypes)pkUnitInfo->GetUnitClassType(); - if (eFreeSpecUnitType != NO_UNIT) - { - pFreeUnit = owningPlayer.initUnit(eUnit, getX(), getY()); - } - bool bJumpSuccess = pFreeUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - addProductionExperience(pFreeUnit); + + // Failed to find a replacement + if (!bFound) + continue; } - else + + for (iFreeUnitLoop = 0; iFreeUnitLoop < iNumFreeUnits; iFreeUnitLoop++) { - pFreeUnit->kill(false); + SpawnFreeUnit(eFreeUnit); } } -#endif } } -#if defined(MOD_BALANCE_CORE) // Is this a Corporation building? CvBuildingClassInfo* pkBuildingClass = GC.getBuildingClassInfo(eBuildingClass); if (pkBuildingClass) @@ -14752,7 +14081,6 @@ void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, } } } -#endif // Free building BuildingClassTypes eFreeBuildingClassThisCity = (BuildingClassTypes)pBuildingInfo->GetFreeBuildingThisCity(); @@ -14842,20 +14170,7 @@ void CvCity::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, { int iMedianTechResearch = owningPlayer.GetPlayerTechs()->GetMedianTechResearch(); iMedianTechResearch = (iMedianTechResearch * owningPlayer.GetMedianTechPercentage()) / 100; -#if defined(MOD_BALANCE_CORE) owningPlayer.doInstantYield(INSTANT_YIELD_TYPE_INSTANT, false, NO_GREATPERSON, eBuilding, iMedianTechResearch, false, NO_PLAYER, NULL, false, this); -#else - - TechTypes eCurrentTech = owningPlayer.GetPlayerTechs()->GetCurrentResearch(); - if (eCurrentTech == NO_TECH) - { - owningPlayer.changeOverflowResearch(iMedianTechResearch); - } - else - { - owningTeam.GetTeamTechs()->ChangeResearchProgress(eCurrentTech, iMedianTechResearch, owningPlayer.GetID()); - } -#endif } } } @@ -17770,18 +17085,10 @@ void CvCity::SetAdditionalFood(int iValue) } #endif // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) int CvCity::getPopulation(bool bIncludeAutomatons /* = false */) const -#else -int CvCity::getPopulation() const -#endif { VALIDATE_OBJECT -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) return m_iPopulation + (bIncludeAutomatons ? getAutomatons() : 0); -#else - return m_iPopulation; -#endif } // --------------------------------------------------------------------------------- @@ -17795,6 +17102,7 @@ void CvCity::setPopulation(int iNewValue, bool bReassignPop /* = true */, bool b iNewValue = max(0, iNewValue); int iOldPopulation = getPopulation(); + int iOldHighestPopulation = getHighestPopulation(); int iPopChange = iNewValue - iOldPopulation; if (iOldPopulation != iNewValue) @@ -17826,7 +17134,7 @@ void CvCity::setPopulation(int iNewValue, bool bReassignPop /* = true */, bool b if (getPopulation() > getHighestPopulation()) { setHighestPopulation(getPopulation()); -#if defined(MOD_BALANCE_CORE_BELIEFS) + int iGameTurn = GC.getGame().getGameTurn() - getGameTurnFounded(); if (!IsResistance() && iGameTurn > 0 && !bNoBonus) { @@ -17840,17 +17148,18 @@ void CvCity::setPopulation(int iNewValue, bool bReassignPop /* = true */, bool b GET_PLAYER(getOwner()).doInstantYield(INSTANT_YIELD_TYPE_BIRTH_HOLY_CITY, false, NO_GREATPERSON, NO_BUILDING, iPopChange, false, NO_PLAYER, NULL, false, this); } } -#endif -#if defined(MOD_BALANCE_CORE_POLICIES) + if (MOD_BALANCE_CORE_POLICIES && GET_PLAYER(getOwner()).GetXPopulationConscription() > 0 && !IsRazing()) { int iRemainder = (getPopulation() % GET_PLAYER(getOwner()).GetXPopulationConscription()); - if (iRemainder == 0) + int iPopThreshold = getPopulation() - iRemainder; + + // Account for population jumps + if (iRemainder < iPopChange && iPopThreshold > iOldHighestPopulation) { GET_PLAYER(getOwner()).DoXPopulationConscription(this); } } -#endif } plot()->area()->changePopulationPerPlayer(getOwner(), (getPopulation() - iOldPopulation)); @@ -18653,7 +17962,6 @@ void CvCity::ChangeYieldFromTraits(YieldTypes eIndex, int iChange) } } -#if defined(MOD_BALANCE_CORE) // -------------------------------------------------------------------------------- int CvCity::GetYieldPerTurnFromTraits(YieldTypes eYield) const { @@ -18716,7 +18024,6 @@ int CvCity::GetYieldPerTurnFromTraits(YieldTypes eYield) const return (iYield + m_iaAddedYieldPerTurnFromTraits[eYield]); } -#endif // -------------------------------------------------------------------------------- int CvCity::GetJONSCulturePerTurnFromReligion() const { @@ -18732,11 +18039,7 @@ int CvCity::GetJONSCulturePerTurnFromLeagues() const } // -------------------------------------------------------------------------------- -#if defined(MOD_BALANCE_CORE) int CvCity::GetFaithPerTurn(bool bStatic) const -#else -int CvCity::GetFaithPerTurn() const -#endif { VALIDATE_OBJECT // Anarchy, Resistance or Razing? Then no Faith is given! @@ -18751,10 +18054,7 @@ int CvCity::GetFaithPerTurn() const int iFaith = GetFaithPerTurnFromBuildings(); iFaith += GetBaseYieldRateFromSpecialists(YIELD_FAITH); iFaith += (GetYieldPerPopTimes100(YIELD_FAITH) * getPopulation()) / 100; - -#if defined(MOD_BALANCE_CORE) iFaith += (GetYieldPerPopInEmpireTimes100(YIELD_FAITH) * GET_PLAYER(getOwner()).getTotalPopulation()) / 100; -#endif if (IsRouteToCapitalConnected()) { @@ -18789,14 +18089,11 @@ int CvCity::GetFaithPerTurn() const } } -#if defined(MOD_BALANCE_CORE) iFaith += GetBaseYieldRateFromCSAlliance(YIELD_FAITH); iFaith += GetBaseYieldRateFromCSFriendship(YIELD_FAITH); iFaith += GetYieldFromMinors(YIELD_FAITH); iFaith += GetYieldPerTurnFromTraits(YIELD_FAITH); iFaith += GetYieldChangeFromCorporationFranchises(YIELD_FAITH); -#endif -#if defined(MOD_BALANCE_CORE) iFaith += GetEventCityYield(YIELD_FAITH); //Update Yields from yields ... need to sidestep constness @@ -18814,7 +18111,6 @@ int CvCity::GetFaithPerTurn() const //NOTE! We flip it here, because we want the OUT yield iFaith += GetRealYieldFromYield(eIndex2, YIELD_FAITH); } -#endif if (MOD_BALANCE_CORE_JFD) { @@ -19374,6 +18670,7 @@ void CvCity::UpdateYieldPerXUnimprovedFeature(YieldTypes eYield, FeatureTypes eF const CvReligion* pPantheon = NULL; BeliefTypes ePantheonBelief = NO_BELIEF; + // Mod for civs keeping their pantheon belief forever if (MOD_RELIGION_PERMANENT_PANTHEON) { @@ -19384,20 +18681,25 @@ void CvCity::UpdateYieldPerXUnimprovedFeature(YieldTypes eYield, FeatureTypes eF } } - //Passed in a feature? Use that. - if (eFeature != NO_FEATURE) + for (int iI = 0; iI < GC.getNumFeatureInfos(); iI++) { - if (!GC.getFeatureInfo(eFeature)->IsNaturalWonder()) + FeatureTypes eUseFeature = static_cast(iI); + + // Passed in a feature? Use only that + if (eFeature != NO_FEATURE && eFeature != eUseFeature) + continue; + + if (!GC.getFeatureInfo(eUseFeature)->IsNaturalWonder(true)) { - int iBaseYield = kPlayer.getCityYieldFromUnimprovedFeature(eFeature, eYield); - iBaseYield += kPlayer.GetPlayerTraits()->GetCityYieldFromUnimprovedFeature(eFeature, eYield); + int iBaseYield = kPlayer.getCityYieldFromUnimprovedFeature(eUseFeature, eYield); + iBaseYield += kPlayer.GetPlayerTraits()->GetCityYieldFromUnimprovedFeature(eUseFeature, eYield); if (pReligion) { - iBaseYield += pReligion->m_Beliefs.GetCityYieldFromUnimprovedFeature(eFeature, eYield, getOwner(), this); + iBaseYield += pReligion->m_Beliefs.GetCityYieldFromUnimprovedFeature(eUseFeature, eYield, getOwner(), this); if (eSecondaryPantheon != NO_BELIEF) { - iBaseYield += GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetCityYieldFromUnimprovedFeature(eFeature, eYield); + iBaseYield += GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetCityYieldFromUnimprovedFeature(eUseFeature, eYield); } } @@ -19407,12 +18709,12 @@ void CvCity::UpdateYieldPerXUnimprovedFeature(YieldTypes eYield, FeatureTypes eF { if (pReligion == NULL || (pReligion != NULL && !pReligion->m_Beliefs.IsPantheonBeliefInReligion(ePantheonBelief, pReligion->m_eReligion, getOwner()))) // check that the our religion does not have our belief, to prevent double counting { - iBaseYield += GC.GetGameBeliefs()->GetEntry(ePantheonBelief)->GetCityYieldFromUnimprovedFeature(eFeature, eYield); + iBaseYield += GC.GetGameBeliefs()->GetEntry(ePantheonBelief)->GetCityYieldFromUnimprovedFeature(eUseFeature, eYield); } } } - if (eYield == YIELD_FAITH && eFeature == FEATURE_FOREST && kPlayer.GetPlayerTraits()->IsFaithFromUnimprovedForest()) + if (eYield == YIELD_FAITH && eUseFeature == FEATURE_FOREST && kPlayer.GetPlayerTraits()->IsFaithFromUnimprovedForest()) { ++iBaseYield; } @@ -19424,122 +18726,30 @@ void CvCity::UpdateYieldPerXUnimprovedFeature(YieldTypes eYield, FeatureTypes eF for (int iDirectionLoop = 0; iDirectionLoop < NUM_DIRECTION_TYPES; ++iDirectionLoop) { CvPlot* pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iDirectionLoop)); - if (pAdjacentPlot && pAdjacentPlot->getFeatureType() == eFeature && pAdjacentPlot->getImprovementType() == NO_IMPROVEMENT) + if (pAdjacentPlot && pAdjacentPlot->getFeatureType() == eUseFeature && pAdjacentPlot->getImprovementType() == NO_IMPROVEMENT) { iAdjacentFeatures++; } } + if (iAdjacentFeatures > 2) { -#if defined(MOD_ALTERNATE_CELTS) - if (MOD_ALTERNATE_CELTS) - { - iYield += iBaseYield * 3; - } - else - { - iYield += iBaseYield * 2; - } -#else - iYield += iBaseYield * 2; -#endif + iYield += MOD_ALTERNATE_CELTS ? iBaseYield * 3 : iBaseYield * 2; } -#if defined(MOD_ALTERNATE_CELTS) else if (iAdjacentFeatures > 1 && MOD_ALTERNATE_CELTS) { iYield += iBaseYield * 2; } -#endif else if (iAdjacentFeatures > 0) { iYield += iBaseYield; } - SetYieldPerXUnimprovedFeature(eFeature, eYield, iYield); - } - } - } - else - { - for (int iI = 0; iI < GC.getNumFeatureInfos(); iI++) - { - eFeature = (FeatureTypes)iI; -#if defined(MOD_PSEUDO_NATURAL_WONDER) - if (!GC.getFeatureInfo(eFeature)->IsNaturalWonder(true)) -#else - if (!GC.getFeatureInfo(eFeature)->IsNaturalWonder()) -#endif - { - int iBaseYield = kPlayer.getCityYieldFromUnimprovedFeature(eFeature, eYield); - iBaseYield += kPlayer.GetPlayerTraits()->GetCityYieldFromUnimprovedFeature(eFeature, eYield); - - if (pReligion) - { - iBaseYield += pReligion->m_Beliefs.GetCityYieldFromUnimprovedFeature(eFeature, eYield, getOwner(), this); - if (eSecondaryPantheon != NO_BELIEF) - { - iBaseYield += GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetCityYieldFromUnimprovedFeature(eFeature, eYield); - } - } - - if (MOD_RELIGION_PERMANENT_PANTHEON) - { - if (pPantheon != NULL && ePantheonBelief != NO_BELIEF && ePantheonBelief != eSecondaryPantheon) - { - if (pReligion == NULL || (pReligion != NULL && !pReligion->m_Beliefs.IsPantheonBeliefInReligion(ePantheonBelief, pReligion->m_eReligion, getOwner()))) // check that the our religion does not have our belief, to prevent double counting - { - iBaseYield += GC.GetGameBeliefs()->GetEntry(ePantheonBelief)->GetCityYieldFromUnimprovedFeature(eFeature, eYield); - } - } - } - - if (eYield == YIELD_FAITH && eFeature == FEATURE_FOREST && kPlayer.GetPlayerTraits()->IsFaithFromUnimprovedForest()) - { - ++iBaseYield; - } - - if (iBaseYield > 0) - { - int iAdjacentFeatures = 0; - - for (int iDirectionLoop = 0; iDirectionLoop < NUM_DIRECTION_TYPES; ++iDirectionLoop) - { - CvPlot* pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iDirectionLoop)); - if (pAdjacentPlot && pAdjacentPlot->getFeatureType() == eFeature && pAdjacentPlot->getImprovementType() == NO_IMPROVEMENT) - { - iAdjacentFeatures++; - } - } - if (iAdjacentFeatures > 2) - { -#if defined(MOD_ALTERNATE_CELTS) - if (MOD_ALTERNATE_CELTS) - { - iYield += iBaseYield * 3; - } - else - { - iYield += iBaseYield * 2; - } -#else - iYield += iBaseYield * 2; -#endif - } -#if defined(MOD_ALTERNATE_CELTS) - else if (iAdjacentFeatures > 1 && MOD_ALTERNATE_CELTS) - { - iYield += iBaseYield * 2; - } -#endif - else if (iAdjacentFeatures > 0) - { - iYield += iBaseYield; - } - SetYieldPerXUnimprovedFeature(eFeature, eYield, iYield); - } + SetYieldPerXUnimprovedFeature(eUseFeature, eYield, iYield); } } } } + void CvCity::UpdateYieldPerXFeature(YieldTypes eYield, FeatureTypes eFeature) { VALIDATE_OBJECT @@ -19552,118 +18762,67 @@ void CvCity::UpdateYieldPerXFeature(YieldTypes eYield, FeatureTypes eFeature) const CvReligion* pReligion = GetCityReligions()->GetMajorityReligion(); - //If we passed in a feature, let's only refresh that. - if (eFeature != NO_FEATURE) + for (int iI = 0; iI < GC.getNumFeatureInfos(); iI++) { + FeatureTypes eUseFeature = (FeatureTypes)iI; + + // Passed in a feature? Update only that + if (eFeature != NO_FEATURE && eFeature != eUseFeature) + continue; + iYieldBase = 0; iYieldReligion = 0; if (pReligion) { - iBaseYieldReligion = pReligion->m_Beliefs.GetYieldPerXFeatureTimes100(eFeature, eYield, getOwner(), this); + iBaseYieldReligion = pReligion->m_Beliefs.GetYieldPerXFeatureTimes100(eUseFeature, eYield, getOwner(), this); } - iBaseYield = GetYieldPerXFeatureFromBuildingsTimes100(eFeature, eYield); + iBaseYield = GetYieldPerXFeatureFromBuildingsTimes100(eUseFeature, eYield); bool bTest = false; if (iBaseYield <= 0) { - ChangeBaseYieldRateFromBuildings(eYield, -GetYieldPerXFeature(eFeature, eYield)); - SetYieldPerXFeature(eFeature, eYield, 0); + ChangeBaseYieldRateFromBuildings(eYield, -GetYieldPerXFeature(eUseFeature, eYield)); + SetYieldPerXFeature(eUseFeature, eYield, 0); } else + { bTest = true; + } + if (iBaseYieldReligion <= 0) { - SetYieldPerXFeatureFromReligion(eFeature, eYield, iYieldReligion); + SetYieldPerXFeatureFromReligion(eUseFeature, eYield, iYieldReligion); } else + { bTest = true; + } if (bTest) { - iValidTiles = GetNumFeatureWorked(eFeature); + iValidTiles = GetNumFeatureWorked(eUseFeature); if (iValidTiles > 0) { - //Gain 1 yield per x valid tiles - so if 'x' is 3, and you have 3 tiles that match, you get 1 yield + // Gain 1 yield per x valid tiles - so if 'x' is 3, and you have 3 tiles that match, you get 1 yield iYieldBase = (iValidTiles * iBaseYield) / 100; iYieldReligion = (iValidTiles * iBaseYieldReligion) / 100; - //iDifference determines +/- of difference of old value - int iBaseDifference = iYieldBase - GetYieldPerXFeature(eFeature, eYield); + // iDifference determines +/- of difference of old value + int iDifference = iYieldBase - GetYieldPerXFeature(eUseFeature, eYield); - //Change base rate first - ChangeBaseYieldRateFromBuildings(eYield, iBaseDifference); - SetYieldPerXFeature(eFeature, eYield, iYieldBase); + // Change base rate first + ChangeBaseYieldRateFromBuildings(eYield, iDifference); + SetYieldPerXFeature(eUseFeature, eYield, iYieldBase); - SetYieldPerXFeatureFromReligion(eFeature, eYield, iYieldReligion); + SetYieldPerXFeatureFromReligion(eUseFeature, eYield, iYieldReligion); } else { - ChangeBaseYieldRateFromBuildings(eYield, -GetYieldPerXFeature(eFeature, eYield)); - SetYieldPerXFeature(eFeature, eYield, 0); + ChangeBaseYieldRateFromBuildings(eYield, -GetYieldPerXFeature(eUseFeature, eYield)); + SetYieldPerXFeature(eUseFeature, eYield, 0); - SetYieldPerXFeatureFromReligion(eFeature, eYield, 0); - } - } - } - else - { - for (int iI = 0; iI < GC.getNumFeatureInfos(); iI++) - { - eFeature = (FeatureTypes)iI; - if (eFeature == NO_FEATURE) - { - continue; - } - iYieldBase = 0; - iYieldReligion = 0; - if (pReligion) - { - iBaseYieldReligion = pReligion->m_Beliefs.GetYieldPerXFeatureTimes100(eFeature, eYield, getOwner(), this); - } - - iBaseYield = GetYieldPerXFeatureFromBuildingsTimes100(eFeature, eYield); - - bool bTest = false; - if (iBaseYield <= 0) - { - ChangeBaseYieldRateFromBuildings(eYield, -GetYieldPerXFeature(eFeature, eYield)); - SetYieldPerXFeature(eFeature, eYield, 0); - } - else - bTest = true; - if (iBaseYieldReligion <= 0) - { - SetYieldPerXFeatureFromReligion(eFeature, eYield, iYieldReligion); - } - else - bTest = true; - - if (bTest) - { - iValidTiles = GetNumFeatureWorked(eFeature); - if (iValidTiles > 0) - { - //Gain 1 yield per x valid tiles - so if 'x' is 3, and you have 3 tiles that match, you get 1 yield - iYieldBase = (iValidTiles * iBaseYield) / 100; - iYieldReligion = (iValidTiles * iBaseYieldReligion) / 100; - - //iDifference determines +/- of difference of old value - int iDifference = iYieldBase - GetYieldPerXFeature(eFeature, eYield); - - //Change base rate first - ChangeBaseYieldRateFromBuildings(eYield, iDifference); - SetYieldPerXFeature(eFeature, eYield, iYieldBase); - - SetYieldPerXFeatureFromReligion(eFeature, eYield, iYieldReligion); - } - else - { - ChangeBaseYieldRateFromBuildings(eYield, -GetYieldPerXFeature(eFeature, eYield)); - SetYieldPerXFeature(eFeature, eYield, 0); - - SetYieldPerXFeatureFromReligion(eFeature, eYield, 0); - } + SetYieldPerXFeatureFromReligion(eUseFeature, eYield, 0); } } } @@ -19752,7 +18911,6 @@ void CvCity::changeBuildingClassCultureChange(BuildingClassTypes eIndex, int iCh CvAssert(getBuildingClassCultureChange(eIndex) >= 0); } #endif -#if defined(MOD_BALANCE_CORE) // -------------------------------------------------------------------------------- int CvCity::GetBaseTourism() const { @@ -19779,7 +18937,6 @@ void CvCity::SetBaseTourismBeforeModifiers(int iValue) VALIDATE_OBJECT m_iBaseTourismBeforeModifiers = iValue; } -#endif // -------------------------------------------------------------------------------- int CvCity::getTourismRateModifier() const @@ -19940,16 +19097,14 @@ int CvCity::GetLocalResourceWonderProductionMod(BuildingTypes eBuilding, CvStrin int iBonus = pkResource->getWonderProductionMod(); if (iBonus != 0) { -#if defined(MOD_TRADE_WONDER_RESOURCE_ROUTES) bool bHasLocalResource = IsHasResourceLocal(eResource, /*bTestVisible*/ false); - if (MOD_TRADE_WONDER_RESOURCE_ROUTES) { + if (MOD_TRADE_WONDER_RESOURCE_ROUTES) + { // We're shipping one in, or we're not shipping our only one out, or we have more than one bHasLocalResource = bWonderResourceIn || (m_paiNumResourcesLocal[eResource] == 1 && !bWonderResourceOut) || (m_paiNumResourcesLocal[eResource] > 1); } + if (bHasLocalResource) -#else - if (IsHasResourceLocal(eResource, /*bTestVisible*/ false)) -#endif { // Depends on era of wonder? EraTypes eResourceObsoleteEra = pkResource->getWonderProductionModObsoleteEra(); @@ -20893,7 +20048,7 @@ bool CvCity::DoRazingTurn() if (GET_TEAM(GET_PLAYER(eFormerOwner).getTeam()).isAtWar(getTeam())) { - bool bNotification = GC.getGame().DoSpawnUnitsAroundTargetCity(eFormerOwner, this, iNumRebels, true, false, false, true); + bool bNotification = SpawnPlayerUnitsNearby(eFormerOwner, iNumRebels, true); if (bNotification) { //the former owner hates the razing and wants it back @@ -28741,7 +27896,6 @@ void CvCity::BuyPlot(int iPlotX, int iPlotY) thisPlayer.GetTreasury()->LogExpenditure("buy plot", iCost, 1); thisPlayer.GetTreasury()->ChangeGold(-iCost); -#if defined(MOD_UI_CITY_EXPANSION) bool bWithGold = true; if (MOD_UI_CITY_EXPANSION && GET_PLAYER(getOwner()).isHuman()) { // If we have a culture surplus, we got a discount on the tile, so remove the surplus @@ -28752,9 +27906,7 @@ void CvCity::BuyPlot(int iPlotX, int iPlotY) bWithGold = false; } } -#endif -#if defined(MOD_BALANCE_CORE) if (iCost > 0 && !GET_PLAYER(getOwner()).isBarbarian() && !GET_PLAYER(pPlot->getOwner()).isBarbarian()) { // Did we buy this plot from someone? They're gonna be mad! @@ -28909,13 +28061,10 @@ void CvCity::BuyPlot(int iPlotX, int iPlotY) GET_PLAYER(ePlotOwner).GetDiplomacyAI()->ChangeNumTimesCultureBombed(getOwner(), iPenalty); } } -#endif -#if defined(MOD_UI_CITY_EXPANSION) if (iCost > 0) { // Only do this if we actually paid for the plot (as opposed to getting it for free via city growth) -#endif thisPlayer.ChangeNumPlotsBought(1); //Let's look at max range for plot purchases for this City. @@ -28982,10 +28131,7 @@ void CvCity::BuyPlot(int iPlotX, int iPlotY) } } } - -#if defined(MOD_UI_CITY_EXPANSION) } -#endif #if defined(MOD_BALANCE_CORE) GET_PLAYER(getOwner()).doInstantYield(INSTANT_YIELD_TYPE_TILE_PURCHASE, true, NO_GREATPERSON, NO_BUILDING, @@ -29007,17 +28153,12 @@ void CvCity::BuyPlot(int iPlotX, int iPlotY) DoAcquirePlot(iPlotX, iPlotY); -#if defined(MOD_EVENTS_CITY) - if (MOD_EVENTS_CITY) { -#if defined(MOD_UI_CITY_EXPANSION) + if (MOD_EVENTS_CITY) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityBoughtPlot, getOwner(), GetID(), iPlotX, iPlotY, bWithGold, !bWithGold); -#else - GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityBoughtPlot, getOwner(), GetID(), iPlotX, iPlotY, true, false); -#endif } - else { -#endif - + else + { ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if (pkScriptSystem) { @@ -29032,9 +28173,7 @@ void CvCity::BuyPlot(int iPlotX, int iPlotY) bool bResult = false; LuaSupport::CallHook(pkScriptSystem, "CityBoughtPlot", args.get(), bResult); } -#if defined(MOD_EVENTS_CITY) } -#endif //Achievement test for purchasing 1000 tiles if (MOD_API_ACHIEVEMENTS && thisPlayer.isHuman() && !GC.getGame().isGameMultiPlayer()) @@ -29973,8 +29112,7 @@ void CvCity::produce(UnitTypes eTrainUnit, UnitAITypes eTrainAIUnit, bool bCanOv CvUnit* pUnit = CreateUnit(eTrainUnit, eTrainAIUnit, REASON_TRAIN); if (pUnit) { -#if defined(MOD_BALANCE_CORE) - if (pUnit->isFreeUpgrade() || GET_PLAYER(getOwner()).GetPlayerTraits()->IsFreeUpgrade()) + if (pUnit->isFreeUpgrade() || kOwner.GetPlayerTraits()->IsFreeUpgrade()) { UnitTypes eUpgradeUnit = pUnit->GetUpgradeUnitType(); if (eUpgradeUnit != NO_UNIT && this->canTrain(eUpgradeUnit, false, false, true)) @@ -29983,123 +29121,29 @@ void CvCity::produce(UnitTypes eTrainUnit, UnitAITypes eTrainAIUnit, bool bCanOv } } SetUnitInvestment(pUnit->getUnitClassType(), false); - if (GET_PLAYER(getOwner()).GetPlayerTraits()->IsConquestOfTheWorld()) + + if (kOwner.GetPlayerTraits()->IsConquestOfTheWorld()) { if (pUnit->isFound() || pUnit->IsFoundMid()) { - UnitTypes eBestLandUnit = NO_UNIT; - int iStrengthBestLandCombat = 0; - for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) - { - const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo) - { - const UnitTypes eUnit = (UnitTypes)getCivilizationInfo().getCivilizationUnits(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if (pUnitEntry) - { - if (!canTrain(eUnit)) - { - continue; - } - if (pUnitEntry->GetRangedCombat() > 0) - { - continue; - } - if (pUnitEntry->GetDomainType() == DOMAIN_LAND) - { - bool bBad = false; - ResourceTypes eResource; - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes)iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if (GET_PLAYER(getOwner()).getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - iNumResource = pUnitEntry->GetResourceQuantityTotal(eResource); - if (iNumResource > 0) - { - if (GET_PLAYER(getOwner()).getNumResourceTotal(eResource, true) < iNumResource || GET_PLAYER(getOwner()).getNumResourceAvailable(eResource, true) < 0) - { - bBad = true; - break; - } - } - } -#endif - } - if (bBad) - { - continue; - } - int iCombatLandStrength = (std::max(1, pUnitEntry->GetCombat())); - if (iCombatLandStrength > iStrengthBestLandCombat) - { - iStrengthBestLandCombat = iCombatLandStrength; - eBestLandUnit = eUnit; - } - } - } - } - } - if (eBestLandUnit != NO_UNIT) - { - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eBestLandUnit); - if (pkbUnitEntry) - { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit2 = CreateUnit(eBestLandUnit, eUnitAI, REASON_TRAIN); - if (pUnit2) - { - if (!pUnit2->jumpToNearestValidPlot()) - { - pUnit2->kill(false); // Could not find a valid spot! - } - CvNotifications* pNotifications = GET_PLAYER(getOwner()).GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CONQUEST_OF_WORLD_UNIT"); - strText << pUnit2->getNameKey() << getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CONQUEST_OF_WORLD_UNIT"); - strSummary << getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pUnit2->getX(), pUnit2->getY(), -1); - } - } - } - } - else + UnitTypes eFreeUnit = kOwner.GetCompetitiveSpawnUnitType(false, false, false, true, this); + if (eFreeUnit != NO_UNIT) { - UnitTypes eWarrior = (UnitTypes)GC.getInfoTypeForString("UNIT_WARRIOR"); - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eWarrior); - if (pkbUnitEntry) + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eFreeUnit); + if (pUnitInfo) { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit2 = CreateUnit(eWarrior, eUnitAI, REASON_TRAIN); - if (pUnit2) + CvUnit* pFreeUnit = CreateUnit(eFreeUnit, NO_UNITAI, REASON_TRAIN); + if (!pFreeUnit->jumpToNearestValidPlot()) + pFreeUnit->kill(false); // Could not find a valid spot! + + CvNotifications* pNotifications = kOwner.GetNotifications(); + if (pNotifications) { - if (!pUnit2->jumpToNearestValidPlot()) - { - pUnit2->kill(false); // Could not find a valid spot! - } - CvNotifications* pNotifications = GET_PLAYER(getOwner()).GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CONQUEST_OF_WORLD_UNIT"); - strText << pUnit2->getNameKey() << getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CONQUEST_OF_WORLD_UNIT"); - strSummary << getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pUnit2->getX(), pUnit2->getY(), -1); - } + Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CONQUEST_OF_WORLD_UNIT"); + strText << pFreeUnit->getNameKey() << getNameKey(); + Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CONQUEST_OF_WORLD_UNIT"); + strSummary << getNameKey(); + pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pFreeUnit->getX(), pFreeUnit->getY(), -1); } } } @@ -30123,15 +29167,13 @@ void CvCity::produce(UnitTypes eTrainUnit, UnitAITypes eTrainAIUnit, bool bCanOv } } } -#endif -#if defined(MOD_EVENTS_CITY) + if (MOD_EVENTS_CITY) { GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityTrained, getOwner(), GetID(), pUnit->GetID(), false, false); } else { -#endif ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if (pkScriptSystem) { @@ -30145,17 +29187,14 @@ void CvCity::produce(UnitTypes eTrainUnit, UnitAITypes eTrainAIUnit, bool bCanOv bool bResult = false; LuaSupport::CallHook(pkScriptSystem, "CityTrained", args.get(), bResult); } -#if defined(MOD_EVENTS_CITY) } -#endif int iProductionNeeded = getProductionNeeded(eTrainUnit) * 100; -#if defined(MOD_BALANCE_CORE) if (!pUnit->IsCivilianUnit()) { GET_PLAYER(getOwner()).doInstantYield(INSTANT_YIELD_TYPE_U_PROD, true, NO_GREATPERSON, NO_BUILDING, (iProductionNeeded / 100), false, NO_PLAYER, NULL, false, this); } -#endif + if (bCanOverflow) { // max overflow is the value of the item produced (to eliminate prebuild exploits) @@ -30791,7 +29830,6 @@ bool CvCity::IsCanPurchase(const std::vector& vPreExistingBuildings, bool b // slewis - The Venetian Exception bool bIsPuppet = IsPuppet(); bool bVenetianException = false; -#if defined(MOD_BALANCE_CORE_PUPPET_PURCHASE) bool bPuppetExceptionUnit = false; bool bPuppetExceptionBuilding = false; bool bAllowsPuppetPurchase = IsAllowPuppetPurchase(); @@ -30820,27 +29858,19 @@ bool CvCity::IsCanPurchase(const std::vector& vPreExistingBuildings, bool b } } } -#endif -#if defined(MOD_GLOBAL_PURCHASE_FAITH_BUILDINGS_IN_PUPPETS) + bool bPuppetExceptionFaithBuilding = false; if (MOD_GLOBAL_PURCHASE_FAITH_BUILDINGS_IN_PUPPETS && bIsPuppet && eBuildingType >= 0 && ePurchaseYield == YIELD_FAITH) { bPuppetExceptionFaithBuilding = true; } -#endif + if (GET_PLAYER(m_eOwner).GetPlayerTraits()->IsNoAnnexing() && bIsPuppet) { bVenetianException = true; } -#if defined(MOD_BALANCE_CORE_PUPPET_PURCHASE) && defined(MOD_GLOBAL_PURCHASE_FAITH_BUILDINGS_IN_PUPPETS) + if (bIsPuppet && !bVenetianException && !bPuppetExceptionBuilding && !bPuppetExceptionUnit && !bAllowsPuppetPurchase && !bPuppetExceptionFaithBuilding) -#elif defined(MOD_BALANCE_CORE_PUPPET_PURCHASE) - if (bIsPuppet && !bVenetianException && !bPuppetExceptionBuilding && !bPuppetExceptionUnit && !bAllowsPuppetPurchase) -#elif defined(MOD_GLOBAL_PURCHASE_FAITH_BUILDINGS_IN_PUPPETS) - if (bIsPuppet && !bVenetianException && !bPuppetExceptionFaithBuilding) -#else - if (bIsPuppet && !bVenetianException) -#endif { return false; } @@ -31437,11 +30467,7 @@ CvUnit* CvCity::PurchaseUnit(UnitTypes eUnitType, YieldTypes ePurchaseYield) } else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_PROPHET")) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) kPlayer.GetReligions()->ChangeNumProphetsSpawned(1, false); -#else - kPlayer.GetReligions()->ChangeNumProphetsSpawned(1); -#endif } else if (MOD_BALANCE_VP && eUnitClass == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT")) { @@ -32120,7 +31146,6 @@ bool CvCity::doCheckProduction() return CleanUpQueue(); } - // -------------------------------------------------------------------------------- void CvCity::doProduction(bool bAllowNoProduction) { @@ -32167,23 +31192,14 @@ void CvCity::doProduction(bool bAllowNoProduction) changeProductionTimes100(getCurrentProductionDifferenceTimes100(false, true)); -#if defined(MOD_PROCESS_STOCKPILE) if (!(MOD_PROCESS_STOCKPILE && isProductionProcess())) -#endif setOverflowProduction(0); + setFeatureProduction(0); -#if defined(MOD_PROCESS_STOCKPILE) if (getProduction() >= getProductionNeeded()) -#else - if (getProduction() >= getProductionNeeded() && !isProductionProcess()) -#endif { -#if defined(MOD_PROCESS_STOCKPILE) popOrder(0, !isProductionProcess(), true); -#else - popOrder(0, true, true); -#endif } } else @@ -32192,7 +31208,6 @@ void CvCity::doProduction(bool bAllowNoProduction) } } - // -------------------------------------------------------------------------------- void CvCity::doProcess() { @@ -33151,11 +32166,7 @@ bool CvCity::CanRangeStrikeNow() const if (isMadeAttack()) return false; -#if defined(MOD_EVENTS_CITY_BOMBARD) int iRange = getBombardRange(); -#else - int iRange = /*2*/ GD_INT_GET(CITY_ATTACK_RANGE); -#endif CvPlot* pPlot = plot(); for (int iRing=1; iRing<=min(5,iRange); iRing++) @@ -33210,58 +32221,30 @@ bool CvCity::canRangeStrikeAt(int iX, int iY) const { VALIDATE_OBJECT if (!canRangeStrike()) - { return false; - } const CvPlot* pTargetPlot = GC.getMap().plot(iX, iY); - if (NULL == pTargetPlot) - { + if (!pTargetPlot) return false; - } if (!pTargetPlot->isVisible(getTeam())) - { return false; - } -#if defined(MOD_EVENTS_CITY_BOMBARD) - bool bIndirectFireAllowed = false; // By reference, yuck!!! - int iAttackRange = getBombardRange(bIndirectFireAllowed); -#else - int iAttackRange = /*2*/ GD_INT_GET(CITY_ATTACK_RANGE); -#endif + int iAttackRange = getBombardRange(); if (plotDistance(plot()->getX(), plot()->getY(), pTargetPlot->getX(), pTargetPlot->getY()) > iAttackRange) - { return false; - } -#if defined(MOD_EVENTS_CITY_BOMBARD) - if (!bIndirectFireAllowed) -#else - if (/*1*/ GD_INT_GET(CAN_CITY_USE_INDIRECT_FIRE) > 0) -#endif - { - if (!plot()->canSeePlot(pTargetPlot, getTeam(), iAttackRange, NO_DIRECTION)) - { - return false; - } - } + if (!plot()->canSeePlot(pTargetPlot, getTeam(), iAttackRange, NO_DIRECTION)) + return false; - // If it's NOT a city, see if there are any units to aim for - if (!pTargetPlot->isCity()) - { - if (!canRangedStrikeTarget(*pTargetPlot)) - { - return false; - } - } - else // I don't want cities attacking each other directly - { + // Can't attack other cities directly + if (pTargetPlot->isCity()) + return false; + + if (!canRangedStrikeTarget(*pTargetPlot)) return false; - } return true; } @@ -33270,68 +32253,58 @@ bool CvCity::canRangeStrikeAt(int iX, int iY) const CityTaskResult CvCity::rangeStrike(int iX, int iY) { VALIDATE_OBJECT - CvUnit* pDefender = NULL; - - CityTaskResult eResult = TASK_ABORTED; - CvPlot* pPlot = GC.getMap().plot(iX, iY); - if (NULL == pPlot) - return eResult; + if (!pPlot) + return TASK_ABORTED; + + if (isMadeAttack()) + return TASK_ABORTED; // Apparently it's possible for someone to fire during another player's turn if (!GET_PLAYER(getOwner()).isTurnActive()) - return eResult; + return TASK_ABORTED; -#if defined(MOD_BALANCE_CORE_MILITARY) - if (!canRangeStrikeAt(iX, iY) || rangedStrikeTarget(pPlot) == NULL || isMadeAttack()) -#else if (!canRangeStrikeAt(iX, iY)) -#endif - { - return eResult; - } + return TASK_ABORTED; - setMadeAttack(true); + if (pPlot->isCity()) + return TASK_ABORTED; - // No City - if (!pPlot->isCity()) - { - pDefender = rangedStrikeTarget(pPlot); + CvUnit* pDefender = rangedStrikeTarget(pPlot); - CvAssert(pDefender != NULL); - if (!pDefender) return TASK_ABORTED; + setMadeAttack(true); - CvCombatInfo kCombatInfo; - CvUnitCombat::GenerateRangedCombatInfo(*this, pDefender, *pPlot, &kCombatInfo); + CvCombatInfo kCombatInfo; + CvUnitCombat::GenerateRangedCombatInfo(*this, pDefender, *pPlot, &kCombatInfo); - uint uiParentEventID = 0; - if (!CvPreGame::quickCombat()) + uint uiParentEventID = 0; + CityTaskResult eResult = TASK_ABORTED; + if (!CvPreGame::quickCombat()) + { + // Center camera here! + bool isTargetVisibleToActivePlayer = pPlot->isActiveVisible(); + if (isTargetVisibleToActivePlayer) { - // Center camera here! - bool isTargetVisibleToActivePlayer = pPlot->isActiveVisible(); - if (isTargetVisibleToActivePlayer) - { - CvInterfacePtr pDllPlot = GC.WrapPlotPointer(pPlot); - DLLUI->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL); - } - - kCombatInfo.setVisualizeCombat(pPlot->isActiveVisible()); + CvInterfacePtr pDllPlot = GC.WrapPlotPointer(pPlot); + DLLUI->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL); + } - CvInterfacePtr pDllCombatInfo(new CvDllCombatInfo(&kCombatInfo)); - uiParentEventID = gDLL->GameplayCityCombat(pDllCombatInfo.get()); + kCombatInfo.setVisualizeCombat(pPlot->isActiveVisible()); - // Set the combat units so that other missions do not continue until combat is over. - pDefender->setCombatCity(this); - setCombatUnit(pDefender); - eResult = TASK_QUEUED; - } - else - { - eResult = TASK_COMPLETED; - } + CvInterfacePtr pDllCombatInfo(new CvDllCombatInfo(&kCombatInfo)); + uiParentEventID = gDLL->GameplayCityCombat(pDllCombatInfo.get()); - CvUnitCombat::ResolveCombat(kCombatInfo, uiParentEventID); + // Set the combat units so that other missions do not continue until combat is over. + pDefender->setCombatCity(this); + setCombatUnit(pDefender); + eResult = TASK_QUEUED; } + else + { + eResult = TASK_COMPLETED; + } + + CvUnitCombat::ResolveCombat(kCombatInfo, uiParentEventID); return eResult; } @@ -33340,7 +32313,7 @@ CityTaskResult CvCity::rangeStrike(int iX, int iY) bool CvCity::canRangedStrikeTarget(const CvPlot& targetPlot) const { VALIDATE_OBJECT - return (rangedStrikeTarget(&targetPlot) != 0); + return (rangedStrikeTarget(&targetPlot) != NULL); } CvUnit* CvCity::getBestRangedStrikeTarget() const @@ -33351,11 +32324,7 @@ CvUnit* CvCity::getBestRangedStrikeTarget() const if (isMadeAttack()) return NULL; -#if defined(MOD_EVENTS_CITY_BOMBARD) int iRange = getBombardRange(); -#else - int iRange = /*2*/ GD_INT_GET(CITY_ATTACK_RANGE); -#endif int iBestScore = 0; CvUnit* pBestTarget = NULL; @@ -33397,12 +32366,14 @@ CvUnit* CvCity::rangedStrikeTarget(const CvPlot* pPlot) const { if (!pDefender->IsDead()) { -#if defined(MOD_GLOBAL_SUBS_UNDER_ICE_IMMUNITY) - // If the defender is a sub and the plot is ice, return NULL - if (pDefender->getInvisibleType() == 0 && pPlot->getFeatureType() == FEATURE_ICE) { - return NULL; + if (MOD_GLOBAL_SUBS_UNDER_ICE_IMMUNITY) + { + // If the defender is a sub and the plot is ice, return NULL + if (pDefender->getInvisibleType() == 0 && pPlot->getFeatureType() == FEATURE_ICE) + { + return NULL; + } } -#endif return pDefender; } @@ -33423,15 +32394,10 @@ int CvCity::rangeCombatUnitDefense(const CvUnit* pDefender, const CvPlot* pInPlo { iDefenderStrength = pDefender->GetEmbarkedUnitDefense(); } - // Use Ranged combat value for defender, UNLESS it's a boat or an Impi (ranged support) -#if defined(MOD_BALANCE_CORE) - //Correction - make this apply to all ranged units, naval too. + // Use Ranged combat value for defender, UNLESS it's an Impi (ranged support) else if (!pDefender->isRangedSupportFire() && pDefender->IsCanAttackRanged()) -#else - else if (!pDefender->isRangedSupportFire() && !pDefender->getDomainType() == DOMAIN_SEA) -#endif { - //have to consider embarkation explicitly + // Have to consider embarkation explicitly if ((!pInPlot && pDefender->isEmbarked()) || (pInPlot && pInPlot->needsEmbarkation(pDefender) && pDefender->CanEverEmbark())) iDefenderStrength = pDefender->GetEmbarkedUnitDefense(); else @@ -33534,16 +32500,10 @@ void CvCity::DoNearbyEnemy() if (!canRangeStrike()) return; -#if defined(MOD_BALANCE_CORE_MILITARY) if (isMadeAttack()) return; -#endif -#if defined(MOD_EVENTS_CITY_BOMBARD) int iSearchRange = getBombardRange(); -#else - int iSearchRange = /*2*/ GD_INT_GET(CITY_ATTACK_RANGE); -#endif if (IsEnemyInRange(iSearchRange, true)) { @@ -35685,6 +34645,139 @@ int CvCity::GetVassalLevyEra() const return m_iVassalLevyEra; } +// Spawn one eUnit on city plot (moved to nearest valid plot) +void CvCity::SpawnFreeUnit(UnitTypes eUnit) +{ + // Great Prophet goes the other path for proper initialization and popup notification + if (GC.getUnitInfo(eUnit)->IsFoundReligion()) + { + GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, MOD_GLOBAL_TRULY_FREE_GP); + return; + } + + CvPlayer& kPlayer = GET_PLAYER(getOwner()); + CvUnit* pFreeUnit = kPlayer.initUnit(eUnit, getX(), getY()); + + if (pFreeUnit->isTrade()) + { + if (GC.getLogging() && GC.getAILogging()) + { + CvString strCiv = GET_PLAYER(getOwner()).getCivilizationAdjective(); + CvString strLogString; + strLogString.Format("FREE TRADE UNIT CREATED: %s %s at %d,d", strCiv.c_str(), pFreeUnit->getName().c_str(), pFreeUnit->getX(), pFreeUnit->getY()); + GET_PLAYER(getOwner()).GetHomelandAI()->LogHomelandMessage(strLogString); + } + } + + if (pFreeUnit->IsGreatAdmiral()) + { + CvPlot* pSpawnPlot = kPlayer.GetBestCoastalSpawnPlot(pFreeUnit); + if (pFreeUnit->plot() != pSpawnPlot) + { + pFreeUnit->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); + } + } + else if (!pFreeUnit->jumpToNearestValidPlot()) + { + // Could not find a valid spot! Remove the unit and don't process further + pFreeUnit->kill(false); + return; + } + + pFreeUnit->DoGreatPersonSpawnBonus(this); + addProductionExperience(pFreeUnit); + kPlayer.incrementGreatPersonCount(pFreeUnit->getUnitInfo(), false, MOD_GLOBAL_TRULY_FREE_GP); +} + +// Spawn iNumber best military units owned by ePlayer around the best plot near this city +// ePlayer could be city owner, barbarian, or other players +bool CvCity::SpawnPlayerUnitsNearby(const PlayerTypes ePlayer, const int iNumber, const bool bIncludeUUs, const bool bIncludeShips, const bool bNoResource) const +{ + if (iNumber <= 0) + return false; + + int iBestPlot = -1; + int iBestPlotWeight = -1; + CvCityCitizens* pCitizens = GetCityCitizens(); + + // Start at 1, since ID 0 is the city plot itself + for (int iPlotLoop = 1; iPlotLoop < GetNumWorkablePlots(); iPlotLoop++) + { + CvPlot *pPlot = pCitizens->GetCityPlotFromIndex(iPlotLoop); + + // Could be outside of the map... + if (!pPlot) + continue; + + // Can't be impassable + if (!pPlot->isValidMovePlot(getOwner())) + continue; + + // Can't be water + if (pPlot->isWater()) + continue; + + // Don't pick plots that aren't ours + if (pPlot->getOwner() != getOwner()) + continue; + + // Don't place on a plot where a unit is already standing + if (pPlot->getNumUnits() > 0) + continue; + + int iTempWeight = GC.getGame().randRangeExclusive(0, 10, CvSeeder(GET_PLAYER(getOwner()).GetMilitaryMight()).mix(pPlot->GetPseudoRandomSeed())); + + // Add weight if there's an improvement here! + if (pPlot->getImprovementType() != NO_IMPROVEMENT) + { + iTempWeight += 4; + + // If there's also a resource, even more weight! + if (pPlot->getResourceType(getTeam()) != NO_RESOURCE) + iTempWeight += 3; + } + + // Add weight if there's a defensive bonus for this plot + if (pPlot->defenseModifier(BARBARIAN_TEAM, false, false)) + iTempWeight += 4; + + if (iTempWeight > iBestPlotWeight) + { + iBestPlotWeight = iTempWeight; + iBestPlot = iPlotLoop; + } + } + + // Couldn't find a valid spot + if (iBestPlot == -1) + return false; + + CvPlot* pPlot = pCitizens->GetCityPlotFromIndex(iBestPlot); + bool bUnitCreated = false; + CvPlayer& kPlayer = GET_PLAYER(ePlayer); + + // Spawn the units - should give us more melee than ranged + bool bCanBeRanged = false; + for (int i = 0; i < iNumber; i++) + { + UnitTypes eUnit = kPlayer.GetCompetitiveSpawnUnitType(bCanBeRanged, bIncludeShips, false, bIncludeUUs, this, bNoResource, false, true); + bCanBeRanged = !bCanBeRanged; + CvUnit* pUnit = kPlayer.initUnit(eUnit, pPlot->getX(), pPlot->getY()); + if (!pUnit->jumpToNearestValidPlotWithinRange(3)) + { + pUnit->kill(false); // Could not find a spot! + } + else + { + bUnitCreated = true; + pUnit->finishMoves(); + if (!kPlayer.isBarbarian()) + addProductionExperience(pUnit); + } + } + + return bUnitCreated; +} FDataStream& operator<<(FDataStream& saveTo, const SCityExtraYields& readFrom) { diff --git a/CvGameCoreDLL_Expansion2/CvCity.h b/CvGameCoreDLL_Expansion2/CvCity.h index 715eeac9b6..ad63d0472d 100644 --- a/CvGameCoreDLL_Expansion2/CvCity.h +++ b/CvGameCoreDLL_Expansion2/CvCity.h @@ -225,13 +225,8 @@ class CvCity void SetRouteToCapitalConnected(bool bValue, bool bSuppressReligionUpdate = false); bool IsRouteToCapitalConnected(void) const; -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void createGreatGeneral(UnitTypes eGreatPersonUnit, bool bIsFree); void createGreatAdmiral(UnitTypes eGreatPersonUnit, bool bIsFree); -#else - void createGreatGeneral(UnitTypes eGreatPersonUnit); - void createGreatAdmiral(UnitTypes eGreatPersonUnit); -#endif CityTaskResult doTask(TaskTypes eTask, int iData1 = -1, int iData2 = -1, bool bOption = false, bool bAlt = false, bool bShift = false, bool bCtrl = false); @@ -382,8 +377,8 @@ class CvCity bool isProductionProcess() const; bool canContinueProduction(OrderData order); - int getProductionExperience(UnitTypes eUnit = NO_UNIT); - void addProductionExperience(CvUnit* pUnit, bool bHalveXP = false, bool bGoldPurchase = false); + int getProductionExperience(UnitTypes eUnit = NO_UNIT) const; + void addProductionExperience(CvUnit* pUnit, bool bHalveXP = false, bool bGoldPurchase = false) const; UnitTypes getProductionUnit() const; UnitAITypes getProductionUnitAI() const; @@ -467,11 +462,7 @@ class CvCity int getResourceYieldRateModifier(YieldTypes eIndex, ResourceTypes eResource) const; void processResource(ResourceTypes eResource, int iChange); -#if defined(MOD_BALANCE_CORE) void processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, bool bObsolete = false, bool bApplyingAllCitiesBonus = false, bool bNoBonus = false); -#else - void processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst, bool bObsolete = false, bool bApplyingAllCitiesBonus = false); -#endif void processProcess(ProcessTypes eProcess, int iChange); void processSpecialist(SpecialistTypes eSpecialist, int iChange, eUpdateMode updateMode); @@ -603,17 +594,8 @@ class CvCity void SetAdditionalFood(int iValue); #endif -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) int getPopulation(bool bIncludeAutomatons = false) const; -#else - int getPopulation() const; -#endif - -#if defined(MOD_BALANCE_CORE) void setPopulation(int iNewValue, bool bReassignPop = true, bool bNoBonus = false); -#else - void setPopulation(int iNewValue, bool bReassignPop = true); -#endif void changePopulation(int iChange, bool bReassignPop = true, bool bIgnoreStaticUpdate = false); void setLowestRazingPop(int iValue); @@ -665,9 +647,7 @@ class CvCity int GetJONSCulturePerTurnFromTraits() const; void ChangeYieldFromTraits(YieldTypes eIndex, int iChange); -#if defined(MOD_BALANCE_CORE) int GetYieldPerTurnFromTraits(YieldTypes eYield) const; -#endif int GetJONSCulturePerTurnFromReligion() const; @@ -679,21 +659,17 @@ class CvCity int getBuildingClassCultureChange(BuildingClassTypes eIndex) const; void changeBuildingClassCultureChange(BuildingClassTypes eIndex, int iChange); #endif -#if defined(MOD_BALANCE_CORE) + void SetBaseTourism(int iValue); int GetBaseTourism() const; void SetBaseTourismBeforeModifiers(int iValue); int GetBaseTourismBeforeModifiers() const; -#endif // END Culture int getTourismRateModifier() const; void changeTourismRateModifier(int iChange); -#if defined(MOD_BALANCE_CORE) + int GetFaithPerTurn(bool bStatic = true) const; -#else - int GetFaithPerTurn() const; -#endif int GetFaithPerTurnFromBuildings() const; int GetFaithPerTurnFromPolicies() const; @@ -1316,8 +1292,6 @@ class CvCity bool isBorderCity() const; bool isBorderCity(vector& vUnfriendlyMajors) const; - - void DoBarbIncursion(); #endif void changeNukeInterceptionChance(int iNewValue); @@ -1356,9 +1330,6 @@ class CvCity int GetGreatWorkYieldChange(YieldTypes eIndex) const; #endif - int getPowerYieldRateModifier(YieldTypes eIndex) const; - void changePowerYieldRateModifier(YieldTypes eIndex, int iChange); - int getResourceYieldRateModifier(YieldTypes eIndex) const; void changeResourceYieldRateModifier(YieldTypes eIndex, int iChange); @@ -1618,13 +1589,13 @@ class CvCity std::string debugDump(const FAutoVariableBase&) const; std::string stackTraceRemark(const FAutoVariableBase&) const; - bool IsBusy() const; + bool IsBusy() const; // Combat related const CvUnit* getCombatUnit() const; CvUnit* getCombatUnit(); - void setCombatUnit(CvUnit* pCombatUnit, bool bAttacking = false); - void clearCombat(); - bool isFighting() const; + void setCombatUnit(CvUnit* pCombatUnit, bool bAttacking = false); + void clearCombat(); + bool isFighting() const; bool HasBelief(BeliefTypes iBeliefType) const; bool HasBuilding(BuildingTypes iBuildingType) const; @@ -1795,6 +1766,9 @@ class CvCity void ChangeVassalLevyEra(int iChange); int GetVassalLevyEra() const; + void SpawnFreeUnit(UnitTypes eUnit); + bool SpawnPlayerUnitsNearby(const PlayerTypes ePlayer, const int iNumber, const bool bIncludeUUs = false, const bool bIncludeShips = false, const bool bNoResource = false) const; + protected: SYNC_ARCHIVE_MEMBER(CvCity) diff --git a/CvGameCoreDLL_Expansion2/CvCityAI.cpp b/CvGameCoreDLL_Expansion2/CvCityAI.cpp index daffb394d8..bc83a4808b 100644 --- a/CvGameCoreDLL_Expansion2/CvCityAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvCityAI.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -160,11 +160,7 @@ void CvCityAI::AI_chooseProduction(bool bInterruptWonders, bool bInterruptBuildi } else { -#if defined(MOD_BALANCE_CORE) m_pCityStrategyAI->ChooseProduction(NO_BUILDING, NO_UNIT, bInterruptBuildings, bInterruptWonders); -#else - m_pCityStrategyAI->ChooseProduction(); -#endif AI_setChooseProductionDirty(false); } diff --git a/CvGameCoreDLL_Expansion2/CvCityCitizens.cpp b/CvGameCoreDLL_Expansion2/CvCityCitizens.cpp index 0dd3b0eec2..c6d2babcb6 100644 --- a/CvGameCoreDLL_Expansion2/CvCityCitizens.cpp +++ b/CvGameCoreDLL_Expansion2/CvCityCitizens.cpp @@ -382,26 +382,14 @@ void CvCityCitizens::DoTurn() } } -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) CvAssertMsg((GetNumCitizensWorkingPlots() + GetTotalSpecialistCount() + GetNumUnassignedCitizens()) <= GetCity()->getPopulation(true), "Gameplay: More workers than population in the city."); -#else - CvAssertMsg((GetNumCitizensWorkingPlots() + GetTotalSpecialistCount() + GetNumUnassignedCitizens()) <= GetCity()->getPopulation(), "Gameplay: More workers than population in the city."); -#endif DoReallocateCitizens(bForceCheck); } -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) CvAssertMsg((GetNumCitizensWorkingPlots() + GetTotalSpecialistCount() + GetNumUnassignedCitizens()) <= GetCity()->getPopulation(true), "Gameplay: More workers than population in the city."); -#else - CvAssertMsg((GetNumCitizensWorkingPlots() + GetTotalSpecialistCount() + GetNumUnassignedCitizens()) <= GetCity()->getPopulation(), "Gameplay: More workers than population in the city."); -#endif DoSpecialists(); -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) CvAssertMsg((GetNumCitizensWorkingPlots() + GetTotalSpecialistCount() + GetNumUnassignedCitizens()) <= GetCity()->getPopulation(true), "Gameplay: More workers than population in the city."); -#else - CvAssertMsg((GetNumCitizensWorkingPlots() + GetTotalSpecialistCount() + GetNumUnassignedCitizens()) <= GetCity()->getPopulation(), "Gameplay: More workers than population in the city."); -#endif } int CvCityCitizens::GetBonusPlotValue(CvPlot* pPlot, YieldTypes eYield, SPrecomputedExpensiveNumbers& cache) @@ -1363,18 +1351,10 @@ bool CvCityCitizens::DoAddBestCitizenFromUnassigned(CvCity::eUpdateMode updateMo /// Pick the worst Plot to stop working bool CvCityCitizens::DoRemoveWorstCitizen(CvCity::eUpdateMode updateMode, bool bRemoveForcedStatus, SpecialistTypes eDontChangeSpecialist) { -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) int iCurrentCityPopulation = GetCity()->getPopulation(true); -#else - int iCurrentCityPopulation = GetCity()->getPopulation(); -#endif // Are all of our guys already not working Plots? -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) if (GetNumUnassignedCitizens() == GetCity()->getPopulation(true)) -#else - if (GetNumUnassignedCitizens() == GetCity()->getPopulation()) -#endif { return false; } @@ -2607,11 +2587,8 @@ void CvCityCitizens::DoSpecialists() int iGPThreshold = GetSpecialistUpgradeThreshold((UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass()); ChangeSpecialistGreatPersonProgressTimes100(eSpecialist, iGPPChange); -#if defined(MOD_EVENTS_CITY) - if (MOD_EVENTS_CITY) { + if (MOD_EVENTS_CITY) GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityPrepared, GetCity()->getOwner(), GetCity(), eSpecialist, iGPPChange, iGPThreshold); - } -#endif // Enough to spawn a GP? if (GetSpecialistGreatPersonProgress(eSpecialist) >= iGPThreshold) @@ -2624,15 +2601,10 @@ void CvCityCitizens::DoSpecialists() // Now... actually create the GP! const UnitClassTypes eUnitClass = (UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass(); - if (eUnitClass != NO_UNITCLASS) + const UnitTypes eUnit = GET_PLAYER(GetCity()->getOwner()).GetSpecificUnitType(eUnitClass); + if (eUnit != NO_UNIT) { - UnitTypes eUnit = GET_PLAYER(GetCity()->getOwner()).GetSpecificUnitType(eUnitClass); - -#if defined(MOD_GLOBAL_TRULY_FREE_GP) DoSpawnGreatPerson(eUnit, true, false, false); -#else - DoSpawnGreatPerson(eUnit, true, false); -#endif } } } @@ -2652,22 +2624,14 @@ bool CvCityCitizens::IsCanAddSpecialistToBuilding(BuildingTypes eBuilding) CvAssert(eBuilding > -1); CvAssert(eBuilding < GC.getNumBuildingInfos()); -#if defined(MOD_BALANCE_CORE) if (m_pCity->IsResistance() || m_pCity->IsRazing()) - { return false; - } -#endif int iNumSpecialistsAssigned = GetNumSpecialistsInBuilding(eBuilding); -#if defined(MOD_GLOBAL_CITY_AUTOMATON_WORKERS) - if(iNumSpecialistsAssigned < GetCity()->getPopulation(true) && // Limit based on Pop of City -#else - if(iNumSpecialistsAssigned < GetCity()->getPopulation() && // Limit based on Pop of City -#endif - iNumSpecialistsAssigned < GC.getBuildingInfo(eBuilding)->GetSpecialistCount() && // Limit for this particular Building - iNumSpecialistsAssigned < /*4*/ GD_INT_GET(MAX_SPECIALISTS_FROM_BUILDING)) // Overall Limit + if (iNumSpecialistsAssigned < GetCity()->getPopulation(true) && // Limit based on Pop of City + iNumSpecialistsAssigned < GC.getBuildingInfo(eBuilding)->GetSpecialistCount() && // Limit for this particular Building + iNumSpecialistsAssigned < /*4*/ GD_INT_GET(MAX_SPECIALISTS_FROM_BUILDING)) // Overall Limit { return true; } @@ -3082,25 +3046,14 @@ void CvCityCitizens::ChangeSpecialistGreatPersonProgressTimes100(SpecialistTypes if (!GET_PLAYER(GetOwner()).isMinorCiv()) { // Reset progress on this Specialist -#if defined(MOD_BALANCE_CORE) DoResetSpecialistGreatPersonProgressTimes100(eIndex, (iGPThreshold * 100)); -#else - DoResetSpecialistGreatPersonProgressTimes100(eSpecialist); -#endif // Now... actually create the GP! const UnitClassTypes eUnitClass = (UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass(); - if (eUnitClass != NO_UNITCLASS) + const UnitTypes eUnit = GET_PLAYER(GetOwner()).GetSpecificUnitType(eUnitClass); + if (eUnit != NO_UNIT) { - UnitTypes eUnit = GET_PLAYER(GetOwner()).GetSpecificUnitType(eUnitClass); - if (eUnit != NO_UNIT) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - DoSpawnGreatPerson(eUnit, true, false, false); -#else - DoSpawnGreatPerson(eUnit, true, false); -#endif - } + DoSpawnGreatPerson(eUnit, true, false, false); } } } @@ -3159,76 +3112,46 @@ int CvCityCitizens::GetSpecialistUpgradeThreshold(UnitClassTypes eUnitClass) if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_WRITER", true)) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatWritersCreated(MOD_GLOBAL_TRULY_FREE_GP); iThreshold -= /*0*/ GD_INT_GET(GWAM_THRESHOLD_DECREASE); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatWritersCreated(); -#endif } else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_ARTIST", true)) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatArtistsCreated(MOD_GLOBAL_TRULY_FREE_GP); iThreshold -= /*0*/ GD_INT_GET(GWAM_THRESHOLD_DECREASE); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatArtistsCreated(); -#endif } else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_MUSICIAN", true)) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatMusiciansCreated(MOD_GLOBAL_TRULY_FREE_GP); iThreshold -= /*0*/ GD_INT_GET(GWAM_THRESHOLD_DECREASE); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatMusiciansCreated(); -#endif } else if (MOD_BALANCE_VP && eUnitClass == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT", true)) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatDiplomatsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatDiplomatsCreated(); -#endif } else { -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) { - if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_MERCHANT", true)) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) + if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_MERCHANT", true)) + { iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatMerchantsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatMerchantsCreated(); -#endif } - else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_SCIENTIST", true)) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) + else if (eUnitClass == GC.getInfoTypeForString("UNITCLASS_SCIENTIST", true)) + { iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatScientistsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatScientistsCreated(); -#endif } else { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatEngineersCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatEngineersCreated(); -#endif } } else -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) + { iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatPeopleCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGreatPeopleCreated(); -#endif + } } -#if defined(MOD_BALANCE_CORE) + const UnitTypes eThisPlayersUnitType = GET_PLAYER(GetCity()->getOwner()).GetSpecificUnitType(eUnitClass); if (eThisPlayersUnitType != NO_UNIT) { @@ -3237,44 +3160,23 @@ int CvCityCitizens::GetSpecialistUpgradeThreshold(UnitClassTypes eUnitClass) { if (pkUnitInfo->IsGPExtra() == 1) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra1Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra1Created(); -#endif } else if (pkUnitInfo->IsGPExtra() == 2) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra2Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra2Created(); -#endif } - else if (pkUnitInfo->IsGPExtra() == 3) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra3Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra3Created(); -#endif } else if (pkUnitInfo->IsGPExtra() == 4) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra4Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra4Created(); -#endif } else if (pkUnitInfo->IsGPExtra() == 5) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra5Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - iNumCreated = GET_PLAYER(GetCity()->getOwner()).getGPExtra5Created(); -#endif } } } @@ -3285,7 +3187,7 @@ int CvCityCitizens::GetSpecialistUpgradeThreshold(UnitClassTypes eUnitClass) iThreshold *= (100 + iMod); iThreshold /= 100; } -#endif + // Increase threshold based on how many GP have already been spawned iThreshold += (/*100 in CP, 250 in VP*/ GD_INT_GET(GREAT_PERSON_THRESHOLD_INCREASE) * iNumCreated); @@ -3314,16 +3216,13 @@ int CvCityCitizens::GetSpecialistUpgradeThreshold(UnitClassTypes eUnitClass) } /// Create a GP! -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void CvCityCitizens::DoSpawnGreatPerson(UnitTypes eUnit, bool bIncrementCount, bool bCountAsProphet, bool bIsFree) -#else -void CvCityCitizens::DoSpawnGreatPerson(UnitTypes eUnit, bool bIncrementCount, bool bCountAsProphet) -#endif { CvAssert(eUnit != NO_UNIT); - if (eUnit == NO_UNIT) - return; // Better than crashing. + // Not a great person + if (GC.getUnitInfo(eUnit)->GetSpecialUnitType() != static_cast(GC.getInfoTypeForString("SPECIALUNIT_PEOPLE"))) + return; // If it's the active player then show the popup if (GetCity()->getOwner() == GC.getGame().getActivePlayer()) @@ -3339,300 +3238,16 @@ void CvCityCitizens::DoSpawnGreatPerson(UnitTypes eUnit, bool bIncrementCount, b CvPlayer& kPlayer = GET_PLAYER(GetCity()->getOwner()); CvUnit* newUnit = kPlayer.initUnit(eUnit, GetCity()->getX(), GetCity()->getY()); - // Bump up the count - if (bIncrementCount && !bCountAsProphet) - { -#if defined(MOD_BALANCE_CORE) - if (kPlayer.GetPlayerTraits()->IsGPWLTKD()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - GetCity()->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); - strText << newUnit->getNameKey() << GetCity()->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); - strSummary << GetCity()->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), GetCity()->getX(), GetCity()->getY(), -1); - } - } - } - if (newUnit->isWLKTKDOnBirth()) - { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for (pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop)) - { - if (pLoopCity != NULL) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << newUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - } - if (newUnit->isGoldenAgeOnBirth()) - { - kPlayer.changeGoldenAgeTurns(kPlayer.getGoldenAgeLength()); - } - if (newUnit->isCultureBoost()) - { - int iValue = kPlayer.GetTotalJONSCulturePerTurn() * 4; - kPlayer.changeJONSCulture(iValue); - if (kPlayer.getCapitalCity() != NULL) - kPlayer.getCapitalCity()->ChangeJONSCultureStored(iValue); - - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << newUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << newUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), newUnit->getX(), newUnit->getY(), -1); - } - } -#endif - if (newUnit->IsGreatGeneral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatGeneralsCreated(bIsFree); -#else - kPlayer.incrementGreatGeneralsCreated(); -#endif - } - else if (newUnit->IsGreatAdmiral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatAdmiralsCreated(bIsFree); -#else - kPlayer.incrementGreatAdmiralsCreated(); -#endif - CvPlot *pSpawnPlot = kPlayer.GetBestCoastalSpawnPlot(newUnit); - if (newUnit->plot() != pSpawnPlot) - { - newUnit->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); - } - } - else if (newUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_WRITER")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatWritersCreated(bIsFree); -#else - kPlayer.incrementGreatWritersCreated(); -#endif - } - else if (newUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_ARTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatArtistsCreated(bIsFree); -#else - kPlayer.incrementGreatArtistsCreated(); -#endif - } - else if (newUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MUSICIAN")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatMusiciansCreated(bIsFree); -#else - kPlayer.incrementGreatMusiciansCreated(); -#endif - } - else if (MOD_BALANCE_VP && newUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatDiplomatsCreated(bIsFree); -#else - kPlayer.incrementGreatDiplomatsCreated(); -#endif - } -#if defined(MOD_BALANCE_CORE) - else if (newUnit->getUnitInfo().IsGPExtra() == 1) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGPExtra1Created(bIsFree); -#else - kPlayer.incrementGPExtra1Created(); -#endif - } - else if (newUnit->getUnitInfo().IsGPExtra() == 2) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGPExtra2Created(bIsFree); -#else - kPlayer.incrementGPExtra2Created(); -#endif - } - else if (newUnit->getUnitInfo().IsGPExtra() == 3) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGPExtra3Created(bIsFree); -#else - kPlayer.incrementGPExtra3Created(); -#endif - } - else if (newUnit->getUnitInfo().IsGPExtra() == 4) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGPExtra4Created(bIsFree); -#else - kPlayer.incrementGPExtra4Created(); -#endif - } - else if (newUnit->getUnitInfo().IsGPExtra() == 5) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGPExtra5Created(bIsFree); -#else - kPlayer.incrementGPExtra5Created(); -#endif - } -#endif - else - { -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) - if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) - { - if (newUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MERCHANT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatMerchantsCreated(bIsFree); -#else - kPlayer.incrementGreatMerchantsCreated(); -#endif - } - else if (newUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_SCIENTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatScientistsCreated(bIsFree); -#else - kPlayer.incrementGreatScientistsCreated(); -#endif - } - else - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatEngineersCreated(bIsFree); -#else - kPlayer.incrementGreatEngineersCreated(); -#endif - } - } - else -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.incrementGreatPeopleCreated(bIsFree); -#else - kPlayer.incrementGreatPeopleCreated(); -#endif - } - } - if (bCountAsProphet || newUnit->getUnitInfo().IsFoundReligion()) - { -#if defined(MOD_BALANCE_CORE) - if (kPlayer.GetPlayerTraits()->IsGPWLTKD()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - GetCity()->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); - strText << newUnit->getNameKey() << GetCity()->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); - strSummary << GetCity()->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), GetCity()->getX(), GetCity()->getY(), -1); - } - } - } - if (newUnit->isWLKTKDOnBirth()) - { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for (pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop)) - { - if (pLoopCity != NULL) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; + newUnit->DoGreatPersonSpawnBonus(GetCity()); - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << newUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - } - if (newUnit->isGoldenAgeOnBirth()) - { - kPlayer.changeGoldenAgeTurns(kPlayer.getGoldenAgeLength()); - } - if (newUnit->isCultureBoost()) - { - int iValue = kPlayer.GetTotalJONSCulturePerTurn() * 4; - kPlayer.changeJONSCulture(iValue); - if (kPlayer.getCapitalCity() != NULL) - kPlayer.getCapitalCity()->ChangeJONSCultureStored(iValue); - - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << newUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << newUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), newUnit->getX(), newUnit->getY(), -1); - } - } -#endif - if (bIncrementCount) -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - kPlayer.GetReligions()->ChangeNumProphetsSpawned(1, bIsFree); -#else - kPlayer.GetReligions()->ChangeNumProphetsSpawned(1); -#endif - } + if (bIncrementCount) + kPlayer.incrementGreatPersonCount(newUnit->getUnitInfo(), bCountAsProphet, bIsFree); // Setup prophet properly if (newUnit->getUnitInfo().IsFoundReligion()) { ReligionTypes eReligion = kPlayer.GetReligions()->GetOwnedReligion(); - newUnit->GetReligionDataMutable()->SetFullStrength(kPlayer.GetID(),newUnit->getUnitInfo(),eReligion); + newUnit->GetReligionDataMutable()->SetFullStrength(kPlayer.GetID(), newUnit->getUnitInfo(),eReligion); } // Notification diff --git a/CvGameCoreDLL_Expansion2/CvCityCitizens.h b/CvGameCoreDLL_Expansion2/CvCityCitizens.h index b3856890d9..fca813aae2 100644 --- a/CvGameCoreDLL_Expansion2/CvCityCitizens.h +++ b/CvGameCoreDLL_Expansion2/CvCityCitizens.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -190,11 +190,8 @@ class CvCityCitizens int GetNumSpecialistsAllowedByBuilding(const CvBuildingEntry& kBuilding); int GetSpecialistUpgradeThreshold(UnitClassTypes eUnitClass); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) + void DoSpawnGreatPerson(UnitTypes eUnit, bool bIncrementCount, bool bCountAsProphet, bool bIsFree); -#else - void DoSpawnGreatPerson(UnitTypes eUnit, bool bIncrementCount, bool bCountAsProphet); -#endif YieldTypes GetFocusTypeYield(CityAIFocusTypes eFocus); diff --git a/CvGameCoreDLL_Expansion2/CvCitySpecializationAI.cpp b/CvGameCoreDLL_Expansion2/CvCitySpecializationAI.cpp index 34f9977b4c..c21eac844c 100644 --- a/CvGameCoreDLL_Expansion2/CvCitySpecializationAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvCitySpecializationAI.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -152,11 +152,7 @@ int CvCitySpecializationXMLEntries::GetNumCitySpecializations() /// Get a specific entry CvCitySpecializationXMLEntry* CvCitySpecializationXMLEntries::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_CITY_SPECIALIZATION) ? m_paCitySpecializationEntries[index] : NULL; -#else - return m_paCitySpecializationEntries[index]; -#endif + return (index != NO_CITY_SPECIALIZATION) ? m_paCitySpecializationEntries[index] : NULL; } /// Find the first specializations for a yield @@ -1130,42 +1126,27 @@ int CvCitySpecializationAI::AdjustValueBasedOnBuildings(CvCity* pCity, YieldType switch(eYield) { case YIELD_FOOD: - { - int iMaxFoodKeptPercent = pCity->getMaxFoodKeptPercent(); - if(iMaxFoodKeptPercent >= 100) - { - iMaxFoodKeptPercent = 99; - } - iRtnValue *= 100 / (100 - iMaxFoodKeptPercent); - } - break; + iRtnValue *= 100 / (100 - min(99, pCity->getMaxFoodKeptPercent())); + break; case YIELD_PRODUCTION: - // Double production if any military training facilities present -#if defined(MOD_BALANCE_CORE) - if(pCity->getDomainFreeExperience(DOMAIN_LAND) > 0) + if (pCity->getDomainFreeExperience(DOMAIN_LAND) > 0) { iRtnValue = iRtnValue * (100 + (pCity->getDomainFreeExperience(DOMAIN_LAND) * 10)) / 100; } - if(pCity->getDomainFreeExperience(DOMAIN_AIR) > 0) + if (pCity->getDomainFreeExperience(DOMAIN_AIR) > 0) { iRtnValue = iRtnValue * (100 + (pCity->getDomainFreeExperience(DOMAIN_AIR) * 10)) / 100; } - if(pCity->getDomainFreeExperience(DOMAIN_SEA) > 0) + if (pCity->getDomainFreeExperience(DOMAIN_SEA) > 0) { iRtnValue = iRtnValue * (100 + (pCity->getDomainFreeExperience(DOMAIN_SEA) * 10)) / 100; } -#else - if(pCity->getDomainFreeExperience(DOMAIN_LAND) > 0) - { - iRtnValue *= 2; - } -#endif break; case YIELD_SCIENCE: break; -#if defined(MOD_BALANCE_CORE) + case YIELD_CULTURE: iYieldChanges = pCity->getCultureRateModifier(); if(iYieldChanges > 0) @@ -1183,7 +1164,7 @@ int CvCitySpecializationAI::AdjustValueBasedOnBuildings(CvCity* pCity, YieldType iRtnValue = iRtnValue * (100 + (iYieldChanges * 15)) / 100; } break; -#endif + case NO_YIELD: case YIELD_GOLD: case YIELD_TOURISM: diff --git a/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp b/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp index 9070ec7d49..5650d474cb 100644 --- a/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvCityStrategyAI.cpp @@ -228,11 +228,7 @@ void CvAICityStrategies::DeleteArray() /// Get a specific entry CvAICityStrategyEntry* CvAICityStrategies::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_AICITYSTRATEGY) ? m_paAICityStrategyEntries[index] : NULL; -#else - return m_paAICityStrategyEntries[index]; -#endif + return (index != NO_AICITYSTRATEGY) ? m_paAICityStrategyEntries[index] : NULL; } //===================================== @@ -2607,11 +2603,7 @@ bool CityStrategyAIHelpers::IsTestCityStrategy_NeedNavalTileImprovement(CvCity* if(pCity->GetCityCitizens()->IsCanWork(pLoopPlot)) { // Does this Tile already have a Resource, and if so, is it already improved? -#if defined(MOD_BALANCE_CORE) ResourceTypes eResource = pLoopPlot->getResourceType(pCity->getTeam()); -#else - ResourceTypes eResource = pLoopPlot->getResourceType(); -#endif if(eResource != NO_RESOURCE && pLoopPlot->getImprovementType() == NO_IMPROVEMENT) { if (!kPlayer.NeedWorkboatToImproveResource(eResource)) @@ -3160,14 +3152,12 @@ bool CityStrategyAIHelpers::IsTestCityStrategy_GoodGPCity(CvCity* pCity) } } -#if defined(MOD_BALANCE_CORE_RESOURCE_MONOPOLIES) // GPP from resource monopolies GreatPersonTypes eGreatPerson = GetGreatPersonFromSpecialist(eSpecialist); if (eGreatPerson != NO_GREATPERSON) { iGPPChange += pCity->GetPlayer()->getSpecificGreatPersonRateChangeFromMonopoly(eGreatPerson) * 100; } -#endif if (iGPPChange > 0) { @@ -3261,7 +3251,7 @@ bool CityStrategyAIHelpers::IsTestCityStrategy_GoodGPCity(CvCity* pCity) { iMod += 25; } - } + } else if((UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass() == GC.getInfoTypeForString("UNITCLASS_ARTIST")) { iMod += pCity->GetPlayer()->getGreatArtistRateModifier(); @@ -3273,7 +3263,7 @@ bool CityStrategyAIHelpers::IsTestCityStrategy_GoodGPCity(CvCity* pCity) { iMod += 25; } - } + } else if((UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass() == GC.getInfoTypeForString("UNITCLASS_MUSICIAN")) { iMod += pCity->GetPlayer()->getGreatMusicianRateModifier(); @@ -3307,11 +3297,8 @@ bool CityStrategyAIHelpers::IsTestCityStrategy_GoodGPCity(CvCity* pCity) } } } -#if defined(MOD_BALANCE_CORE) + if (iTotalGPPChange >= 2500) -#else - if (iTotalGPPChange >= 800) -#endif { return true; } diff --git a/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp b/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp index 1bc01dab42..9b4e6ba4b6 100644 --- a/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvCultureClasses.cpp @@ -1280,14 +1280,9 @@ void CvPlayerCulture::DoSwapGreatWorksHuman(bool bSwap) } #endif /// AI routine to decide what Great Work swapping should take place (including placing Great Works up for swap from another player) -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) void CvPlayerCulture::DoSwapGreatWorks(YieldTypes eFocusYield) { // CUSTOMLOG("DoSwapGreatWorks focus is %i", ((int) eFocusYield)); -#else -void CvPlayerCulture::DoSwapGreatWorks() -{ -#endif GreatWorkClass eWritingClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_LITERATURE"); GreatWorkClass eArtClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_ART"); GreatWorkClass eArtifactsClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_ARTIFACT"); @@ -1335,7 +1330,7 @@ void CvPlayerCulture::DoSwapGreatWorks() CvGreatWorkBuildingInMyEmpire building; building.m_eBuilding = eBuilding; building.m_iCityID = pLoopCity->GetID(); -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) + if (pLoopCity->isCapital()) building.m_bEndangered = false; else @@ -1343,12 +1338,6 @@ void CvPlayerCulture::DoSwapGreatWorks() building.m_bPuppet = pLoopCity->IsPuppet(); building.m_eYieldType = GC.GetGameBuildings()->GetEntry(eBuilding)->GetGreatWorkYieldType(); -#else - if (pLoopCity->isCapital()) - building.m_bEndangered = false; - else - building.m_bEndangered = (pLoopCity->getDamage() > 0); -#endif GreatWorkSlotType eSlotType = pkBuilding->GetGreatWorkSlotType(); if (eSlotType == CvTypes::getGREAT_WORK_SLOT_LITERATURE()) @@ -1405,15 +1394,10 @@ void CvPlayerCulture::DoSwapGreatWorks() } } } -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) - MoveWorks (CvTypes::getGREAT_WORK_SLOT_LITERATURE(), aGreatWorkBuildingsWriting, aGreatWorksWriting, aNull, eFocusYield, true); - MoveWorks (CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT(), aGreatWorkBuildingsArt, aGreatWorksArt, aGreatWorksArtifacts, eFocusYield, true); - MoveWorks (CvTypes::getGREAT_WORK_SLOT_MUSIC(), aGreatWorkBuildingsMusic, aGreatWorksMusic, aNull, eFocusYield, true); -#else - MoveWorks (CvTypes::getGREAT_WORK_SLOT_LITERATURE(), aGreatWorkBuildingsWriting, aGreatWorksWriting, aNull); - MoveWorks (CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT(), aGreatWorkBuildingsArt, aGreatWorksArt, aGreatWorksArtifacts); - MoveWorks (CvTypes::getGREAT_WORK_SLOT_MUSIC(), aGreatWorkBuildingsMusic, aGreatWorksMusic, aNull); -#endif + + MoveWorks(CvTypes::getGREAT_WORK_SLOT_LITERATURE(), aGreatWorkBuildingsWriting, aGreatWorksWriting, aNull, eFocusYield, true); + MoveWorks(CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT(), aGreatWorkBuildingsArt, aGreatWorksArt, aGreatWorksArtifacts, eFocusYield, true); + MoveWorks(CvTypes::getGREAT_WORK_SLOT_MUSIC(), aGreatWorkBuildingsMusic, aGreatWorksMusic, aNull, eFocusYield, true); } /// Sorts building by AI priority which determines the order they should be evaluated when applying theming bonuses @@ -1441,17 +1425,12 @@ static bool SortThemingBonus(const CvGreatWorkBuildingInMyEmpire& kEntry1, const } /// Overall routine that orchestrates all the maneuvering of Great Works between buildings and players for one AI turn -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) -void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vector &buildings, vector &works1, vector &works2, YieldTypes eFocusYield, bool bSwap) -#else -void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vector &buildings, vector &works1, vector &works2) -#endif +void CvPlayerCulture::MoveWorks(GreatWorkSlotType eType, vector &buildings, vector &works1, vector &works2, YieldTypes eFocusYield, bool bSwap) { // CUSTOMLOG("Move Works for slot type %i", ((int) eType)); std::stable_sort (buildings.begin(), buildings.end(), SortThemingBonus); -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) - // The order is + // The order is // - theme homeland and puppet buildings // - theme endangered buildings // - work out the swaps @@ -1463,11 +1442,9 @@ void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vectorm_bThemed = true; -#if defined(MOD_BALANCE_CORE) bUpdate = true; -#endif } } } @@ -1497,9 +1472,7 @@ void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vectorm_bThemed = true; -#if defined(MOD_BALANCE_CORE) bUpdate = true; -#endif } } } @@ -1510,13 +1483,12 @@ void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vector 0) { // CUSTOMLOG(" ... for writing to %i", works1[0].m_iGreatWorkIndex); @@ -1531,46 +1503,39 @@ void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vector 0) - { - // CUSTOMLOG(" ... for art(ifact) to %i", works1[0].m_iGreatWorkIndex); - SetSwappableArtIndex(works1[0].m_iGreatWorkIndex); - } - else - { - SetSwappableArtIndex(-1); - } -#if defined(MOD_BALANCE_CORE) + if (works1.size() > 0) + { + // CUSTOMLOG(" ... for art(ifact) to %i", works1[0].m_iGreatWorkIndex); + SetSwappableArtIndex(works1[0].m_iGreatWorkIndex); + } + else + { + SetSwappableArtIndex(-1); + } } else { SetSwappableArtIndex(-1); } -#endif } + if (eType == CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT() && GetSwappableArtIndex() == -1) { -#if defined(MOD_BALANCE_CORE) if (bSwap) { -#endif if (works2.size() > 0) { // CUSTOMLOG(" ... for art(ifact) to %i", works2[0].m_iGreatWorkIndex); @@ -1585,20 +1550,16 @@ void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vectorm_bThemed = true; -#if defined(MOD_BALANCE_CORE) bUpdate = true; -#endif } } } } -#if defined(MOD_BALANCE_CORE) } -#endif // Then endangered ones // CUSTOMLOG(" ... theming endangered buildings"); @@ -1631,33 +1588,13 @@ void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vectorm_bThemed = true; -#if defined(MOD_BALANCE_CORE) bUpdate = true; -#endif } } } -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) bool bSecondUpdate = MoveSingleWorks(buildings, works1, works2, eFocusYield, true); -#else - // Fill unthemed buildings, first those that aren't endangered - for (itBuilding = buildings.begin(); itBuilding != buildings.end(); itBuilding++) - { - if (!itBuilding->m_bEndangered && !itBuilding->m_bThemed) - { - FillBuilding(itBuilding, works1, works2); - } - } - for (itBuilding = buildings.begin(); itBuilding != buildings.end(); itBuilding++) - { - if (itBuilding->m_bEndangered && !itBuilding->m_bThemed) - { - FillBuilding(itBuilding, works1, works2); - } - } -#endif -#if defined(MOD_BALANCE_CORE) + if(bSecondUpdate || bUpdate) { std::vector CityList; @@ -1687,7 +1624,6 @@ void CvPlayerCulture::MoveWorks (GreatWorkSlotType eType, vector::const // Try each of the theming bonuses for this building for (int iI = 0; iI < bestThemes.size(); iI++) { -#if defined(MOD_BALANCE_CORE) bool bThemedProperly = false; -#endif CvThemingBonusInfo *pkBonusInfo = pkEntry->GetThemingBonusInfo(bestThemes.GetElement(iI)); if (pkBonusInfo->IsMustBeArt()) { @@ -1796,16 +1730,12 @@ bool CvPlayerCulture::ThemeBuilding(vector::const } // Did we theme it properly? -#if defined(MOD_BALANCE_CORE) bThemedProperly = false; -#else - bool bThemedProperly = false; -#endif if (aWorksChosen.size() == iCountSlots && CultureHelpers::GetThemingBonusIndex(m_pPlayer->GetID(), pkEntry, aWorksChosen) == bestThemes.GetElement(iI)) { bThemedProperly = true; } -#if defined(MOD_BALANCE_CORE) + if (!bThemedProperly && bConsiderOtherPlayers && (pkEntry->GetGreatWorkSlotType() != CvTypes::getGREAT_WORK_SLOT_MUSIC())) { //Let's look at every applicable GW in the world. @@ -2182,147 +2112,13 @@ bool CvPlayerCulture::ThemeBuilding(vector::const return true; } } -#else - // If we are one work short, let's look to other players - else if (bConsiderOtherPlayers && aWorksChosen.size() == (iCountSlots - 1) && (pkEntry->GetGreatWorkSlotType() != CvTypes::getGREAT_WORK_SLOT_MUSIC())) - { - for (int iLoopPlayer = 0; iLoopPlayer < MAX_MAJOR_CIVS; iLoopPlayer++) - { - CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iLoopPlayer); - if (kPlayer.isAlive() && m_pPlayer->GetDiplomacyAI()->IsPlayerValid((PlayerTypes)iLoopPlayer)) - { - int iToBeAcquiredWorkIndex = NO_GREAT_WORK; - int iToBeDiscardedWorkIndex = NO_GREAT_WORK; - - if (pkEntry->GetGreatWorkSlotType() == CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT()) - { - if (pkBonusInfo->IsMustBeArt()) - { - iToBeAcquiredWorkIndex = kPlayer.GetCulture()->GetSwappableArtIndex(); - iToBeDiscardedWorkIndex = CultureHelpers::FindWorkNotChosen(works1, aWorksChosen); - } - else if (pkBonusInfo->IsMustBeArtifact()) - { - iToBeAcquiredWorkIndex = kPlayer.GetCulture()->GetSwappableArtifactIndex(); - iToBeDiscardedWorkIndex = CultureHelpers::FindWorkNotChosen(works2, aWorksChosen); - } - } - else - { - iToBeAcquiredWorkIndex = kPlayer.GetCulture()->GetSwappableWritingIndex(); - iToBeDiscardedWorkIndex = CultureHelpers::FindWorkNotChosen(works1, aWorksChosen); - } - - // Does this work fit? - if (iToBeAcquiredWorkIndex != NO_GREAT_WORK && iToBeDiscardedWorkIndex != NO_GREAT_WORK) - { - EraTypes eEra = pkGameCulture->m_CurrentGreatWorks[iToBeAcquiredWorkIndex].m_eEra; - PlayerTypes ePlayer = pkGameCulture->GetGreatWorkCreator(iToBeAcquiredWorkIndex); - if (CultureHelpers::IsValidForThemingBonus(pkBonusInfo, eEra, aErasSeen, ePlayer, aPlayersSeen, m_pPlayer->GetID())) - { - aWorksChosen.push_back(iToBeAcquiredWorkIndex); - if (CultureHelpers::GetThemingBonusIndex(m_pPlayer->GetID(), pkEntry, aWorksChosen) == iI) - { - bool bSwapSuccess = pkGameCulture->SwapGreatWorks(m_pPlayer->GetID(), iToBeDiscardedWorkIndex, ePlayer, iToBeAcquiredWorkIndex); - if (bSwapSuccess) - { - bThemedProperly = true; - - LogSwapWorks(ePlayer, iToBeDiscardedWorkIndex, iToBeAcquiredWorkIndex); - - // Update works list - tempWorks.clear(); - if (!pkBonusInfo->IsMustBeArtifact()) - { - for (it3 = works1.begin(); it3 != works1.end(); it3++) - { - if (it3->m_iGreatWorkIndex == iToBeDiscardedWorkIndex) - { - it3->m_iGreatWorkIndex = iToBeAcquiredWorkIndex; - GetGreatWorkLocation(it3->m_iGreatWorkIndex, it3->m_iCityID, it3->m_eBuilding, it3->m_iSlot); - } - tempWorks.push_back(*it3); - } - works1 = tempWorks; - } - else - { - for (it3 = works2.begin(); it3 != works2.end(); it3++) - { - if (it3->m_iGreatWorkIndex == iToBeDiscardedWorkIndex) - { - it3->m_iGreatWorkIndex = iToBeAcquiredWorkIndex; - GetGreatWorkLocation(it3->m_iGreatWorkIndex, it3->m_iCityID, it3->m_eBuilding, it3->m_iSlot); - } - tempWorks.push_back(*it3); - } - works2 = tempWorks; - } - - CultureHelpers::SendArtSwapNotification(pkEntry->GetGreatWorkSlotType(), pkBonusInfo->IsMustBeArt(), m_pPlayer->GetID(), ePlayer, iToBeDiscardedWorkIndex, iToBeAcquiredWorkIndex); - break; // Themed it through acquisition - } - } - } - } - } - } - } - if (bThemedProperly) - { - for (int jJ = 0; jJ < (int)aWorksChosen.size(); jJ++) - { - for (int kK = 0; kK < (int)worksToConsider.size(); kK++) - { - if (worksToConsider[kK].m_iGreatWorkIndex == aWorksChosen[jJ]) - { - MoveWorkIntoSlot(worksToConsider[kK], buildingIt->m_iCityID, buildingIt->m_eBuilding, jJ); - break; - } - } - } - - // Remove these works from those to consider later - tempWorks.clear(); - for (it3 = works1.begin(); it3 != works1.end(); it3++) - { - // Copy it over if not chosen, updating its location - if (find(aWorksChosen.begin(), aWorksChosen.end(), it3->m_iGreatWorkIndex) == aWorksChosen.end()) - { - GetGreatWorkLocation(it3->m_iGreatWorkIndex, it3->m_iCityID, it3->m_eBuilding, it3->m_iSlot); - tempWorks.push_back(*it3); - } - } - works1 = tempWorks; - - tempWorks.clear(); - for (it3 = works2.begin(); it3 != works2.end(); it3++) - { - // Copy it over if not chosen, updating its location - if (find(aWorksChosen.begin(), aWorksChosen.end(), it3->m_iGreatWorkIndex) == aWorksChosen.end()) - { - GetGreatWorkLocation(it3->m_iGreatWorkIndex, it3->m_iCityID, it3->m_eBuilding, it3->m_iSlot); - tempWorks.push_back(*it3); - } - } - works2 = tempWorks; - - // All done - LogThemedBuilding(buildingIt->m_iCityID, buildingIt->m_eBuilding, pkBonusInfo->GetBonus()); - return true; - } -#endif } } return false; } /// Specialized version of ThemeBuilding() that handles those buildings that are split between Art and Artifact -#if defined(MOD_BALANCE_CORE) bool CvPlayerCulture::ThemeEqualArtArtifact(CvGreatWorkBuildingInMyEmpire kBldg, int iThemingBonusIndex, int iNumSlots, vector &works1, vector &works2, bool bConsiderOtherPlayers, int iThemeID) -#else -bool CvPlayerCulture::ThemeEqualArtArtifact(CvGreatWorkBuildingInMyEmpire kBldg, int iThemingBonusIndex, int iNumSlots, vector &works1, vector &works2, bool /*bConsiderOtherPlayers*/) -#endif { CvGameCulture *pkGameCulture = GC.getGame().GetGameCulture(); @@ -2437,7 +2233,7 @@ bool CvPlayerCulture::ThemeEqualArtArtifact(CvGreatWorkBuildingInMyEmpire kBldg, { bThemedProperly = true; } -#if defined(MOD_BALANCE_CORE) + if (!bThemedProperly && bConsiderOtherPlayers && (pkEntry->GetGreatWorkSlotType() != CvTypes::getGREAT_WORK_SLOT_MUSIC())) { //Let's look at every applicable GW in the world. @@ -2823,107 +2619,6 @@ bool CvPlayerCulture::ThemeEqualArtArtifact(CvGreatWorkBuildingInMyEmpire kBldg, return true; } } -#else - // If we are one work short, let's look to other players for a last piece of art - else if (aWorksChosen.size() == (iNumSlots - 1)) - { - for (int iLoopPlayer = 0; iLoopPlayer < MAX_MAJOR_CIVS; iLoopPlayer++) - { - CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iLoopPlayer); - if (kPlayer.isAlive() && m_pPlayer->GetDiplomacyAI()->IsPlayerValid((PlayerTypes)iLoopPlayer)) - { - int iToBeAcquiredWorkIndex = kPlayer.GetCulture()->GetSwappableArtIndex(); - int iToBeDiscardedWorkIndex = CultureHelpers::FindWorkNotChosen(works1, aWorksChosen); - - // Does this work fit? - if (iToBeAcquiredWorkIndex != NO_GREAT_WORK && iToBeDiscardedWorkIndex != NO_GREAT_WORK) - { - EraTypes eEra = pkGameCulture->m_CurrentGreatWorks[iToBeAcquiredWorkIndex].m_eEra; - PlayerTypes ePlayer = pkGameCulture->GetGreatWorkCreator(iToBeAcquiredWorkIndex); - if (CultureHelpers::IsValidForThemingBonus(pkBonusInfo, eEra, aErasSeen, ePlayer, aPlayersSeen, m_pPlayer->GetID())) - { - aWorksChosen.push_back(iToBeAcquiredWorkIndex); - if (CultureHelpers::GetThemingBonusIndex(m_pPlayer->GetID(), pkEntry, aWorksChosen) == iThemingBonusIndex) - { - bool bSwapSuccessful = pkGameCulture->SwapGreatWorks(m_pPlayer->GetID(), iToBeDiscardedWorkIndex, ePlayer, iToBeAcquiredWorkIndex); - if (bSwapSuccessful) - { - bThemedProperly = true; - - // Update works list - tempWorks.clear(); - for (it5 = works1.begin(); it5 != works1.end(); it5++) - { - if (it5->m_iGreatWorkIndex == iToBeDiscardedWorkIndex) - { - it5->m_iGreatWorkIndex = iToBeAcquiredWorkIndex; - GetGreatWorkLocation(it5->m_iGreatWorkIndex, it5->m_iCityID, it5->m_eBuilding, it5->m_iSlot); - } - tempWorks.push_back(*it5); - } - works1 = tempWorks; - - CultureHelpers::SendArtSwapNotification(pkEntry->GetGreatWorkSlotType(), pkBonusInfo->IsMustBeArt(), m_pPlayer->GetID(), ePlayer, iToBeDiscardedWorkIndex, iToBeAcquiredWorkIndex); - break; // Themed it through acquisition - } - } - } - } - } - } - } - if (bThemedProperly) - { - for (int jJ = 0; jJ < (int)aWorksChosen.size(); jJ++) - { - for (int kK = 0; kK < (int)works1.size(); kK++) - { - if (works1[kK].m_iGreatWorkIndex == aWorksChosen[jJ]) - { - MoveWorkIntoSlot(works1[kK], kBldg.m_iCityID, kBldg.m_eBuilding, jJ); - break; - } - } - for (int kK = 0; kK < (int)works2.size(); kK++) - { - if (works2[kK].m_iGreatWorkIndex == aWorksChosen[jJ]) - { - MoveWorkIntoSlot(works2[kK], kBldg.m_iCityID, kBldg.m_eBuilding, jJ); - break; - } - } - } - - // Remove these works from those to consider later - tempWorks.clear(); - for (it5 = works1.begin(); it5 != works1.end(); it5++) - { - // Copy it over if not chosen, updating its location - if (find(aWorksChosen.begin(), aWorksChosen.end(), it5->m_iGreatWorkIndex) == aWorksChosen.end()) - { - GetGreatWorkLocation(it5->m_iGreatWorkIndex, it5->m_iCityID, it5->m_eBuilding, it5->m_iSlot); - tempWorks.push_back(*it5); - } - } - works1 = tempWorks; - - tempWorks.clear(); - for (it5 = works2.begin(); it5 != works2.end(); it5++) - { - // Copy it over if not chosen, updating its location - if (find(aWorksChosen.begin(), aWorksChosen.end(), it5->m_iGreatWorkIndex) == aWorksChosen.end()) - { - GetGreatWorkLocation(it5->m_iGreatWorkIndex, it5->m_iCityID, it5->m_eBuilding, it5->m_iSlot); - tempWorks.push_back(*it5); - } - } - works2 = tempWorks; - - // All done - LogThemedBuilding(kBldg.m_iCityID, kBldg.m_eBuilding, pkBonusInfo->GetBonus()); - return true; - } -#endif } } } @@ -3045,9 +2740,8 @@ bool CvPlayerCulture::FillBuilding(vector::const_ return false; } -#if defined(MOD_BALANCE_CORE) + bool bUpdate = false; -#endif vector worksToConsider; vector aWorksChosen; @@ -3064,11 +2758,7 @@ bool CvPlayerCulture::FillBuilding(vector::const_ { aWorksChosen.push_back(worksToConsider[iI].m_iGreatWorkIndex); // CUSTOMLOG(" filling slot %i with Great Work %i", iI, worksToConsider[iI].m_iGreatWorkIndex); -#if defined(MOD_BALANCE_CORE) bUpdate = MoveWorkIntoSlot(worksToConsider[iI], buildingIt->m_iCityID, buildingIt->m_eBuilding, iI); -#else - MoveWorkIntoSlot(worksToConsider[iI], buildingIt->m_iCityID, buildingIt->m_eBuilding, iI); -#endif } // Remove these works from those to consider later @@ -3101,19 +2791,12 @@ bool CvPlayerCulture::FillBuilding(vector::const_ } works2 = tempWorks; } -#if defined(MOD_BALANCE_CORE) + return bUpdate; -#else - return true; -#endif } /// Lower-level routine to perform the swap between two Great Works within your own empire -#if defined(MOD_BALANCE_CORE) bool CvPlayerCulture::MoveWorkIntoSlot (CvGreatWorkInMyEmpire kWork, int iCityID, BuildingTypes eBuilding, int iSlot) -#else -void CvPlayerCulture::MoveWorkIntoSlot (CvGreatWorkInMyEmpire kWork, int iCityID, BuildingTypes eBuilding, int iSlot) -#endif { CvBuildingEntry *pkToEntry = GC.getBuildingInfo(eBuilding); @@ -3145,17 +2828,13 @@ void CvPlayerCulture::MoveWorkIntoSlot (CvGreatWorkInMyEmpire kWork, int iCityID eFromBuildingClass, iFromSlot ); - -#if defined(MOD_BALANCE_CORE) return true; -#endif } } } } -#if defined(MOD_BALANCE_CORE) + return false; -#endif } int CvPlayerCulture::GetSwappableWritingIndex() const @@ -5898,11 +5577,7 @@ int CvPlayerCulture::GetTotalThemingBonuses() const int iLoop = 0; for(pCity = m_pPlayer->firstCity(&iLoop); pCity != NULL; pCity = m_pPlayer->nextCity(&iLoop)) { -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) iRtnValue += pCity->GetCityBuildings()->GetCurrentThemingBonuses(YIELD_CULTURE); -#else - iRtnValue += pCity->GetCityBuildings()->GetCurrentThemingBonuses(); -#endif } return iRtnValue; @@ -6261,17 +5936,9 @@ void CvCityCulture::Init(CvCity* pCity) } /// How many Great Works are in the city? -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) int CvCityCulture::GetNumGreatWorks(bool bIgnoreYield) const -#else -int CvCityCulture::GetNumGreatWorks() const -#endif { -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) return m_pCity->GetCityBuildings()->GetNumGreatWorks(bIgnoreYield); -#else - return m_pCity->GetCityBuildings()->GetNumGreatWorks(); -#endif } /// How many Great Works slots are available in the city? (counting both open and filled and counting all types) @@ -6377,20 +6044,12 @@ void CvCityCulture::CalculateBaseTourismBeforeModifiers() return; } -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) // Ignore those Great Works in storage (ie not generating a yield) int iBase = GetNumGreatWorks(false) * (/*2 in CP, 3 in VP*/ GD_INT_GET(BASE_TOURISM_PER_GREAT_WORK) + GET_PLAYER(m_pCity->getOwner()).GetGreatWorkYieldChange(YIELD_TOURISM)); -#else - int iBase = GetNumGreatWorks() * /*2 in CP, 3 in VP*/ GD_INT_GET(BASE_TOURISM_PER_GREAT_WORK); -#endif int iBonus = ((m_pCity->GetCityBuildings()->GetGreatWorksTourismModifier() + GET_PLAYER(m_pCity->getOwner()).GetGreatWorksTourismModifierGlobal()) * iBase / 100); iBase += iBonus; -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) iBase += m_pCity->GetCityBuildings()->GetCurrentThemingBonuses(YIELD_CULTURE); -#else - iBase += m_pCity->GetCityBuildings()->GetCurrentThemingBonuses(); -#endif // Add in all the tourism from yields iBase += m_pCity->getYieldRate(YIELD_TOURISM, false); @@ -6708,33 +6367,24 @@ CvString CvCityCulture::GetTourismTooltip() CvString differentIdeologyCivs = ""; CvPlayer &kCityPlayer = GET_PLAYER(m_pCity->getOwner()); // Great Works -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) // Ignore those Great Works in storage, ie not generating a yield int iGWTourism = GetNumGreatWorks(false) * (/*2 in CP, 3 in VP*/ GD_INT_GET(BASE_TOURISM_PER_GREAT_WORK) + kCityPlayer.GetGreatWorkYieldChange(YIELD_TOURISM)); -#else - int iGWTourism = GetNumGreatWorks() * /*2 in CP, 3 in VP*/ GD_INT_GET(BASE_TOURISM_PER_GREAT_WORK); -#endif iGWTourism += ((m_pCity->GetCityBuildings()->GetGreatWorksTourismModifier() + +GET_PLAYER(m_pCity->getOwner()).GetGreatWorksTourismModifierGlobal()) * iGWTourism / 100); szRtnValue = GetLocalizedText("TXT_KEY_CO_CITY_TOURISM_GREAT_WORKS", iGWTourism, m_pCity->GetCityCulture()->GetNumGreatWorks()); -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) int iThemingBonuses = m_pCity->GetCityBuildings()->GetCurrentThemingBonuses(YIELD_CULTURE); -#else - int iThemingBonuses = m_pCity->GetCityBuildings()->GetCurrentThemingBonuses(); -#endif if (iThemingBonuses != 0) { szRtnValue += "[NEWLINE][NEWLINE]"; szRtnValue += GetLocalizedText("TXT_KEY_CO_CITY_TOURISM_THEMING_BONUSES", iThemingBonuses); } -#if defined(MOD_BALANCE_CORE) + int iTraitBonuses = m_pCity->GetYieldPerTurnFromTraits(YIELD_TOURISM); if (iTraitBonuses != 0) { szRtnValue += "[NEWLINE][NEWLINE]"; szRtnValue += GetLocalizedText("TXT_KEY_CO_CITY_TOURISM_TRAIT_BONUSES", iTraitBonuses); } -#endif // Landmarks, Wonders, Natural Wonders, Improvements int iTileTourism = 0; @@ -7586,11 +7236,7 @@ int CvCityCulture::GetCultureFromNaturalWonders() const for (size_t ui=0; uigetFeatureType() != NO_FEATURE && GC.getFeatureInfo(pLoopPlot->getFeatureType())->IsNaturalWonder(true)) -#else - if(pLoopPlot->getFeatureType() != NO_FEATURE && GC.getFeatureInfo(pLoopPlot->getFeatureType())->IsNaturalWonder()) -#endif + if (pLoopPlot->getFeatureType() != NO_FEATURE && GC.getFeatureInfo(pLoopPlot->getFeatureType())->IsNaturalWonder(true)) { iRtnValue += pLoopPlot->getYield(YIELD_CULTURE); } diff --git a/CvGameCoreDLL_Expansion2/CvCultureClasses.h b/CvGameCoreDLL_Expansion2/CvCultureClasses.h index 8c09684b5d..e08c736110 100644 --- a/CvGameCoreDLL_Expansion2/CvCultureClasses.h +++ b/CvGameCoreDLL_Expansion2/CvCultureClasses.h @@ -195,37 +195,30 @@ class CvPlayerCulture int GetNumGreatWorks() const; int GetNumGreatWorkSlots() const; int GetNumGreatWorkSlots(GreatWorkSlotType eSlotType) const; - bool ControlsGreatWork (int iIndex); + bool ControlsGreatWork(int iIndex); bool GetGreatWorkLocation(int iSearchIndex, int &iReturnCityID, BuildingTypes &eReturnBuilding, int &iReturnSlot); #if defined(MOD_BALANCE_CORE) void DoSwapGreatWorksHuman(bool bSwap); #endif -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) + void DoSwapGreatWorks(YieldTypes eFocusYield); - void MoveWorks (GreatWorkSlotType eType, vector &buildings, vector &works1, vector &works2, YieldTypes eFocusYield, bool bSwap); -#else - void DoSwapGreatWorks(); - void MoveWorks (GreatWorkSlotType eType, vector &buildings, vector &works1, vector &works2); -#endif + void MoveWorks(GreatWorkSlotType eType, vector &buildings, vector &works1, vector &works2, YieldTypes eFocusYield, bool bSwap); bool ThemeBuilding(vector::const_iterator it, vector &works1, vector &works2, bool bConsiderOtherPlayers); bool ThemeEqualArtArtifact(CvGreatWorkBuildingInMyEmpire kBldg, int iThemingBonusIndex, int iNumSlots, vector &works1, vector &works2, bool bConsiderOtherPlayers, int iThemeID = -1); #if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) bool MoveSingleWorks(vector &buildings, vector &works1, vector &works2, YieldTypes eFocusYield, bool bPuppet); #endif bool FillBuilding(vector::const_iterator it, vector &works1, vector &works2); -#if defined(MOD_BALANCE_CORE) bool MoveWorkIntoSlot (CvGreatWorkInMyEmpire kWork, int iCityID, BuildingTypes eBuilding, int iSlot); -#else - void MoveWorkIntoSlot (CvGreatWorkInMyEmpire kWork, int iCityID, BuildingTypes eBuilding, int iSlot); -#endif + int GetSwappableWritingIndex() const; int GetSwappableArtIndex() const; int GetSwappableArtifactIndex() const; int GetSwappableMusicIndex() const; - void SetSwappableWritingIndex (int iIndex); - void SetSwappableArtIndex (int iIndex); - void SetSwappableArtifactIndex (int iIndex); - void SetSwappableMusicIndex (int iIndex); + void SetSwappableWritingIndex(int iIndex); + void SetSwappableArtIndex(int iIndex); + void SetSwappableArtifactIndex(int iIndex); + void SetSwappableMusicIndex(int iIndex); // Archaeology void AddDigCompletePlot(CvPlot* pPlot); @@ -236,8 +229,8 @@ class CvPlayerCulture bool HasDigCompleteHere(CvPlot* pPlot) const; int GetWrittenArtifactCulture() const; - void DoArchaeologyChoice (ArchaeologyChoiceType eChoice); - // AI support routine - move elsewhere later? + void DoArchaeologyChoice(ArchaeologyChoiceType eChoice); + // AI support routine - move elsewhere later? ArchaeologyChoiceType GetArchaeologyChoice(CvPlot *pPlot); // Cultural Influence @@ -378,11 +371,7 @@ class CvCityCulture void Init(CvCity* m_pCity); -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) int GetNumGreatWorks(bool bIgnoreYield = true) const; -#else - int GetNumGreatWorks() const; -#endif int GetNumGreatWorkSlots() const; int GetNumAvailableGreatWorkSlots(GreatWorkSlotType eSlotType) const; int GetNumFilledGreatWorkSlots(GreatWorkSlotType eSlotType) const; diff --git a/CvGameCoreDLL_Expansion2/CvDangerPlots.cpp b/CvGameCoreDLL_Expansion2/CvDangerPlots.cpp index 804fc5eef8..bf0ef23dcf 100644 --- a/CvGameCoreDLL_Expansion2/CvDangerPlots.cpp +++ b/CvGameCoreDLL_Expansion2/CvDangerPlots.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -76,11 +76,12 @@ bool CvDangerPlots::UpdateDangerSingleUnit(const CvUnit* pLoopUnit, bool bIgnore //the IGNORE_DANGER flag is extremely important here, otherwise we can get into endless loops //(when the pathfinder does a lazy danger update) -#ifdef MOD_CORE_TWO_PASS_DANGER - int iFlags = CvUnit::MOVEFLAG_IGNORE_STACKING_SELF | CvUnit::MOVEFLAG_IGNORE_STACKING_NEUTRAL | CvUnit::MOVEFLAG_IGNORE_ENEMIES | CvUnit::MOVEFLAG_IGNORE_DANGER | CvUnit::MOVEFLAG_SELECTIVE_ZOC; -#else - int iFlags = CvUnit::MOVEFLAG_IGNORE_STACKING_SELF | CvUnit::MOVEFLAG_IGNORE_STACKING_NEUTRAL | CvUnit::MOVEFLAG_IGNORE_ENEMIES | CvUnit::MOVEFLAG_IGNORE_DANGER | CvUnit::MOVEFLAG_IGNORE_ZOC; -#endif + int iFlags = CvUnit::MOVEFLAG_IGNORE_STACKING_SELF | CvUnit::MOVEFLAG_IGNORE_STACKING_NEUTRAL | CvUnit::MOVEFLAG_IGNORE_ENEMIES | CvUnit::MOVEFLAG_IGNORE_DANGER; + if (MOD_CORE_TWO_PASS_DANGER) + iFlags |= CvUnit::MOVEFLAG_SELECTIVE_ZOC; + else + iFlags |= CvUnit::MOVEFLAG_IGNORE_ZOC; + ReachablePlots reachablePlots = TacticalAIHelpers::GetAllPlotsInReachThisTurn(pLoopUnit,pLoopUnit->plot(),iFlags,0,pLoopUnit->maxMoves(),plotsToIgnoreForZOC); if (pLoopUnit->IsCanAttackRanged()) @@ -127,28 +128,31 @@ void CvDangerPlots::UpdateDanger(bool bKeepKnownUnits) return; //two pass danger is dangerous ... it might happen that a covering unit moves away, leaving other exposed -#ifdef MOD_CORE_TWO_PASS_DANGER - CvPlayer& thisPlayer = GET_PLAYER(m_ePlayer); - PlotIndexContainer plotsWithOwnedUnitsLikelyToBeKilled; + if (MOD_CORE_TWO_PASS_DANGER) + { + CvPlayer& thisPlayer = GET_PLAYER(m_ePlayer); + PlotIndexContainer plotsWithOwnedUnitsLikelyToBeKilled; + + //first pass + UpdateDangerInternal(true, plotsWithOwnedUnitsLikelyToBeKilled); - //first pass - UpdateDangerInternal(true, plotsWithOwnedUnitsLikelyToBeKilled); + //find out which units might die and therefore won't have a ZOC + int iLoop; + for (CvUnit* pLoopUnit = thisPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = thisPlayer.nextUnit(&iLoop)) + { + if (pLoopUnit->IsCombatUnit() && pLoopUnit->GetDanger() > pLoopUnit->GetCurrHitPoints()) + plotsWithOwnedUnitsLikelyToBeKilled.push_back(pLoopUnit->plot()->GetPlotIndex()); + } - //find out which units might die and therefore won't have a ZOC - int iLoop; - for (CvUnit* pLoopUnit = thisPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = thisPlayer.nextUnit(&iLoop)) + //second pass + if (!plotsWithOwnedUnitsLikelyToBeKilled.empty() || !bKeepKnownUnits) + UpdateDangerInternal(bKeepKnownUnits, plotsWithOwnedUnitsLikelyToBeKilled); + } + else { - if (pLoopUnit->IsCombatUnit() && pLoopUnit->GetDanger() > pLoopUnit->GetCurrHitPoints()) - plotsWithOwnedUnitsLikelyToBeKilled.push_back(pLoopUnit->plot()->GetPlotIndex()); + PlotIndexContainer dummy; + UpdateDangerInternal(bKeepKnownUnits, dummy); } - - //second pass - if (!plotsWithOwnedUnitsLikelyToBeKilled.empty() || !bKeepKnownUnits) - UpdateDangerInternal(bKeepKnownUnits, plotsWithOwnedUnitsLikelyToBeKilled); -#else - PlotIndexContainer dummy; - UpdateDangerInternal(bKeepKnownUnits, dummy); -#endif } //fog of war is dangerous, but we don't know whether we will take the damage or not ... @@ -241,12 +245,8 @@ void CvDangerPlots::UpdateDangerInternal(bool bKeepKnownUnits, const PlotIndexCo if(ShouldIgnoreCity(pLoopCity, false)) continue; -#if defined(MOD_EVENTS_CITY_BOMBARD) bool bIndirectFireAllowed = false; //this is an OUT parameter ... int iRange = pLoopCity->getBombardRange(bIndirectFireAllowed); -#else - int iRange = /*2*/ GD_INT_GET(CITY_ATTACK_RANGE); -#endif CvPlot* pCityPlot = pLoopCity->plot(); CvPlot* pLoopPlot = NULL; for(int iDX = -(iRange); iDX <= iRange; iDX++) diff --git a/CvGameCoreDLL_Expansion2/CvDealAI.cpp b/CvGameCoreDLL_Expansion2/CvDealAI.cpp index e55b6c74b8..b9b6400faf 100644 --- a/CvGameCoreDLL_Expansion2/CvDealAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvDealAI.cpp @@ -312,7 +312,6 @@ DealOfferResponseTypes CvDealAI::DoHumanOfferDealToThisAI(CvDeal* pDeal) /// Deal has been accepted void CvDealAI::DoAcceptedDeal(PlayerTypes eFromPlayer, const CvDeal& kDeal, int iDealValueToMe, int iValueImOffering, int iValueTheyreOffering) { -#if defined(MOD_ACTIVE_DIPLOMACY) if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(kDeal, true); @@ -322,10 +321,6 @@ void CvDealAI::DoAcceptedDeal(PlayerTypes eFromPlayer, const CvDeal& kDeal, int GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(eFromPlayer, GetPlayer()->GetID(), true); } -#else - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(eFromPlayer, GetPlayer()->GetID(), true); -#endif if (GET_PLAYER(eFromPlayer).isHuman()) { @@ -600,8 +595,8 @@ void CvDealAI::DoAcceptedDemand(PlayerTypes eFromPlayer, const CvDeal& kDeal) CvGameDeals& kGameDeals = kGame.GetGameDeals(); const PlayerTypes eActivePlayer = kGame.getActivePlayer(); const PlayerTypes ePlayer = GetPlayer()->GetID(); -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { kGameDeals.FinalizeMPDeal(kDeal, true); } @@ -610,10 +605,7 @@ void CvDealAI::DoAcceptedDemand(PlayerTypes eFromPlayer, const CvDeal& kDeal) kGameDeals.AddProposedDeal(kDeal); kGameDeals.FinalizeDeal(eFromPlayer, ePlayer, true); } -#else - kGameDeals.AddProposedDeal(kDeal); - kGameDeals.FinalizeDeal(eFromPlayer, ePlayer, true); -#endif + if(eActivePlayer == eFromPlayer || eActivePlayer == ePlayer) { GC.GetEngineUserInterface()->makeInterfaceDirty(); @@ -1918,10 +1910,6 @@ vector CvDealAI::GetStrategicResourceItemList(ResourceTypes eResource, int for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo == NULL) - continue; - const UnitTypes eUnit = pPlayer->GetSpecificUnitType(eUnitClass); if (eUnit == NO_UNIT) continue; @@ -2901,77 +2889,64 @@ int CvDealAI::GetThirdPartyPeaceValue(bool bFromMe, PlayerTypes eOtherPlayer, Te /// What is the value of war with eWithPlayer? int CvDealAI::GetThirdPartyWarValue(bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam, bool /*bLogging*/) { - PlayerTypes ePlayerDeclaringWar = bFromMe ? m_pPlayer->GetID() : eOtherPlayer; - TeamTypes eTeamDeclaringWar = GET_PLAYER(ePlayerDeclaringWar).getTeam(); + PlayerTypes ePlayerDeclaringWar = bFromMe ? GetPlayer()->GetID() : eOtherPlayer; + CvPlayer& kPlayerDeclaringWar = GET_PLAYER(ePlayerDeclaringWar); + TeamTypes eTeamDeclaringWar = kPlayerDeclaringWar.getTeam(); PlayerTypes eWithPlayer = GET_TEAM(eWithTeam).getLeaderID(); - CvCity* pCapital = GET_PLAYER(ePlayerDeclaringWar).getCapitalCity(); + CvCity* pCapital = kPlayerDeclaringWar.getCapitalCity(); if (!pCapital) - { return INT_MAX; - } + // No deals if there is a denouncement in either direction CvDiplomacyAI* pOurDiploAI = GetPlayer()->GetDiplomacyAI(); CivApproachTypes eApproachTowardsAskingPlayer = pOurDiploAI->GetCivApproach(eOtherPlayer); if (pOurDiploAI->IsDenouncedPlayer(eOtherPlayer) || pOurDiploAI->IsDenouncedByPlayer(eOtherPlayer)) - { return INT_MAX; - } + // No war deals with backstabbers - it's a trap! if (pOurDiploAI->IsUntrustworthy(eOtherPlayer)) - { return INT_MAX; - } - //Minor Civ? - if(GET_PLAYER(eWithPlayer).isMinorCiv()) + // Minor Civ? + CvDiplomacyAI* pDiploAI = kPlayerDeclaringWar.GetDiplomacyAI(); + if (GET_PLAYER(eWithPlayer).isMinorCiv()) { - CivApproachTypes eMinorApproachTowardsWarPlayer = GET_PLAYER(ePlayerDeclaringWar).GetDiplomacyAI()->GetCivApproach(eWithPlayer); + CivApproachTypes eMinorApproachTowardsWarPlayer = pDiploAI->GetCivApproach(eWithPlayer); if (eMinorApproachTowardsWarPlayer == CIV_APPROACH_FRIENDLY) return INT_MAX; } + // If we're in bad shape to start a war, no wars - if (GET_PLAYER(ePlayerDeclaringWar).IsNoNewWars()) - { + if (kPlayerDeclaringWar.IsNoNewWars()) return INT_MAX; - } + // Don't get distracted by bribed wars when we're close to winning - if (GET_PLAYER(ePlayerDeclaringWar).GetDiplomacyAI()->IsCloseToAnyVictoryCondition()) - { + if (pDiploAI->IsCloseToAnyVictoryCondition()) return INT_MAX; - } //do we even have a target to attack? - if (!GET_PLAYER(ePlayerDeclaringWar).GetMilitaryAI()->HavePreferredAttackTarget(eWithPlayer)) - { + if (!kPlayerDeclaringWar.GetMilitaryAI()->HavePreferredAttackTarget(eWithPlayer)) return INT_MAX; - } + //don't get into additional wars if we cannot afford it - if (GET_PLAYER(ePlayerDeclaringWar).IsAtWarAnyMajor() && GET_PLAYER(ePlayerDeclaringWar).GetDiplomacyAI()->GetStateAllWars() != STATE_ALL_WARS_WINNING) - { + if (kPlayerDeclaringWar.IsAtWarAnyMajor() && pDiploAI->GetStateAllWars() != STATE_ALL_WARS_WINNING) return INT_MAX; - } // Player must be a potential war target - CvDiplomacyAI* pDiploAI = GET_PLAYER(ePlayerDeclaringWar).GetDiplomacyAI(); if (GET_PLAYER(eWithPlayer).isMajorCiv() && !pDiploAI->IsPotentialWarTarget(eWithPlayer)) - { return INT_MAX; - } + // Would this war cause us or our teammates to backstab a friend/ally? Don't do it! if (!pDiploAI->IsWarSane(eWithPlayer)) - { return INT_MAX; - } - // already planning a coop war against the target? then we aren't interested! (reduce the chance of a premature declaration...) + + // Already planning a coop war against the target? then we aren't interested! (reduce the chance of a premature declaration...) if (pDiploAI->GetGlobalCoopWarAgainstState(eWithPlayer) >= COOP_WAR_STATE_PREPARING) - { return INT_MAX; - } - // can't be too far away - if (GET_PLAYER(ePlayerDeclaringWar).GetProximityToPlayer(eWithPlayer) < PLAYER_PROXIMITY_CLOSE) - { + + // Can't be too far away + if (kPlayerDeclaringWar.GetProximityToPlayer(eWithPlayer) < PLAYER_PROXIMITY_CLOSE) return INT_MAX; - } // Don't accept war bribes if we recently made peace. if (pDiploAI->GetNumWarsFought(eWithPlayer) > 0) @@ -2980,31 +2955,30 @@ int CvDealAI::GetThirdPartyWarValue(bool bFromMe, PlayerTypes eOtherPlayer, Team if (iPeaceTreatyTurn > -1) { int iTurnsSincePeace = GC.getGame().getGameTurn() - iPeaceTreatyTurn; - int iPeaceDampenerTurns = 23 + GC.getGame().randRangeExclusive(0, 15, GET_PLAYER(ePlayerDeclaringWar).GetPseudoRandomSeed()); + int iPeaceDampenerTurns = 23 + GC.getGame().randRangeExclusive(0, 15, kPlayerDeclaringWar.GetPseudoRandomSeed()); if (iTurnsSincePeace < iPeaceDampenerTurns) - { return INT_MAX; - } } } // AI sanity check - who else would we go to war with? - if (!GET_PLAYER(ePlayerDeclaringWar).isHuman()) + if (!kPlayerDeclaringWar.isHuman()) { - vector vDefensiveWarAllies = pDiploAI->GetDefensiveWarAllies(eWithPlayer, /*bIncludeMinors*/ true, /*bReverseMode*/ true, /*bNewWarsOnly*/ true); - for (std::vector::iterator it = vDefensiveWarAllies.begin(); it != vDefensiveWarAllies.end(); it++) + CivsList vDefensiveWarAllies = pDiploAI->GetDefensiveWarAllies(eWithPlayer, /*bIncludeMinors*/ true, /*bReverseMode*/ true, /*bNewWarsOnly*/ true); + for (CivsList::iterator it = vDefensiveWarAllies.begin(); it != vDefensiveWarAllies.end(); ++it) { // Would we be declaring war on a powerful neighbor? - if (GET_PLAYER(*it).GetProximityToPlayer(ePlayerDeclaringWar) >= PLAYER_PROXIMITY_CLOSE) + CvPlayer& kDefensiveWarAlly = GET_PLAYER(*it); + if (kDefensiveWarAlly.GetProximityToPlayer(ePlayerDeclaringWar) >= PLAYER_PROXIMITY_CLOSE) { - if (GET_PLAYER(*it).isMajorCiv()) + if (kDefensiveWarAlly.isMajorCiv()) { if (pDiploAI->GetCivApproach(*it) == CIV_APPROACH_AFRAID) { return INT_MAX; } // If we're already planning a war/demand against them, then we don't care. - else if (pDiploAI->GetCivApproach(*it) != CIV_APPROACH_WAR && pDiploAI->GetDemandTargetPlayer() != GET_PLAYER(*it).GetID()) + else if (pDiploAI->GetCivApproach(*it) != CIV_APPROACH_WAR && pDiploAI->GetDemandTargetPlayer() != *it) { if (pDiploAI->GetMilitaryStrengthComparedToUs(*it) > STRENGTH_AVERAGE) { @@ -3016,29 +2990,26 @@ int CvDealAI::GetThirdPartyWarValue(bool bFromMe, PlayerTypes eOtherPlayer, Team if (!pDiploAI->IsWarSane(*it)) return INT_MAX; } - else + else if (pDiploAI->GetCivApproach(*it) > CIV_APPROACH_HOSTILE) { - if (pDiploAI->GetCivApproach(*it) > CIV_APPROACH_HOSTILE) + if (pDiploAI->GetMilitaryStrengthComparedToUs(*it) > STRENGTH_AVERAGE) { - if (pDiploAI->GetMilitaryStrengthComparedToUs(*it) > STRENGTH_AVERAGE) - { - return INT_MAX; - } + return INT_MAX; } } } } } - //what does a basic unit cost these days, use that as a base - UnitTypes eUnit = GC.getGame().GetCompetitiveSpawnUnitType(ePlayerDeclaringWar, true, true, false, false, true, false); + // What does a basic unit cost these days, use that as a base + UnitTypes eUnit = kPlayerDeclaringWar.GetCompetitiveSpawnUnitType(true, true, true, true); int iItemValue = pCapital->GetPurchaseCost(eUnit); // Scale with WarmongerHate flavor // Rationale: If the AI hates warmongers, they'll require more in order to go to war, and they'll also pay more to have others wage their battles iItemValue *= bFromMe ? GetPlayer()->GetDiplomacyAI()->GetWarmongerHate() : GetPlayer()->GetDiplomacyAI()->GetWarmongerHate() / 2; - if (!GET_PLAYER(ePlayerDeclaringWar).isHuman()) + if (!kPlayerDeclaringWar.isHuman()) { if (pDiploAI->GetBiggestCompetitor() == eWithPlayer) { diff --git a/CvGameCoreDLL_Expansion2/CvDealClasses.cpp b/CvGameCoreDLL_Expansion2/CvDealClasses.cpp index f443371bb5..b007857fbd 100644 --- a/CvGameCoreDLL_Expansion2/CvDealClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvDealClasses.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -5266,37 +5266,15 @@ void CvGameDeals::DoTurnPost() DoUpdateCurrentDealsList(); } - PlayerTypes CvGameDeals::HasMadeProposal(PlayerTypes ePlayer) { -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if (!m_ProposedDeals.empty() || (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY)) { for (DealList::const_iterator it = m_ProposedDeals.begin(); it != m_ProposedDeals.end(); ++it) - { - if (it->GetFromPlayer() == ePlayer) - return it->GetToPlayer(); - } - } - else - { - if(!m_ProposedDeals.empty()) - { - DealList::iterator iter; - for(iter = m_ProposedDeals.begin(); iter != m_ProposedDeals.end(); ++iter) - if(iter->m_eFromPlayer == ePlayer) - return iter->m_eToPlayer; - } - } -#else - if(m_ProposedDeals.size() > 0) - { - DealList::iterator iter; - for(iter = m_ProposedDeals.begin(); iter != m_ProposedDeals.end(); ++iter) - if(iter->m_eFromPlayer == ePlayer) - return iter->m_eToPlayer; + if (it->GetFromPlayer() == ePlayer) + return it->GetToPlayer(); } -#endif + return NO_PLAYER; } @@ -5315,7 +5293,6 @@ bool CvGameDeals::ProposedDealExists(PlayerTypes eFromPlayer, PlayerTypes eToPla return false; } -#if defined(MOD_ACTIVE_DIPLOMACY) CvDeal* CvGameDeals::GetProposedMPDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, bool latest) { int start = latest ? m_ProposedDeals.size() - 1 : 0; @@ -5331,7 +5308,7 @@ CvDeal* CvGameDeals::GetProposedMPDeal(PlayerTypes eFromPlayer, PlayerTypes eToP } return NULL; } -#endif + CvDeal* CvGameDeals::GetProposedDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer) { if(!m_ProposedDeals.empty()) @@ -6307,7 +6284,6 @@ CvDeal* CvGameDeals::GetCurrentDeal(PlayerTypes ePlayer, uint index) // ------------------------------------------------------------------------ CvDeal* CvGameDeals::GetHistoricDeal(PlayerTypes ePlayer, uint index) { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { //iterate backwards, usually the latest deals are most interesting @@ -6337,21 +6313,7 @@ CvDeal* CvGameDeals::GetHistoricDeal(PlayerTypes ePlayer, uint index) } } } -#else - DealList::iterator iter; - DealList::iterator end = m_HistoricalDeals.end(); - uint iCount = 0; - for(iter = m_HistoricalDeals.begin(); iter != end; ++iter) - { - if((iter->m_eToPlayer == ePlayer || - iter->m_eFromPlayer == ePlayer) && - (iCount++ == index)) - { - return &(*iter); - } - } -#endif return NULL; } @@ -6426,29 +6388,23 @@ CvDeal* CvGameDeals::GetCurrentDealWithPlayer(PlayerTypes ePlayer, PlayerTypes e // ------------------------------------------------------------------------ CvDeal* CvGameDeals::GetHistoricDealWithPlayer(PlayerTypes ePlayer, PlayerTypes eOtherPlayer, uint index) { -#if defined(MOD_ACTIVE_DIPLOMACY) + uint iCount = 0; if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { - //iterate backwards, usually the latest deals are most interesting - uint iCount = 0; - for (int i = m_HistoricalDeals.size() - 1; i >= 0; --i) + // Iterate backwards, usually the latest deals are most interesting + for (DealList::reverse_iterator riter = m_HistoricalDeals.rbegin(); riter != m_HistoricalDeals.rend(); ++riter) { - CvDeal& kDeal = m_HistoricalDeals[i]; - if ((kDeal.m_eToPlayer == ePlayer || kDeal.m_eFromPlayer == ePlayer) && - (kDeal.m_eToPlayer == eOtherPlayer || kDeal.m_eFromPlayer == eOtherPlayer) && + if ((riter->m_eToPlayer == ePlayer || riter->m_eFromPlayer == ePlayer) && + (riter->m_eToPlayer == eOtherPlayer || riter->m_eFromPlayer == eOtherPlayer) && (iCount++ == index)) { - return &kDeal; + return &(*riter); } } } else { - DealList::iterator iter; - DealList::iterator end = m_HistoricalDeals.end(); - - uint iCount = 0; - for (iter = m_HistoricalDeals.begin(); iter != end; ++iter) + for (DealList::iterator iter = m_HistoricalDeals.begin(); iter != m_HistoricalDeals.end(); ++iter) { if ((iter->m_eToPlayer == ePlayer || iter->m_eFromPlayer == ePlayer) && (iter->m_eToPlayer == eOtherPlayer || iter->m_eFromPlayer == eOtherPlayer) && @@ -6458,21 +6414,7 @@ CvDeal* CvGameDeals::GetHistoricDealWithPlayer(PlayerTypes ePlayer, PlayerTypes } } } -#else - DealList::iterator iter; - DealList::iterator end = m_HistoricalDeals.end(); - uint iCount = 0; - for (iter = m_HistoricalDeals.begin(); iter != end; ++iter) - { - if ((iter->m_eToPlayer == ePlayer || - iter->m_eFromPlayer == ePlayer) && - (iCount++ == index)) - { - return &(*iter); - } - } -#endif return NULL; } diff --git a/CvGameCoreDLL_Expansion2/CvDealClasses.h b/CvGameCoreDLL_Expansion2/CvDealClasses.h index 977a7ebd47..f2c6cff766 100644 --- a/CvGameCoreDLL_Expansion2/CvDealClasses.h +++ b/CvGameCoreDLL_Expansion2/CvDealClasses.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -82,7 +82,7 @@ typedef vector TradedItemList; //! - Also stores the players involved and the turn the deal ends (if any) //! - Populated through calls to a group of methods that each create and add a CvTradedItem //! - These methods to create CvTradedItems have customized parameters so the external caller -//! doesn’t need to know how the data is stored internally +//! doesn�t need to know how the data is stored internally //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ class CvDeal { @@ -298,14 +298,14 @@ class CvGameDeals static void Serialize(GameDeals& gameDeals, Visitor& visitor); void AddProposedDeal(const CvDeal& kDeal); -#if defined(MOD_ACTIVE_DIPLOMACY) bool RemoveProposedDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, CvDeal* pDealOut, bool latest); + bool FinalizeMPDeal(CvDeal kDeal, bool bAccepted); bool FinalizeMPDealLatest(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, bool bAccepted, bool latest); void FinalizeDealValidAndAccepted(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, CvDeal& kDeal, bool bAccepted, CvWeightedVector& veNowAtPeacePairs); CvDeal* GetProposedMPDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, bool latest = false); void DoCancelAllProposedMPDealsWithPlayer(PlayerTypes eCancelPlayer, DiplomacyMode eTargetPlayers); -#endif + bool FinalizeDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, bool bAccepted); void ActivateDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, CvDeal& kDeal, CvWeightedVector& veNowAtPeacePairs); void DoTurn(); diff --git a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp index fd7fa1e1a8..9c47b2c17f 100644 --- a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp @@ -7610,7 +7610,6 @@ void CvDiplomacyAI::ChangeNumCiviliansReturnedToMe(PlayerTypes ePlayer, int iCha { if (!GC.getGame().IsComplimentMessagesDisabled() && !GC.getGame().IsAllDiploStatementsDisabled()) { -#if defined(MOD_ACTIVE_DIPLOMACY) if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { const char* strText = GetDiploStringForMessage(DIPLO_MESSAGE_RETURNED_CIVILIAN); @@ -7623,23 +7622,12 @@ void CvDiplomacyAI::ChangeNumCiviliansReturnedToMe(PlayerTypes ePlayer, int iCha { if (GC.getGame().getActivePlayer() == ePlayer) { - GC.GetEngineUserInterface()->SetForceDiscussionModeQuitOnBack(true); // Set force quit so that when discuss mode pops up the Back button won't go to leader root + GC.GetEngineUserInterface()->SetForceDiscussionModeQuitOnBack(true); // Set force quit so that when discuss mode pops up the Back button won't go to leader root const char* strText = GetDiploStringForMessage(DIPLO_MESSAGE_RETURNED_CIVILIAN); gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_BLANK_DISCUSSION, strText, LEADERHEAD_ANIM_POSITIVE); } } } -#else - if (!GC.getGame().isNetworkMultiPlayer()) // KWG: Candidate for !GC.getGame().IsOption(GAMEOPTION_SIMULTANEOUS_TURNS) - { - if (GC.getGame().getActivePlayer() == ePlayer) - { - GC.GetEngineUserInterface()->SetForceDiscussionModeQuitOnBack(true); // Set force quit so that when discuss mode pops up the Back button won't go to leader root - const char* strText = GetDiploStringForMessage(DIPLO_MESSAGE_RETURNED_CIVILIAN); - gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_BLANK_DISCUSSION, strText, LEADERHEAD_ANIM_POSITIVE); - } - } -#endif } } } @@ -9373,18 +9361,15 @@ void CvDiplomacyAI::DoTurn(DiplomacyMode eDiploMode, PlayerTypes ePlayer) MakeWar(); DoContactMinorCivs(); DoContactMajorCivs(); -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().DoCancelAllProposedMPDealsWithPlayer(GetID(), DIPLO_AI_PLAYERS); } else { - GC.getGame().GetGameDeals().DoCancelAllProposedDealsWithPlayer(GetID()); //Proposed deals with AI players are purely transitional. + GC.getGame().GetGameDeals().DoCancelAllProposedDealsWithPlayer(GetID()); // Proposed deals with AI players are purely transitional. } -#else - GC.getGame().GetGameDeals().DoCancelAllProposedDealsWithPlayer(GetID()); //Proposed deals with AI players are purely transitional. -#endif } // Update Counters @@ -27790,8 +27775,7 @@ void CvDiplomacyAI::MakeWar() for (int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++) { PlayerTypes eTarget = (PlayerTypes)iPlayerLoop; -#if defined(MOD_ACTIVE_DIPLOMACY) - if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if (IsValidUIDiplomacyTarget(eTarget) || (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY)) { if (IsPlayerValid(eTarget)) { @@ -27804,24 +27788,6 @@ void CvDiplomacyAI::MakeWar() playerList.push_back(eTarget, iWeight); } } - else - { - if (IsValidUIDiplomacyTarget(eTarget) && IsPlayerValid(eTarget)) -#else - if (IsValidUIDiplomacyTarget(eTarget) && IsPlayerValid(eTarget)) -#endif - { - int iWeight = GET_PLAYER(eTarget).isMajorCiv() ? GetPlayerStrategicApproachValue(eTarget, CIV_APPROACH_WAR) : (int)GetTargetValue(eTarget) + 1; - - // Square the distance enum to make it crucial - iWeight *= (1 + (int)GetPlayer()->GetProximityToPlayer(eTarget)); - iWeight *= (1 + (int)GetPlayer()->GetProximityToPlayer(eTarget)); - - playerList.push_back(eTarget, iWeight); - } -#if defined(MOD_ACTIVE_DIPLOMACY) - } -#endif } playerList.StableSortItems(); @@ -27985,7 +27951,6 @@ bool CvDiplomacyAI::DeclareWar(PlayerTypes ePlayer) // Show scene to human if (!GC.getGame().IsAllDiploStatementsDisabled()) { -#if defined(MOD_ACTIVE_DIPLOMACY) if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { // JdH: deciding whether to send a notification or pop up directy is done in SendRequest @@ -28003,13 +27968,6 @@ bool CvDiplomacyAI::DeclareWar(PlayerTypes ePlayer) gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_AI_DECLARED_WAR, strText, LEADERHEAD_ANIM_DECLARE_WAR); } } -#else - if (!CvPreGame::isNetworkMultiplayerGame() && GC.getGame().getActivePlayer() == ePlayer) - { - const char* strText = GetDiploStringForMessage(DIPLO_MESSAGE_DOW_ROOT, ePlayer); - gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_AI_DECLARED_WAR, strText, LEADERHEAD_ANIM_DECLARE_WAR); - } -#endif } LogWarDeclaration(ePlayer); @@ -29753,7 +29711,6 @@ void CvDiplomacyAI::DoFirstContact(PlayerTypes ePlayer) DoFirstContactInitRelationship(ePlayer); // Humans don't say hi to one another through the shadow diplo AI and, uh, don't show up in MP please -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { // JdH: notifications do get send in MP + updated to new @@ -29768,7 +29725,7 @@ void CvDiplomacyAI::DoFirstContact(PlayerTypes ePlayer) } else { - if(!GC.getGame().isNetworkMultiPlayer()) // KWG: Candidate for !GC.getGame().IsOption(GAMEOPTION_SIMULTANEOUS_TURNS) + if(!GC.getGame().isNetworkMultiPlayer()) // KWG: Candidate for !GC.getGame().IsOption(GAMEOPTION_SIMULTANEOUS_TURNS) { if(!GetPlayer()->isHuman()) { @@ -29811,51 +29768,7 @@ void CvDiplomacyAI::DoFirstContact(PlayerTypes ePlayer) } } -#else - if(!GC.getGame().isNetworkMultiPlayer()) // KWG: Candidate for !GC.getGame().IsOption(GAMEOPTION_SIMULTANEOUS_TURNS) - { - if(!GetPlayer()->isHuman()) - { - // Should fire off a diplo message when we meet a human - if(GET_PLAYER(ePlayer).isHuman()) - { - if(!IsAtWar(ePlayer)) - { - if(GC.getGame().isFinalInitialized()) - { - if(std::find(m_aGreetPlayers.begin(), m_aGreetPlayers.end(), ePlayer) == m_aGreetPlayers.end()) - { - // Put in the list of people to greet when their turn comes up. - m_aGreetPlayers.push_back(ePlayer); - } - } - } - } - } - else - { - // Human to Human will just send a notification - CvPlayer& kTargetPlayer = GET_PLAYER(ePlayer); - if(kTargetPlayer.isHuman()) - { - if(!IsAtWar(ePlayer)) - { - if(GC.getGame().isFinalInitialized()) - { - CvNotifications* pNotifications = kTargetPlayer.GetNotifications(); - if(pNotifications) - { - CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_SUMMARY_MET_MINOR_CIV", GetPlayer()->getNameKey()); - pNotifications->Add(NOTIFICATION_GENERIC, strBuffer, strBuffer, -1, -1, GetID()); - } - } - } - } - } - } -#endif // Catch up on public declarations this player has made - if(!GET_PLAYER(ePlayer).isMinorCiv()) { PublicDeclarationTypes eDeclaration; @@ -29939,7 +29852,6 @@ void CvDiplomacyAI::DoFirstContactInitRelationship(PlayerTypes ePlayer) /// Player killed us void CvDiplomacyAI::DoKilledByPlayer(PlayerTypes ePlayer) { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { if(ePlayer != NO_PLAYER && CvPreGame::isHuman(ePlayer)) @@ -29955,12 +29867,6 @@ void CvDiplomacyAI::DoKilledByPlayer(PlayerTypes ePlayer) const char* szText = GetDiploStringForMessage(DIPLO_MESSAGE_DEFEATED); gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_BLANK_DISCUSSION, szText, LEADERHEAD_ANIM_DEFEATED); } -#else - if(ePlayer == GC.getGame().getActivePlayer() && !GC.getGame().isNetworkMultiPlayer()) - { - const char* szText = GetDiploStringForMessage(DIPLO_MESSAGE_DEFEATED); - gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_BLANK_DISCUSSION, szText, LEADERHEAD_ANIM_DEFEATED); -#endif if (MOD_API_ACHIEVEMENTS && !GC.getGame().isGameMultiPlayer()) { @@ -30215,7 +30121,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT SetSentAttackProtectedMinorTaunt(ePlayer, eMinorCiv, true); } } -#if defined(MOD_BALANCE_CORE) else { PlayerTypes eMinorCiv = (PlayerTypes) iData1; @@ -30254,7 +30159,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } } } -#endif } // We bullied a Minor someone has a PtP with @@ -30275,7 +30179,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT CvDiplomacyRequests::SendRequest(GetID(), ePlayer, DIPLO_UI_STATE_DISCUSS_I_BULLIED_YOUR_MINOR_CIV, szText, LEADERHEAD_ANIM_POSITIVE, eMinorCiv); } } -#if defined(MOD_BALANCE_CORE) else { PlayerTypes eMinorCiv = (PlayerTypes) iData1; @@ -30309,7 +30212,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } } } -#endif } // We'd like a defense pact @@ -30324,8 +30226,7 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); } @@ -30336,13 +30237,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // We'd like a 3rd party war @@ -30356,8 +30250,7 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); } @@ -30369,13 +30262,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // We'd like a peace trade @@ -30389,8 +30275,7 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); } @@ -30402,13 +30287,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // We'd like a vote trade @@ -30422,8 +30300,7 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); } @@ -30435,13 +30312,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -30456,7 +30326,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -30469,13 +30338,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // We'd like to exchange cities @@ -30489,7 +30351,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -30502,13 +30363,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -30709,7 +30563,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GET_PLAYER(ePlayer).GetDiplomacyAI()->LogDenounce(eTarget); // Denounced a human? -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { if(GET_PLAYER(eTarget).isHuman()) @@ -30721,16 +30574,11 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT else { if(eTarget == GC.getGame().getActivePlayer()) -#else - if(eTarget == GC.getGame().getActivePlayer()) -#endif { szText = GetDiploStringForMessage(DIPLO_MESSAGE_WORK_AGAINST_SOMEONE, eTarget); CvDiplomacyRequests::SendRequest(ePlayer, eTarget, DIPLO_UI_STATE_BLANK_DISCUSSION_MEAN_AI, szText, LEADERHEAD_ANIM_HATE_NEGATIVE); } -#if defined(MOD_ACTIVE_DIPLOMACY) } -#endif } else { @@ -30816,7 +30664,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Did they accept? if (eResponse == DEMAND_RESPONSE_ACCEPT) { -#if defined(MOD_ACTIVE_DIPLOMACY) if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -30828,11 +30675,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } // Demand rebuffed else @@ -30945,8 +30787,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT else { // For now the AI will always give in - may eventually write additional logic here - -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -30958,12 +30798,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -30979,7 +30813,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -30992,13 +30825,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -31012,7 +30838,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31025,13 +30850,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -31045,7 +30863,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31058,13 +30875,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -31080,7 +30890,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31093,13 +30902,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -31114,7 +30916,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31127,13 +30928,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -31148,7 +30942,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31161,13 +30954,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -31770,7 +31556,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31783,13 +31568,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } @@ -31879,7 +31657,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31892,13 +31669,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // We'd like to purchase a technology from this player @@ -31911,7 +31681,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31924,13 +31693,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // We're making a generous offer to this player @@ -31943,7 +31705,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -31956,13 +31717,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - // For now the AI will always accept - may eventually write additional logic here - CvDeal kDeal = *pDeal; - - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } //We want to declare independence from our master @@ -31998,7 +31752,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -32011,13 +31764,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // AI offers to make ePlayer his voluntary vassal @@ -32029,7 +31775,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -32042,13 +31787,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // AI offers to become voluntary vassal of ePlayer @@ -32061,7 +31799,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT } else { -#if defined(MOD_ACTIVE_DIPLOMACY) if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -32074,13 +31811,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif } } // AI is happy that they were liberated from vassalage @@ -32169,7 +31899,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT // Offer to an AI player else { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GC.getGame().GetGameDeals().FinalizeMPDeal(*pDeal, true); @@ -32182,13 +31911,6 @@ void CvDiplomacyAI::DoSendStatementToPlayer(PlayerTypes ePlayer, DiploStatementT GC.getGame().GetGameDeals().AddProposedDeal(kDeal); GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); } -#else - CvDeal kDeal = *pDeal; - - // Don't need to call DoOffer because we check to see if the deal works for both sides BEFORE sending - GC.getGame().GetGameDeals().AddProposedDeal(kDeal); - GC.getGame().GetGameDeals().FinalizeDeal(GetID(), ePlayer, true); -#endif LogPeaceMade(ePlayer); } @@ -32302,7 +32024,6 @@ void CvDiplomacyAI::DoContactMajorCivs() // handled at the end prevents the Diplo AI from having this problem // Loop through AI Players -#if defined(MOD_ACTIVE_DIPLOMACY) if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { if (m_eDiploMode == DIPLO_SPECIFIC_PLAYER) @@ -32413,39 +32134,6 @@ void CvDiplomacyAI::DoContactMajorCivs() } } } -#else - for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++) - { - PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop; - - if (!IsPlayerValid(eLoopPlayer)) - continue; - - // No humans - if (GET_PLAYER(eLoopPlayer).isHuman()) - continue; - - DoContactPlayer(eLoopPlayer); - } - - // Loop through HUMAN Players - if we're not in MP - if (!CvPreGame::isNetworkMultiplayerGame()) - { - for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++) - { - PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop; - - if (!IsPlayerValid(eLoopPlayer)) - continue; - - // No AI - if (!GET_PLAYER(eLoopPlayer).isHuman()) - continue; - - DoContactPlayer(eLoopPlayer); - } - } -#endif } /// Individual contact opportunity @@ -35413,19 +35101,15 @@ void CvDiplomacyAI::DoHostileStatement(PlayerTypes ePlayer, DiploStatementTypes& CivApproachTypes eApproach = GetSurfaceApproach(ePlayer); - if(eStatement == NO_DIPLO_STATEMENT_TYPE) + if (eStatement == NO_DIPLO_STATEMENT_TYPE) { -#if defined(MOD_BALANCE_CORE) - if(!IsTooEarlyForDoF(ePlayer) && (eApproach == CIV_APPROACH_HOSTILE) && (GetMeanness() > 6)) -#else - if(eApproach == CIV_APPROACH_HOSTILE) -#endif + if (!IsTooEarlyForDoF(ePlayer) && (eApproach == CIV_APPROACH_HOSTILE) && (GetMeanness() > 6)) { TeamTypes eTeam = GET_PLAYER(ePlayer).getTeam(); // If we've made peace recently, don't go mouthing off right away int iPeaceTreatyTurn = GET_TEAM(GetTeam()).GetTurnMadePeaceTreatyWithTeam(eTeam); - if(iPeaceTreatyTurn != -1) + if (iPeaceTreatyTurn != -1) { int iTurnsSincePeace = GC.getGame().getElapsedGameTurns() - iPeaceTreatyTurn; if (iTurnsSincePeace < GC.getGame().getHandicapInfo().getPeaceTreatyDampenerTurns()) @@ -35433,11 +35117,7 @@ void CvDiplomacyAI::DoHostileStatement(PlayerTypes ePlayer, DiploStatementTypes& } DiploStatementTypes eTempStatement = DIPLO_STATEMENT_INSULT; -#if defined(MOD_BALANCE_CORE) int iTurnsBetweenStatements = 75; -#else - int iTurnsBetweenStatements = 35; -#endif if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= iTurnsBetweenStatements) eStatement = eTempStatement; @@ -37031,7 +36711,6 @@ void CvDiplomacyAI::DoBeginDiploWithHuman() { if(!GC.getGame().isOption(GAMEOPTION_ALWAYS_WAR)) { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { // JdH => go into the deal, if there is anything proposed @@ -37054,12 +36733,6 @@ void CvDiplomacyAI::DoBeginDiploWithHuman() gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_DEFAULT_ROOT, szText, eAnimation); } -#else - LeaderheadAnimationTypes eAnimation = LEADERHEAD_ANIM_NEUTRAL_HELLO; - const char* szText = GetGreetHumanMessage(eAnimation); - - gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_DEFAULT_ROOT, szText, eAnimation); -#endif } } @@ -37437,12 +37110,8 @@ const char* CvDiplomacyAI::GetDiploStringForMessage(DiploMessageTypes eDiploMess // AI would like to work against someone with a player case DIPLO_MESSAGE_WORK_AGAINST_SOMEONE: -#if defined(MOD_BALANCE_CORE) iMessage = GetDenounceMessage(eForPlayer); strText = GetDenounceMessageValue(iMessage); -#else - strText = GetDiploTextFromTag("RESPONSE_WORK_AGAINST_SOMEONE", strOptionalKey1); -#endif break; // AI is done working with a player against someone @@ -37896,11 +37565,7 @@ const char* CvDiplomacyAI::GetDiploStringForMessage(DiploMessageTypes eDiploMess // AI offers a counter-deal case DIPLO_MESSAGE_TRADE_AI_MAKES_OFFER: -#if defined(MOD_BALANCE_CORE) strText = GetOfferText(eForPlayer); -#else - strText = GetDiploTextFromTag("RESPONSE_TRADE_AI_MAKES_OFFER"); -#endif break; // AI doesn't see a way to make proposed deal work @@ -51444,7 +51109,6 @@ void CvDiplomacyAI::LogDenounce(PlayerTypes ePlayer, bool bBackstab, bool bRefus else if(bRefusal) strOutBuf = strBaseString + ",***** REFUSED TO FORGIVE " + otherPlayerName + "! *****"; else -#if defined(MOD_BALANCE_CORE) { strOutBuf = strBaseString + ",***** DENOUNCED GENERIC " + otherPlayerName + "! *****"; int iMessage = GetDenounceMessage(ePlayer); @@ -51513,9 +51177,6 @@ void CvDiplomacyAI::LogDenounce(PlayerTypes ePlayer, bool bBackstab, bool bRefus strOutBuf = strBaseString + ",***** DENOUNCED BECAUSE OF VICTORY BLOCK " + otherPlayerName + "! *****"; } } -#else - strOutBuf = strBaseString + ",***** DENOUNCED " + otherPlayerName + "! *****"; -#endif pLog->Msg(strOutBuf); } @@ -58237,7 +57898,6 @@ void CvDiplomacyAI::DoLiberatedFromVassalage(TeamTypes eTeam, bool bSkipPopup) if (bSkipPopup) continue; -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { if (CvPreGame::isHuman(eMasterPlayer)) @@ -58254,13 +57914,6 @@ void CvDiplomacyAI::DoLiberatedFromVassalage(TeamTypes eTeam, bool bSkipPopup) gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_BLANK_DISCUSSION, strText, LEADERHEAD_ANIM_POSITIVE); } } -#else - if(!CvPreGame::isNetworkMultiplayerGame() && GC.getGame().getActivePlayer() == eMasterPlayer) - { - const char* strText = GetDiploStringForMessage(DIPLO_MESSAGE_VASSALAGE_LIBERATED_HUMAN, eMasterPlayer); - gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_BLANK_DISCUSSION, strText, LEADERHEAD_ANIM_POSITIVE); - } -#endif } } } diff --git a/CvGameCoreDLL_Expansion2/CvDiplomacyRequests.cpp b/CvGameCoreDLL_Expansion2/CvDiplomacyRequests.cpp index 2dbe0af2a8..9a61750991 100644 --- a/CvGameCoreDLL_Expansion2/CvDiplomacyRequests.cpp +++ b/CvGameCoreDLL_Expansion2/CvDiplomacyRequests.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -127,7 +127,6 @@ FDataStream& operator<<(FDataStream& stream, const CvDiplomacyRequests& diplomac /// Update - called from within CvPlayer void CvDiplomacyRequests::Update(void) { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { if (HasActiveRequest()) @@ -162,27 +161,11 @@ void CvDiplomacyRequests::Update(void) m_aRequests.pop_front(); } } -#else - PlayerTypes eActivePlayer = GC.getGame().getActivePlayer(); - // If we are active, send out the requests - if(m_aRequests.size() && m_ePlayer == eActivePlayer && GET_PLAYER(eActivePlayer).isTurnActive()) - { - CvDiplomacyRequests::Request& kRequest = m_aRequests.front(); - - // Make sure the player this is from is still alive. - if(kRequest.m_eFromPlayer != NO_PLAYER && GET_PLAYER(kRequest.m_eFromPlayer).isAlive()) - { - Send(kRequest.m_eFromPlayer, kRequest.m_eDiploType, kRequest.m_strMessage, kRequest.m_eAnimationType, kRequest.m_iExtraGameData); - } - m_aRequests.pop_front(); - } -#endif } // ---------------------------------------------------------------------------- // Called from within CvPlayer at the beginning of the turn void CvDiplomacyRequests::BeginTurn(void) { -#if defined(MOD_ACTIVE_DIPLOMACY) if (m_aRequests.size() > 0) { // JdH: change requests to notifications @@ -206,9 +189,6 @@ void CvDiplomacyRequests::BeginTurn(void) { m_eNextAIPlayer = (PlayerTypes)0; } -#else - m_eNextAIPlayer = (PlayerTypes)0; -#endif } // ---------------------------------------------------------------------------- @@ -475,7 +455,6 @@ bool CvDiplomacyRequests::HasActiveRequest() const // ---------------------------------------------------------------------------- bool CvDiplomacyRequests::HasActiveRequestFrom(PlayerTypes eFromPlayer) const { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { for (RequestList::const_iterator iter = m_aRequests.begin(); iter != m_aRequests.end(); ++iter) @@ -484,17 +463,10 @@ bool CvDiplomacyRequests::HasActiveRequestFrom(PlayerTypes eFromPlayer) const return true; } } - else - { - return m_bRequestActive && m_eRequestActiveFromPlayer == eFromPlayer; - } - return m_bRequestActive && m_eRequestActiveFromPlayer == eFromPlayer; -#else - return m_bRequestActive && m_eRequestActiveFromPlayer == eFromPlayer; -#endif + + return m_bRequestActive && (m_eRequestActiveFromPlayer == eFromPlayer); } -#if defined(MOD_ACTIVE_DIPLOMACY) // --------------------------------------------------------------------------- // Have all the AIs do a diplomacy evaluation with the turn active human players. // Please note that the destination player may not be the active player. @@ -523,7 +495,7 @@ void CvDiplomacyRequests::ClearAllRequests() { m_aRequests.clear(); } /*static*/ std::vector CvDiplomacyRequests::s_aDiploHumans; -#endif + // ---------------------------------------------------------------------------- // Send a request from a player to another player. // If the toPlayer is the active human player, it will be sent right away, else @@ -531,7 +503,6 @@ void CvDiplomacyRequests::ClearAllRequests() { // static void CvDiplomacyRequests::SendRequest(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, DiploUIStateTypes eDiploType, const char* pszMessage, LeaderheadAnimationTypes eAnimationType, int iExtraGameData /*= -1*/) { -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { CvPlayer& kPlayer = GET_PLAYER(eToPlayer); @@ -563,20 +534,6 @@ void CvDiplomacyRequests::SendRequest(PlayerTypes eFromPlayer, PlayerTypes eToPl pkDiploRequests->Add(eFromPlayer, eDiploType, pszMessage, eAnimationType, iExtraGameData); } } -#else - CvPlayer& kPlayer = GET_PLAYER(eToPlayer); - CvDiplomacyRequests* pkDiploRequests = kPlayer.GetDiplomacyRequests(); - if(pkDiploRequests) - { - if(!CvPreGame::isNetworkMultiplayerGame() && GC.getGame().getActivePlayer() == eToPlayer) - { - // Target is the active player, just send it right now - pkDiploRequests->Send(eFromPlayer, eDiploType, pszMessage, eAnimationType, iExtraGameData); - } - else - pkDiploRequests->Add(eFromPlayer, eDiploType, pszMessage, eAnimationType, iExtraGameData); - } -#endif } // ---------------------------------------------------------------------------- @@ -587,7 +544,6 @@ void CvDiplomacyRequests::SendDealRequest(PlayerTypes eFromPlayer, PlayerTypes e if (pkDeal->GetNumItems() <= 0) return; -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { CvAssert(eFromPlayer != NO_PLAYER); @@ -625,15 +581,6 @@ void CvDiplomacyRequests::SendDealRequest(PlayerTypes eFromPlayer, PlayerTypes e } } } -#else - // Deals must currently happen on the active player's turn... - if(GC.getGame().getActivePlayer() == eToPlayer && pkDeal->GetNumItems() > 0) - { - CvInterfacePtr pDeal = GC.WrapDealPointer(pkDeal); - GC.GetEngineUserInterface()->SetScratchDeal(pDeal.get()); - SendRequest(eFromPlayer, eToPlayer, eDiploType, pszMessage, eAnimationType, -1); - } -#endif } // --------------------------------------------------------------------------- diff --git a/CvGameCoreDLL_Expansion2/CvDllGameDeals.cpp b/CvGameCoreDLL_Expansion2/CvDllGameDeals.cpp index ebaf589b5d..7f791d7db4 100644 --- a/CvGameCoreDLL_Expansion2/CvDllGameDeals.cpp +++ b/CvGameCoreDLL_Expansion2/CvDllGameDeals.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -89,7 +89,6 @@ void CvDllGameDeals::AddProposedDeal(ICvDeal1* pDeal) //------------------------------------------------------------------------------ bool CvDllGameDeals::FinalizeDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, bool bAccepted) { -#if defined(MOD_ACTIVE_DIPLOMACY) // was getting errors in the diplomacy log for human-human deals, bypassing seems ok. if((!GET_PLAYER(eFromPlayer).isHuman() || !GET_PLAYER(eToPlayer).isHuman()) && GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { @@ -97,9 +96,6 @@ bool CvDllGameDeals::FinalizeDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer } else return m_pGameDeals->FinalizeDeal(eFromPlayer, eToPlayer, bAccepted); -#else - return m_pGameDeals->FinalizeDeal(eFromPlayer, eToPlayer, bAccepted); -#endif } //------------------------------------------------------------------------------ ICvDeal1* CvDllGameDeals::GetTempDeal() @@ -121,23 +117,16 @@ PlayerTypes CvDllGameDeals::HasMadeProposal(PlayerTypes eFromPlayer) //------------------------------------------------------------------------------ bool CvDllGameDeals::ProposedDealExists(PlayerTypes eFromPlayer, PlayerTypes eToPlayer) { -#if defined(MOD_ACTIVE_DIPLOMACY) - if((!GET_PLAYER(eFromPlayer).isHuman() || !GET_PLAYER(eToPlayer).isHuman()) && GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) - { + if ((!GET_PLAYER(eFromPlayer).isHuman() || !GET_PLAYER(eToPlayer).isHuman()) && GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) return m_pGameDeals->GetProposedMPDeal(eFromPlayer, eToPlayer, false) != NULL; - } - else - return m_pGameDeals->ProposedDealExists(eFromPlayer, eToPlayer); -#else + return m_pGameDeals->ProposedDealExists(eFromPlayer, eToPlayer); -#endif } //------------------------------------------------------------------------------ ICvDeal1* CvDllGameDeals::GetProposedDeal(PlayerTypes eFromPlayer, PlayerTypes eToPlayer) { -#if defined(MOD_ACTIVE_DIPLOMACY) CvDeal* pDeal = NULL; - if((!GET_PLAYER(eFromPlayer).isHuman() || !GET_PLAYER(eToPlayer).isHuman()) && GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if ((!GET_PLAYER(eFromPlayer).isHuman() || !GET_PLAYER(eToPlayer).isHuman()) && GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { pDeal = m_pGameDeals->GetProposedMPDeal(eFromPlayer, eToPlayer, false); } @@ -145,10 +134,8 @@ ICvDeal1* CvDllGameDeals::GetProposedDeal(PlayerTypes eFromPlayer, PlayerTypes e { pDeal = m_pGameDeals->GetProposedDeal(eFromPlayer, eToPlayer); } -#else - CvDeal* pDeal = m_pGameDeals->GetProposedDeal(eFromPlayer, eToPlayer); -#endif - return (NULL != pDeal)? new CvDllDeal(pDeal) : NULL; + + return pDeal ? new CvDllDeal(pDeal) : NULL; } //------------------------------------------------------------------------------ diff --git a/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.cpp b/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.cpp index 2dcf44a9b5..697624a4f9 100644 --- a/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.cpp +++ b/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.cpp @@ -45,9 +45,7 @@ CvDllNetInitInfo::CvDllNetInitInfo() m_iNumMinorCivs = CvPreGame::numMinorCivs(); m_eMode = CvPreGame::gameMode(); -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) m_aiKnownPlayersTable = CvPreGame::GetKnownPlayersTable(); -#endif ZeroMemory(m_szDebugString, sizeof m_szDebugString); } @@ -110,7 +108,6 @@ void* CvDllNetInitInfo::operator new(size_t bytes) //------------------------------------------------------------------------------ const char* CvDllNetInitInfo::GetDebugString() { -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) sprintf(m_szDebugString, "NetInitInfo : m_szLoadFileName=\"%s\", "\ "m_szMapScriptName=\"%s\", "\ "m_bWBMapNoPlayers=\"%s\", "\ @@ -144,39 +141,6 @@ const char* CvDllNetInitInfo::GetDebugString() , CvPreGame::mapRandomSeed() , CvPreGame::GetKnownPlayersTable().size() ); -#else - sprintf(m_szDebugString, "NetInitInfo : m_szLoadFileName=\"%s\", "\ - "m_szMapScriptName=\"%s\", "\ - "m_bWBMapNoPlayers=\"%s\", "\ - "m_eWorldSize=%d, "\ - "m_eClimate=%d "\ - "m_eSeaLevel=%d "\ - "m_eEra=%d "\ - "m_eCalendar=%d "\ - "m_iGameTurn=%d "\ - "m_bGameStarted=%d "\ - "m_eGameSpeed=%d "\ - "m_eTurnTimer=%d "\ - "m_szGameName=\"%s\" "\ - "m_uiSyncRandSeed=%u "\ - "m_uiMapRandSeed=%u " - , CvPreGame::loadFileName().c_str() - , CvPreGame::mapScriptName().c_str() - , CvPreGame::mapNoPlayers() ? "true" : "false" - , static_cast(CvPreGame::worldSize()) - , static_cast(CvPreGame::climate()) - , static_cast(CvPreGame::seaLevel()) - , static_cast(CvPreGame::era()) - , static_cast(CvPreGame::calendar()) - , CvPreGame::gameTurn() - , static_cast(CvPreGame::gameStarted()) - , static_cast(CvPreGame::gameSpeed()) - , static_cast(CvPreGame::turnTimer()) - , CvPreGame::gameName().c_str() - , CvPreGame::syncRandomSeed() - , CvPreGame::mapRandomSeed() - ); -#endif return m_szDebugString; } //------------------------------------------------------------------------------ @@ -215,9 +179,7 @@ bool CvDllNetInitInfo::Read(FDataStream& kStream) kStream >> m_iNumMinorCivs; kStream >> m_eMode; kStream >> m_bStatReporting; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) kStream >> m_aiKnownPlayersTable; -#endif return true; } //------------------------------------------------------------------------------ @@ -254,9 +216,7 @@ bool CvDllNetInitInfo::Write(FDataStream& kStream) kStream << m_iNumMinorCivs; kStream << m_eMode; kStream << m_bStatReporting; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) kStream << m_aiKnownPlayersTable; -#endif return true; } //------------------------------------------------------------------------------ @@ -302,9 +262,7 @@ bool CvDllNetInitInfo::Commit() CvPreGame::setMaxCityElimination(m_iMaxCityElimination); CvPreGame::setNumMinorCivs(m_iNumMinorCivs); CvPreGame::setGameMode(m_eMode); -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) CvPreGame::SetKnownPlayersTable(m_aiKnownPlayersTable); -#endif return true; } diff --git a/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.h b/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.h index e1956f9063..cddd7376f5 100644 --- a/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.h +++ b/CvGameCoreDLL_Expansion2/CvDllNetInitInfo.h @@ -80,8 +80,6 @@ class CvDllNetInitInfo : public ICvNetInitInfo1 unsigned int m_uiRefCount; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) - #if MAX_MAJOR_CIVS <= 32 typedef uint32 KnownPlayersBitArray; #elif MAX_MAJOR_CIVS <= 64 @@ -93,6 +91,4 @@ class CvDllNetInitInfo : public ICvNetInitInfo1 // this is not an FAutoVariable since it doesn't need syncing since it is just derived data. std::vector m_aiKnownPlayersTable; -#endif - }; diff --git a/CvGameCoreDLL_Expansion2/CvDllNetMessageHandler.cpp b/CvGameCoreDLL_Expansion2/CvDllNetMessageHandler.cpp index aa7656fb63..25a691556d 100644 --- a/CvGameCoreDLL_Expansion2/CvDllNetMessageHandler.cpp +++ b/CvGameCoreDLL_Expansion2/CvDllNetMessageHandler.cpp @@ -151,11 +151,7 @@ void CvDllNetMessageHandler::ResponseCityBuyPlot(PlayerTypes ePlayer, int iCityI // (-1,-1) means pick a random plot to buy if(iX == -1 && iY == -1) { -#if defined(MOD_BALANCE_CORE) pkPlot = pkCity->GetNextBuyablePlot(false); -#else - pkPlot = pkCity->GetNextBuyablePlot(); -#endif } else { @@ -360,11 +356,7 @@ void CvDllNetMessageHandler::ResponseFoundPantheon(PlayerTypes ePlayer, BeliefTy CvGameReligions::FOUNDING_RESULT eResult = pkGameReligions->CanCreatePantheon(ePlayer, true); if(eResult == CvGameReligions::FOUNDING_OK) { -#if defined(MOD_TRAITS_ANY_BELIEF) if(pkGameReligions->IsPantheonBeliefAvailable(eBelief, ePlayer)) -#else - if(pkGameReligions->IsPantheonBeliefAvailable(eBelief)) -#endif { pkGameReligions->FoundPantheon(ePlayer, eBelief); } @@ -815,141 +807,11 @@ void CvDllNetMessageHandler::ResponsePlayerDealFinalized(PlayerTypes eFromPlayer CvGame& game = GC.getGame(); PlayerTypes eActivePlayer = game.getActivePlayer(); + bool bIsMP = (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY); // is the deal valid? -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) - { - if(!game.GetGameDeals().FinalizeMPDealLatest(eFromPlayer, eToPlayer, bAccepted, true)) - { - Localization::String strMessage; - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_EXPIRED"); - - CvPlayerAI& kToPlayer = GET_PLAYER(eToPlayer); - CvPlayerAI& kFromPlayer = GET_PLAYER(eFromPlayer); - CvPlayerAI& kActivePlayer = GET_PLAYER(eActivePlayer); - - strMessage = Localization::Lookup("TXT_KEY_DEAL_EXPIRED_FROM_YOU"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strMessage = Localization::Lookup("TXT_KEY_DEAL_EXPIRED_FROM_THEM"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - else - { - CvPlayerAI& kToPlayer = GET_PLAYER(eToPlayer); - CvPlayerAI& kFromPlayer = GET_PLAYER(eFromPlayer); - if(bAccepted) - { - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED"); - Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED_BY_THEM"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strSummary = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED"); - strMessage = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED_BY_YOU"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - else - { - if(eActBy == eFromPlayer) - { - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN"); - Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN_BY_YOU"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strSummary = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN"); - strMessage = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN_BY_THEM"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - else - { - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_REJECTED"); - Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_REJECTED_BY_THEM"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strSummary = Localization::Lookup("TXT_KEY_DEAL_REJECTED"); - strMessage = Localization::Lookup("TXT_KEY_DEAL_REJECTED_BY_YOU"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - } - } - } - else - { - - if(!game.GetGameDeals().FinalizeDeal(eFromPlayer, eToPlayer, bAccepted)) - { - Localization::String strMessage; - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_EXPIRED"); - - CvPlayerAI& kToPlayer = GET_PLAYER(eToPlayer); - CvPlayerAI& kFromPlayer = GET_PLAYER(eFromPlayer); - CvPlayerAI& kActivePlayer = GET_PLAYER(eActivePlayer); - - strMessage = Localization::Lookup("TXT_KEY_DEAL_EXPIRED_FROM_YOU"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strMessage = Localization::Lookup("TXT_KEY_DEAL_EXPIRED_FROM_THEM"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - else - { - CvPlayerAI& kToPlayer = GET_PLAYER(eToPlayer); - CvPlayerAI& kFromPlayer = GET_PLAYER(eFromPlayer); - if(bAccepted) - { - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED"); - Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED_BY_THEM"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strSummary = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED"); - strMessage = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED_BY_YOU"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - else - { - if(eActBy == eFromPlayer) - { - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN"); - Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN_BY_YOU"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strSummary = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN"); - strMessage = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN_BY_THEM"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - else - { - Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_REJECTED"); - Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_REJECTED_BY_THEM"); - strMessage << kToPlayer.getNickName(); - kFromPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eToPlayer, -1, -1); - - strSummary = Localization::Lookup("TXT_KEY_DEAL_REJECTED"); - strMessage = Localization::Lookup("TXT_KEY_DEAL_REJECTED_BY_YOU"); - strMessage << kFromPlayer.getNickName(); - kToPlayer.GetNotifications()->Add(NOTIFICATION_PLAYER_DEAL_RESOLVED, strMessage.toUTF8(), strSummary.toUTF8(), eFromPlayer, -1, -1); - } - } - } - } - -#else - if(!game.GetGameDeals().FinalizeDeal(eFromPlayer, eToPlayer, bAccepted)) + if ((bIsMP && !game.GetGameDeals().FinalizeMPDealLatest(eFromPlayer, eToPlayer, bAccepted, true)) || + !bIsMP && !game.GetGameDeals().FinalizeDeal(eFromPlayer, eToPlayer, bAccepted)) { Localization::String strMessage; Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_EXPIRED"); @@ -970,7 +832,7 @@ void CvDllNetMessageHandler::ResponsePlayerDealFinalized(PlayerTypes eFromPlayer { CvPlayerAI& kToPlayer = GET_PLAYER(eToPlayer); CvPlayerAI& kFromPlayer = GET_PLAYER(eFromPlayer); - if(bAccepted) + if (bAccepted) { Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED"); Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_ACCEPTED_BY_THEM"); @@ -984,7 +846,7 @@ void CvDllNetMessageHandler::ResponsePlayerDealFinalized(PlayerTypes eFromPlayer } else { - if(eActBy == eFromPlayer) + if (eActBy == eFromPlayer) { Localization::String strSummary = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN"); Localization::String strMessage = Localization::Lookup("TXT_KEY_DEAL_WITHDRAWN_BY_YOU"); @@ -1010,7 +872,6 @@ void CvDllNetMessageHandler::ResponsePlayerDealFinalized(PlayerTypes eFromPlayer } } } -#endif } //------------------------------------------------------------------------------ void CvDllNetMessageHandler::ResponsePlayerOption(PlayerTypes ePlayer, PlayerOptionTypes eOption, bool bValue) @@ -1060,11 +921,7 @@ void CvDllNetMessageHandler::ResponseGreatPersonChoice(PlayerTypes ePlayer, Unit CvCity* pCity = kPlayer.GetGreatPersonSpawnCity(eGreatPersonUnit); if(pCity) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pCity->GetCityCitizens()->DoSpawnGreatPerson(eGreatPersonUnit, true, false, MOD_GLOBAL_TRULY_FREE_GP); -#else - pCity->GetCityCitizens()->DoSpawnGreatPerson(eGreatPersonUnit, true, false); -#endif } kPlayer.ChangeNumFreeGreatPeople(-1); } @@ -1079,11 +936,7 @@ void CvDllNetMessageHandler::ResponseMayaBonusChoice(PlayerTypes ePlayer, UnitTy CvCity* pCity = kPlayer.GetGreatPersonSpawnCity(eGreatPersonUnit); if(pCity) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pCity->GetCityCitizens()->DoSpawnGreatPerson(eGreatPersonUnit, true, false, MOD_GLOBAL_TRULY_FREE_GP); -#else - pCity->GetCityCitizens()->DoSpawnGreatPerson(eGreatPersonUnit, true, false); -#endif } kPlayer.ChangeNumMayaBoosts(-1); kPlayer.GetPlayerTraits()->SetUnitBaktun(eGreatPersonUnit); @@ -1099,11 +952,7 @@ void CvDllNetMessageHandler::ResponseFaithGreatPersonChoice(PlayerTypes ePlayer, CvCity* pCity = kPlayer.GetGreatPersonSpawnCity(eGreatPersonUnit); if(pCity) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pCity->GetCityCitizens()->DoSpawnGreatPerson(eGreatPersonUnit, true, true, false); -#else - pCity->GetCityCitizens()->DoSpawnGreatPerson(eGreatPersonUnit, true, true); -#endif } kPlayer.ChangeNumFaithGreatPeople(-1); } diff --git a/CvGameCoreDLL_Expansion2/CvDllPlot.cpp b/CvGameCoreDLL_Expansion2/CvDllPlot.cpp index 40cde56543..090441331b 100644 --- a/CvGameCoreDLL_Expansion2/CvDllPlot.cpp +++ b/CvGameCoreDLL_Expansion2/CvDllPlot.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -148,18 +148,10 @@ bool CvDllPlot::IsTradeRoute(PlayerTypes ePlayer) const //------------------------------------------------------------------------------ bool CvDllPlot::IsImpassable() const { -#if defined(MOD_BALANCE_CORE) - if(m_pPlot->getOwner() != NO_PLAYER) - { + if (m_pPlot->getOwner() != NO_PLAYER) return m_pPlot->isImpassable(GET_PLAYER(m_pPlot->getOwner()).getTeam()); - } - else - { - return m_pPlot->isImpassable(BARBARIAN_TEAM); - } -#else - return m_pPlot->isImpassable(); -#endif + + return m_pPlot->isImpassable(BARBARIAN_TEAM); } //------------------------------------------------------------------------------ void CvDllPlot::GetPosition(int& iX, int& iY) const diff --git a/CvGameCoreDLL_Expansion2/CvEconomicAI.cpp b/CvGameCoreDLL_Expansion2/CvEconomicAI.cpp index ac2036018d..465591746e 100644 --- a/CvGameCoreDLL_Expansion2/CvEconomicAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvEconomicAI.cpp @@ -252,11 +252,7 @@ void CvEconomicAIStrategyXMLEntries::DeleteArray() /// Get a specific entry CvEconomicAIStrategyXMLEntry* CvEconomicAIStrategyXMLEntries::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_ECONOMICAISTRATEGY) ? m_paAIStrategyEntries[index] : NULL; -#else - return m_paAIStrategyEntries[index]; -#endif + return (index != NO_ECONOMICAISTRATEGY) ? m_paAIStrategyEntries[index] : NULL; } //===================================== @@ -774,8 +770,11 @@ void CvEconomicAI::DoTurn() } } - if(!m_pPlayer->isHuman()) + if (!m_pPlayer->isHuman()) { + // This needs to be called first + m_pPlayer->DoUpdateCoreCitiesForSpaceshipProduction(); + DoHurry(); DoPlotPurchases(); DisbandExtraWorkers(); @@ -786,7 +785,6 @@ void CvEconomicAI::DoTurn() DisbandMiscUnits(); DisbandUnitsToFreeSpaceshipResources(); -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) YieldTypes eFocusYield = NO_YIELD; if (EconomicAIHelpers::IsTestStrategy_GS_Spaceship(m_pPlayer)) { eFocusYield = YIELD_SCIENCE; @@ -799,9 +797,6 @@ void CvEconomicAI::DoTurn() } m_pPlayer->GetCulture()->DoSwapGreatWorks(eFocusYield); -#else - m_pPlayer->GetCulture()->DoSwapGreatWorks(); -#endif } } @@ -1801,40 +1796,7 @@ void CvEconomicAI::DoHurry() if (m_pPlayer->GetEconomicAI()->CanWithdrawMoneyForPurchase(PURCHASE_TYPE_UNIT, iGoldCost)) { // Resource requirement - bool bMissingResource = false; - if (!m_pPlayer->isMinorCiv() && !m_pPlayer->isBarbarian()) - { - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos() && !bMissingResource; iResourceLoop++) - { - ResourceTypes eResource = (ResourceTypes)iResourceLoop; - int iNumResource = pkUnitInfo->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - //Don't use all of our Aluminum, keep some for spaceship parts - ResourceTypes eAluminumResource = (ResourceTypes)GC.getInfoTypeForString("RESOURCE_ALUMINUM", true); - if (eResource == eAluminumResource) - { - iNumResource += (m_pPlayer->GetNumAluminumStillNeededForSpaceship() + m_pPlayer->GetNumAluminumStillNeededForCoreCities()); - } - - if (m_pPlayer->getNumResourceAvailable(eResource) < iNumResource) - { - bMissingResource = true; - } - - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - int iResourceTotal = pkUnitInfo->GetResourceQuantityTotal(eResource); - if (m_pPlayer->getNumResourceTotal(eResource) < iResourceTotal || m_pPlayer->getNumResourceAvailable(eResource) < 0) - { - bMissingResource = true; - } - } - } - } - } - - if (bMissingResource) + if (m_pPlayer->HasResourceForNewUnit(eUnitType, false, true)) continue; //Log it @@ -1930,12 +1892,15 @@ void CvEconomicAI::DoHurry() if (GC.getLogging() && GC.getAILogging()) { CvString strLogString; -#if defined(MOD_BALANCE_CORE_BUILDING_INVESTMENTS) - strLogString.Format("MOD - Investing in building: %s in %s. Cost: %d, Balance (before buy): %d, TurnsLeft: %d, ExcessValuation: %d", -#else - strLogString.Format("MOD - Buying building: %s in %s. Cost: %d, Balance (before buy): %d, TurnsLeft: %d, ExcessValuation: %d", -#endif - pkBuildingInfo->GetDescription(), pSelectedCity->getName().c_str(), iGoldCost, m_pPlayer->GetTreasury()->GetGold(), iTurnsLeft, iExcessValuation); + if (MOD_BALANCE_CORE_BUILDING_INVESTMENTS) + strLogString = "MOD - Investing in building:"; + else + strLogString = "MOD - Buying building:"; + + strLogString.Format("%s %s in %s. Cost: %d, Balance (before buy): %d, TurnsLeft: %d, ExcessValuation: %d", + strLogString.c_str(), pkBuildingInfo->GetDescription(), pSelectedCity->getName().c_str(), + iGoldCost, m_pPlayer->GetTreasury()->GetGold(), iTurnsLeft, iExcessValuation); + m_pPlayer->GetHomelandAI()->LogHomelandMessage(strLogString); } @@ -2372,7 +2337,7 @@ void CvEconomicAI::DisbandUnitsToFreeSpaceshipResources() ResourceTypes eAluminum = (ResourceTypes)GC.getInfoTypeForString("RESOURCE_ALUMINUM", true); int iNumAluminumWeNeed = max(0, iNumTotalAluminumNeededForSpaceship + iNumTotalAluminumNeededForCoreCities - m_pPlayer->getNumResourceAvailable(eAluminum, true)); - vector vCoreCities = m_pPlayer->GetCoreCitiesForSpaceshipProduction(); + const vector& vCoreCities = m_pPlayer->GetCoreCitiesForSpaceshipProduction(); if (GC.getLogging() && GC.getAILogging()) { CvString strLogString; @@ -2383,7 +2348,7 @@ void CvEconomicAI::DisbandUnitsToFreeSpaceshipResources() strLogString.Format("Core Cities: "); for (size_t i = 0; i < vCoreCities.size(); i++) { - strLogString += vCoreCities[i]->getName(); + strLogString += m_pPlayer->getCity(vCoreCities[i])->getName(); strLogString += ", "; } } @@ -2460,7 +2425,7 @@ void CvEconomicAI::DisbandUnitsToFreeSpaceshipResources() { // sort cities by economic value, cities in which we want to build spaceship parts are extra valuable CvWeightedVector vCityEconomicWeights; - vector vCitiesForSpaceshipParts = m_pPlayer->GetCoreCitiesForSpaceshipProduction(); + const vector& vCitiesForSpaceshipParts = m_pPlayer->GetCoreCitiesForSpaceshipProduction(); int iLoopCity = 0; for (CvCity* pLoopCity = m_pPlayer->firstCity(&iLoopCity); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoopCity)) { @@ -2469,7 +2434,7 @@ void CvEconomicAI::DisbandUnitsToFreeSpaceshipResources() continue; int iWeight = pLoopCity->getEconomicValue(m_pPlayer->GetID()); - if (pLoopCity->isProductionSpaceshipPart() || (vCitiesForSpaceshipParts.size() > 0 && std::find(vCitiesForSpaceshipParts.begin(), vCitiesForSpaceshipParts.end(), pLoopCity) != vCitiesForSpaceshipParts.end())) + if (pLoopCity->isProductionSpaceshipPart() || (vCitiesForSpaceshipParts.size() > 0 && std::find(vCitiesForSpaceshipParts.begin(), vCitiesForSpaceshipParts.end(), pLoopCity->GetID()) != vCitiesForSpaceshipParts.end())) { iWeight *= 2; } @@ -4350,29 +4315,18 @@ bool EconomicAIHelpers::IsTestStrategy_NeedArchaeologists(CvPlayer* pPlayer) { int iNumSites = pPlayer->GetEconomicAI()->GetVisibleAntiquitySites(); int iNumArchaeologists = pPlayer->GetNumUnitsWithUnitAI(UNITAI_ARCHAEOLOGIST, true); -#if defined(MOD_BALANCE_CORE) int iNumSitesOwn = pPlayer->GetEconomicAI()->GetVisibleAntiquitySitesOwnTerritory(); int iNumSitesNeutral = pPlayer->GetEconomicAI()->GetVisibleAntiquitySitesUnownedTerritory(); -#endif -#if defined(MOD_BALANCE_CORE) - if(iNumSitesOwn > iNumArchaeologists) - { - return true; - } - else if((iNumSitesOwn + iNumSitesNeutral) > (iNumArchaeologists * 2) && !pPlayer->IsAtWar()) - { + + if (iNumSitesOwn > iNumArchaeologists) return true; - } - else if((iNumSitesOwn + iNumSitesNeutral + iNumSites) > (iNumArchaeologists * 4) && !pPlayer->IsAtWar() && (iNumArchaeologists < 3)) - { + + if ((iNumSitesOwn + iNumSitesNeutral > iNumArchaeologists * 2) && !pPlayer->IsAtWar()) return true; - } -#else - if (iNumSites > iNumArchaeologists) - { + + if ((iNumSitesOwn + iNumSitesNeutral + iNumSites > iNumArchaeologists * 4) && !pPlayer->IsAtWar() && iNumArchaeologists < 3) return true; - } -#endif + return false; } diff --git a/CvGameCoreDLL_Expansion2/CvEconomicAI.h b/CvGameCoreDLL_Expansion2/CvEconomicAI.h index 812257ceba..565f6e3540 100644 --- a/CvGameCoreDLL_Expansion2/CvEconomicAI.h +++ b/CvGameCoreDLL_Expansion2/CvEconomicAI.h @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. diff --git a/CvGameCoreDLL_Expansion2/CvEmphasisClasses.cpp b/CvGameCoreDLL_Expansion2/CvEmphasisClasses.cpp index 7982fed559..d806d08f10 100644 --- a/CvGameCoreDLL_Expansion2/CvEmphasisClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvEmphasisClasses.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -102,11 +102,7 @@ void CvEmphasisXMLEntries::DeleteArray() /// Get a specific entry CvEmphasisEntry* CvEmphasisXMLEntries::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_EMPHASIZE) ? m_paEmphasisEntries[index] : NULL; -#else - return m_paEmphasisEntries[index]; -#endif + return (index != NO_EMPHASIZE) ? m_paEmphasisEntries[index] : NULL; } //===================================== diff --git a/CvGameCoreDLL_Expansion2/CvGame.cpp b/CvGameCoreDLL_Expansion2/CvGame.cpp index ecc989cf52..b100baa830 100644 --- a/CvGameCoreDLL_Expansion2/CvGame.cpp +++ b/CvGameCoreDLL_Expansion2/CvGame.cpp @@ -1479,37 +1479,6 @@ void CvGame::assignStartingPlots() GetStartPositioner()->Run(countMajorCivsAlive()); } -#if defined(EXTERNAL_PAUSING) -bool ExternalPause() -{ - bool bPause = false; - - // wait for an external mutex if it exists to make it easier to see what the AI is doing - HANDLE hMutex = ::OpenMutex(SYNCHRONIZE, FALSE, "TurnByTurn"); - if(hMutex != NULL) - { - if (::WaitForSingleObject(hMutex,0)==WAIT_OBJECT_0) - { - //we acquired the mutex, that means we can continue - ReleaseMutex(hMutex); - //also sleep a bit to keep the cpu requirements down if the player is not doing anything - Sleep(10); - } - else - { - //couldn't acquire it, we should pause - bPause = true; - //sleep a little bit for simple rate limiting - Sleep(200); - } - //close the handle in any case - CloseHandle(hMutex); - } - - return bPause; -} -#endif - // --------------------------------------------------------------------------- void CvGame::update() { @@ -1564,20 +1533,14 @@ void CvGame::update() gDLL->AutoSave(true); } -#if defined(EXTERNAL_PAUSING) - bool bExternalPause = ExternalPause(); -#else - bool bExternalPause = false; -#endif - // If there are no active players, move on to the AI - if ( !bExternalPause && getNumGameTurnActive()==0 ) + if (getNumGameTurnActive() == 0) { if(gDLL->CanAdvanceTurn()) doTurn(); } - if(!isPaused() && !bExternalPause) // Check for paused again, the doTurn call might have called something that paused the game and we don't want an update to sneak through + if(!isPaused()) // Check for paused again, the doTurn call might have called something that paused the game and we don't want an update to sneak through { updateScore(); @@ -1585,7 +1548,7 @@ void CvGame::update() updateMoves(); - if(!isPaused()) // And again, the player can change after the automoves and that can pause the game + if(!isPaused()) // And again, the player can change after the automoves and that can pause the game { updateTimers(); @@ -1605,13 +1568,11 @@ void CvGame::update() changeTurnSlice(1); -#if defined(MOD_ACTIVE_DIPLOMACY) if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { // JdH: humans may have been activated, check for AI diplomacy CvDiplomacyRequests::DoAIMPDiplomacyWithHumans(); } -#endif gDLL->FlushTurnReminders(); } @@ -5725,111 +5686,85 @@ Localization::String CvGame::GetDiploResponse(const char* szLeader, const char* //NOTE: Profiled on my machine to take 0.006965 seconds on average to complete. std::vector probabilities; probabilities.reserve(512); + std::vector biasList; + int totbias = 0; -#if defined(MOD_NO_RANDOM_TEXT_CIVS) - std::vector biasList; - - Database::Results* tempDatabase = NULL; - const char* callTemp = "select Tag, Bias from Diplomacy_Responses, Language_en_US where LeaderType = ? and ResponseType = ? and Tag like Response"; - tempDatabase = new Database::Results(); - if(!GC.GetGameDatabase()->Execute(*tempDatabase, callTemp, strlen(callTemp))) - { - CvAssertMsg(false, "Failed to generate diplo response query."); - } - - tempDatabase->Bind(1, szLeader); - tempDatabase->Bind(2, szResponse); - - int totbias=0; - while(tempDatabase->Step()) - { - const char* szTag = tempDatabase->GetText(0); - int bias = tempDatabase->GetInt(1); - totbias+=bias; - biasList.push_back(totbias); - probabilities.push_back(szTag); - } - - tempDatabase->Reset(); - delete tempDatabase; //Just to be safe - - int tempRand = 0; - unsigned int choice = 0; - - if(!probabilities.empty()) - { - tempRand = randRangeExclusive(0, totbias, CvSeeder(probabilities.size())); - for (choice=0; choiceBind(1, szLeader); - m_pDiploResponseQuery->Bind(2, szResponse); - - totbias=0; - biasList.clear(); //Just to be safe - probabilities.clear(); //Just to be safe - while(m_pDiploResponseQuery->Step()) - { - const char* szTag = m_pDiploResponseQuery->GetText(0); - int bias = m_pDiploResponseQuery->GetInt(1); - totbias+=bias; - biasList.push_back(totbias); - probabilities.push_back(szTag); - } - - m_pDiploResponseQuery->Reset(); - - - if(!probabilities.empty()) - { - tempRand = randRangeExclusive(0, totbias, CvSeeder(probabilities.size())); - for (choice=0; choiceExecute(*tempDatabase, callTemp, strlen(callTemp))) + { + CvAssertMsg(false, "Failed to generate diplo response query."); + } - m_pDiploResponseQuery->Bind(1, szLeader); - m_pDiploResponseQuery->Bind(2, szResponse); + tempDatabase->Bind(1, szLeader); + tempDatabase->Bind(2, szResponse); - while(m_pDiploResponseQuery->Step()) - { - const char* szTag = m_pDiploResponseQuery->GetText(0); - int bias = m_pDiploResponseQuery->GetInt(1); - for(int i = 0; i < bias; i++) + while (tempDatabase->Step()) { + const char* szTag = tempDatabase->GetText(0); + int bias = tempDatabase->GetInt(1); + totbias += bias; + biasList.push_back(totbias); probabilities.push_back(szTag); } + + tempDatabase->Reset(); + + if (!probabilities.empty()) + { + int tempRand = randRangeExclusive(0, totbias, CvSeeder(probabilities.size())); + for (uint choice = 0; choice < biasList.size(); choice++) + { + if (tempRand < biasList[choice]) + { + response = Localization::Lookup(probabilities[choice].c_str()); + response << strOptionalKey1 << strOptionalKey2; + return response; + } + } + } } - m_pDiploResponseQuery->Reset(); + CvAssert(totbias == 0); + CvAssert(biasList.empty()); + CvAssert(probabilities.empty()); - if(!probabilities.empty()) + m_pDiploResponseQuery->Bind(1, szLeader); + m_pDiploResponseQuery->Bind(2, szResponse); + while (m_pDiploResponseQuery->Step()) { - response = Localization::Lookup(probabilities[getAsyncRandNum(probabilities.size(), "Diplomacy Rand")].c_str()); - response << strOptionalKey1 << strOptionalKey2; + const char* szTag = m_pDiploResponseQuery->GetText(0); + int bias = m_pDiploResponseQuery->GetInt(1); + totbias += bias; + biasList.push_back(totbias); + probabilities.push_back(szTag); } -#endif - if(response.IsEmpty()) + m_pDiploResponseQuery->Reset(); + + if (!probabilities.empty()) { - char szMessage[256]; - sprintf_s(szMessage, "Please send Jon this with your last 5 autosaves and what changelist # you're playing. Could not find diplomacy response. Leader - %s, Response - %s", szLeader, szResponse); - CvAssertMsg(false, szMessage); + int tempRand = randRangeExclusive(0, totbias, CvSeeder(probabilities.size())); + for (uint choice = 0; choice < biasList.size(); choice++) + { + if(tempRand < biasList[choice]) + { + response = Localization::Lookup(probabilities[choice].c_str()); + response << strOptionalKey1 << strOptionalKey2; + return response; + } + } } + char szMessage[256]; + sprintf_s(szMessage, "Please send Jon this with your last 5 autosaves and what changelist # you're playing. Could not find diplomacy response. Leader - %s, Response - %s", szLeader, szResponse); + CvAssertMsg(false, szMessage); + + // Shouldn't be here return response; } @@ -8514,9 +8449,8 @@ void CvGame::removeGreatPersonBornName(const CvString& szName) // -------------------------------------------------------------------------------- void CvGame::doTurn() { -#if defined(MOD_BALANCE_CORE) && defined(MOD_UNIT_KILL_STATS) - GC.getMap().DoKillCountDecay(); -#endif + if (MOD_UNIT_KILL_STATS) + GC.getMap().DoKillCountDecay(); //create an autosave at turn start if(!isNetworkMultiPlayer()) @@ -8804,530 +8738,6 @@ void DumpUnitInfo(CvUnitEntry* pkUnitInfo) iUnitEra,pkUnitInfo->GetCombat(),pkUnitInfo->GetRangedCombat(),pkUnitInfo->GetMoves(),pkUnitInfo->GetProductionCost()).c_str() ); } -// -------------------------------------------------------------------------------- -/// Determine a random Unit type -UnitTypes CvGame::GetRandomSpawnUnitType(PlayerTypes ePlayer, bool bIncludeUUs, bool bIncludeRanged) -{ - UnitTypes eBestUnit = NO_UNIT; - int iBestValue = 0; - int iValue = 0; - int iBonusValue = 0; - - // Loop through all Unit Classes - for(int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) - { - bool bValid = false; - const UnitTypes eLoopUnit = static_cast(iUnitLoop); - CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eLoopUnit); - - if(pkUnitInfo != NULL) - { - //DumpUnitInfo(pkUnitInfo); - - iBonusValue = 0; - - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo((UnitClassTypes)pkUnitInfo->GetUnitClassType()); - if(pkUnitClassInfo) - { - // If this is NOT a UU, add extra value so that the default unit is more likely to get picked - if(eLoopUnit == pkUnitClassInfo->getDefaultUnitIndex()) - iBonusValue += 700; - else if(!bIncludeUUs) - continue; - } - - bValid = (pkUnitInfo->GetCombat() > 0); - if(bValid) - { - // Unit has combat strength, make sure it isn't only defensive (and with no ranged combat ability) - if(pkUnitInfo->GetRange() == 0) - { - for(int iLoop = 0; iLoop < GC.getNumPromotionInfos(); iLoop++) - { - const PromotionTypes ePromotion = static_cast(iLoop); - CvPromotionEntry* pkPromotionInfo = GC.getPromotionInfo(ePromotion); - if(pkPromotionInfo) - { - if(pkUnitInfo->GetFreePromotions(iLoop)) - { - if(pkPromotionInfo->IsOnlyDefensive()) - { - bValid = false; - break; - } - } - } - } - } - } - - if(!bValid) - continue; - - // Avoid Recon units - if(pkUnitInfo->GetDefaultUnitAIType() == UNITAI_EXPLORE) - continue; - - // No Ranged units? - if(!bIncludeRanged && pkUnitInfo->GetRangedCombat() > 0) - continue; - - // Must be land Unit - if(pkUnitInfo->GetDomainType() != DOMAIN_LAND) - continue; - - // Must NOT be a hovering unit - for(int iI = 0; iI < GC.getNumPromotionInfos(); iI++) - { - if(pkUnitInfo->GetFreePromotions(iI)) - { - if(GC.getPromotionInfo((PromotionTypes) iI)->IsHoveringUnit()) - continue; - } - } - - // Must be able to train this thing - if(!GET_PLAYER(ePlayer).canTrainUnit(eLoopUnit, false, false, false, /*bIgnoreUniqueUnitStatus*/ true)) - continue; - - // Random weighting - iValue = GC.getGame().randRangeInclusive(1, 10, CvSeeder(iUnitLoop).mix(GET_PLAYER(ePlayer).getNumUnits())) * 100; - iValue += iBonusValue; - - if(iValue > iBestValue) - { - eBestUnit = eLoopUnit; - iBestValue = iValue; - } - } - } - - return eBestUnit; -} - -// -------------------------------------------------------------------------------- -/// Pick a random a Unit type that is ranked by unit power and restricted to units available to ePlayer's technology -UnitTypes CvGame::GetCompetitiveSpawnUnitType(PlayerTypes ePlayer, bool bIncludeUUs, bool bIncludeRanged, bool bIncludeShips, bool bNoResource, bool bIncludeOwnUUsOnly, bool bRandom, bool bMinorCivGift) -{ - if (bIncludeRanged) - return GetCompetitiveSpawnUnitType(ePlayer, bIncludeUUs, true, bIncludeShips, bNoResource, bIncludeOwnUUsOnly, bRandom, bMinorCivGift, CvSeeder::fromRaw(0xb5272cbd).mix(GET_PLAYER(ePlayer).GetID())); - - return GetCompetitiveSpawnUnitType(ePlayer, bIncludeUUs, false, bIncludeShips, bNoResource, bIncludeOwnUUsOnly, bRandom, bMinorCivGift, CvSeeder::fromRaw(0xdea52530).mix(GET_PLAYER(ePlayer).GetID())); -} - -UnitTypes CvGame::GetCompetitiveSpawnUnitType(PlayerTypes ePlayer, bool bIncludeUUs, bool bIncludeRanged, bool bIncludeShips, bool bNoResource, bool bIncludeOwnUUsOnly, bool bRandom, bool bMinorCivGift, CvSeeder seed) -{ - CvAssertMsg(ePlayer >= 0, "ePlayer is expected to be non-negative (invalid Index)"); - CvAssertMsg(ePlayer < MAX_CIV_PLAYERS, "ePlayer is expected to be within maximum bounds (invalid Index)"); - - CvWeightedVector veUnitRankings; - - // Loop through all Unit Classes - for(int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) - { - const UnitTypes eLoopUnit = (UnitTypes) iUnitLoop; - CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eLoopUnit); - if(pkUnitInfo == NULL) - { - continue; - } - - if (pkUnitInfo->GetCombat() <= 0) - continue; - - if (bMinorCivGift && pkUnitInfo->IsInvalidMinorCivGift()) - continue; - - if (MOD_POLICIES_UNIT_CLASS_REPLACEMENTS) - { - // Is the unit's class replaced by another? - UnitClassTypes eUnitClass = (UnitClassTypes)pkUnitInfo->GetUnitClassType(); - if (eUnitClass != NO_UNITCLASS && GET_PLAYER(ePlayer).GetUnitClassReplacement(eUnitClass) != NO_UNITCLASS) - { - if (bIncludeUUs) - { - if (GET_PLAYER(ePlayer).getCivilizationInfo().isCivilizationUnitOverridden((int)eUnitClass) == false) - { - continue; - } - } - else - { - continue; - } - } - } - - bool bValid = true; - - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - const ResourceTypes eResource = static_cast(iResourceLoop); - CvResourceInfo* pkResourceInfo = GC.getResourceInfo(eResource); - if (pkResourceInfo) - { - int iResourceRequirement = pkUnitInfo->GetResourceQuantityRequirement(eResource); - - if (iResourceRequirement > 0) - { - if (bNoResource) - { - bValid = false; - break; - } - - // If a major civ, must have enough strategic resources to build this unit! - if (GET_PLAYER(ePlayer).isMajorCiv() && iResourceRequirement > GET_PLAYER(ePlayer).getNumResourceAvailable(eResource, true)) - { - bValid = false; - break; - } - } - -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS && pkUnitInfo->GetResourceQuantityTotal(eResource) > 0) - { - bValid = false; - break; - } -#endif - } - } - - // Unit has combat strength, make sure it isn't only defensive (and with no ranged combat ability) - if(bValid && pkUnitInfo->GetRange() == 0) - { - for(int iPromotionLoop = 0; iPromotionLoop < GC.getNumPromotionInfos(); iPromotionLoop++) - { - const PromotionTypes ePromotion = (PromotionTypes) iPromotionLoop; - CvPromotionEntry* pkPromotionInfo = GC.getPromotionInfo(ePromotion); - if(pkPromotionInfo) - { - if(pkUnitInfo->GetFreePromotions(iPromotionLoop)) - { - if(pkPromotionInfo->IsOnlyDefensive()) - { - bValid = false; - break; - } - } - } - } - } - if(!bValid) - continue; - - UnitClassTypes eLoopUnitClass = (UnitClassTypes) pkUnitInfo->GetUnitClassType(); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eLoopUnitClass); - - if(pkUnitClassInfo == NULL) - { - CvAssertMsg(false, "UnitClassInfo is NULL. Please send Anton your save file and version."); - continue; - } - - // Default unit - if(eLoopUnit == pkUnitClassInfo->getDefaultUnitIndex()) - { - // Allowed, do nothing - } - // Unique unit - else - { - if(!bIncludeUUs) - { - continue; - } - - //Skip own player if to include own UUs. - else if(bIncludeOwnUUsOnly && ((UnitTypes)GET_PLAYER(ePlayer).getCivilizationInfo().getCivilizationUnits(eLoopUnitClass) != eLoopUnit)) - { - continue; - } - - else - { - // Cannot be a UU from a civ that is in our game - for(int iMajorLoop = 0; iMajorLoop < MAX_PLAYERS; iMajorLoop++) // MAX_PLAYERS so that we look at Barbarian UUs (ie. Brute) as well - { - PlayerTypes eMajorLoop = (PlayerTypes) iMajorLoop; - if(GET_PLAYER(eMajorLoop).isAlive()) - { - - UnitTypes eUniqueUnitInGame = (UnitTypes) GET_PLAYER(eMajorLoop).getCivilizationInfo().getCivilizationUnits(eLoopUnitClass); - if(eLoopUnit == eUniqueUnitInGame) - { - bValid = false; - break; - } - } - } - if(!bValid) - continue; - } - } - - // Avoid Recon units - if(pkUnitInfo->GetDefaultUnitAIType() == UNITAI_EXPLORE) - continue; - - // No Ranged units? - if(!bIncludeRanged && pkUnitInfo->GetRangedCombat() > 0) - continue; - - // Must be land Unit, or Naval Units must be allowed - if (pkUnitInfo->GetDomainType() == DOMAIN_LAND || (pkUnitInfo->GetDomainType() == DOMAIN_SEA && bIncludeShips)) - { - // Must be able to train this thing - if (!GET_PLAYER(ePlayer).canTrainUnit(eLoopUnit, false, true, false, /*bIgnoreUniqueUnitStatus*/ true)) - continue; - - veUnitRankings.push_back(eLoopUnit, pkUnitInfo->GetPower()); - } - } - - if (veUnitRankings.size() == 0) - return NO_UNIT; - - // Choose from weighted unit types - veUnitRankings.StableSortItems(); - int iNumChoices = bRandom ? /*5*/ GD_INT_GET(UNIT_SPAWN_NUM_CHOICES) : 1; - UnitTypes eChosenUnit = veUnitRankings.ChooseFromTopChoices(iNumChoices, seed); - - return eChosenUnit; -} - -#if defined(MOD_GLOBAL_CS_GIFTS) -// -------------------------------------------------------------------------------- -/// Pick a random a Unit type that is ranked by unit power and restricted to recon units available to ePlayer's technology -UnitTypes CvGame::GetCsGiftSpawnUnitType(PlayerTypes ePlayer, bool bIncludeShips) -{ - CvAssertMsg(ePlayer >= 0, "ePlayer is expected to be non-negative (invalid Index)"); - CvAssertMsg(ePlayer < MAX_CIV_PLAYERS, "ePlayer is expected to be within maximum bounds (invalid Index)"); - - CvPlayer& kPlayer = GET_PLAYER(ePlayer); - vector> veUnitRankings; - - // Loop through all Unit Classes - for (int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) { - const UnitTypes eLoopUnit = (UnitTypes) iUnitLoop; - CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eLoopUnit); - if (pkUnitInfo == NULL) - continue; - - bool bValid = (pkUnitInfo->GetUnitCombatType() == (UnitCombatTypes)GC.getInfoTypeForString("UNITCOMBAT_RECON", true)); - bValid = bValid || (pkUnitInfo->GetUnitCombatType() == (UnitCombatTypes)GC.getInfoTypeForString("UNITCOMBAT_ARCHER", true)); - bValid = bValid || (pkUnitInfo->GetUnitCombatType() == (UnitCombatTypes)GC.getInfoTypeForString("UNITCOMBAT_MOUNTED", true)); - bValid = bValid || (pkUnitInfo->GetUnitCombatType() == (UnitCombatTypes)GC.getInfoTypeForString("UNITCOMBAT_HELICOPTER", true)); - -#if defined(MOD_GLOBAL_CS_GIFT_SHIPS) - // Exclude carrier units - if (pkUnitInfo->GetSpecialCargo() == (SpecialUnitTypes) GC.getInfoTypeForString("SPECIALUNIT_FIGHTER")) - continue; - - // Include shipping - bValid = bValid || (bIncludeShips && (pkUnitInfo->GetUnitCombatType() == (UnitCombatTypes)GC.getInfoTypeForString("UNITCOMBAT_NAVALMELEE", true))); - bValid = bValid || (bIncludeShips && (pkUnitInfo->GetUnitCombatType() == (UnitCombatTypes)GC.getInfoTypeForString("UNITCOMBAT_NAVALRANGED", true))); -#endif - - if (!bValid) - continue; - - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo((UnitClassTypes) pkUnitInfo->GetUnitClassType()); - if (pkUnitClassInfo == NULL) - continue; - - // Exclude unique units - if (eLoopUnit != pkUnitClassInfo->getDefaultUnitIndex()) - continue; - - // Must be able to train this thing - if (!kPlayer.canTrainUnit(eLoopUnit, false, false, false, /*bIgnoreUniqueUnitStatus*/ true)) - continue; - - // CUSTOMLOG("CS Gift considering unit type %i", eLoopUnit); - veUnitRankings.push_back( OptionWithScore(eLoopUnit, pkUnitInfo->GetPower())); - } - - // Choose from weighted unit types - return PseudoRandomChoiceByWeight(veUnitRankings, NO_UNIT, /*5*/ GD_INT_GET(UNIT_SPAWN_NUM_CHOICES), CvSeeder(kPlayer.getNumUnits()).mix(kPlayer.GetTreasury()->GetLifetimeGrossGold())); -} -#endif -#if defined(MOD_BALANCE_CORE) -bool CvGame::DoSpawnUnitsAroundTargetCity(PlayerTypes ePlayer, CvCity* pCity, int iNumber, bool bIncludeUUs, bool bIncludeShips, bool bNoResource, bool bIncludeOwnUUsOnly) -{ - if(pCity == NULL) - return false; - - if(iNumber <= 0) - return false; - - int iBestPlot = -1; - int iBestPlotWeight = -1; - CvCityCitizens* pCitizens = pCity->GetCityCitizens(); - - // Start at 1, since ID 0 is the city plot itself - for(int iPlotLoop = 1; iPlotLoop < pCity->GetNumWorkablePlots(); iPlotLoop++) - { - CvPlot *pPlot = pCitizens->GetCityPlotFromIndex(iPlotLoop); - // Could be outside of the map ... - if(!pPlot) - continue; - - // Can't be impassable - if(!pPlot->isValidMovePlot(pCity->getOwner())) - continue; - - // Can't be water - if(pPlot->isWater()) - continue; - - // Don't pick plots that aren't ours - if(pPlot->getOwner() != pCity->getOwner()) - continue; - - // Don't place on a plot where a unit is already standing - if(pPlot->getNumUnits() > 0) - continue; - - int iTempWeight = randRangeExclusive(0, 10, CvSeeder(GET_PLAYER(pCity->getOwner()).GetMilitaryMight()).mix(pPlot->GetPseudoRandomSeed())); - - // Add weight if there's an improvement here! - if(pPlot->getImprovementType() != NO_IMPROVEMENT) - { - iTempWeight += 4; - - // If there's also a resource, even more weight! - if(pPlot->getResourceType(pCity->getTeam()) != NO_RESOURCE) - iTempWeight += 3; - } - - // Add weight if there's a defensive bonus for this plot - if(pPlot->defenseModifier(BARBARIAN_TEAM, false, false)) - iTempWeight += 4; - - if(iTempWeight > iBestPlotWeight) - { - iBestPlotWeight = iTempWeight; - iBestPlot = iPlotLoop; - } - } - - bool bUnitCreated = false; - // Found valid plot - if(iBestPlot != -1) - { - CvPlot* pPlot = pCitizens->GetCityPlotFromIndex(iBestPlot); - - // Pick a unit type - should give us more melee than ranged - UnitTypes eUnit = GetCompetitiveSpawnUnitType(ePlayer, /*bIncludeUUs*/ bIncludeUUs, /*bIncludeRanged*/ true, bIncludeShips, bNoResource, bIncludeOwnUUsOnly); - UnitTypes emUnit = GetCompetitiveSpawnUnitType(ePlayer, /*bIncludeUUs*/ bIncludeUUs, /*bIncludeRanged*/ false, bIncludeShips, bNoResource, bIncludeOwnUUsOnly); - - CvCivilizationInfo* pkInfo = GC.getCivilizationInfo(GET_PLAYER(ePlayer).getCivilizationType()); - if (pkInfo) - { - CvUnitEntry* eUnitEntry = GC.getUnitInfo(eUnit); - - if (pkInfo->isCivilizationUnitOverridden(eUnitEntry->GetUnitClassType())) - { - UnitTypes eCivilizationUnit = static_cast(pkInfo->getCivilizationUnits(eUnitEntry->GetUnitClassType())); - if (eCivilizationUnit != NO_UNIT) - { - CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eCivilizationUnit); - if (pkUnitEntry) - eUnit = eCivilizationUnit; - } - } - - CvUnitEntry* emUnitEntry = GC.getUnitInfo(emUnit); - - if (pkInfo->isCivilizationUnitOverridden(emUnitEntry->GetUnitClassType())) - { - UnitTypes eCivilizationUnit = static_cast(pkInfo->getCivilizationUnits(emUnitEntry->GetUnitClassType())); - if (eCivilizationUnit != NO_UNIT) - { - CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eCivilizationUnit); - if (pkUnitEntry) - emUnit = eCivilizationUnit; - } - } - } - - CvUnit* pstartUnit = GET_PLAYER(ePlayer).initUnit(emUnit, pPlot->getX(), pPlot->getY()); - CvAssert(pstartUnit); - if (pstartUnit) - { - if (!pstartUnit->jumpToNearestValidPlotWithinRange(3) || !pstartUnit->IsCombatUnit()) - { - pstartUnit->kill(false); // Could not find a spot! - } - else - { - pstartUnit->finishMoves(); - if(ePlayer != BARBARIAN_PLAYER) - { - pCity->addProductionExperience(pstartUnit); - } - bUnitCreated = true; - } - } - iNumber--; // Reduce the count since we just added the seed rebel - if(iNumber > 0) - { - // Loop until all rebels are placed - do - { - iNumber--; - - // Init unit - CvUnit* pmUnit = GET_PLAYER(ePlayer).initUnit(emUnit, pPlot->getX(), pPlot->getY()); - CvAssert(pmUnit); - if (pmUnit) - { - if (!pmUnit->jumpToNearestValidPlotWithinRange(3) || !pmUnit->IsCombatUnit()) - { - pmUnit->kill(false); // Could not find a spot! - } - else - { - pmUnit->finishMoves(); - if(ePlayer != BARBARIAN_PLAYER) - { - pCity->addProductionExperience(pmUnit); - } - bUnitCreated = true; - } - } - if(iNumber > 0) - { - iNumber--; - // Init unit - CvUnit* pUnit = GET_PLAYER(ePlayer).initUnit(eUnit, pPlot->getX(), pPlot->getY()); - CvAssert(pUnit); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlotWithinRange(3) || !pUnit->IsCombatUnit()) - { - pUnit->kill(false); // Could not find a spot! - } - else - { - pUnit->finishMoves(); - if(ePlayer != BARBARIAN_PLAYER) - { - pCity->addProductionExperience(pUnit); - } - bUnitCreated = true; - } - } - } - } - while(iNumber > 0); - } - } - return bUnitCreated; -} -#endif // -------------------------------------------------------------------------------- UnitTypes CvGame::GetRandomUniqueUnitType(bool bIncludeCivsInGame, bool bIncludeStartEra, bool bIncludeOldEras, bool bIncludeRanged, bool bCoastal, int iPlotX, int iPlotY) { @@ -9650,11 +9060,7 @@ void CvGame::updateMoves() else { const CvUnit* pReadyUnit = player.GetFirstReadyUnit(); -#if defined(MOD_BALANCE_CORE) if (pReadyUnit) //there was a hang with a queued attack on autoplay so setAutoMoves(true) was never called -#else - if(pReadyUnit && !player.GetTacticalAI()->IsInQueuedAttack(pReadyUnit)) -#endif { int iWaitTime = 1000; if(!isNetworkMultiPlayer()) @@ -12388,24 +11794,12 @@ void CvGame::DoMinorBullyUnit(PlayerTypes eBully, PlayerTypes eMinor) CvAssertMsg(eMinor >= MAX_MAJOR_CIVS, "eMinor is not in expected range (invalid Index)"); CvAssertMsg(eMinor < MAX_CIV_PLAYERS, "eMinor is not in expected range (invalid Index)"); -#if defined(MOD_BALANCE_CORE) UnitClassTypes eUnitClassType = GET_PLAYER(eMinor).GetMinorCivAI()->GetBullyUnit(); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClassType); - UnitTypes eUnitType = NO_UNIT; - if(pkUnitClassInfo != NULL) - { - eUnitType = ((GET_PLAYER(eBully).GetSpecificUnitType(eUnitClassType))); - } - if(eUnitType != NO_UNIT) + UnitTypes eUnitType = GET_PLAYER(eBully).GetSpecificUnitType(eUnitClassType); + if (eUnitType != NO_UNIT) { -#else - UnitTypes eUnitType = (UnitTypes) GC.getInfoTypeForString("UNIT_WORKER"); //antonjs: todo: XML/function -#endif - - gDLL->sendMinorBullyUnit(eBully, eMinor, eUnitType); -#if defined(MOD_BALANCE_CORE) + gDLL->sendMinorBullyUnit(eBully, eMinor, eUnitType); } -#endif } // -------------------------------------------------------------------------------- @@ -14767,7 +14161,7 @@ bool CvGame::CreateFreeCityPlayer(CvCity* pStartingCity, bool bJustChecking, boo if (bWorkaround) GET_PLAYER(eNewPlayer).initFreeUnits(); else - DoSpawnUnitsAroundTargetCity(eNewPlayer, pNewCity, GC.getGame().getCurrentEra() + 2, false, true, false, false); + pNewCity->SpawnPlayerUnitsNearby(eNewPlayer, GC.getGame().getCurrentEra() + 2, false, true); // Move Units from player that don't belong here if (pPlot->getNumUnits() > 0) diff --git a/CvGameCoreDLL_Expansion2/CvGame.h b/CvGameCoreDLL_Expansion2/CvGame.h index 8ee570b1cc..827cc2c2c7 100644 --- a/CvGameCoreDLL_Expansion2/CvGame.h +++ b/CvGameCoreDLL_Expansion2/CvGame.h @@ -669,13 +669,7 @@ class CvGame int GetBarbarianReleaseTurn() const; void SetBarbarianReleaseTurn(int iValue); - UnitTypes GetRandomSpawnUnitType(PlayerTypes ePlayer, bool bIncludeUUs, bool bIncludeRanged); - UnitTypes GetCompetitiveSpawnUnitType(PlayerTypes ePlayer, bool bIncludeUUs, bool bIncludeRanged, bool bIncludeShips, bool bNoResource = false, bool bIncludeOwnUUsOnly = false, bool bRandom = true, bool bMinorCivGift = false); - UnitTypes GetCompetitiveSpawnUnitType(PlayerTypes ePlayer, bool bIncludeUUs, bool bIncludeRanged, bool bIncludeShips, bool bNoResource, bool bIncludeOwnUUsOnly, bool bRandom, bool bMinorCivGift, CvSeeder seed); - UnitTypes GetCsGiftSpawnUnitType(PlayerTypes ePlayer, bool bIncludeShips); - UnitTypes GetRandomUniqueUnitType(bool bIncludeCivsInGame, bool bIncludeStartEra, bool bIncludeOldEras, bool bIncludeRanged, bool bCoastal, int iPlotX, int iPlotY); - bool DoSpawnUnitsAroundTargetCity(PlayerTypes ePlayer, CvCity* pCity, int iNumber, bool bIncludeUUs, bool bIncludeShips, bool bNoResource, bool bIncludeOwnUUsOnly); CvSiteEvaluatorForSettler* GetSettlerSiteEvaluator(); CvCitySiteEvaluator* GetStartSiteEvaluator(); diff --git a/CvGameCoreDLL_Expansion2/CvGameCoreStructs.cpp b/CvGameCoreDLL_Expansion2/CvGameCoreStructs.cpp index 4718ca87f6..cc5847eed4 100644 --- a/CvGameCoreDLL_Expansion2/CvGameCoreStructs.cpp +++ b/CvGameCoreDLL_Expansion2/CvGameCoreStructs.cpp @@ -345,47 +345,48 @@ bool CvCombatInfo::getDefenderCaptured() const int CvCombatInfo::getDamageInflicted(BattleUnitTypes unitType) const { checkBattleUnitType(unitType); -#if defined(MOD_EVENTS_BATTLES) int iDamage = m_iDamageInflicted[unitType]; - if (MOD_EVENTS_BATTLES_DAMAGE) { + if (MOD_EVENTS_BATTLES_DAMAGE) + { int iValue = 0; - if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_BattleDamageDelta, unitType, iDamage) == GAMEEVENTRETURN_VALUE) { - if (iValue != 0) { - if (iValue < 0) { - // Decreasing the amount of damage, in which case it can't be more than the amount inflicted (as that's called 'healing'!) - if (iDamage + iValue < 0) { - iValue = -iDamage; - } - } else { - // Increasing the amount of damage, in which case we can't exceed unit/city hit points - CvCity* pCity = m_pCities[unitType]; - if (pCity) + if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_BattleDamageDelta, unitType, iDamage) == GAMEEVENTRETURN_VALUE) + { + if (iValue < 0) + { + // Decreasing the amount of damage, in which case it can't be more than the amount inflicted (as that's called 'healing'!) + if (iDamage + iValue < 0) + { + iValue = -iDamage; + } + } + else if (iValue > 0) + { + // Increasing the amount of damage, in which case we can't exceed unit/city hit points + CvCity* pCity = m_pCities[unitType]; + if (pCity) + { + if (iDamage + iValue + pCity->getDamage() > pCity->GetMaxHitPoints()) { - if (iDamage + iValue + pCity->getDamage() > pCity->GetMaxHitPoints()) - { - iValue = pCity->GetMaxHitPoints() - pCity->getDamage() - iDamage; - } + iValue = pCity->GetMaxHitPoints() - pCity->getDamage() - iDamage; } - else + } + else + { + if (iDamage + iValue > m_pUnits[unitType]->GetCurrHitPoints()) { - if (iDamage + iValue > m_pUnits[unitType]->GetCurrHitPoints()) - { - iValue = m_pUnits[unitType]->GetCurrHitPoints() - iDamage; - } + iValue = m_pUnits[unitType]->GetCurrHitPoints() - iDamage; } } - - iDamage += iValue; } + + iDamage += iValue; } } return iDamage; -#else - return m_iDamageInflicted[unitType]; -#endif } + void CvCombatInfo::setDamageInflicted(BattleUnitTypes unitType, int iDamage) { checkBattleUnitType(unitType); diff --git a/CvGameCoreDLL_Expansion2/CvGameCoreUtils.cpp b/CvGameCoreDLL_Expansion2/CvGameCoreUtils.cpp index 06b6eca3de..70b740d195 100644 --- a/CvGameCoreDLL_Expansion2/CvGameCoreUtils.cpp +++ b/CvGameCoreDLL_Expansion2/CvGameCoreUtils.cpp @@ -116,42 +116,11 @@ int plotDistance(int iIndexA, int iIndexB) CvPlot* plotDirection(int iX, int iY, DirectionTypes eDirection) { -#if defined(MOD_BALANCE_CORE) return GC.getMap().getNeighborUnchecked(iX,iY,eDirection); -#else - if(eDirection == NO_DIRECTION) - { - return GC.getMap().plot(iX, iY); - } - else - { - // convert to hex-space coordinates - the coordinate system axes are E and NE (not orthogonal) - iX = xToHexspaceX(iX , iY); - iX += GC.getPlotDirectionX()[eDirection]; - iY += GC.getPlotDirectionY()[eDirection]; - - // convert from hex-space coordinates to the storage array - iX = hexspaceXToX(iX, iY); - - return GC.getMap().plot(iX, iY); - } -#endif } DirectionTypes directionXY(const CvPlot* pFromPlot, const CvPlot* pToPlot) { -#if 0 - CvPlot** aPlotsToCheck = GC.getMap().getNeighborsUnchecked(pFromPlot); - for(int iI=0; iIgetX(),pFromPlot->getY(),pToPlot->getX(),pToPlot->getY()); -#else int iSourceX = pFromPlot->getX(); int iSourceY = pFromPlot->getY(); int iDestX = pToPlot->getX(); @@ -200,7 +169,6 @@ DirectionTypes directionXY(const CvPlot* pFromPlot, const CvPlot* pToPlot) return DIRECTION_SOUTHWEST; } } -#endif } /// This function will return the CvPlot associated with the Index (0 to 36) of a City at iX,iY. The lower the Index the closer the Plot is to the City (roughly) @@ -459,24 +427,16 @@ bool IsPromotionValidForUnitCombatType(PromotionTypes ePromotion, UnitTypes eUni CvUnitEntry* unitInfo = GC.getUnitInfo(eUnit); CvPromotionEntry* promotionInfo = GC.getPromotionInfo(ePromotion); - if(unitInfo == NULL || promotionInfo == NULL) + if (!unitInfo || !promotionInfo) return false; // No combat class (civilians) - if(unitInfo->GetUnitCombatType() == NO_UNITCOMBAT) - { + if (unitInfo->GetUnitCombatType() == NO_UNITCOMBAT) return false; - } // Combat class not valid for this Promotion -#if defined(MOD_GLOBAL_PROMOTION_CLASSES) - if(!(promotionInfo->GetUnitCombatClass(unitInfo->GetUnitPromotionType()))) -#else - if(!(promotionInfo->GetUnitCombatClass(unitInfo->GetUnitCombatType()))) -#endif - { + if (!promotionInfo->GetUnitCombatClass(unitInfo->GetUnitPromotionType())) return false; - } return true; } @@ -486,13 +446,11 @@ bool IsPromotionValidForCivilianUnitType(PromotionTypes ePromotion, UnitTypes eU { CvPromotionEntry* promotionInfo = GC.getPromotionInfo(ePromotion); - if(promotionInfo == NULL) + if (!promotionInfo) return false; - if(!(promotionInfo->GetCivilianUnitType((int)eUnit))) - { + if (!promotionInfo->GetCivilianUnitType(eUnit)) return false; - } return true; } @@ -826,11 +784,7 @@ bool isUnitLimitPerCity(UnitClassTypes eUnitClass) bool isLimitedUnitClass(UnitClassTypes eUnitClass) { -#if defined(MOD_BALANCE_CORE) return (isWorldUnitClass(eUnitClass) || isTeamUnitClass(eUnitClass) || isNationalUnitClass(eUnitClass) || isUnitLimitPerCity(eUnitClass)); -#else - return (isWorldUnitClass(eUnitClass) || isTeamUnitClass(eUnitClass) || isNationalUnitClass(eUnitClass)); -#endif } bool isWorldProject(ProjectTypes eProject) diff --git a/CvGameCoreDLL_Expansion2/CvGlobals.cpp b/CvGameCoreDLL_Expansion2/CvGlobals.cpp index 961eff11e8..5b169fdbbc 100644 --- a/CvGameCoreDLL_Expansion2/CvGlobals.cpp +++ b/CvGameCoreDLL_Expansion2/CvGlobals.cpp @@ -2486,8 +2486,7 @@ void CvGlobals::init() // // These vars are used to initialize the globals. // -#if defined(MOD_BALANCE_CORE) - int aiPlotDirectionX[NUM_DIRECTION_TYPES+2] = + int aiPlotDirectionX[NUM_DIRECTION_TYPES + 2] = { 0, // DIRECTION_NORTHEAST 1, // DIRECTION_EAST @@ -2497,19 +2496,9 @@ void CvGlobals::init() -1, // DIRECTION_NORTHWEST 0, // DUMMY 0, // NONE -#else - int aiPlotDirectionX[NUM_DIRECTION_TYPES] = - { - 0, // DIRECTION_NORTHEAST - 1, // DIRECTION_EAST - 1, // DIRECTION_SOUTHEAST - 0, // DIRECTION_SOUTHWEST - -1, // DIRECTION_WEST - -1, // DIRECTION_NORTHWEST -#endif }; -#if defined(MOD_BALANCE_CORE) - int aiPlotDirectionY[NUM_DIRECTION_TYPES+2] = + + int aiPlotDirectionY[NUM_DIRECTION_TYPES + 2] = { 1, // DIRECTION_NORTHEAST 0, // DIRECTION_EAST @@ -2519,16 +2508,6 @@ void CvGlobals::init() 1, // DIRECTION_NORTHWEST 0, // DUMMY 0, // NONE -#else - int aiPlotDirectionY[NUM_DIRECTION_TYPES] = - { - 1, // DIRECTION_NORTHEAST - 0, // DIRECTION_EAST - -1, // DIRECTION_SOUTHEAST - -1, // DIRECTION_SOUTHWEST - 0, // DIRECTION_WEST - 1, // DIRECTION_NORTHWEST -#endif }; // these are now in hex-space coords diff --git a/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp b/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp index 72f8cc2dca..9b58e940ae 100644 --- a/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp @@ -1385,42 +1385,9 @@ void CvHomelandAI::PlotUpgradeMoves() iArmySlot = pArmy->RemoveUnit(pUnit->GetID(), true); // Resource requirement - bool bMissingResource = false; - if (!m_pPlayer->isMinorCiv() && !m_pPlayer->isBarbarian()) - { - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos() && !bMissingResource; iResourceLoop++) - { - ResourceTypes eResource = (ResourceTypes)iResourceLoop; - UnitTypes eUpgradeUnitType = pUnit->GetUpgradeUnitType(); - int iNumResource = GC.getUnitInfo(eUpgradeUnitType)->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - //Don't use all of our Aluminum, keep some for spaceship parts - ResourceTypes eAluminumResource = (ResourceTypes)GC.getInfoTypeForString("RESOURCE_ALUMINUM", true); - if (eResource == eAluminumResource) - { - iNumResource += (m_pPlayer->GetNumAluminumStillNeededForSpaceship() + m_pPlayer->GetNumAluminumStillNeededForCoreCities()); - } - - int iNumResourceInUnit = pUnit->getUnitInfo().GetResourceQuantityRequirement(eResource); - if (m_pPlayer->getNumResourceAvailable(eResource) + iNumResourceInUnit < iNumResource) - { - bMissingResource = true; - } - - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - int iResourceTotal = GC.getUnitInfo(eUpgradeUnitType)->GetResourceQuantityTotal(eResource); - if (m_pPlayer->getNumResourceTotal(eResource) < iResourceTotal || m_pPlayer->getNumResourceAvailable(eResource) + iNumResourceInUnit < 0) - { - bMissingResource = true; - } - } - } - } - } - - if (bMissingResource) + UnitTypes eUnit = pUnit->getUnitType(); + UnitTypes eUpgradeUnit = pUnit->GetUpgradeUnitType(); + if (!m_pPlayer->HasResourceForNewUnit(eUpgradeUnit, false, true, eUnit)) continue; //this removes the unit from the army (if any) @@ -1608,11 +1575,7 @@ void CvHomelandAI::PlotEngineerMoves() CvUnit* pUnit = m_pPlayer->getUnit(*it); if(pUnit) { -#if defined(MOD_BALANCE_CORE) if(pUnit->AI_getUnitAIType() == UNITAI_ENGINEER || (pUnit->getUnitInfo().GetUnitAIType(UNITAI_ENGINEER) && !m_pPlayer->IsAtWar())) -#else - if(pUnit->AI_getUnitAIType() == UNITAI_ENGINEER) -#endif { CvHomelandUnit unit; unit.SetID(pUnit->GetID()); @@ -1741,11 +1704,7 @@ void CvHomelandAI::PlotMissionaryMoves() CvUnit* pUnit = m_pPlayer->getUnit(*it); if(pUnit) { -#if defined(MOD_BALANCE_CORE) if(pUnit->AI_getUnitAIType() == UNITAI_MISSIONARY || (pUnit->IsAutomated() && pUnit->GetAutomateType() == AUTOMATE_MISSIONARY)) -#else - if(pUnit->AI_getUnitAIType() == UNITAI_MISSIONARY) -#endif { CvHomelandUnit unit; unit.SetID(pUnit->GetID()); @@ -1950,11 +1909,7 @@ void CvHomelandAI::PlotArchaeologistMoves() CvUnit* pUnit = m_pPlayer->getUnit(*it); if(pUnit) { -#if defined(MOD_BALANCE_CORE) if(pUnit->AI_getUnitAIType() == UNITAI_ARCHAEOLOGIST || (pUnit->IsAutomated() && pUnit->GetAutomateType() == AUTOMATE_ARCHAEOLOGIST)) -#else - if(pUnit->AI_getUnitAIType() == UNITAI_ARCHAEOLOGIST) -#endif { CvHomelandUnit unit; unit.SetID(pUnit->GetID()); diff --git a/CvGameCoreDLL_Expansion2/CvHomelandAI.h b/CvGameCoreDLL_Expansion2/CvHomelandAI.h index 3460544a3d..a8b7c93747 100644 --- a/CvGameCoreDLL_Expansion2/CvHomelandAI.h +++ b/CvGameCoreDLL_Expansion2/CvHomelandAI.h @@ -10,13 +10,9 @@ #ifndef CIV5_HOMELAND_AI_H #define CIV5_HOMELAND_AI_H -#if defined(MOD_BALANCE_CORE_MILITARY) #define UPGRADE_THIS_TURN_PRIORITY_BOOST 5000 #define UPGRADE_IN_TERRITORY_PRIORITY_BOOST 2000 -#else -#define UPGRADE_THIS_TURN_PRIORITY_BOOST 1000 -#define UPGRADE_IN_TERRITORY_PRIORITY_BOOST 500 -#endif + enum AIHomelandTargetType { AI_HOMELAND_TARGET_NONE, diff --git a/CvGameCoreDLL_Expansion2/CvImprovementClasses.cpp b/CvGameCoreDLL_Expansion2/CvImprovementClasses.cpp index cb28950790..880dabc337 100644 --- a/CvGameCoreDLL_Expansion2/CvImprovementClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvImprovementClasses.cpp @@ -1657,11 +1657,7 @@ int CvImprovementXMLEntries::GetNumImprovements() /// Get a specific entry CvImprovementEntry* CvImprovementXMLEntries::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_IMPROVEMENT) ? m_paImprovementEntries[index] : NULL; -#else - return m_paImprovementEntries[index]; -#endif + return (index != NO_IMPROVEMENT) ? m_paImprovementEntries[index] : NULL; } /// Tell which improvement unlocks a resource diff --git a/CvGameCoreDLL_Expansion2/CvInfos.cpp b/CvGameCoreDLL_Expansion2/CvInfos.cpp index d6356cb5e3..edbf767345 100644 --- a/CvGameCoreDLL_Expansion2/CvInfos.cpp +++ b/CvGameCoreDLL_Expansion2/CvInfos.cpp @@ -7062,24 +7062,15 @@ bool CvFeatureInfo::IsRough() const return m_bRough; } //------------------------------------------------------------------------------ -#if defined(MOD_PSEUDO_NATURAL_WONDER) bool CvFeatureInfo::IsNaturalWonder(bool orPseudoNatural) const -#else -bool CvFeatureInfo::IsNaturalWonder() const -#endif { -#if defined(MOD_PSEUDO_NATURAL_WONDER) return m_bNaturalWonder || (orPseudoNatural && IsPseudoNaturalWonder()); -#else - return m_bNaturalWonder; -#endif } -#if defined(MOD_PSEUDO_NATURAL_WONDER) +//------------------------------------------------------------------------------ bool CvFeatureInfo::IsPseudoNaturalWonder() const { return m_bPseudoNaturalWonder; } -#endif //------------------------------------------------------------------------------ const char* CvFeatureInfo::getArtDefineTag() const { diff --git a/CvGameCoreDLL_Expansion2/CvInfos.h b/CvGameCoreDLL_Expansion2/CvInfos.h index 4a4c961103..29bd4f6442 100644 --- a/CvGameCoreDLL_Expansion2/CvInfos.h +++ b/CvGameCoreDLL_Expansion2/CvInfos.h @@ -2043,12 +2043,9 @@ class CvFeatureInfo : public CvBaseInfo bool isVisibleAlways() const; bool isNukeImmune() const; bool IsRough() const; -#if defined(MOD_PSEUDO_NATURAL_WONDER) + bool IsNaturalWonder(bool orPseudoNatural = false) const; bool IsPseudoNaturalWonder() const; -#else - bool IsNaturalWonder() const; -#endif const char* getArtDefineTag() const; void setArtDefineTag(const char* szTag); diff --git a/CvGameCoreDLL_Expansion2/CvMap.cpp b/CvGameCoreDLL_Expansion2/CvMap.cpp index 3db38629f4..c88828e46d 100644 --- a/CvGameCoreDLL_Expansion2/CvMap.cpp +++ b/CvGameCoreDLL_Expansion2/CvMap.cpp @@ -1051,11 +1051,7 @@ CvPlot* CvMap::syncRandPlot(int iFlags, int iArea, int iMinUnitDistance, int iTi { if(iFlags & RANDPLOT_PASSIBLE) { -#if defined(MOD_BALANCE_CORE) if(pTestPlot->isImpassable(BARBARIAN_TEAM)) -#else - if(pTestPlot->isImpassable()) -#endif { bValid = false; } @@ -1908,11 +1904,7 @@ void CvMap::DoPlaceNaturalWonders() { eFeature = (FeatureTypes) iFeatureLoop; CvFeatureInfo* feature = GC.getFeatureInfo(eFeature); -#if defined(MOD_PSEUDO_NATURAL_WONDER) - if(feature && feature->IsNaturalWonder(true)) -#else - if(feature && feature->IsNaturalWonder()) -#endif + if (feature && feature->IsNaturalWonder(true)) { eNWFeature = eFeature; @@ -2729,7 +2721,6 @@ int CvMap::GetAIMapHint() return m_iAIMapHints; } -#if defined(MOD_UNIT_KILL_STATS) int CvMap::GetUnitKillCount(PlayerTypes ePlayer, int iPlotIndex) { if (killCount.find(ePlayer) != killCount.end()) @@ -2785,7 +2776,6 @@ void CvMap::DoKillCountDecay(float fDecayFactor) for (UnitKillCount::value_type::second_type::iterator itPlot = itPlayer->second.begin(); itPlot != itPlayer->second.end(); ++itPlot) itPlot->second = int(itPlot->second*fDecayFactor); } -#endif void CvMap::LineOfSightChanged(const CvPlot* pPlot) { diff --git a/CvGameCoreDLL_Expansion2/CvMap.h b/CvGameCoreDLL_Expansion2/CvMap.h index c1c140a5f0..a8e7d5acb8 100644 --- a/CvGameCoreDLL_Expansion2/CvMap.h +++ b/CvGameCoreDLL_Expansion2/CvMap.h @@ -386,12 +386,10 @@ class CvMap int GetPopupCount(int iPlotIndex); void IncreasePopupCount(int iPlotIndex); -#if defined(MOD_UNIT_KILL_STATS) int GetUnitKillCount(PlayerTypes ePlayer, int iPlotIndex); void IncrementUnitKillCount(PlayerTypes ePlayer, int iPlotIndex); void ExportUnitKillCount(PlayerTypes ePlayer); void DoKillCountDecay(float fDecayFactor = 0.98f); -#endif protected: @@ -462,10 +460,8 @@ class CvMap map m_plotPopupCount; //not serialized -#if defined(MOD_UNIT_KILL_STATS) // player -> plot index -> number of owned units killed UnitKillCount killCount; -#endif }; #endif diff --git a/CvGameCoreDLL_Expansion2/CvMilitaryAI.cpp b/CvGameCoreDLL_Expansion2/CvMilitaryAI.cpp index ed42cf9dd4..1bd3325d9e 100644 --- a/CvGameCoreDLL_Expansion2/CvMilitaryAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvMilitaryAI.cpp @@ -243,11 +243,7 @@ void CvMilitaryAIStrategyXMLEntries::DeleteArray() /// Get a specific entry _Ret_maybenull_ CvMilitaryAIStrategyXMLEntry* CvMilitaryAIStrategyXMLEntries::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_MILITARYAISTRATEGY) ? m_paAIStrategyEntries[index] : NULL; -#else - return m_paAIStrategyEntries[index]; -#endif + return (index != NO_MILITARYAISTRATEGY) ? m_paAIStrategyEntries[index] : NULL; } @@ -322,9 +318,10 @@ void CvMilitaryAI::Reset() m_eNavalDefenseState = NO_DEFENSE_STATE; m_iNumberOfTimesOpsBuildSkippedOver = 0; m_iNumberOfTimesSettlerBuildSkippedOver = 0; -#if defined(MOD_BALANCE_CORE) + for (int iI = 0; iI < MAX_MAJOR_CIVS; iI++) m_aiWarFocus[iI] = WARTYPE_UNDEFINED; + m_iNumFreeCarriers = 0; //new unit counters m_iNumArcherLandUnits = 0; @@ -339,7 +336,6 @@ void CvMilitaryAI::Reset() m_iNumCarrierNavalUnits = 0; m_iNumMissileUnits = 0; m_iNumActiveUniqueUnits = 0; -#endif for(int iI = 0; iI < m_pAIStrategies->GetNumMilitaryAIStrategies(); iI++) { @@ -1831,10 +1827,7 @@ void CvMilitaryAI::UpdateDefenseState() /// Count up barbarian camps and units visible to us void CvMilitaryAI::ScanForBarbarians() { - -#if defined(MOD_BALANCE_CORE) int iLastTurnBarbarianCount = m_iVisibleBarbarianCount; -#endif m_iBarbarianCampCount = 0; m_iVisibleBarbarianCount = 0; @@ -1864,12 +1857,9 @@ void CvMilitaryAI::ScanForBarbarians() } } -#if defined(MOD_BALANCE_CORE) //try to smooth the count a bit if (m_iVisibleBarbarianCount < iLastTurnBarbarianCount) - m_iVisibleBarbarianCount = iLastTurnBarbarianCount-1; -#endif - + m_iVisibleBarbarianCount = iLastTurnBarbarianCount - 1; } /// Start or stop military strategies to get flavors set properly @@ -1985,10 +1975,8 @@ void CvMilitaryAI::UpdateMilitaryStrategies() bStrategyShouldBeActive = MilitaryAIHelpers::IsTestStrategy_MinorCivThreatCritical(m_pPlayer); else if(strStrategyName == "MILITARYAISTRATEGY_ERADICATE_BARBARIANS") bStrategyShouldBeActive = MilitaryAIHelpers::IsTestStrategy_EradicateBarbarians(eStrategy, m_pPlayer, m_iBarbarianCampCount, m_iVisibleBarbarianCount); -#if defined(MOD_BALANCE_CORE) else if(strStrategyName == "MILITARYAISTRATEGY_ERADICATE_BARBARIANS_CRITICAL") bStrategyShouldBeActive = MilitaryAIHelpers::IsTestStrategy_EradicateBarbariansCritical(eStrategy, m_pPlayer, m_iBarbarianCampCount, m_iVisibleBarbarianCount); -#endif else if(strStrategyName == "MILITARYAISTRATEGY_WINNING_WARS") bStrategyShouldBeActive = MilitaryAIHelpers::IsTestStrategy_WinningWars(m_pPlayer); else if(strStrategyName == "MILITARYAISTRATEGY_LOSING_WARS") @@ -2635,28 +2623,12 @@ CvUnit* CvMilitaryAI::FindUnitToScrap(DomainTypes eDomain, bool bCheckObsolete, UnitTypes eUpgradeUnit = pLoopUnit->GetUpgradeUnitType(); if (eUpgradeUnit != NO_UNIT) { - //ok nice looks like we can upgrade + // Ok nice looks like we can upgrade bIsObsolete = false; - //but does this unit's upgrade require additional resources we don't have? - CvUnitEntry* pUpgradeUnitInfo = GC.GetGameUnits()->GetEntry(eUpgradeUnit); - if (pUpgradeUnitInfo != NULL) - { - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - ResourceTypes eResource = (ResourceTypes)iResourceLoop; - int iNumResourceNeeded = pUpgradeUnitInfo->GetResourceQuantityRequirement(eResource); - int iNumResourceInUse = pLoopUnit->getUnitInfo().GetResourceQuantityRequirement(eResource); - if (iNumResourceNeeded - iNumResourceInUse > m_pPlayer->getNumResourceTotal(eResource)) - bIsObsolete = true; - - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - if (pUpgradeUnitInfo->GetResourceQuantityTotal(eResource) > m_pPlayer->getNumResourceTotal(eResource)) - bIsObsolete = true; - } - } - } + // But do we have the resources for it? + if (!m_pPlayer->HasResourceForNewUnit(eUpgradeUnit, false, true, pLoopUnit->getUnitType())) + bIsObsolete = true; } } @@ -3632,7 +3604,7 @@ bool MilitaryAIHelpers::IsTestStrategy_WarMobilization(MilitaryAIStrategyTypes e for(int iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++) { eOtherPlayer = (PlayerTypes) iMajorLoop; -#if defined(MOD_BALANCE_CORE) + if(pkDiplomacyAI->GetVictoryBlockLevel(eOtherPlayer) > BLOCK_LEVEL_WEAK) { iCurrentWeight += 5; @@ -3641,7 +3613,6 @@ bool MilitaryAIHelpers::IsTestStrategy_WarMobilization(MilitaryAIStrategyTypes e { iCurrentWeight += 5; } -#endif // Mobilize for war is automatic if we are preparing a sneak attack if (pkDiplomacyAI->GetCivApproach(eOtherPlayer) == CIV_APPROACH_WAR) @@ -3845,7 +3816,6 @@ bool MilitaryAIHelpers::IsTestStrategy_EnoughRangedUnits(CvPlayer* pPlayer, int /// "Need Ranged" Player Strategy: If a player has too many melee units bool MilitaryAIHelpers::IsTestStrategy_NeedRangedUnits(CvPlayer* pPlayer, int iNumRanged, int iNumMelee) { -#if defined(MOD_BALANCE_CORE_MILITARY) if(pPlayer->GetMilitaryAI()->IsBuildingArmy(ARMY_TYPE_LAND)) { if (pPlayer->IsUnderrepresentedUnitType(UNITAI_RANGED) || pPlayer->IsUnderrepresentedUnitType(UNITAI_CITY_BOMBARD)) @@ -3853,7 +3823,7 @@ bool MilitaryAIHelpers::IsTestStrategy_NeedRangedUnits(CvPlayer* pPlayer, int iN return true; } } -#endif + int iFlavorRange = pPlayer->GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes)GC.getInfoTypeForString("FLAVOR_RANGED")); int iRatio = iNumRanged * 10 / max(1,iNumMelee+iNumRanged); return (iRatio <= iFlavorRange / 2); diff --git a/CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp b/CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp index 6aa79a8f0e..4b27532f06 100644 --- a/CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp @@ -2010,8 +2010,7 @@ bool CvMinorCivQuest::IsExpired() for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo && pkUnitInfo->GetUpgradeUnitClass(iI)) + if (pkUnitInfo->GetUpgradeUnitClass(iI)) { UnitTypes eUpgradeUnit = GET_PLAYER(m_eAssignedPlayer).GetSpecificUnitType(eUnitClass); if (GET_PLAYER(m_eAssignedPlayer).canTrainUnit(eUpgradeUnit, false, false, false, false)) @@ -10960,7 +10959,7 @@ UnitTypes CvMinorCivAI::GetBestUnitGiftFromPlayer(PlayerTypes ePlayer) UnitAITypes eUnitAI = pkUnitInfo->GetDefaultUnitAIType(); const UnitClassTypes eUnitClass = (UnitClassTypes)pkUnitInfo->GetUnitClassType(); CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo == NULL || GetPlayer()->GetSpecificUnitType(eUnitClass) == NO_UNIT) + if (!pkUnitClassInfo || GetPlayer()->GetSpecificUnitType(eUnitClass) == NO_UNIT) continue; // No planes, no naval units unless allowed, and no siege units @@ -10984,29 +10983,12 @@ UnitTypes CvMinorCivAI::GetBestUnitGiftFromPlayer(PlayerTypes ePlayer) if (eUnitAI == UNITAI_EXPLORE || eUnitAI == UNITAI_EXPLORE_SEA) continue; - bool bValid = true; - for (int iLoop = 0; iLoop < GC.getNumPromotionInfos(); iLoop++) - { - const PromotionTypes ePromotion = static_cast(iLoop); - CvPromotionEntry* pkPromotionInfo = GC.getPromotionInfo(ePromotion); - if (pkPromotionInfo && pkUnitInfo->GetFreePromotions(iLoop)) - { - if (pkPromotionInfo->IsOnlyDefensive() || pkPromotionInfo->IsHoveringUnit()) - { - bValid = false; - break; - } - } - } - if (!bValid) - continue; - // Can we train the unit type this unit upgrades to? + bool bValid = true; for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo && pkUnitInfo->GetUpgradeUnitClass(iI)) + if (pkUnitInfo->GetUpgradeUnitClass(iI)) { UnitTypes eUpgradeUnit = GET_PLAYER(ePlayer).GetSpecificUnitType(eUnitClass); if (GET_PLAYER(ePlayer).canTrainUnit(eUpgradeUnit, false, false, false, false)) @@ -15126,8 +15108,9 @@ void CvMinorCivAI::SetUnitSpawningDisabled(PlayerTypes ePlayer, bool bValue) CvUnit* CvMinorCivAI::DoSpawnUnit(PlayerTypes eMajor, bool bLocal, bool bExplore, bool bCityStateAnnexed, bool bJuggernaut) { if (eMajor < 0 || eMajor >= MAX_MAJOR_CIVS) return NULL; + CvPlayer& kMajor = GET_PLAYER(eMajor); - if (bCityStateAnnexed && !GET_PLAYER(eMajor).GetPlayerTraits()->IsAnnexedCityStatesGiveYields()) + if (bCityStateAnnexed && !kMajor.GetPlayerTraits()->IsAnnexedCityStatesGiveYields()) return NULL; if (bExplore && !MOD_GLOBAL_CS_GIFTS) @@ -15136,7 +15119,7 @@ CvUnit* CvMinorCivAI::DoSpawnUnit(PlayerTypes eMajor, bool bLocal, bool bExplore if (!bJuggernaut) { // Unit spawning is not allowed (manually disabled, or major is over supply limit) - bool bCanSupply = GET_PLAYER(eMajor).GetNumUnitsToSupply() < GET_PLAYER(eMajor).GetNumUnitsSupplied(); // this works when we're at the limit + bool bCanSupply = kMajor.GetNumUnitsToSupply() < kMajor.GetNumUnitsSupplied(); // this works when we're at the limit if (!bCanSupply || (IsUnitSpawningDisabled(eMajor) && !bCityStateAnnexed)) return NULL; } @@ -15150,22 +15133,22 @@ CvUnit* CvMinorCivAI::DoSpawnUnit(PlayerTypes eMajor, bool bLocal, bool bExplore else { CvPlot* pStartingPlot = GC.getMap().plotCheckInvalid(GetPlayer()->GetOriginalCapitalX(), GetPlayer()->GetOriginalCapitalY()); - if(pStartingPlot) + if (pStartingPlot) pMinorCapital = pStartingPlot->getPlotCity(); } if (!pMinorCapital) return NULL; - if (pMinorCapital->plot() == NULL) + if (!pMinorCapital->plot()) return NULL; // Major has no capital - CvCity* pMajorCapital = GET_PLAYER(eMajor).getCapitalCity(); + CvCity* pMajorCapital = kMajor.getCapitalCity(); if (!pMajorCapital) return NULL; - if (pMajorCapital->plot() == NULL) + if (!pMajorCapital->plot()) return NULL; bool bBoatsAllowed = MOD_GLOBAL_CS_GIFT_SHIPS && pMinorCapital->isCoastal(/*10*/ GD_INT_GET(MIN_WATER_SIZE_FOR_OCEAN)); @@ -15189,9 +15172,9 @@ CvUnit* CvMinorCivAI::DoSpawnUnit(PlayerTypes eMajor, bool bLocal, bool bExplore iLowestCoastalDistance = MIN_INT; int iCityLoop = 0; - for (CvCity* pLoopCity = GET_PLAYER(eMajor).firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(eMajor).nextCity(&iCityLoop)) + for (CvCity* pLoopCity = kMajor.firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = kMajor.nextCity(&iCityLoop)) { - if (pLoopCity->plot() == NULL) + if (!pLoopCity->plot()) continue; int iDistance = plotDistance(*pMinorCapital->plot(), *pLoopCity->plot()); @@ -15231,38 +15214,17 @@ CvUnit* CvMinorCivAI::DoSpawnUnit(PlayerTypes eMajor, bool bLocal, bool bExplore // If naval, major must have a coastal city if (bBoatsAllowed || pkUnitInfo->GetDomainType() != DOMAIN_SEA) { - // If scout, must be a scout - if (!bExplore || pkUnitInfo->GetDefaultUnitAIType() == UNITAI_EXPLORE || pkUnitInfo->GetDefaultUnitAIType() == UNITAI_EXPLORE_SEA) + // Ally must have unit's prereq tech + TechTypes ePrereqTech = (TechTypes) pkUnitInfo->GetPrereqAndTech(); + if (ePrereqTech == NO_TECH || kMajor.HasTech(ePrereqTech)) { - // Ally must have unit's prereq tech - TechTypes ePrereqTech = (TechTypes) pkUnitInfo->GetPrereqAndTech(); - if (ePrereqTech == NO_TECH || GET_TEAM(GET_PLAYER(eMajor).getTeam()).GetTeamTechs()->HasTech(ePrereqTech)) + // Ally must NOT have unit's obsolete tech + TechTypes eObsoleteTech = (TechTypes) pkUnitInfo->GetObsoleteTech(); + if (eObsoleteTech == NO_TECH || !kMajor.HasTech(eObsoleteTech)) { - // Ally must NOT have unit's obsolete tech - TechTypes eObsoleteTech = (TechTypes) pkUnitInfo->GetObsoleteTech(); - if (eObsoleteTech == NO_TECH || !GET_TEAM(GET_PLAYER(eMajor).getTeam()).GetTeamTechs()->HasTech(eObsoleteTech)) + if (kMajor.HasResourceForNewUnit(eUniqueUnit)) { - bool bFailedResourceCheck = false; - - // Ally must meet this unit's strategic resource requirements - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - const ResourceTypes eResource = static_cast(iResourceLoop); - CvResourceInfo* pkResourceInfo = GC.getResourceInfo(eResource); - if (pkResourceInfo) - { - int iResourceRequirement = pkUnitInfo->GetResourceQuantityRequirement(eResource); - - if (iResourceRequirement > 0 && iResourceRequirement > GET_PLAYER(eMajor).getNumResourceAvailable(eResource, true)) - { - bFailedResourceCheck = true; - break; - } - } - } - - if (!bFailedResourceCheck) - eUnit = eUniqueUnit; + eUnit = eUniqueUnit; } } } @@ -15273,10 +15235,21 @@ CvUnit* CvMinorCivAI::DoSpawnUnit(PlayerTypes eMajor, bool bLocal, bool bExplore if (eUnit == NO_UNIT) { - if (bExplore) // Free exploration unit (First contact bonus) - eUnit = GC.getGame().GetCsGiftSpawnUnitType(eMajor, bBoatsAllowed); + if (bExplore) + { + vector viUnitCombat; + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_RECON")); + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_ARCHER")); + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_MOUNTED")); + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_HELICOPTER")); + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_NAVALMELEE")); + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_NAVALRANGED")); + eUnit = kMajor.GetCompetitiveSpawnUnitType(true, true, true, false, NULL, false, true, true, NULL, viUnitCombat); + } else - eUnit = GC.getGame().GetCompetitiveSpawnUnitType(eMajor, /*bIncludeUUs*/ false, /*bIncludeRanged*/ true, bBoatsAllowed, false, false, true, true, CvSeeder::fromRaw(0xf00798cf).mix(GetPlayer()->GetID()).mix(GET_PLAYER(eMajor).GetID())); + { + eUnit = kMajor.GetCompetitiveSpawnUnitType(true, bBoatsAllowed, false, false, NULL, false, true, true); + } } if (eUnit == NO_UNIT) @@ -16427,25 +16400,15 @@ CvString CvMinorCivAI::GetMajorBullyUnitDetails(PlayerTypes ePlayer) CvString sFactors = ""; int iScore = CalculateBullyScore(ePlayer, /*bForUnit*/ true, &sFactors); bool bCanBully = CanMajorBullyUnit(ePlayer, iScore); -#if defined(MOD_BALANCE_CORE) + UnitClassTypes eUnitClassType = GetBullyUnit(); - if(eUnitClassType == NO_UNITCLASS) - { + if (eUnitClassType == NO_UNITCLASS) return ""; - } - UnitTypes eUnitType = NO_UNIT; - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClassType); - if(pkUnitClassInfo != NULL) - { - eUnitType = (GET_PLAYER(ePlayer).GetSpecificUnitType(eUnitClassType)); - } - if(eUnitType == NO_UNIT) - { + + UnitTypes eUnitType = GET_PLAYER(ePlayer).GetSpecificUnitType(eUnitClassType); + if (eUnitType == NO_UNIT) return ""; - } -#else - UnitTypes eUnitType = (UnitTypes) GC.getInfoTypeForString("UNIT_WORKER"); //antonjs: todo: XML/function -#endif + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnitType); CvAssert(pUnitInfo); if (!pUnitInfo) @@ -16488,21 +16451,15 @@ CvString CvMinorCivAI::GetMajorBullyAnnexDetails(PlayerTypes ePlayer) CvString sFactors = ""; int iScore = CalculateBullyScore(ePlayer, /*bForUnit*/ true, &sFactors); bool bCanBully = CanMajorBullyUnit(ePlayer, iScore); + UnitClassTypes eUnitClassType = GetBullyUnit(); if (eUnitClassType == NO_UNITCLASS) - { return ""; - } - UnitTypes eUnitType = NO_UNIT; - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClassType); - if (pkUnitClassInfo != NULL) - { - eUnitType = (GET_PLAYER(ePlayer).GetSpecificUnitType(eUnitClassType)); - } + + UnitTypes eUnitType = GET_PLAYER(ePlayer).GetSpecificUnitType(eUnitClassType); if (eUnitType == NO_UNIT) - { return ""; - } + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnitType); CvAssert(pUnitInfo); if (!pUnitInfo) @@ -16510,17 +16467,12 @@ CvString CvMinorCivAI::GetMajorBullyAnnexDetails(PlayerTypes ePlayer) Localization::String sFear = Localization::Lookup("TXT_KEY_POP_CSTATE_BULLY_AFRAID"); if (!bCanBully) - { sFear = Localization::Lookup("TXT_KEY_POP_CSTATE_BULLY_RESILIENT"); - } - if (MOD_BALANCE_CORE_MINOR_VARIABLE_BULLYING) - { - if (iScore < 0) - iScore *= -1; - sFear << iScore; - } - else - sFear << iScore; + + if (MOD_BALANCE_CORE_MINOR_VARIABLE_BULLYING && iScore < 0) + iScore *= -1; + + sFear << iScore; Localization::String sResult = Localization::Lookup("TXT_KEY_POP_CSTATE_BULLY_UNIT_TT_ANNEX"); sResult << sFear.toUTF8() << sFactors << pUnitInfo->GetDescriptionKey(); diff --git a/CvGameCoreDLL_Expansion2/CvMinorCivAI.h b/CvGameCoreDLL_Expansion2/CvMinorCivAI.h index eabf940800..4dec8ad18e 100644 --- a/CvGameCoreDLL_Expansion2/CvMinorCivAI.h +++ b/CvGameCoreDLL_Expansion2/CvMinorCivAI.h @@ -433,11 +433,7 @@ class CvMinorCivAI void DoTestStartGlobalQuest(); void DoTestStartPersonalQuest(PlayerTypes ePlayer); -#if defined(MOD_BALANCE_CORE) void AddQuestForPlayer(PlayerTypes ePlayer, MinorCivQuestTypes eType, int iStartTurn, PlayerTypes pCallingPlayer = NO_PLAYER); -#else - void AddQuestForPlayer(PlayerTypes ePlayer, MinorCivQuestTypes eType, int iStartTurn); -#endif void AddQuestCopyForPlayer(PlayerTypes ePlayer, CvMinorCivQuest* pQuest); void DoTestQuestsOnFirstContact(PlayerTypes eMajor); diff --git a/CvGameCoreDLL_Expansion2/CvPlayer.cpp b/CvGameCoreDLL_Expansion2/CvPlayer.cpp index 9d176246b1..c6e52453b2 100644 --- a/CvGameCoreDLL_Expansion2/CvPlayer.cpp +++ b/CvGameCoreDLL_Expansion2/CvPlayer.cpp @@ -1,9 +1,9 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. - Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software - and their respective logos are all trademarks of Take-Two interactive Software, Inc. - All other marks and trademarks are the property of their respective owners. - All rights reserved. + © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software + and their respective logos are all trademarks of Take-Two interactive Software, Inc. + All other marks and trademarks are the property of their respective owners. + All rights reserved. ------------------------------------------------------------------------------------------------------- */ #include "CvGameCoreDLLPCH.h" @@ -447,10 +447,7 @@ CvPlayer::CvPlayer() : , m_iNumFreeTenets() , m_iCachedCurrentWarValue() , m_iLastSliceMoved() // not serialized -, m_vCitiesForSpaceshipParts() // not serialized -, m_iCitiesForSpaceshipPartsUpdateTurn(-1) // not serialized -, m_vCoreCitiesForSpaceshipProduction() // not serialized -, m_iCoreCitiesForSpaceshipProductionUpdateTurn(-1) // not serialized +, m_viCoreCitiesForSpaceshipProduction() , m_eEndTurnBlockingType(NO_ENDTURN_BLOCKING_TYPE) , m_iEndTurnBlockingNotificationIndex(0) , m_activeWaitingForEndTurnMessage(false) @@ -839,10 +836,8 @@ CvPlayer::CvPlayer() : // -------------------------------------------------------------------------------- CvPlayer::~CvPlayer() { -#if defined(MOD_BALANCE_CORE) && defined(MOD_UNIT_KILL_STATS) - if (isMajorCiv() && GC.getAILogging()) + if (MOD_UNIT_KILL_STATS && isMajorCiv() && GC.getAILogging()) GC.getMap().ExportUnitKillCount(GetID()); -#endif uninit(); @@ -897,10 +892,10 @@ void CvPlayer::init(PlayerTypes eID) { if (!m_pNotifications) m_pNotifications = FNEW(CvNotifications, c_eCiv5GameplayDLL, 0); -#if defined(MOD_WH_MILITARY_LOG) + if (MOD_WH_MILITARY_LOG && !m_pMilitaryLog) m_pMilitaryLog = FNEW(CvEventLog, c_eCiv5GameplayDLL, 0); -#endif + if (!m_pDiplomacyRequests) m_pDiplomacyRequests = FNEW(CvDiplomacyRequests, c_eCiv5GameplayDLL, 0); } @@ -938,7 +933,7 @@ void CvPlayer::init(PlayerTypes eID) m_bPotentiallyAlive = true; } - + if ((s == SS_TAKEN) || (s == SS_COMPUTER)) { setAlive(true); @@ -996,12 +991,8 @@ void CvPlayer::init(PlayerTypes eID) changeMaxTeamBuildingProductionModifier(GetPlayerTraits()->GetMaxTeamBuildingProductionModifier()); changeMaxPlayerBuildingProductionModifier(GetPlayerTraits()->GetMaxPlayerBuildingProductionModifier()); ChangePlotGoldCostMod(GetPlayerTraits()->GetPlotBuyCostModifier()); -#if defined(MOD_TRAITS_CITY_WORKING) ChangeCityWorkingChange(GetPlayerTraits()->GetCityWorkingChange()); -#endif -#if defined(MOD_TRAITS_CITY_AUTOMATON_WORKERS) ChangeCityAutomatonWorkersChange(GetPlayerTraits()->GetCityAutomatonWorkersChange()); -#endif ChangePlotCultureCostModifier(GetPlayerTraits()->GetPlotCultureCostModifier()); GetTreasury()->ChangeCityConnectionTradeRouteGoldChange(GetPlayerTraits()->GetCityConnectionTradeRouteChange()); changeWonderProductionModifier(GetPlayerTraits()->GetWonderProductionModifier()); @@ -1019,7 +1010,7 @@ void CvPlayer::init(PlayerTypes eID) { updateExtraYieldThreshold((YieldTypes)iI); } -#if defined(MOD_BALANCE_CORE) + if (GetPlayerTraits()->GetSpySecurityModifier() != 0) { ChangeSpySecurityModifier(GetPlayerTraits()->GetSpySecurityModifier()); @@ -1032,7 +1023,7 @@ void CvPlayer::init(PlayerTypes eID) { ChangeIncreasedQuestInfluence(GetPlayerTraits()->GetQuestYieldModifier()); } -#endif + const CvCivilizationInfo& playerCivilizationInfo = getCivilizationInfo(); for(iI = 0; iI < GC.getNumUnitClassInfos(); ++iI) { @@ -1044,7 +1035,6 @@ void CvPlayer::init(PlayerTypes eID) if(NO_UNIT != eUnit) { CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit); -#if defined(MOD_BALANCE_CORE_SETTLER_ADVANCED) if (pkUnitInfo != NULL && pkUnitInfo->IsFoundLate()) { if (pkUnitInfo->IsFoodProduction()) @@ -1059,7 +1049,6 @@ void CvPlayer::init(PlayerTypes eID) setUnitExtraCost(eUnitClass, getNewCityProductionValue()); } } -#endif else if(NULL != pkUnitInfo && pkUnitInfo->IsFound()) { setUnitExtraCost(eUnitClass, getNewCityProductionValue()); @@ -1071,7 +1060,6 @@ void CvPlayer::init(PlayerTypes eID) BuildingTypes eFreeBuilding = GetPlayerTraits()->GetFreeBuilding(); if(eFreeBuilding != NO_BUILDING) { -#if defined(MOD_BALANCE_CORE) CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eFreeBuilding); if(pkBuildingInfo) { @@ -1085,16 +1073,11 @@ void CvPlayer::init(PlayerTypes eID) changeFreeBuildingCount(eFreeBuilding, 1); } } -#else - changeFreeBuildingCount(eFreeBuilding, 1); -#endif } SetGreatGeneralCombatBonus(/*15*/ GD_INT_GET(GREAT_GENERAL_STRENGTH_MOD)); } -#if defined(MOD_BALANCE_CORE) GET_TEAM(getTeam()).DoUpdateBestRoute(); -#endif m_aiPlots.clear(); m_bfEverConqueredBy.ClearAll(); @@ -1191,12 +1174,12 @@ void CvPlayer::uninit() { m_pNotifications->Uninit(); } -#if defined(MOD_WH_MILITARY_LOG) - if(MOD_WH_MILITARY_LOG && m_pMilitaryLog) + + if (MOD_WH_MILITARY_LOG && m_pMilitaryLog) { m_pMilitaryLog->Uninit(); } -#endif + if(m_pDiplomacyRequests) { m_pDiplomacyRequests->Uninit(); @@ -1658,12 +1641,10 @@ void CvPlayer::uninit() m_iCapitalGrowthMod = 0; m_iNumPlotsBought = 0; m_iPlotGoldCostMod = 0; -#if defined(MOD_TRAITS_CITY_WORKING) || defined(MOD_BUILDINGS_CITY_WORKING) || defined(MOD_POLICIES_CITY_WORKING) || defined(MOD_TECHS_CITY_WORKING) + m_iCityWorkingChange = 0; -#endif -#if defined(MOD_TRAITS_CITY_AUTOMATON_WORKERS) || defined(MOD_BUILDINGS_CITY_AUTOMATON_WORKERS) || defined(MOD_POLICIES_CITY_AUTOMATON_WORKERS) || defined(MOD_TECHS_CITY_AUTOMATON_WORKERS) m_iCityAutomatonWorkersChange = 0; -#endif + m_iCachedGoldRate = 0; m_iBorderGrowthRateIncreaseGlobal = 0; m_iPlotCultureCostModifier = 0; @@ -1702,10 +1683,7 @@ void CvPlayer::uninit() m_eFaithPurchaseType = NO_AUTOMATIC_FAITH_PURCHASE; m_iFaithPurchaseIndex = 0; m_iLastSliceMoved = 0; - m_vCitiesForSpaceshipParts.clear(); - m_iCitiesForSpaceshipPartsUpdateTurn = -1; - m_vCoreCitiesForSpaceshipProduction.clear(); - m_iCoreCitiesForSpaceshipProductionUpdateTurn = -1; + m_viCoreCitiesForSpaceshipProduction.clear(); m_bNoNewWars = false; m_bTerribleShapeForWar = false; @@ -1735,7 +1713,7 @@ void CvPlayer::uninit() m_iVassalGoldMaintenanceMod = 0; #if defined(MOD_BATTLE_ROYALE) m_iNumMilitarySeaUnits = 0; - m_iNumMilitaryAirUnits = 0; + m_iNumMilitaryAirUnits = 0; m_iNumMilitaryLandUnits = 0; m_iMilitarySeaMight = 0; m_iMilitaryAirMight = 0; @@ -1810,7 +1788,7 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) m_aiYieldFromBirthCapital.clear(); m_aiYieldFromBirthCapital.resize(NUM_YIELD_TYPES, 0); - + m_aiYieldFromDeath.clear(); m_aiYieldFromDeath.resize(NUM_YIELD_TYPES, 0); @@ -1851,7 +1829,7 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) m_aiMusicYieldBonus.resize(NUM_YIELD_TYPES, 0); m_aiLitYieldBonus.clear(); - m_aiLitYieldBonus.resize(NUM_YIELD_TYPES, 0); + m_aiLitYieldBonus.resize(NUM_YIELD_TYPES, 0); m_aiFilmYieldBonus.clear(); m_aiFilmYieldBonus.resize(NUM_YIELD_TYPES, 0); @@ -1999,7 +1977,7 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) m_aiSiphonLuxuryCount.clear(); m_aiSiphonLuxuryCount.resize(MAX_PLAYERS, 0); - + m_aiTourismBonusTurnsPlayer.clear(); m_aiTourismBonusTurnsPlayer.resize(MAX_PLAYERS, 0); @@ -2058,10 +2036,8 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) m_paiImprovementCount.resize(GC.getNumImprovementInfos(), 0); m_paiImprovementBuiltCount.clear(); m_paiImprovementBuiltCount.resize(GC.getNumImprovementInfos(), 0); -#if defined(MOD_BALANCE_CORE) m_paiTotalImprovementsBuilt.clear(); m_paiTotalImprovementsBuilt.resize(GC.getNumImprovementInfos(), 0); -#endif #if defined(MOD_IMPROVEMENTS_EXTENSIONS) m_piResponsibleForRouteCount.clear(); @@ -2154,10 +2130,8 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) m_pDiplomacyAI->Init(this); m_pReligions->Init(this); m_pReligionAI->Init(GC.GetGameBeliefs(), this); -#if defined(MOD_BALANCE_CORE) m_pCorporations->Init(this); m_pContracts->Init(this); -#endif m_pPlayerPolicies->Init(GC.GetGamePolicies(), this, false); m_pPlayerTechs->Init(GC.GetGameTechs(), this, false); m_pTacticalAI->Init(this); @@ -2170,12 +2144,12 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) { m_pNotifications->Init(eID); } -#if defined(MOD_WH_MILITARY_LOG) - if(MOD_WH_MILITARY_LOG && m_pMilitaryLog) + + if (MOD_WH_MILITARY_LOG && m_pMilitaryLog) { m_pMilitaryLog->Init(eID); } -#endif + if(m_pDiplomacyRequests) { m_pDiplomacyRequests->Init(eID); @@ -2249,35 +2223,35 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) { m_ppiFeatureYieldChange[i] = yield; } - + m_ppiResourceYieldChange.clear(); m_ppiResourceYieldChange.resize(GC.getNumResourceInfos()); for(unsigned int i = 0; i < m_ppiResourceYieldChange.size(); ++i) { m_ppiResourceYieldChange[i] = yield; } - + m_ppiTerrainYieldChange.clear(); m_ppiTerrainYieldChange.resize(GC.getNumTerrainInfos()); for(unsigned int i = 0; i < m_ppiTerrainYieldChange.size(); ++i) { m_ppiTerrainYieldChange[i] = yield; } - + m_ppiTradeRouteYieldChange.clear(); m_ppiTradeRouteYieldChange.resize(NUM_DOMAIN_TYPES); for(unsigned int i = 0; i < m_ppiTradeRouteYieldChange.size(); ++i) { m_ppiTradeRouteYieldChange[i] = yield; } - + m_ppiGreatPersonExpendedYield.clear(); m_ppiGreatPersonExpendedYield.resize(GC.getNumGreatPersonInfos()); for(unsigned int i = 0; i < m_ppiGreatPersonExpendedYield.size(); ++i) { m_ppiGreatPersonExpendedYield[i] = yield; } - + m_piGoldenAgeGreatPersonRateModifier.clear(); m_piGoldenAgeGreatPersonRateModifier.resize(GC.getNumGreatPersonInfos(), 0); @@ -2287,14 +2261,14 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) { m_ppiUnimprovedFeatureYieldChange[i] = yield; } - + m_ppiCityYieldFromUnimprovedFeature.clear(); m_ppiCityYieldFromUnimprovedFeature.resize(GC.getNumFeatureInfos()); for(unsigned int i = 0; i < m_ppiCityYieldFromUnimprovedFeature.size(); ++i) { m_ppiCityYieldFromUnimprovedFeature[i] = yield; } - + m_piYieldFromKills.clear(); m_piYieldFromKills.resize(NUM_YIELD_TYPES, 0); @@ -2365,29 +2339,15 @@ void CvPlayer::reset(PlayerTypes eID, bool bConstructorCall) /// This is called after the map and other game constructs have been setup and just before the game starts. void CvPlayer::gameStartInit() { -#if defined(MOD_BALANCE_CORE) //make sure the non-serialized infos are up to date m_pDangerPlots->Init(GetID(), true); -#else - // if the game is loaded, don't init the danger plots. This was already done in the serialization process. - if(CvPreGame::gameStartType() != GAME_LOADED) - { - if(!GC.GetEngineUserInterface()->IsLoadedGame()) - { - InitDangerPlots(); // moved this up because everyone should have danger plots inited. This is bad because saved games get much bigger for no reason. - } - } -#endif + verifyAlive(); - if(!isAlive()) - { + if (!isAlive()) return; - } - if(!GC.GetEngineUserInterface()->IsLoadedGame()) - { + if (!GC.GetEngineUserInterface()->IsLoadedGame()) UpdatePlots(); - } if (GC.getGame().isNetworkMultiPlayer()) { @@ -2503,9 +2463,6 @@ void CvPlayer::initFreeUnits() for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (!pkUnitClassInfo) - continue; UnitTypes eUnit = GetSpecificUnitType(eUnitClass); if (eUnit == NO_UNIT) @@ -2566,9 +2523,8 @@ void CvPlayer::initFreeUnits() } // Trait units - UnitClassTypes eUnitClass = (UnitClassTypes)GetPlayerTraits()->GetFirstFreeUnit(NO_TECH); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - while (eUnitClass != NO_UNITCLASS && pkUnitClassInfo) + UnitClassTypes eUnitClass = static_cast(GetPlayerTraits()->GetFirstFreeUnit(NO_TECH)); + while (eUnitClass != NO_UNITCLASS) { UnitTypes eUnit = GetSpecificUnitType(eUnitClass); CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit); @@ -2579,8 +2535,7 @@ void CvPlayer::initFreeUnits() } // Another? - eUnitClass = (UnitClassTypes)GetPlayerTraits()->GetNextFreeUnit(); - pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); + eUnitClass = static_cast(GetPlayerTraits()->GetNextFreeUnit()); } // Add Workers @@ -2699,13 +2654,6 @@ void CvPlayer::addFreeUnitAI(UnitAITypes eUnitAI, bool bGameStart, int iCount) for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - if (eUnitClass == NO_UNITCLASS) - continue; - - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (!pkUnitClassInfo) - continue; - UnitTypes eLoopUnit = GetSpecificUnitType(eUnitClass); if (eLoopUnit == NO_UNIT) continue; @@ -2714,34 +2662,10 @@ void CvPlayer::addFreeUnitAI(UnitAITypes eUnitAI, bool bGameStart, int iCount) if (!pkUnitInfo) continue; - if (canTrainUnit(eLoopUnit) || (bGameStart && pkUnitInfo->IsFound())) + // Starting Settler is the only unit that doesn't require a canTrainUnit check + bool bIsSettler = (pkUnitInfo->GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_SETTLER")); + if ((bGameStart && bIsSettler) || canTrainUnit(eLoopUnit)) { - if (!bGameStart || !pkUnitInfo->IsFound()) - { - // Unit can't require resources - bool bValid = true; - for (int iJ = 0; iJ < GC.getNumResourceInfos(); iJ++) - { - const ResourceTypes eResource = static_cast(iJ); - CvResourceInfo* pkResource = GC.getResourceInfo(eResource); - if (pkResource) - { - if (pkUnitInfo->GetResourceQuantityRequirement(iJ) > 0) - { - bValid = false; - break; - } - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS && pkUnitInfo->GetResourceQuantityTotal(iJ) > 0) - { - bValid = false; - break; - } - } - } - if (!bValid) - continue; - } - int iValue = 0; // Default unit AI matches @@ -2800,10 +2724,6 @@ CvPlot* CvPlayer::addFreeUnit(UnitTypes eUnit, bool bGameStart, UnitAITypes eUni for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (!pkUnitClassInfo) - continue; - const UnitTypes eLocalUnit = GetSpecificUnitType(eUnitClass); if (eLocalUnit != NO_UNIT) { @@ -2816,7 +2736,7 @@ CvPlot* CvPlayer::addFreeUnit(UnitTypes eUnit, bool bGameStart, UnitAITypes eUni break; } } - } + } } } } @@ -2944,14 +2864,16 @@ CvPlot* CvPlayer::addFreeUnit(UnitTypes eUnit, bool bGameStart, UnitAITypes eUni if (!pNewUnit->jumpToNearestValidPlot()) { // Could not find a spot for the unit - pNewUnit->kill(false); + pNewUnit->kill(false); return NULL; } if (pCapital) { pCapital->addProductionExperience(pNewUnit); + pNewUnit->DoGreatPersonSpawnBonus(pCapital); } + // Remove XP bonuses from starting scouts else if (bGameStart && MOD_BALANCE_VP && pNewUnit->IsGainsXPFromScouting()) { @@ -2959,51 +2881,6 @@ CvPlot* CvPlayer::addFreeUnit(UnitTypes eUnit, bool bGameStart, UnitAITypes eUni pNewUnit->changeExperiencePercent(-pNewUnit->getExperiencePercent()); } - if (pNewUnit->isWLKTKDOnBirth()) - { - int iLoop = 0; - for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << pNewUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - if (pNewUnit->isGoldenAgeOnBirth()) - { - changeGoldenAgeTurns(getGoldenAgeLength()); - } - if (pNewUnit->isCultureBoost()) - { - int iValue = GetTotalJONSCulturePerTurn() * 4; - changeJONSCulture(iValue); - if (getCapitalCity()) - getCapitalCity()->ChangeJONSCultureStored(iValue); - - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << pNewUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << pNewUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pNewUnit->getX(), pNewUnit->getY(), -1); - } - } if (pNewUnit->getUnitInfo().IsSpreadReligion()) { ReligionTypes eReligion = GetReligions()->GetStateReligion(); @@ -3038,7 +2915,7 @@ CvCity* CvPlayer::initCity(int iX, int iY, bool bBumpUnits, bool bInitialFoundin return pNewCity; } -/// This player acquires a city. +/// This player acquires a city. /// bConquest is true if the city was directly captured by this player's units, and false otherwise. /// bGift is true if the city was gifted to the player (can be from a trade or from the Austria/Venice UAs; liberation does NOT count in this) /// bOriginally treats the city as if it was always owned by the acquiring player (can't be liberated later). However, this still counts as killing the old owner if they die. @@ -3187,10 +3064,10 @@ CvCity* CvPlayer::acquireCity(CvCity* pCity, bool bConquest, bool bGift, bool bO } else { - if (activePlayer.isObserver() || + if (activePlayer.isObserver() || (activePlayer.isAlive() && - pCity->isRevealed(activePlayer.getTeam(), false, false) && - GET_TEAM(activePlayer.getTeam()).isHasMet(GET_PLAYER(eOldOwner).getTeam()) && + pCity->isRevealed(activePlayer.getTeam(), false, false) && + GET_TEAM(activePlayer.getTeam()).isHasMet(GET_PLAYER(eOldOwner).getTeam()) && GET_TEAM(activePlayer.getTeam()).isHasMet(getTeam()))) { CvString strBuffer = GetLocalizedText("TXT_KEY_MISC_CITY_CAPTURED_BY", strName.GetCString(), getCivilizationShortDescriptionKey()); @@ -3379,7 +3256,7 @@ CvCity* CvPlayer::acquireCity(CvCity* pCity, bool bConquest, bool bGift, bool bO pOldOwnerDiploAI->SetPlayerReturnedHolyCity(GetID(), false); pOldOwnerDiploAI->SetMasterLiberatedMeFromVassalage(GetID(), false); pOldOwnerDiploAI->SetVassalagePeacefullyRevokedTurn(GetID(), -1); - + // Clear positive diplomatic values pOldOwnerDiploAI->SetNumCiviliansReturnedToMe(GetID(), 0); pOldOwnerDiploAI->SetNumLandmarksBuiltForMe(GetID(), 0); @@ -3509,7 +3386,7 @@ CvCity* CvPlayer::acquireCity(CvCity* pCity, bool bConquest, bool bGift, bool bO { Localization::String localizedText = Localization::Lookup("TXT_KEY_SCIENCE_BOOST_CONQUEST_ASSYRIA"); localizedText << pCity->getNameKey(); - chooseTech(1, localizedText.toUTF8()); + chooseTech(1, localizedText.toUTF8()); } } else @@ -3798,7 +3675,7 @@ CvCity* CvPlayer::acquireCity(CvCity* pCity, bool bConquest, bool bGift, bool bO //Did we cap what was originally a sassinid city? typedef std::pair Location; typedef std::tr1::array SassanidCityArray; - SassanidCityArray SassanidCities = + SassanidCityArray SassanidCities = { Location(87,17), //Ctesiphon Location(85,20), //Singara @@ -4535,7 +4412,7 @@ CvCity* CvPlayer::acquireCity(CvCity* pCity, bool bConquest, bool bGift, bool bO // Set the plots to the new owner. bool bBumpUnits = isMajorCiv(); - + for (size_t i = 0; i < ownedPlots.size(); i++) { ownedPlots[i]->setOwner(GetID(), pNewCity->GetID(), (bBumpUnits || ownedPlots[i]->isCity()), true); @@ -4995,7 +4872,7 @@ CvString CvPlayer::getNewCityName() const { if(iPlayersFound == iChosenPlayer) { - strName = GetBorrowedCityName(kPlayer.getCivilizationType()); + strName = GetBorrowedCityName(kPlayer.getCivilizationType()); break; } else @@ -5062,7 +4939,7 @@ CvString CvPlayer::GetBorrowedCityName(CivilizationTypes eCivToBorrowFrom) const { int iRange = pCivInfo->getNumCityNames() - RESERVE_TOP_X_NAMES; int iRandOffset = GC.getGame().getJonRandNum(iRange, "Random City Name To Steal"); - for(int iI = 0; iI < iRange; iI++) + for(int iI = 0; iI < iRange; iI++) { CvString strCityName = pCivInfo->getCityNames(RESERVE_TOP_X_NAMES + ((iI + iRandOffset) % iRange)); szRtnValue = GetLocalizedText(strCityName.c_str()); @@ -5196,17 +5073,14 @@ int CvPlayer::getBuyPlotDistance() const int CvPlayer::getWorkPlotDistance() const { int iDistance = /*3*/ GD_INT_GET(MAXIMUM_WORK_PLOT_DISTANCE); - -#if defined(MOD_TRAITS_CITY_WORKING) || defined(MOD_BUILDINGS_CITY_WORKING) || defined(MOD_POLICIES_CITY_WORKING) + // Change distance based on traits, policies, wonders, etc iDistance += GetCityWorkingChange(); -#endif -#if defined(MOD_TECHS_CITY_WORKING) + // Change distance based on techs, etc - if (getTeam()!=NO_TEAM) + if (getTeam() != NO_TEAM) iDistance += GET_TEAM(getTeam()).GetCityWorkingChange(); -#endif - + return std::min(MAX_CITY_RADIUS, std::max(MIN_CITY_RADIUS, iDistance)); } @@ -5288,7 +5162,7 @@ void CvPlayer::UpdateCityThreatCriteria() // Is this a focused city? If so, we need to support it ASAP. if (GetTacticalAI()->IsInFocusArea(pLoopCity->plot())) iThreatValue += /*125*/ GD_INT_GET(AI_MILITARY_CITY_THREAT_WEIGHT_CAPITAL); - + //check the wider area for enemy tiles. may also be on another landmass for(int i=RING2_PLOTS; igetYieldMinimum(eYield); iNeededYield *= GC.getGame().getGameSpeedInfo().getInstantYieldPercent(); iNeededYield /= 100; @@ -6843,7 +6717,7 @@ bool CvPlayer::IsEventChoiceValid(EventChoiceTypes eChosenEventChoice, EventType YieldTypes eYield = (YieldTypes)iI; if(eYield == NO_YIELD) continue; - + int iNeededYield = pkEventInfo->getYieldMinimum(eYield); if(pkEventInfo->getPreCheckEventYield(eYield) != 0) { @@ -6935,7 +6809,7 @@ void CvPlayer::DoStartEvent(EventTypes eChosenEvent, bool bSendMsg) { //Set true so we know we're doing an event right now. SetEventActive(eChosenEvent, true); - + //Set oneshot stuff so this event can't fire ever again. if(pkEventInfo->isOneShot()) { @@ -7007,7 +6881,7 @@ void CvPlayer::DoStartEvent(EventTypes eChosenEvent, bool bSendMsg) else { //Lua Hook - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_OverrideAIEvent, GetID(), eChosenEvent) == GAMEEVENTRETURN_TRUE) + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_OverrideAIEvent, GetID(), eChosenEvent) == GAMEEVENTRETURN_TRUE) { return; } @@ -7047,7 +6921,7 @@ void CvPlayer::DoCancelEventChoice(EventChoiceTypes eChosenEventChoice) } //Let's make sure this is at zero. ChangeEventChoiceDuration(eChosenEventChoice, -GetEventChoiceDuration(eChosenEventChoice)); - + //Let's only deduct if we actually started this event and it expires. if(IsEventChoiceActive(eChosenEventChoice) && pkEventChoiceInfo->Expires()) { @@ -7074,11 +6948,11 @@ void CvPlayer::DoCancelEventChoice(EventChoiceTypes eChosenEventChoice) if(eBuildingClass != -1) { const CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass); - + if (pkBuildingClassInfo) { CvCivilizationInfo* pCivilizationInfo = GC.getCivilizationInfo(getCivilizationType()); - + if (pCivilizationInfo != NULL) { BuildingTypes eBuildingType = NO_BUILDING; @@ -7511,7 +7385,7 @@ CvString CvPlayer::GetScaledHelpText(EventChoiceTypes eEventChoice, bool bYields CvString yieldInstantTip = ""; CvString yieldCityTip = ""; CvString turnsTip = ""; - + for(int iI = 0; iI < NUM_YIELD_TYPES; iI++) { YieldTypes eIndex = (YieldTypes)iI; @@ -7876,7 +7750,7 @@ CvString CvPlayer::GetDisabledTooltip(EventChoiceTypes eChosenEventChoice) localizedDurationText = Localization::Lookup("TXT_KEY_NEED_OTHER_PLAYER_EVENT_ACTIVE"); } else - { + { localizedDurationText = Localization::Lookup("TXT_KEY_NEED_ACTIVE_EVENT"); } } @@ -7889,7 +7763,7 @@ CvString CvPlayer::GetDisabledTooltip(EventChoiceTypes eChosenEventChoice) else { localizedDurationText = Localization::Lookup("TXT_KEY_NEED_NO_ACTIVE_PLAYER_EVENT"); - + } } localizedDurationText << GC.getEventInfo(eLinkerEvent)->GetDescription(); @@ -8320,7 +8194,7 @@ CvString CvPlayer::GetDisabledTooltip(EventChoiceTypes eChosenEventChoice) YieldTypes eYield = (YieldTypes)iI; if(eYield == NO_YIELD) continue; - + int iNeededYield = pkEventInfo->getYieldMinimum(eYield); if(pkEventInfo->getPreCheckEventYield(eYield) != 0) { @@ -8446,11 +8320,11 @@ void CvPlayer::DoEventSyncChoices(EventChoiceTypes eEventChoice, CvCity* pCity) if(eBuildingClass != NO_BUILDINGCLASS) { const CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass); - + if (pkBuildingClassInfo) { CvCivilizationInfo* pCivilizationInfo = GC.getCivilizationInfo(getCivilizationType()); - + if (pCivilizationInfo != NULL) { BuildingTypes eBuildingType = NO_BUILDING; @@ -8862,7 +8736,7 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b YieldTypes eYield = (YieldTypes)iI; if(eYield == NO_YIELD) continue; - + int iPassYield = pkEventChoiceInfo->getPreCheckEventYield(eYield); if(iPassYield != 0) { @@ -8940,11 +8814,11 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b if(eBuildingClass != NO_BUILDINGCLASS) { const CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass); - + if (pkBuildingClassInfo) { CvCivilizationInfo* pCivilizationInfo = GC.getCivilizationInfo(getCivilizationType()); - + if (pCivilizationInfo != NULL) { BuildingTypes eBuildingType = NO_BUILDING; @@ -8952,7 +8826,7 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b { eBuildingType = (BuildingTypes)pCivilizationInfo->getCivilizationBuildings(eBuildingClass); } - + if (MOD_BUILDINGS_THOROUGH_PREREQUISITES || eBuildingType != NO_BUILDING) { int iLoop = 0; @@ -9142,7 +9016,7 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b } } } - + int iPassYield = pkEventChoiceInfo->getEventYield(eYield); if(iPassYield != 0) { @@ -9364,7 +9238,7 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b continue; } - GC.getGame().DoSpawnUnitsAroundTargetCity(GetID(), pLoopCity, iNumRecruits, false, pLoopCity->isCoastal(), false, true); + pLoopCity->SpawnPlayerUnitsNearby(GetID(), iNumRecruits, true, pLoopCity->isCoastal()); } } } @@ -9390,46 +9264,39 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b for(int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - if(pkEventChoiceInfo->getNumFreeUnits((UnitClassTypes)iI) <= 0) - continue; + if (pkEventChoiceInfo->getNumFreeUnits(eUnitClass) <= 0) + continue; - const UnitTypes eLoopUnit = GetSpecificUnitType(eUnitClass); - if(eLoopUnit != NO_UNIT) + const UnitTypes eLoopUnit = GetSpecificUnitType(eUnitClass); + if (eLoopUnit != NO_UNIT) + { + CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eLoopUnit); + if (pkUnitEntry) { - CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eLoopUnit); - if(pkUnitEntry) + int iLoop = 0; + for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { - int iLoop = 0; - for(CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) + if (pkEventChoiceInfo->isCoastalOnly() && !pLoopCity->isCoastal()) + continue; + + if (pkEventChoiceInfo->isCapitalEffectOnly() && !pLoopCity->isCapital()) + continue; + + for (int iJ = 0; iJ < pkEventChoiceInfo->getNumFreeUnits(eUnitClass); iJ++) { - if(pkEventChoiceInfo->isCoastalOnly() && !pLoopCity->isCoastal()) - { - continue; - } - if(pkEventChoiceInfo->isCapitalEffectOnly() && !pLoopCity->isCapital()) - { - continue; - } - for(int iJ = 0; iJ < pkEventChoiceInfo->getNumFreeUnits((UnitClassTypes)iI); iJ++) + UnitAITypes eUnitAI = pkUnitEntry->GetDefaultUnitAIType(); + CvUnit* pUnit = pLoopCity->CreateUnit(eLoopUnit, eUnitAI, REASON_GIFT); + if (pUnit) { - UnitAITypes eUnitAI = pkUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pLoopCity->CreateUnit(eLoopUnit, eUnitAI, REASON_GIFT); - - if (pUnit) + if (!pUnit->jumpToNearestValidPlot()) { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - else - { - pUnit->finishMoves(); - //Lua Hook - GAMEEVENTINVOKE_HOOK(GAMEEVENT_EventUnitCreated, GetID(), eEventChoice, pUnit); - } + pUnit->kill(false); // Could not find a valid spot! + } + else + { + pUnit->finishMoves(); + //Lua Hook + GAMEEVENTINVOKE_HOOK(GAMEEVENT_EventUnitCreated, GetID(), eEventChoice, pUnit); } } } @@ -9441,27 +9308,25 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b { const UnitTypes eUnit = static_cast(iI); CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eUnit); - if(pkUnitEntry) + if (pkUnitEntry) { - if(pkEventChoiceInfo->getNumFreeSpecificUnits((UnitTypes)iI) <= 0) + if (pkEventChoiceInfo->getNumFreeSpecificUnits(eUnit) <= 0) continue; - - for(int iJ = 0; iJ < pkEventChoiceInfo->getNumFreeSpecificUnits((UnitTypes)iI); iJ++) + + for (int iJ = 0; iJ < pkEventChoiceInfo->getNumFreeSpecificUnits(eUnit); iJ++) { UnitAITypes eUnitAI = pkUnitEntry->GetDefaultUnitAIType(); int iLoop = 0; - for(CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) + for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { - if(pLoopCity != NULL) + if (pLoopCity != NULL) { - if(pkEventChoiceInfo->isCoastalOnly() && !pLoopCity->isCoastal()) - { + if (pkEventChoiceInfo->isCoastalOnly() && !pLoopCity->isCoastal()) continue; - } - if(pkEventChoiceInfo->isCapitalEffectOnly() && !pLoopCity->isCapital()) - { + + if (pkEventChoiceInfo->isCapitalEffectOnly() && !pLoopCity->isCapital()) continue; - } + CvUnit* pUnit = pLoopCity->CreateUnit(eUnit, eUnitAI, REASON_GIFT); if (pUnit) { @@ -9563,11 +9428,11 @@ void CvPlayer::DoEventChoice(EventChoiceTypes eEventChoice, EventTypes eEvent, b //Let's do our notification stuff here. for(int iI = 0; iI < pkEventChoiceInfo->GetNumNotifications(); iI++) { - CvString strNotificationString = pkEventChoiceInfo->GetNotificationInfo(iI)->GetNotificationString(); + CvString strNotificationString = pkEventChoiceInfo->GetNotificationInfo(iI)->GetNotificationString(); if(strNotificationString != NULL && !strNotificationString.empty()) { NotificationTypes eNotificationType = (NotificationTypes)FString::Hash(strNotificationString); - + if(eNotificationType != NO_NOTIFICATION_TYPE) { Localization::String strMessage; @@ -9666,15 +9531,19 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce return; } + CvPlayer& kPlayer = GET_PLAYER(ePlayer); + // Set that this team has been liberated TeamTypes eTeam = getTeam(); - TeamTypes eLiberatedTeam = GET_PLAYER(ePlayer).getTeam(); + TeamTypes eLiberatedTeam = kPlayer.getTeam(); + CvTeam& kTeam = GET_TEAM(eTeam); + CvTeam& kLiberatedTeam = GET_TEAM(eLiberatedTeam); // Who originally took out this team? - TeamTypes eConquerorTeam = GET_TEAM(eLiberatedTeam).GetKilledByTeam(); + TeamTypes eConquerorTeam = kLiberatedTeam.GetKilledByTeam(); - CvDiplomacyAI* pDiploAI = GET_PLAYER(ePlayer).GetDiplomacyAI(); - bool bAlive = GET_PLAYER(ePlayer).isAlive(); + CvDiplomacyAI* pDiploAI = kPlayer.GetDiplomacyAI(); + bool bAlive = kPlayer.isAlive(); // If they aren't alive, start the resurrection process if (!bAlive) @@ -9682,50 +9551,51 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce // Mark the liberators if (!bForced && !bSphereRemoval) { - GET_TEAM(eLiberatedTeam).SetLiberatedByTeam(eTeam); + kLiberatedTeam.SetLiberatedByTeam(eTeam); } // Put everyone at peace with this guy for (int iOtherTeamLoop = 0; iOtherTeamLoop < MAX_CIV_TEAMS; iOtherTeamLoop++) { - if (eLiberatedTeam != iOtherTeamLoop) + TeamTypes eOtherTeam = static_cast(iOtherTeamLoop); + if (eLiberatedTeam != eOtherTeam) { - GET_TEAM(eLiberatedTeam).makePeace((TeamTypes)iOtherTeamLoop, /*bBumpUnits*/false, /*bSuppressNotification*/true, GetID()); + kLiberatedTeam.makePeace(eOtherTeam, /*bBumpUnits*/ false, /*bSuppressNotification*/ true, GetID()); } } } // Diplo bonus for returning the city - if (!bForced && GET_PLAYER(ePlayer).isMajorCiv()) + if (!bForced && kPlayer.isMajorCiv()) { // Liberated the capital - big diplo bonus! - if (pCity->getX() == GET_PLAYER(ePlayer).GetOriginalCapitalX() && pCity->getY() == GET_PLAYER(ePlayer).GetOriginalCapitalY()) + if (pCity->getX() == kPlayer.GetOriginalCapitalX() && pCity->getY() == kPlayer.GetOriginalCapitalY()) { - pDiploAI->SetPlayerLiberatedCapital(m_eID, true); + pDiploAI->SetPlayerLiberatedCapital(GetID(), true); } // Liberated the Holy City - big bonus IF the Holy City status still remains - if (GET_PLAYER(ePlayer).IsHasLostHolyCity() && pCity->GetCityReligions()->IsHolyCityForReligion(GET_PLAYER(ePlayer).GetReligions()->GetOriginalReligionCreatedByPlayer())) + if (kPlayer.IsHasLostHolyCity() && pCity->GetCityReligions()->IsHolyCityForReligion(kPlayer.GetReligions()->GetOriginalReligionCreatedByPlayer())) { - pDiploAI->SetPlayerLiberatedHolyCity(m_eID, true); + pDiploAI->SetPlayerLiberatedHolyCity(GetID(), true); } - pDiploAI->ChangeNumCitiesLiberatedBy(m_eID, 1); + pDiploAI->ChangeNumCitiesLiberatedBy(GetID(), 1); } // Give the city back to the liberated player - CvCity* pNewCity = GET_PLAYER(ePlayer).acquireCity(pCity, false, false, false); + CvCity* pNewCity = kPlayer.acquireCity(pCity, false, false, false); if (!pNewCity) return; - //do not use this anymore! + // DO NOT USE THIS ANYMORE! pCity = NULL; // Now verify that the player is alive - GET_PLAYER(ePlayer).verifyAlive(); + kPlayer.verifyAlive(); // Process other diplomatic consequences if a major was liberated - if (!bForced && GET_PLAYER(ePlayer).isMajorCiv()) + if (!bForced && kPlayer.isMajorCiv()) { // Player was alive? Just notify that a city was liberated. if (bAlive) @@ -9740,23 +9610,23 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce strMessage << getNameKey(); } strMessage << pNewCity->getNameKey(); // CITY NAME - strMessage << GET_PLAYER(ePlayer).getCivilizationShortDescriptionKey();// RESTORED CIV NAME + strMessage << kPlayer.getCivilizationShortDescriptionKey();// RESTORED CIV NAME Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_CIV_LIBERATED_SHORT"); strSummary << pNewCity->getNameKey(); - if (GC.getGame().isGameMultiPlayer() && GET_PLAYER(ePlayer).isHuman()) + if (GC.getGame().isGameMultiPlayer() && kPlayer.isHuman()) { - strSummary << GET_PLAYER(ePlayer).getNickName(); + strSummary << kPlayer.getNickName(); } else { - strSummary << GET_PLAYER(ePlayer).getNameKey(); + strSummary << kPlayer.getNameKey(); } for (int iI = 0; iI < MAX_MAJOR_CIVS; iI++) { - CvPlayerAI& kOtherPlayer = GET_PLAYER((PlayerTypes)iI); - if (iI == m_eID) + CvPlayerAI& kOtherPlayer = GET_PLAYER(static_cast(iI)); + if (iI == GetID()) continue; if (!kOtherPlayer.isObserver()) @@ -9772,133 +9642,134 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce kOtherPlayer.GetNotifications()->Add(NOTIFICATION_LIBERATED_MAJOR_CITY, strMessage.toUTF8(), strSummary.toUTF8(), pNewCity->getX(), pNewCity->getY(), -1); } } - // Player was dead? Huge diplo bonuses! else { - for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++) + CivsList veMembers = kTeam.getPlayers(); + for (CivsList::iterator it = veMembers.begin(); it != veMembers.end(); ++it) { - PlayerTypes eMyTeamPlayer = (PlayerTypes) iPlayerLoop; + if (kPlayer.GetDiplomacyAI()->IsResurrectorAttackedUs(*it)) + continue; - if (GET_PLAYER(eMyTeamPlayer).getTeam() == getTeam() && !GET_PLAYER(ePlayer).GetDiplomacyAI()->IsResurrectorAttackedUs(eMyTeamPlayer)) - { - pDiploAI->SetResurrectedBy(eMyTeamPlayer, true); + CvPlayer& kMember = GET_PLAYER(*it); + CvDiplomacyAI* pMemberDiploAI = kMember.GetDiplomacyAI(); - pDiploAI->SetLandDisputeLevel(eMyTeamPlayer, DISPUTE_LEVEL_NONE); - pDiploAI->SetWonderDisputeLevel(eMyTeamPlayer, DISPUTE_LEVEL_NONE); - pDiploAI->SetMinorCivDisputeLevel(eMyTeamPlayer, DISPUTE_LEVEL_NONE); - pDiploAI->SetVictoryDisputeLevel(eMyTeamPlayer, DISPUTE_LEVEL_NONE); - pDiploAI->SetVictoryBlockLevel(eMyTeamPlayer, BLOCK_LEVEL_NONE); - pDiploAI->SetTechBlockLevel(eMyTeamPlayer, BLOCK_LEVEL_NONE); - pDiploAI->SetPolicyBlockLevel(eMyTeamPlayer, BLOCK_LEVEL_NONE); + pDiploAI->SetResurrectedBy(*it, true); - pDiploAI->SetWarmongerThreat(eMyTeamPlayer, THREAT_NONE); - pDiploAI->SetOtherPlayerWarmongerAmountTimes100(eMyTeamPlayer, 0); - - pDiploAI->SetNumDemandsMade(eMyTeamPlayer, 0); + pDiploAI->SetLandDisputeLevel(*it, DISPUTE_LEVEL_NONE); + pDiploAI->SetWonderDisputeLevel(*it, DISPUTE_LEVEL_NONE); + pDiploAI->SetMinorCivDisputeLevel(*it, DISPUTE_LEVEL_NONE); + pDiploAI->SetVictoryDisputeLevel(*it, DISPUTE_LEVEL_NONE); + pDiploAI->SetVictoryBlockLevel(*it, BLOCK_LEVEL_NONE); + pDiploAI->SetTechBlockLevel(*it, BLOCK_LEVEL_NONE); + pDiploAI->SetPolicyBlockLevel(*it, BLOCK_LEVEL_NONE); - if (pDiploAI->GetCoopWarScore(eMyTeamPlayer) < 0) - { - pDiploAI->SetCoopWarScore(eMyTeamPlayer, 0); - } + pDiploAI->SetWarmongerThreat(*it, THREAT_NONE); + pDiploAI->SetOtherPlayerWarmongerAmountTimes100(*it, 0); - if (GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->GetCoopWarScore(ePlayer) < 0) - { - pDiploAI->SetCoopWarScore(ePlayer, 0); - } - - // Forget war history - pDiploAI->SetNumWarsDeclaredOnUs(eMyTeamPlayer, 0); - pDiploAI->SetNumCitiesCapturedBy(eMyTeamPlayer, 0); - pDiploAI->SetNumTradeRoutesPlundered(eMyTeamPlayer, 0); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetNumWarsDeclaredOnUs(ePlayer, 0); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetNumCitiesCapturedBy(ePlayer, 0); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetNumTradeRoutesPlundered(ePlayer, 0); - - pDiploAI->SetNumArtifactsEverDugUp(eMyTeamPlayer, 0); - pDiploAI->SetEverConvertedCity(eMyTeamPlayer, false); - - pDiploAI->SetNumTimesTheyPlottedAgainstUs(eMyTeamPlayer, 0); - pDiploAI->SetNumTimesTheyLoweredOurInfluence(eMyTeamPlayer, 0); - pDiploAI->SetNumTimesPerformedCoupAgainstUs(eMyTeamPlayer, 0); - pDiploAI->SetNumTimesCultureBombed(eMyTeamPlayer, 0); - pDiploAI->SetNegativeReligiousConversionPoints(eMyTeamPlayer, 0); - pDiploAI->SetNegativeArchaeologyPoints(eMyTeamPlayer, 0); - pDiploAI->SetNumTimesRobbedBy(eMyTeamPlayer, 0); - - // Reset all promises - pDiploAI->SetPlayerMilitaryPromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerExpansionPromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerBorderPromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerBullyCityStatePromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerAttackCityStatePromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerSpyPromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerNoConvertPromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerNoDiggingPromiseState(eMyTeamPlayer, NO_PROMISE_STATE); - pDiploAI->SetPlayerBrokenCoopWarPromise(eMyTeamPlayer, false); + pDiploAI->SetNumDemandsMade(*it, 0); + + if (pDiploAI->GetCoopWarScore(*it) < 0) + { + pDiploAI->SetCoopWarScore(*it, 0); + } - pDiploAI->SetOtherPlayerNumProtectedMinorsKilled(eMyTeamPlayer, 0); - pDiploAI->SetOtherPlayerNumProtectedMinorsAttacked(eMyTeamPlayer, 0); - pDiploAI->SetOtherPlayerNumProtectedMinorsBullied(eMyTeamPlayer, 0); - pDiploAI->SetOtherPlayerSidedWithProtectedMinorTurn(eMyTeamPlayer, -1); + if (pMemberDiploAI->GetCoopWarScore(ePlayer) < 0) + { + pDiploAI->SetCoopWarScore(ePlayer, 0); + } - pDiploAI->SetDoFBroken(eMyTeamPlayer, false, true); - pDiploAI->SetFriendDenouncedUs(eMyTeamPlayer, false); // clear backstabbing penalties - pDiploAI->SetFriendDeclaredWarOnUs(eMyTeamPlayer, false); // clear backstabbing penalties - pDiploAI->SetDenouncedPlayer(eMyTeamPlayer, false); // forget any denouncing - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetDenouncedPlayer(ePlayer, false); // forget any denouncing + // Forget war history + pDiploAI->SetNumWarsDeclaredOnUs(*it, 0); + pDiploAI->SetNumCitiesCapturedBy(*it, 0); + pDiploAI->SetNumTradeRoutesPlundered(*it, 0); + pMemberDiploAI->SetNumWarsDeclaredOnUs(ePlayer, 0); + pMemberDiploAI->SetNumCitiesCapturedBy(ePlayer, 0); + pMemberDiploAI->SetNumTradeRoutesPlundered(ePlayer, 0); - pDiploAI->SetNumTimesNuked(eMyTeamPlayer, 0); + pDiploAI->SetNumArtifactsEverDugUp(*it, 0); + pDiploAI->SetEverConvertedCity(*it, false); - pDiploAI->SetWeDislikedTheirProposalTurn(eMyTeamPlayer, -1); - pDiploAI->SetTheyFoiledOurProposalTurn(eMyTeamPlayer, -1); + pDiploAI->SetNumTimesTheyPlottedAgainstUs(*it, 0); + pDiploAI->SetNumTimesTheyLoweredOurInfluence(*it, 0); + pDiploAI->SetNumTimesPerformedCoupAgainstUs(*it, 0); + pDiploAI->SetNumTimesCultureBombed(*it, 0); + pDiploAI->SetNegativeReligiousConversionPoints(*it, 0); + pDiploAI->SetNegativeArchaeologyPoints(*it, 0); + pDiploAI->SetNumTimesRobbedBy(*it, 0); - if (pDiploAI->GetLikedTheirProposalValue(eMyTeamPlayer) > 0) - { - pDiploAI->SetLikedTheirProposalValue(eMyTeamPlayer, 0); - } - if (pDiploAI->GetSupportedOurProposalValue(eMyTeamPlayer) > 0) - { - pDiploAI->SetSupportedOurProposalValue(eMyTeamPlayer, 0); - } - if (pDiploAI->GetVotingHistoryScore(eMyTeamPlayer) < 0) - { - pDiploAI->SetVotingHistoryScore(eMyTeamPlayer, 0); - } - pDiploAI->SetTheySanctionedUsTurn(eMyTeamPlayer, -1); - pDiploAI->SetEverSanctionedUs(eMyTeamPlayer, false); + // Reset all promises + pDiploAI->SetPlayerMilitaryPromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerExpansionPromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerBorderPromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerBullyCityStatePromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerAttackCityStatePromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerSpyPromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerNoConvertPromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerNoDiggingPromiseState(*it, NO_PROMISE_STATE); + pDiploAI->SetPlayerBrokenCoopWarPromise(*it, false); - pDiploAI->SetVassalageForcefullyRevokedTurn(eMyTeamPlayer, -1); - pDiploAI->SetPlayerBrokenVassalAgreement(eMyTeamPlayer, false); + pDiploAI->SetOtherPlayerNumProtectedMinorsKilled(*it, 0); + pDiploAI->SetOtherPlayerNumProtectedMinorsAttacked(*it, 0); + pDiploAI->SetOtherPlayerNumProtectedMinorsBullied(*it, 0); + pDiploAI->SetOtherPlayerSidedWithProtectedMinorTurn(*it, -1); - // Clear this player's backstabbing penalties - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetDoFBroken(ePlayer, false, true); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetFriendDenouncedUs(ePlayer, false); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetFriendDeclaredWarOnUs(ePlayer, false); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetVassalageForcefullyRevokedTurn(ePlayer, -1); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetPlayerBrokenVassalAgreement(ePlayer, false); + pDiploAI->SetDoFBroken(*it, false, true); + pDiploAI->SetFriendDenouncedUs(*it, false); // clear backstabbing penalties + pDiploAI->SetFriendDeclaredWarOnUs(*it, false); // clear backstabbing penalties + pDiploAI->SetDenouncedPlayer(*it, false); // forget any denouncing + pMemberDiploAI->SetDenouncedPlayer(ePlayer, false); // forget any denouncing - // Clear backstabbing mark - pDiploAI->SetBackstabbedBy(eMyTeamPlayer, false, false); - GET_PLAYER(eMyTeamPlayer).GetDiplomacyAI()->SetBackstabbedBy(ePlayer, false, false); + pDiploAI->SetNumTimesNuked(*it, 0); + + pDiploAI->SetWeDislikedTheirProposalTurn(*it, -1); + pDiploAI->SetTheyFoiledOurProposalTurn(*it, -1); + + if (pDiploAI->GetLikedTheirProposalValue(*it) > 0) + { + pDiploAI->SetLikedTheirProposalValue(*it, 0); + } + if (pDiploAI->GetSupportedOurProposalValue(*it) > 0) + { + pDiploAI->SetSupportedOurProposalValue(*it, 0); + } + if (pDiploAI->GetVotingHistoryScore(*it) < 0) + { + pDiploAI->SetVotingHistoryScore(*it, 0); } + pDiploAI->SetTheySanctionedUsTurn(*it, -1); + pDiploAI->SetEverSanctionedUs(*it, false); + + pDiploAI->SetVassalageForcefullyRevokedTurn(*it, -1); + pDiploAI->SetPlayerBrokenVassalAgreement(*it, false); + + // Clear this player's backstabbing penalties + pMemberDiploAI->SetDoFBroken(ePlayer, false, true); + pMemberDiploAI->SetFriendDenouncedUs(ePlayer, false); + pMemberDiploAI->SetFriendDeclaredWarOnUs(ePlayer, false); + pMemberDiploAI->SetVassalageForcefullyRevokedTurn(ePlayer, -1); + pMemberDiploAI->SetPlayerBrokenVassalAgreement(ePlayer, false); + + // Clear backstabbing mark + pDiploAI->SetBackstabbedBy(*it, false, false); + pMemberDiploAI->SetBackstabbedBy(ePlayer, false, false); } // Resurrected civ becomes a vassal of the resurrector, if possible - if (GET_TEAM(eLiberatedTeam).GetLiberatedByTeam() != eConquerorTeam && !IsVassalOfSomeone() && GD_INT_GET(DIPLOAI_DISABLE_VOLUNTARY_VASSALAGE) == 0) + if (kLiberatedTeam.GetLiberatedByTeam() != eConquerorTeam && !IsVassalOfSomeone() && GD_INT_GET(DIPLOAI_DISABLE_VOLUNTARY_VASSALAGE) == 0) { - if (!GET_TEAM(GET_PLAYER(ePlayer).getTeam()).IsVassal(getTeam())) + if (!kLiberatedTeam.IsVassal(getTeam())) { - GET_TEAM(GET_PLAYER(ePlayer).getTeam()).SetNumTurnsIsVassal(-1); - GET_TEAM(GET_PLAYER(ePlayer).getTeam()).SetNumTurnsSinceVassalEnded(getTeam(), -1); - GET_TEAM(GET_PLAYER(ePlayer).getTeam()).DoBecomeVassal(getTeam(), true, GetID()); + kLiberatedTeam.SetNumTurnsIsVassal(-1); + kLiberatedTeam.SetNumTurnsSinceVassalEnded(getTeam(), -1); + kLiberatedTeam.DoBecomeVassal(getTeam(), true, GetID()); } } // Add resurrection notification Localization::String strMessage; - if (GET_TEAM(eLiberatedTeam).GetMaster() == getTeam()) + if (kLiberatedTeam.GetMaster() == getTeam()) { strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_CIV_RESURRECTED_VOLUNTARY_VASSAL"); } @@ -9909,26 +9780,19 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce strMessage << getCivilizationShortDescriptionKey(); // LIBERATING CIV NAME strMessage << pNewCity->getNameKey(); // CITY NAME - strMessage << GET_PLAYER(ePlayer).getCivilizationAdjectiveKey(); // LIBERATED CIV NAME - strMessage << GET_PLAYER(ePlayer).getCivilizationDescriptionKey();// LIBERATED CIV NAME + strMessage << kPlayer.getCivilizationAdjectiveKey(); // LIBERATED CIV NAME + strMessage << kPlayer.getCivilizationDescriptionKey();// LIBERATED CIV NAME Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_CIV_RESURRECTED_SHORT"); - if (GC.getGame().isGameMultiPlayer() && GET_PLAYER(ePlayer).isHuman()) - { - strSummary << GET_PLAYER(ePlayer).getNickName(); - } + if (GC.getGame().isGameMultiPlayer() && kPlayer.isHuman()) + strSummary << kPlayer.getNickName(); else - { - strSummary << GET_PLAYER(ePlayer).getNameKey(); - } - if (GC.getGame().isGameMultiPlayer() && GET_PLAYER(m_eID).isHuman()) - { - strSummary << GET_PLAYER(m_eID).getNickName(); - } + strSummary << kPlayer.getNameKey(); + + if (GC.getGame().isGameMultiPlayer() && isHuman()) + strSummary << getNickName(); else - { - strSummary << GET_PLAYER(m_eID).getNameKey(); - } + strSummary << getNameKey(); for (int iI = 0; iI < MAX_MAJOR_CIVS; iI++) { @@ -9950,7 +9814,7 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce } CvString temp = strMessage.toUTF8(); - GC.getGame().addReplayMessage(REPLAY_MESSAGE_MAJOR_EVENT, m_eID, temp); + GC.getGame().addReplayMessage(REPLAY_MESSAGE_MAJOR_EVENT, GetID(), temp); } } @@ -9963,8 +9827,7 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce { for (IDInfoVector::const_iterator itr = currentUnits.begin(); itr != currentUnits.end(); ++itr) { - CvUnit* pLoopUnit = (CvUnit*)GetPlayerUnit(*itr); - + CvUnit* pLoopUnit = GetPlayerUnit(*itr); if (pLoopUnit && pLoopUnit->getOwner() != ePlayer) { pLoopUnit->finishMoves(); @@ -9976,20 +9839,18 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce } // If a City-State was liberated, adjust Influence levels and give the City-State a basic but state-of-the-art garrison - if (GET_PLAYER(ePlayer).isMinorCiv()) + if (kPlayer.isMinorCiv()) { if (bSphereRemoval) - GET_PLAYER(ePlayer).GetMinorCivAI()->SetFriendshipWithMajor(GetID(), /*0*/ GD_INT_GET(MINOR_REMOVE_SPHERE_FRIENDSHIP)); + kPlayer.GetMinorCivAI()->SetFriendshipWithMajor(GetID(), /*0*/ GD_INT_GET(MINOR_REMOVE_SPHERE_FRIENDSHIP)); else if (!bForced) - GET_PLAYER(ePlayer).GetMinorCivAI()->DoLiberationByMajor(eOldOwner, eConquerorTeam); + kPlayer.GetMinorCivAI()->DoLiberationByMajor(eOldOwner, eConquerorTeam); else - GET_PLAYER(ePlayer).GetMinorCivAI()->SetFriendshipWithMajor(GetID(), /*-60*/ GD_INT_GET(MINOR_FRIENDSHIP_AT_WAR)); + kPlayer.GetMinorCivAI()->SetFriendshipWithMajor(GetID(), /*-60*/ GD_INT_GET(MINOR_FRIENDSHIP_AT_WAR)); if (MOD_BALANCE_VP) { - UnitTypes eUnit = GC.getGame().GetCompetitiveSpawnUnitType(ePlayer, false, false, false, true, false, true, false, CvSeeder::fromRaw(0xb89fcc34).mix(GET_PLAYER(ePlayer).GetID()).mix(GetID())); - if (eUnit != NO_UNIT) - GET_PLAYER(ePlayer).initUnit(eUnit, pNewCity->getX(), pNewCity->getY()); + pNewCity->SpawnPlayerUnitsNearby(ePlayer, 1, false, false, false); } } @@ -10022,8 +9883,8 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce } // If liberating a City-State, increase Influence resting point - if (GET_PLAYER(ePlayer).isMinorCiv()) - GET_PLAYER(ePlayer).GetMinorCivAI()->ChangeRestingPointChange(GetID(), /*0 in CP, 100 in VP*/ GD_INT_GET(MINOR_LIBERATION_RESTING_INFLUENCE)); + if (kPlayer.isMinorCiv()) + kPlayer.GetMinorCivAI()->ChangeRestingPointChange(GetID(), /*0 in CP, 100 in VP*/ GD_INT_GET(MINOR_LIBERATION_RESTING_INFLUENCE)); } // Bonuses for liberation OR sphere removal @@ -10052,12 +9913,12 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce PlayerTypes eMinorLoop = (PlayerTypes)iMinorLoop; if (eMinorLoop != NO_PLAYER) { - CvPlayer* pMinorLoop = &GET_PLAYER(eMinorLoop); - if (pMinorLoop->isMinorCiv() && pMinorLoop->isAlive()) + CvPlayer& kMinorLoop = GET_PLAYER(eMinorLoop); + if (kMinorLoop.isMinorCiv() && kMinorLoop.isAlive()) { - if (GET_TEAM(pMinorLoop->getTeam()).isHasMet(getTeam())) + if (GET_TEAM(kMinorLoop.getTeam()).isHasMet(getTeam())) { - pMinorLoop->GetMinorCivAI()->ChangeFriendshipWithMajor(GetID(), iInfluence, false); + kMinorLoop.GetMinorCivAI()->ChangeFriendshipWithMajor(GetID(), iInfluence, false); } } } @@ -10083,36 +9944,29 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce //liberated city gets a building? for (int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++) { - if ((BuildingClassTypes)iI != NO_BUILDINGCLASS && getNumBuildingClassInLiberatedCities((BuildingClassTypes)iI) > 0) + BuildingClassTypes eBuildingClass = static_cast(iI); + int iNumBuilding = getNumBuildingClassInLiberatedCities(eBuildingClass); + if (iNumBuilding > 0) { - CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo((BuildingClassTypes)iI); - if (pkBuildingClassInfo) + BuildingTypes eBuilding = static_cast(getCivilizationInfo().getCivilizationBuildings(iI)); + if (eBuilding != NO_BUILDING) { - BuildingTypes eBuilding = ((BuildingTypes)(getCivilizationInfo().getCivilizationBuildings(pkBuildingClassInfo->GetID()))); - if (eBuilding != NO_BUILDING) - { - pNewCity->GetCityBuildings()->SetNumRealBuilding(eBuilding, getNumBuildingClassInLiberatedCities((BuildingClassTypes)iI)); - } + pNewCity->GetCityBuildings()->SetNumRealBuilding(eBuilding, iNumBuilding); } } } //liberated city gets units? int iNumUnit = getUnitsInLiberatedCities(); - if (iNumUnit > 0) + if (iNumUnit > 0) { - for (int i = 0; i < iNumUnit; i++) - { - UnitTypes eUnit = GC.getGame().GetCompetitiveSpawnUnitType(ePlayer, false, false, false, true, true, true, false, CvSeeder::fromRaw(0x47def5e9).mix(GET_PLAYER(ePlayer).GetID()).mix(GetID()).mix(i)); - if (eUnit != NO_UNIT) - GET_PLAYER(ePlayer).initUnit(eUnit, pNewCity->getX(), pNewCity->getY()); - } + pNewCity->SpawnPlayerUnitsNearby(ePlayer, iNumUnit, true, false, true); } } // Meet the team, if we haven't already - if (!GET_TEAM(getTeam()).isHasMet(GET_PLAYER(ePlayer).getTeam())) - GET_TEAM(getTeam()).makeHasMet(GET_PLAYER(ePlayer).getTeam(), true); + if (!GET_TEAM(getTeam()).isHasMet(eLiberatedTeam)) + GET_TEAM(getTeam()).makeHasMet(eLiberatedTeam, true); for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++) { @@ -10125,7 +9979,7 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce } // Update Proximity between the liberated player and all others - GET_PLAYER(ePlayer).DoUpdateProximityToPlayers(); + kPlayer.DoUpdateProximityToPlayers(); // Minor Civ quest test if (isMajorCiv()) @@ -10149,24 +10003,24 @@ void CvPlayer::DoLiberatePlayer(PlayerTypes ePlayer, int iOldCityID, bool bForce pDiploAI->DoReevaluateEveryone(true, false, true); } - vector v = GET_TEAM(GET_PLAYER(ePlayer).getTeam()).getPlayers(); + vector v = kLiberatedTeam.getPlayers(); GetDiplomacyAI()->DoReevaluatePlayers(v, false, !bAlive); - if (MOD_EVENTS_LIBERATION) + if (MOD_EVENTS_LIBERATION) { GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerLiberated, GetID(), ePlayer, pNewCity->GetID()); } //Let's give the Embassies of the defeated player back to the liberated player - if (GET_PLAYER(ePlayer).GetImprovementLeagueVotes() > 0) + if (kPlayer.GetImprovementLeagueVotes() > 0) { for (int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++) { ePlayer = (PlayerTypes) iPlayerLoop; - if (ePlayer != NO_PLAYER && GET_PLAYER(ePlayer).getTeam() == eConquerorTeam) + if (ePlayer != NO_PLAYER && eLiberatedTeam == eConquerorTeam) { - int iEmbassyVotes = GET_PLAYER(ePlayer).GetImprovementLeagueVotes(); - GET_PLAYER(ePlayer).ChangeImprovementLeagueVotes(-iEmbassyVotes); + int iEmbassyVotes = kPlayer.GetImprovementLeagueVotes(); + kPlayer.ChangeImprovementLeagueVotes(-iEmbassyVotes); } } } @@ -10266,9 +10120,7 @@ CvUnit* CvPlayer::initUnit(UnitTypes eUnit, int iX, int iY, UnitAITypes eUnitAI, return NULL; CvUnitEntry* pkUnitDef = GC.getUnitInfo(eUnit); - CvAssertFmt(pkUnitDef != NULL, "Trying to create unit of type %d, which does not exist", eUnit); - if (pkUnitDef == NULL) - return NULL; + CvAssertFmt(pkUnitDef, "Trying to create unit of type %d, which does not exist", eUnit); if (isMajorCiv() && pkUnitDef->IsMilitarySupport() && GetNumUnitsOutOfSupply() > 4 && eReason!=REASON_UPGRADE && eReason!=REASON_GIFT) { @@ -10276,19 +10128,12 @@ CvUnit* CvPlayer::initUnit(UnitTypes eUnit, int iX, int iY, UnitAITypes eUnitAI, } CvUnit* pUnit = addUnit(); - CvAssertMsg(pUnit != NULL, "Unit is not assigned a valid value"); - if(NULL != pUnit) - { - pUnit->init(pUnit->GetID(), eUnit, ((eUnitAI == NO_UNITAI) ? pkUnitDef->GetDefaultUnitAIType() : eUnitAI), GetID(), iX, iY, eReason, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped, eContract, bHistoric, pPassUnit); + CvAssertMsg(pUnit, "Unit is not assigned a valid value"); + pUnit->init(pUnit->GetID(), eUnit, ((eUnitAI == NO_UNITAI) ? pkUnitDef->GetDefaultUnitAIType() : eUnitAI), GetID(), iX, iY, eReason, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped, eContract, bHistoric, pPassUnit); -#if !defined(NO_TUTORIALS) - // slewis - added for the tutorial - if(pUnit->getUnitInfo().GetWorkRate() > 0 && pUnit->getUnitInfo().GetDomainType() == DOMAIN_LAND) - { - m_bEverTrainedBuilder = true; - } - // end added for the tutorial -#endif + if(pUnit->getUnitInfo().GetWorkRate() > 0 && pUnit->getUnitInfo().GetDomainType() == DOMAIN_LAND) + { + m_bEverTrainedBuilder = true; } m_kPlayerAchievements.AddUnit(pUnit); @@ -10302,24 +10147,15 @@ CvUnit* CvPlayer::initUnitWithNameOffset(UnitTypes eUnit, int nameOffset, int iX return NULL; CvUnitEntry* pkUnitDef = GC.getUnitInfo(eUnit); - CvAssertFmt(pkUnitDef != NULL, "Trying to create unit of type %d, which does not exist", eUnit); - if (pkUnitDef == NULL) - return NULL; + CvAssertFmt(pkUnitDef, "Trying to create unit of type %d, which does not exist", eUnit); CvUnit* pUnit = addUnit(); - CvAssertMsg(pUnit != NULL, "Unit is not assigned a valid value"); - if(NULL != pUnit) - { - pUnit->initWithNameOffset(pUnit->GetID(), eUnit, nameOffset, ((eUnitAI == NO_UNITAI) ? pkUnitDef->GetDefaultUnitAIType() : eUnitAI), GetID(), iX, iY, eReason, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped, eContract, bHistoric, false, pPassUnit); + CvAssertMsg(pUnit, "Unit is not assigned a valid value"); + pUnit->initWithNameOffset(pUnit->GetID(), eUnit, nameOffset, ((eUnitAI == NO_UNITAI) ? pkUnitDef->GetDefaultUnitAIType() : eUnitAI), GetID(), iX, iY, eReason, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped, eContract, bHistoric, false, pPassUnit); -#if !defined(NO_TUTORIALS) - // slewis - added for the tutorial - if(pUnit->getUnitInfo().GetWorkRate() > 0 && pUnit->getUnitInfo().GetDomainType() == DOMAIN_LAND) - { - m_bEverTrainedBuilder = true; - } - // end added for the tutorial -#endif + if(pUnit->getUnitInfo().GetWorkRate() > 0 && pUnit->getUnitInfo().GetDomainType() == DOMAIN_LAND) + { + m_bEverTrainedBuilder = true; } m_kPlayerAchievements.AddUnit(pUnit); @@ -10354,43 +10190,31 @@ CvUnit* CvPlayer::initNamedUnit(UnitTypes eUnit, const char* strKey, int iX, int { pUnit->initWithNameOffset(pUnit->GetID(), eUnit, -1, ((eUnitAI == NO_UNITAI) ? pkUnitDef->GetDefaultUnitAIType() : eUnitAI), GetID(), iX, iY, eReason, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped, NO_CONTRACT, true, true); -#if !defined(NO_TUTORIALS) - // slewis - added for the tutorial if (pUnit->getUnitInfo().GetWorkRate() > 0 && pUnit->getUnitInfo().GetDomainType() == DOMAIN_LAND) { m_bEverTrainedBuilder = true; } - // end added for the tutorial -#endif pUnit->SetGreatWork(NO_GREAT_WORK); -#if !defined(MOD_GLOBAL_NO_LOST_GREATWORKS) - int iUnitName = GC.getGame().getUnitCreatedCount(getUnitType()); - int iNumNames = pUnit->getUnitInfo().GetNumUnitNames(); - if (iUnitName < iNumNames) -#endif + + if (strKey != NULL) { - if (strKey != NULL) + CvString strName = strKey; + int iNumNames = pUnit->getUnitInfo().GetNumUnitNames(); + for (int iI = 0; iI < iNumNames; iI++) { - CvString strName = strKey; - int iNumNames = pUnit->getUnitInfo().GetNumUnitNames(); - for (int iI = 0; iI < iNumNames; iI++) + CvString strOtherName = pUnit->getUnitInfo().GetUnitNames(iI); + if (strOtherName == strName) { - CvString strOtherName = pUnit->getUnitInfo().GetUnitNames(iI); - if (strOtherName == strName) + pUnit->setName(strName); + pUnit->SetGreatWork(pUnit->getUnitInfo().GetGreatWorks(iI)); + GC.getGame().addGreatPersonBornName(strName); + if (MOD_GLOBAL_NO_LOST_GREATWORKS) { - pUnit->setName(strName); - pUnit->SetGreatWork(pUnit->getUnitInfo().GetGreatWorks(iI)); - GC.getGame().addGreatPersonBornName(strName); -#if defined(MOD_GLOBAL_NO_LOST_GREATWORKS) - if (MOD_GLOBAL_NO_LOST_GREATWORKS) - { - // setName strips undesirable characters, but we stored those into the list of GPs born, so we need to keep the original name - pUnit->setGreatName(strName); - } -#endif - break; + // setName strips undesirable characters, but we stored those into the list of GPs born, so we need to keep the original name + pUnit->setGreatName(strName); } + break; } } } @@ -10631,11 +10455,11 @@ BuildingTypes CvPlayer::GetSpecificBuildingType(const char* szBuildingClass, boo BuildingClassTypes eBuildingClassType = (BuildingClassTypes) GC.getInfoTypeForString(szBuildingClass, hideAssert); const CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClassType); - + if (pkBuildingClassInfo) { CvCivilizationInfo* pCivilizationInfo = GC.getCivilizationInfo(getCivilizationType()); - + if (pCivilizationInfo != NULL) { eBuildingType = (BuildingTypes) pCivilizationInfo->getCivilizationBuildings(eBuildingClassType); @@ -10645,7 +10469,7 @@ BuildingTypes CvPlayer::GetSpecificBuildingType(const char* szBuildingClass, boo eBuildingType = (BuildingTypes) pkBuildingClassInfo->getDefaultBuildingIndex(); } } - + if (!isMinorCiv() && !isBarbarian()) { if (eBuildingType == NO_BUILDING) { CUSTOMLOG("GetSpecificBuildingType for player %s: %s is UNKNOWN!!!", getName(), szBuildingClass); @@ -10658,7 +10482,7 @@ BuildingTypes CvPlayer::GetSpecificBuildingType(const char* szBuildingClass, boo } // -------------------------------------------------------------------------------- -CvPlot* CvPlayer::GetBestCoastalSpawnPlot (CvUnit *pUnit) +CvPlot* CvPlayer::GetBestCoastalSpawnPlot(CvUnit *pUnit) { CvPlot* pLargestWaterAreaPlot = NULL; int iLargestWaterSize = -1; @@ -10960,7 +10784,7 @@ const char* CvPlayer::getName() const if(szDisplayName.GetLength()) return szDisplayName.c_str(); } - + const CvString& szPlayerName = CvPreGame::leaderName(GetID()); if(szPlayerName.GetLength() == 0) { @@ -11217,7 +11041,6 @@ void CvPlayer::doTurn() updateTimerAnnexedMilitaryCityStates(); } -#if defined(MOD_BALANCE_CORE) DoVassalLevy(); SetHasUUPeriod(); @@ -11228,7 +11051,7 @@ void CvPlayer::doTurn() } GET_TEAM(getTeam()).updateTeamStatus(); UpdateBestMilitaryCities(); - + if(GetFaithPurchaseCooldown() > 0) { ChangeFaithPurchaseCooldown(-1); @@ -11271,7 +11094,6 @@ void CvPlayer::doTurn() RefreshCSAlliesFriends(); UpdateHappinessFromMinorCivs(); ProcessEspionageEvents(); -#endif DoUnitDiversity(); DoUpdateCramped(); @@ -11291,7 +11113,6 @@ void CvPlayer::doTurn() if (NO_UNIT != eUnit) { CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit); -#if defined(MOD_BALANCE_CORE_SETTLER_ADVANCED) if (pkUnitInfo != NULL && pkUnitInfo->IsFoundLate()) { if (pkUnitInfo->IsFoodProduction()) @@ -11308,7 +11129,6 @@ void CvPlayer::doTurn() } else { -#endif if (NULL != pkUnitInfo && pkUnitInfo->IsFound()) { setUnitExtraCost(eUnitClass, getNewCityProductionValue()); @@ -11331,15 +11151,14 @@ void CvPlayer::doTurn() pLog = LOGFILEMGR.GetLog(strFileName, FILogFile::kDontTimeStamp); strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns()); strBaseString += playerName + ", "; - strOutBuf.Format("Approval: %d, GoldU: %d, DefenseU: %d, ScienceU: %d, CultureU: %d, War Weariness: %d, Supply: %d, Use: %d", - GetExcessHappiness() , GetUnhappinessFromPoverty(), GetUnhappinessFromDistress(), GetUnhappinessFromIlliteracy(), + strOutBuf.Format("Approval: %d, GoldU: %d, DefenseU: %d, ScienceU: %d, CultureU: %d, War Weariness: %d, Supply: %d, Use: %d", + GetExcessHappiness() , GetUnhappinessFromPoverty(), GetUnhappinessFromDistress(), GetUnhappinessFromIlliteracy(), GetUnhappinessFromBoredom(), GetUnhappinessFromWarWeariness(), GetNumUnitsSupplied(), GetNumUnitsToSupply()); strBaseString += strOutBuf; pLog->Msg(strBaseString); } } -#if defined(MOD_BALANCE_CORE) //Reset every turn for CS events. for(int iQuestLoop = 0; iQuestLoop < NUM_MINOR_CIV_QUEST_TYPES; iQuestLoop++) { @@ -11347,59 +11166,43 @@ void CvPlayer::doTurn() } GetCorporations()->DoTurn(); -#endif if(GetPlayerTraits()->IsEndOfMayaLongCount()) { ChangeNumMayaBoosts(1); } -#if defined(MOD_BALANCE_CORE) + if(GetPlayerTraits()->IsTradeRouteMinorInfluenceAdmiralPoints()) { DoTradeInfluenceAP(); } } -#endif bool bHasActiveDiploRequest = false; if (isAlive() && isMajorCiv()) { GetGrandStrategyAI()->DoTurn(); -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { GetDiplomacyAI()->DoTurn(DIPLO_AI_PLAYERS); } else { - if(GC.getGame().isHotSeat() && !isHuman()) + if (GC.getGame().isHotSeat() && !isHuman()) { // In Hotseat, AIs only do their diplomacy pass for other AIs on their turn // Diplomacy toward a human is done at the beginning of the humans turn. - GetDiplomacyAI()->DoTurn(DIPLO_AI_PLAYERS); // Do diplomacy for toward everyone + GetDiplomacyAI()->DoTurn(DIPLO_AI_PLAYERS); // Do diplomacy for toward everyone } else - GetDiplomacyAI()->DoTurn(DIPLO_ALL_PLAYERS); // Do diplomacy for toward everyone + GetDiplomacyAI()->DoTurn(DIPLO_ALL_PLAYERS); // Do diplomacy for toward everyone if (!isHuman()) bHasActiveDiploRequest = CvDiplomacyRequests::HasActiveDiploRequestWithHuman(GetID()); } -#else - if(GC.getGame().isHotSeat() && !isHuman()) - { - // In Hotseat, AIs only do their diplomacy pass for other AIs on their turn - // Diplomacy toward a human is done at the beginning of the humans turn. - GetDiplomacyAI()->DoTurn(CvDiplomacyAI::DIPLO_AI_PLAYERS); // Do diplomacy for toward everyone - } - else - GetDiplomacyAI()->DoTurn(CvDiplomacyAI::DIPLO_ALL_PLAYERS); // Do diplomacy for toward everyone - - if (!isHuman()) - bHasActiveDiploRequest = CvDiplomacyRequests::HasActiveDiploRequestWithHuman(GetID()); -#endif } -#if defined(MOD_BALANCE_CORE) for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) { ResourceTypes eResourceLoop = (ResourceTypes) iResourceLoop; @@ -11408,7 +11211,6 @@ void CvPlayer::doTurn() DoTestOverResourceNotification(eResourceLoop); } } -#endif if(isHuman() && !GC.getGame().isGameMultiPlayer()) checkArmySizeAchievement(); @@ -11646,15 +11448,14 @@ void CvPlayer::doTurnPostDiplomacy() { GetTrade()->DoTurn(); } -#if defined(MOD_BALANCE_CORE) + if (MOD_BALANCE_CORE_JFD) { DoPiety(); DoReformCooldown(); DoGovernmentCooldown(); } -#endif -#if defined(MOD_BALANCE_CORE_EVENTS) + if (MOD_BALANCE_CORE_EVENTS) { if (GC.getGame().isOption(GAMEOPTION_EVENTS)) @@ -11668,8 +11469,7 @@ void CvPlayer::doTurnPostDiplomacy() } updateYieldPerTurnHistory(); -#endif -#if defined(MOD_BALANCE_CORE) + for (int iInstantYield = 0; iInstantYield < NUM_INSTANT_YIELD_TYPES; iInstantYield++) { InstantYieldType eInstantYield = (InstantYieldType)iInstantYield; @@ -11694,7 +11494,6 @@ void CvPlayer::doTurnPostDiplomacy() setInstantGreatPersonProgressText(eInstantYield, ""); } } -#endif //note that this isn't actually the end of the turn - AI_unitUpdate is called later AI_doTurnPost(); @@ -11792,18 +11591,13 @@ void CvPlayer::SetAllUnitsUnprocessed() for (CvUnit* pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop)) { pLoopUnit->SetTurnProcessed(false); - -#if defined(MOD_CORE_PER_TURN_DAMAGE) pLoopUnit->flipDamageReceivedPerTurn(); -#endif } -#if defined(MOD_CORE_PER_TURN_DAMAGE) for(CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { pLoopCity->flipDamageReceivedPerTurn(); } -#endif } // -------------------------------------------------------------------------------- @@ -11834,28 +11628,24 @@ void CvPlayer::DoUnitReset() int iCitadelDamage = pUnitPlot->GetDamageFromAdjacentPlots(pLoopUnit->getOwner()); if (iCitadelDamage != 0 && !pLoopUnit->isInvisible(NO_TEAM, false, false)) { - + pLoopUnit->changeDamage(iCitadelDamage, pUnitPlot->getOwner(), /*fAdditionalTextDelay*/ 0.5f); -#if defined(MOD_CORE_PER_TURN_DAMAGE) pLoopUnit->addDamageReceivedThisTurn(iCitadelDamage); -#endif } - + if (pUnitPlot->isDeepWater()) { CvCity* pOwner = pUnitPlot->getEffectiveOwningCity(); if (pOwner != NULL && GET_TEAM(pOwner->getTeam()).isAtWar(getTeam())) { - + int iTempDamage = pUnitPlot->getEffectiveOwningCity()->GetDeepWaterTileDamage(); if (iTempDamage > 0) { if (pLoopUnit->getDomainType() == DOMAIN_SEA || pLoopUnit->isEmbarked()) { pLoopUnit->changeDamage(iTempDamage, pUnitPlot->getOwner(), /*fAdditionalTextDelay*/ 0.5f); -#if defined(MOD_CORE_PER_TURN_DAMAGE) pLoopUnit->addDamageReceivedThisTurn(iTempDamage); -#endif } } } @@ -11929,7 +11719,7 @@ void CvPlayer::updateYield() // This will go through all of the plots and update the yield if the player owns it. // The plot will not contribute to the player's yield unless it is worked by a city. // Previously this would just go through all the plots the city can work (3 rings around it) - // but all plots have their yields updated on load and not updating them here could lead to + // but all plots have their yields updated on load and not updating them here could lead to // a visual discrepancy. CvMap& kMap = GC.getMap(); int iNumPlots = kMap.numPlots(); @@ -12026,12 +11816,13 @@ void CvPlayer::updateTimers() for (size_t i = 0; i < unitsToDelete.size(); i++) unitsToDelete[i]->doDelayedDeath(); -#if defined(MOD_CORE_DELAYED_VISIBILITY) - //force explicit visibility update for killed units (but not if the player is currently active) - if (!unitsToDelete.empty() && GetID()!=GC.getGame().getActivePlayer()) - for (int iI = 0; iI < GC.getMap().numPlots(); iI++) - GC.getMap().plotByIndexUnchecked(iI)->flipVisibility(getTeam()); -#endif + if (MOD_CORE_DELAYED_VISIBILITY) + { + // Force explicit visibility update for killed units (but not if the player is currently active) + if (!unitsToDelete.empty() && GetID()!=GC.getGame().getActivePlayer()) + for (int iI = 0; iI < GC.getMap().numPlots(); iI++) + GC.getMap().plotByIndexUnchecked(iI)->flipVisibility(getTeam()); + } GetDiplomacyAI()->update(); } @@ -12284,10 +12075,9 @@ int CvPlayer::GetScore(bool bFinal, bool bWinner) const iScore += GetScoreFromTechs(); iScore += GetScoreFromVassals(); -#if defined(MOD_BALANCE_CORE) iScore += GetScoreFromMinorAllies(); iScore += GetScoreFromMilitarySize(); -#endif + iScore += GetScoreFromFutureTech(); iScore += GetScoreFromScenario1(); iScore += GetScoreFromScenario2(); @@ -12563,7 +12353,7 @@ void CvPlayer::setCityFeatures(FeatureTypes eFeature, int iValue) { CvAssertMsg(eFeature >= 0, "eIndex1 is expected to be non-negative (invalid Index)"); CvAssertMsg(eFeature < GC.getNumFeatureInfos(), "eIndex1 is expected to be within maximum bounds (invalid Index)"); - + m_piCityFeatures[eFeature] = iValue; } int CvPlayer::getCityFeatures(FeatureTypes eFeature) const @@ -12773,7 +12563,6 @@ void CvPlayer::findNewCapital() CvAssertMsg(!(pBestCity->GetCityBuildings()->GetNumRealBuilding(eCapitalBuilding)), "(pBestCity->getNumRealBuilding(eCapitalBuilding)) did not return false as expected"); pBestCity->GetCityBuildings()->SetNumRealBuilding(eCapitalBuilding, 1); -#if defined(MOD_BALANCE_CORE) for (int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++) { const BuildingClassTypes eBuildingClass = static_cast(iI); @@ -12795,13 +12584,11 @@ void CvPlayer::findNewCapital() } } } -#endif -#if defined(MOD_EVENTS_CITY_CAPITAL) - if (MOD_EVENTS_CITY_CAPITAL) { + if (MOD_EVENTS_CITY_CAPITAL) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_CapitalChanged, GetID(), pBestCity->GetID(), (pOldCapital ? pOldCapital->GetID() : -1)); } -#endif if (pBestCity->IsPuppet()) { @@ -12813,20 +12600,21 @@ void CvPlayer::findNewCapital() gDLL->sendDoTask(pBestCity->GetID(), TASK_UNRAZE, -1, -1, false, false, false, false); } -#if defined(MOD_GLOBAL_NO_CONQUERED_SPACESHIPS) - if (MOD_GLOBAL_NO_CONQUERED_SPACESHIPS && !isMinorCiv() && !isBarbarian()) { + if (MOD_GLOBAL_NO_CONQUERED_SPACESHIPS && !isMinorCiv() && !isBarbarian()) + { // Rebuild the spaceship launch pad CvTeam& thisTeam = GET_TEAM(getTeam()); - if (thisTeam.getProjectCount((ProjectTypes)GD_INT_GET(SPACE_RACE_TRIGGER_PROJECT)) == 1) { - if (isAlive()) { + if (thisTeam.getProjectCount((ProjectTypes)GD_INT_GET(SPACE_RACE_TRIGGER_PROJECT)) == 1) + { + if (isAlive()) + { CUSTOMLOG("Rebuilding launch pad at (%i, %i)", pBestCity->getX(), pBestCity->getY()); CvInterfacePtr pDllPlot(new CvDllPlot(pBestCity->plot())); gDLL->GameplaySpaceshipEdited(pDllPlot.get(), 0x0001); // Display just the launch pad } } } -#endif } } @@ -13087,7 +12875,6 @@ void CvPlayer::disband(CvCity* pCity) bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) { CvCity* pCity = NULL; - UnitTypes eUnit; bool bTechFound = false; int iI = 0; @@ -13131,15 +12918,15 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) } } bestCityFinder; -#if defined(MOD_EVENTS_GOODY_CHOICE) - if (MOD_EVENTS_GOODY_CHOICE) { + if (MOD_EVENTS_GOODY_CHOICE) + { bool bPick = (pUnit && pUnit->isHasPromotion((PromotionTypes)GD_INT_GET(PROMOTION_GOODY_HUT_PICKER))); int iUnit = pUnit ? pUnit->GetID() : -1; - if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_GoodyHutCanNotReceive, GetID(), iUnit, eGoody, bPick) == GAMEEVENTRETURN_TRUE) { + if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_GoodyHutCanNotReceive, GetID(), iUnit, eGoody, bPick) == GAMEEVENTRETURN_TRUE) + { return false; } } -#endif if (!CvGoodyHuts::IsCanPlayerReceiveGoody(GetID(), eGoody)) { @@ -13394,31 +13181,21 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) } // Unit Upgrade - if(kGoodyInfo.isUpgradeUnit()) + if (kGoodyInfo.isUpgradeUnit()) { - if(pUnit == NULL) - { + if (!pUnit) return false; - } - if(pUnit->IsHasBeenPromotedFromGoody()) - { + if (pUnit->IsHasBeenPromotedFromGoody()) return false; - } - - UnitClassTypes eUpgradeUnitClass = (UnitClassTypes) GC.getUnitInfo(pUnit->getUnitType())->GetGoodyHutUpgradeUnitClass(); + UnitClassTypes eUpgradeUnitClass = static_cast(GC.getUnitInfo(pUnit->getUnitType())->GetGoodyHutUpgradeUnitClass()); if(eUpgradeUnitClass == NO_UNITCLASS) - { return false; - } UnitTypes eUpgradeUnit = GetSpecificUnitType(eUpgradeUnitClass); - if(eUpgradeUnit == NO_UNIT) - { return false; - } } // Tech @@ -13439,7 +13216,7 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) { bool bUseTech = true; ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + if (pkScriptSystem) { CvLuaArgsHandle args; args->Push(GetID()); @@ -13448,7 +13225,7 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) // Attempt to execute the game events. // Will return false if there are no registered listeners. bool bScriptResult = false; - if (LuaSupport::CallTestAll(pkScriptSystem, "GoodyHutCanResearch", args.get(), bScriptResult)) + if (LuaSupport::CallTestAll(pkScriptSystem, "GoodyHutCanResearch", args.get(), bScriptResult)) { bUseTech = bResult; } @@ -13483,35 +13260,31 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) } } - if(kGoodyInfo.getUnitClassType() != NO_UNITCLASS) + UnitClassTypes eUnitClass = static_cast(kGoodyInfo.getUnitClassType()); + if (eUnitClass != NO_UNITCLASS) { - eUnit = GetSpecificUnitType((UnitClassTypes)kGoodyInfo.getUnitClassType()); - - if(eUnit == NO_UNIT) - { + UnitTypes eUnit = GetSpecificUnitType(eUnitClass); + if (eUnit == NO_UNIT) return false; - } CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnit); - if(pUnitInfo == NULL) - { + if (!pUnitInfo) return false; - } // No combat units in MP in the first 20 turns - if(pUnitInfo->GetCombat() > 0) + if (pUnitInfo->GetCombat() > 0) { - if(GC.getGame().isGameMultiPlayer() || (GC.getGame().getElapsedGameTurns() < 20)) + if (GC.getGame().isGameMultiPlayer() || (GC.getGame().getElapsedGameTurns() < 20)) { return false; } } // Builders - if(pUnitInfo->GetWorkRate() > 0) + if (pUnitInfo->GetWorkRate() > 0) { // Max limit - if(GetMaxNumBuilders() > -1 && GetNumBuilders() >= GetMaxNumBuilders()) + if (GetMaxNumBuilders() > -1 && GetNumBuilders() >= GetMaxNumBuilders()) { return false; } @@ -13521,21 +13294,21 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) // Need a tech which unlocks something to do int iNumTechInfos = GC.getNumTechInfos(); int iNumBuildInfos = GC.getNumBuildInfos(); - for(int iTechLoop = 0; iTechLoop < iNumTechInfos; iTechLoop++) + for (int iTechLoop = 0; iTechLoop < iNumTechInfos; iTechLoop++) { - if(GET_TEAM(getTeam()).GetTeamTechs()->HasTech((TechTypes) iTechLoop)) + TechTypes eTech = static_cast(iTechLoop); + if (GET_TEAM(getTeam()).GetTeamTechs()->HasTech(eTech)) { // Look at Builds - for(int iBuildLoop = 0; iBuildLoop < iNumBuildInfos; iBuildLoop++) + for (int iBuildLoop = 0; iBuildLoop < iNumBuildInfos; iBuildLoop++) { - CvBuildInfo* pkBuildInfo = GC.getBuildInfo((BuildTypes) iBuildLoop); - if(!pkBuildInfo) - { + CvBuildInfo* pkBuildInfo = GC.getBuildInfo(static_cast(iBuildLoop)); + if (!pkBuildInfo) continue; - } - if(pkBuildInfo->getTechPrereq() == (TechTypes) iTechLoop) + + if (pkBuildInfo->getTechPrereq() == eTech) { - if(pkBuildInfo->getImprovement() != NO_IMPROVEMENT || pkBuildInfo->getRoute() != NO_ROUTE) + if (pkBuildInfo->getImprovement() != NO_IMPROVEMENT || pkBuildInfo->getRoute() != NO_ROUTE) { bHasTechWhichUnlocksImprovement = true; break; @@ -13543,24 +13316,21 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) } } } + // Already found something - if(bHasTechWhichUnlocksImprovement) - { + if (bHasTechWhichUnlocksImprovement) break; - } } // Player doesn't have any Tech which allows Improvements - if(!bHasTechWhichUnlocksImprovement) - { + if (!bHasTechWhichUnlocksImprovement) return false; - } } // OCC games - no Settlers - if(GetPlayerTraits()->IsNoAnnexing() || (GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE) && isHuman())) + if (GetPlayerTraits()->IsNoAnnexing() || (GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE) && isHuman())) { - if(pUnitInfo->IsFound() || pUnitInfo->IsFoundAbroad()) + if (pUnitInfo->IsFound() || pUnitInfo->IsFoundAbroad()) { return false; } @@ -13597,7 +13367,6 @@ bool CvPlayer::canReceiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) return true; } - // -------------------------------------------------------------------------------- void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) { @@ -13836,7 +13605,7 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) changeInstantYieldValue(YIELD_SCIENCE, iScience); } - // New Goodies modmod + // New Goodies modmod if (MOD_NEW_GOODIES) { int iFood = kGoodyInfo.getFood(); @@ -13946,11 +13715,7 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) int iProphetPercent = kGoodyInfo.getProphetPercent(); if(iProphetPercent > 0) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) iFaith = GetReligions()->GetCostNextProphet(false /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/, MOD_GLOBAL_TRULY_FREE_GP) * iProphetPercent / 100; -#else - iFaith = GetReligions()->GetCostNextProphet(false /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/) * iProphetPercent / 100; -#endif int iDivisor = /*10*/ GD_INT_GET(GOLD_PURCHASE_VISIBLE_DIVISOR); iFaith /= iDivisor; iFaith *= (iDivisor / 2); @@ -14174,7 +13939,7 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) eUpgradeUnitClass = (UnitClassTypes) pUnit->getUnitInfo().GetGoodyHutUpgradeUnitClass(); eUpgradeUnit = GetSpecificUnitType(eUpgradeUnitClass); } - + if(eUpgradeUnit != NO_UNIT) { // Add new upgrade Unit @@ -14197,27 +13962,26 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) CvAssert(pNewUnit); if (pNewUnit != NULL) { -#if defined(MOD_EVENTS_UNIT_UPGRADES) - // MUST call the event before convert() as that kills the old unit - if (MOD_EVENTS_UNIT_UPGRADES) { - GAMEEVENTINVOKE_HOOK(GAMEEVENT_UnitUpgraded, GetID(), pUnit->GetID(), pNewUnit->GetID(), true); - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + // MUST call the event before convert() as that kills the old unit + if (MOD_EVENTS_UNIT_UPGRADES) { - CvLuaArgsHandle args; - args->Push(GetID()); - args->Push(pUnit->GetID()); - args->Push(pNewUnit->GetID()); - args->Push(true); // bGoodyHut + GAMEEVENTINVOKE_HOOK(GAMEEVENT_UnitUpgraded, GetID(), pUnit->GetID(), pNewUnit->GetID(), true); + } + else + { + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if (pkScriptSystem) + { + CvLuaArgsHandle args; + args->Push(GetID()); + args->Push(pUnit->GetID()); + args->Push(pNewUnit->GetID()); + args->Push(true); // bGoodyHut - bool bScriptResult = false; - LuaSupport::CallHook(pkScriptSystem, "UnitUpgraded", args.get(), bScriptResult); + bool bScriptResult = false; + LuaSupport::CallHook(pkScriptSystem, "UnitUpgraded", args.get(), bScriptResult); + } } -#if defined(MOD_EVENTS_UNIT_UPGRADES) - } -#endif pNewUnit->convert(pUnit, true); pNewUnit->setupGraphical(); @@ -14246,38 +14010,38 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) { bool bUseTech = true; -#if defined(MOD_EVENTS_GOODY_TECH) - if (MOD_EVENTS_GOODY_TECH) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_GoodyHutCanResearch, GetID(), iI) == GAMEEVENTRETURN_FALSE) { + if (MOD_EVENTS_GOODY_TECH) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_GoodyHutCanResearch, GetID(), iI) == GAMEEVENTRETURN_FALSE) + { bUseTech = false; } - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + } + else { - CvLuaArgsHandle args; - args->Push(GetID()); - args->Push(eTech); - - // Attempt to execute the game events. - // Will return false if there are no registered listeners. - bool bScriptResult = false; - if (LuaSupport::CallTestAll(pkScriptSystem, "GoodyHutCanResearch", args.get(), bScriptResult)) + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if (pkScriptSystem) { - bUseTech = bScriptResult; + CvLuaArgsHandle args; + args->Push(GetID()); + args->Push(eTech); + + // Attempt to execute the game events. + // Will return false if there are no registered listeners. + bool bScriptResult = false; + if (LuaSupport::CallTestAll(pkScriptSystem, "GoodyHutCanResearch", args.get(), bScriptResult)) + { + bUseTech = bScriptResult; + } } } -#if defined(MOD_EVENTS_GOODY_TECH) - } -#endif -#if defined(MOD_BALANCE_CORE) + //Are we already researching a tech? No value here. if(MOD_BALANCE_CORE && GetPlayerTechs()->GetCurrentResearch() == eTech) { bUseTech = false; } -#endif + if(bUseTech) { iValue = (1 + GC.getGame().randRangeExclusive(0, 10, CvSeeder(iI))); @@ -14294,24 +14058,23 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) CvAssertMsg(eBestTech != NO_TECH, "BestTech is not assigned a valid value"); -#if defined(MOD_EVENTS_GOODY_TECH) - if (MOD_EVENTS_GOODY_TECH) { + if (MOD_EVENTS_GOODY_TECH) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_GoodyHutTechResearched, GetID(), eBestTech); - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + } + else { - CvLuaArgsHandle args; - args->Push(GetID()); - args->Push(eBestTech); + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if (pkScriptSystem) + { + CvLuaArgsHandle args; + args->Push(GetID()); + args->Push(eBestTech); - bool bScriptResult = false; - LuaSupport::CallHook(pkScriptSystem, "GoodyHutTechResearched", args.get(), bScriptResult); - } -#if defined(MOD_EVENTS_GOODY_TECH) + bool bScriptResult = false; + LuaSupport::CallHook(pkScriptSystem, "GoodyHutTechResearched", args.get(), bScriptResult); + } } -#endif GET_TEAM(getTeam()).setHasTech(eBestTech, true, GetID(), true, true); GET_TEAM(getTeam()).GetTeamTechs()->SetNoTradeTech(eBestTech, true); @@ -14326,7 +14089,7 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) { CvUnit* pNewUnit = initUnit(eUnit, pPlot->getX(), pPlot->getY()); // see if there is an open spot to put him - no over-stacking allowed! - if(pNewUnit && pUnit && pNewUnit->IsCombatUnit()) + if(pNewUnit && pUnit && pNewUnit->IsCombatUnit()) { pBestPlot = NULL; iBestValue = INT_MAX; @@ -14447,18 +14210,16 @@ void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit) { int iSpecialValue = 0; - if(iGold > 0) + if (iGold > 0) iSpecialValue = iGold; - else if(iCulture > 0) + else if (iCulture > 0) iSpecialValue = iCulture; - else if(iFaith > 0) + else if (iFaith > 0) iSpecialValue = iFaith; -#if defined(MOD_BALANCE_CORE) - else if(iProduction > 0) + else if (iProduction > 0) iSpecialValue = iProduction; else if (iScience > 0) iSpecialValue = iScience; -#endif CvPopupInfo kPopupInfo(BUTTONPOPUP_GOODY_HUT_REWARD, eGoody, iSpecialValue); GC.GetEngineUserInterface()->AddPopup(kPopupInfo); @@ -14697,7 +14458,7 @@ void CvPlayer::SetChainLength(BuildingTypes eBuilding) } } } - + v_ChainBuildings = v_TempChainBuildings; v_TempChainBuildings.clear(); @@ -14756,21 +14517,14 @@ bool CvPlayer::canFoundCityExt(int iX, int iY, bool bIgnoreDistanceToExistingCit { CvPlot* pPlot = GC.getMap().plot(iX, iY); -#if defined(MOD_EVENTS_CITY_FOUNDING) - if (MOD_EVENTS_CITY_FOUNDING) { - if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_PlayerCanFoundCityRegardless, GetID(), iX, iY) == GAMEEVENTRETURN_TRUE) { + if (MOD_EVENTS_CITY_FOUNDING) + { + if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_PlayerCanFoundCityRegardless, GetID(), iX, iY) == GAMEEVENTRETURN_TRUE) return true; - } - } -#endif -#if defined(MOD_EVENTS_CITY_FOUNDING) - if (MOD_EVENTS_CITY_FOUNDING) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundCity, GetID(), iX, iY) == GAMEEVENTRETURN_FALSE) { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundCity, GetID(), iX, iY) == GAMEEVENTRETURN_FALSE) return false; - } } -#endif if (!pPlot->isRevealed(getTeam())) return false; @@ -14790,7 +14544,7 @@ void CvPlayer::foundCity(int iX, int iY, ReligionTypes eReligion, bool bForce, C SetTurnsSinceSettledLastCity(0); - //if this is the player's first city, remember how good it is as a reference. + //if this is the player's first city, remember how good it is as a reference. //capital founding does not depend on this score so it's fair to all players independend of order if (GetNumCitiesFounded() == 0 && isMajorCiv()) GC.getGame().NewCapitalFounded(getPlotFoundValue(iX, iY)); @@ -14833,11 +14587,7 @@ void CvPlayer::foundCity(int iX, int iY, ReligionTypes eReligion, bool bForce, C } else { -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) const BeliefTypes eBelief = GetReligionAI()->ChoosePantheonBelief(GetID()); -#else - const BeliefTypes eBelief = owningPlayer.GetReligionAI()->ChoosePantheonBelief(); -#endif GC.getGame().GetGameReligions()->FoundPantheon(GetID(), eBelief); } } @@ -14846,33 +14596,26 @@ void CvPlayer::foundCity(int iX, int iY, ReligionTypes eReligion, bool bForce, C std::vector allBuildingCount = GetTotalBuildingCount(); for(int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++) { - const BuildingClassTypes eBuildingClass = static_cast(iI); - CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass); - if(pkBuildingClassInfo) + const BuildingTypes eLoopBuilding = static_cast(getCivilizationInfo().getCivilizationBuildings(iI)); + if (eLoopBuilding == NO_BUILDING) + continue; + + CvBuildingEntry* pBuildingInfo = GC.getBuildingInfo(eLoopBuilding); + if (!pBuildingInfo) + continue; + + if (pBuildingInfo->GetFreeStartEra() == NO_ERA) + continue; + + if (GC.getGame().getStartEra() >= pBuildingInfo->GetFreeStartEra()) { - const BuildingTypes eLoopBuilding = ((BuildingTypes)(getCivilizationInfo().getCivilizationBuildings(iI))); - if(eLoopBuilding != NO_BUILDING) + if (pCity->canConstruct(eLoopBuilding, allBuildingCount)) { - CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eLoopBuilding); - if(pkBuildingInfo) - { - if(pkBuildingInfo->GetFreeStartEra() != NO_ERA) - { - if(GC.getGame().getStartEra() >= pkBuildingInfo->GetFreeStartEra()) - { - if(pCity->canConstruct(eLoopBuilding,allBuildingCount)) - { - pCity->GetCityBuildings()->SetNumRealBuilding(eLoopBuilding, 1); + pCity->GetCityBuildings()->SetNumRealBuilding(eLoopBuilding, 1); -#if defined(MOD_EVENTS_CITY) - if (MOD_EVENTS_CITY) - { - GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityConstructed, pCity->getOwner(), pCity->GetID(), eLoopBuilding, false, false); - } -#endif - } - } - } + if (MOD_EVENTS_CITY) + { + GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityConstructed, pCity->getOwner(), pCity->GetID(), eLoopBuilding, false, false); } } } @@ -14926,7 +14669,7 @@ void CvPlayer::foundCity(int iX, int iY, ReligionTypes eReligion, bool bForce, C args->Push(GetID()); args->Push(pCity->getX()); args->Push(pCity->getY()); - + bool bResult = false; LuaSupport::CallHook(pkScriptSystem, "PlayerCityFounded", args.get(), bResult); } @@ -15061,7 +14804,7 @@ bool CvPlayer::canTrainUnit(UnitTypes eUnit, bool bContinue, bool bTestVisible, } } - + if (pUnitInfo.IsFound() || pUnitInfo.IsFoundAbroad()) { // No Settlers for non-majors @@ -15076,7 +14819,7 @@ bool CvPlayer::canTrainUnit(UnitTypes eUnit, bool bContinue, bool bTestVisible, if (GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE) && isHuman()) return false; } - + //Policy Requirement PolicyTypes ePolicy = (PolicyTypes)pUnitInfo.GetPolicyType(); if (ePolicy != NO_POLICY) @@ -15179,54 +14922,8 @@ bool CvPlayer::canTrainUnit(UnitTypes eUnit, bool bContinue, bool bTestVisible, } // Resource Requirements - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - const ResourceTypes eResource = static_cast(iResourceLoop); - CvResourceInfo* pkResourceInfo = GC.getResourceInfo(eResource); - if(pkResourceInfo) - { - const int iNumResource = pUnitInfo.GetResourceQuantityRequirement(eResource); - - if(iNumResource > 0) - { - // Starting project, need enough Resources plus some to start - if(!bContinue && getNumResourceAvailable(eResource) < iNumResource) - { - GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_NO_ACTION_UNIT_LACKS_RESOURCES", pkResourceInfo->GetIconString(), pkResourceInfo->GetTextKey(), iNumResource); - if(toolTipSink == NULL) - return false; - } - // Continuing project, need enough Resources - else if(bContinue && (getNumResourceAvailable(eResource) < 0)) - { - GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_NO_ACTION_UNIT_LACKS_RESOURCES", pkResourceInfo->GetIconString(), pkResourceInfo->GetTextKey(), iNumResource); - if(toolTipSink == NULL) - return false; - } - } - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - int iNumResourceTotal = pUnitInfo.GetResourceQuantityTotal(eResource); - - if (iNumResourceTotal > 0) - { - if (getNumResourceTotal(eResource) < iNumResourceTotal) - { - GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_NO_ACTION_UNIT_LACKS_GROSS_RESOURCES", pkResourceInfo->GetIconString(), pkResourceInfo->GetTextKey(), iNumResourceTotal); - if (toolTipSink == NULL) - return false; - } - else if (getNumResourceAvailable(eResource) < 0) - { - GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_NO_ACTION_UNIT_NET_RESOURCES_NEGATIVE", pkResourceInfo->GetIconString(), pkResourceInfo->GetTextKey()); - if (toolTipSink == NULL) - return false; - } - } - } - } - - } + if (!HasResourceForNewUnit(eUnit, false, false, NO_UNIT, bContinue)) + return false; if(GC.getGame().isUnitClassMaxedOut(eUnitClass, (GET_TEAM(getTeam()).getUnitClassMaking(eUnitClass) + ((bContinue) ? -1 : 0)))) { @@ -15294,7 +14991,7 @@ bool CvPlayer::canTrainUnit(UnitTypes eUnit, bool bContinue, bool bTestVisible, { GC.getGame().BuildCannotPerformActionHelpText(toolTipSink, "TXT_KEY_TRADE_UNIT_CONSTRUCTION_NO_EXTRA_SLOTS"); if (toolTipSink == NULL) - return false; + return false; } DomainTypes eDomain = pUnitInfo.GetDomainType(); @@ -15397,7 +15094,7 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr return false; } } -#if defined(MOD_BALANCE_CORE_POLICIES) + PolicyTypes ePolicy = pBuildingInfo.GetPolicyType(); if (MOD_BALANCE_CORE_POLICIES && ePolicy != NO_POLICY) { @@ -15406,8 +15103,8 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr return false; } } -#endif -#if defined(MOD_BALANCE_CORE) + + ResourceTypes eResource = (ResourceTypes)pBuildingInfo.GetResourceType(); if (MOD_BALANCE_CORE && eResource != NO_RESOURCE) { @@ -15416,11 +15113,10 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr return false; } } -#endif - if(!(currentTeam.GetTeamTechs()->HasTech((TechTypes)(pBuildingInfo.GetPrereqAndTech())))) - { + + if (!(currentTeam.GetTeamTechs()->HasTech((TechTypes)(pBuildingInfo.GetPrereqAndTech())))) return false; - } + for(iI = 0; iI < /*3*/ GD_INT_GET(NUM_BUILDING_AND_TECH_PREREQS); iI++) { if(pBuildingInfo.GetPrereqAndTechs(iI) != NO_TECH) @@ -15432,10 +15128,8 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr } } - if(currentTeam.isObsoleteBuilding(eBuilding)) - { + if (currentTeam.isObsoleteBuilding(eBuilding)) return false; - } // Building upgrade to another type BuildingClassTypes eReplacementBuildingClass = (BuildingClassTypes) pBuildingInfo.GetReplacementBuildingClass(); @@ -15476,20 +15170,14 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr } } - if(GC.getGame().isBuildingClassMaxedOut(eBuildingClass)) - { + if (GC.getGame().isBuildingClassMaxedOut(eBuildingClass)) return false; - } - if(currentTeam.isBuildingClassMaxedOut(eBuildingClass)) - { + if (currentTeam.isBuildingClassMaxedOut(eBuildingClass)) return false; - } - if(isBuildingClassMaxedOut(eBuildingClass)) - { + if (isBuildingClassMaxedOut(eBuildingClass)) return false; - } if (pBuildingInfo.GetNumRequiredTier3Tenets() > 0) { @@ -15497,7 +15185,7 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr if (eIdeology == NO_POLICY_BRANCH_TYPE) return false; } - + /////////////////////////////////////////////////////////////////////////////////// // Everything above this is what is checked to see if Building shows up in the list of construction items @@ -15606,7 +15294,7 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr { return false; } -#if defined(MOD_BALANCE_CORE) + if(GetPlayerPolicies() && !isMinorCiv() && !isBarbarian()) { int iNumPoliciesNeeded = pBuildingInfo.GetNumPoliciesNeeded(); @@ -15674,9 +15362,7 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr } } } -#endif -#if defined(MOD_BALANCE_CORE_POP_REQ_BUILDINGS) //Requires a certain population size, nationally. if(MOD_BALANCE_CORE_POP_REQ_BUILDINGS) { @@ -15692,7 +15378,7 @@ bool CvPlayer::canConstruct(BuildingTypes eBuilding, const std::vector& vPr } } } -#endif + //Requires a certain religion follower size, either nationally or globally. if (MOD_BALANCE_CORE_FOLLOWER_POP_WONDER) { @@ -16039,7 +15725,6 @@ bool CvPlayer::canMaintain(ProcessTypes eProcess, bool) const return false; } -#if defined(MOD_CIVILIZATIONS_UNIQUE_PROCESSES) // Is this a process that is only useable by a specific civ? if (MOD_CIVILIZATIONS_UNIQUE_PROCESSES) { @@ -16049,7 +15734,6 @@ bool CvPlayer::canMaintain(ProcessTypes eProcess, bool) const return false; } } -#endif for(int iI = 0; iI < GC.getNumLeagueProjectInfos(); iI++) { @@ -16252,7 +15936,6 @@ int CvPlayer::getProductionNeeded(UnitTypes eUnit, bool bIgnoreDifficulty) const iProductionNeeded *= GC.getGame().getStartEraInfo().getTrainPercent(); iProductionNeeded /= 100; -#if defined(MOD_BALANCE_CORE) int iMod = 100; UnitCombatTypes eUnitCombat = (UnitCombatTypes)pkUnitEntry->GetUnitCombatType(); if (eUnitCombat != NO_UNITCOMBAT && GetPlayerTraits()->GetUnitCombatProductionCostModifier(eUnitCombat).first != 0) @@ -16264,7 +15947,6 @@ int CvPlayer::getProductionNeeded(UnitTypes eUnit, bool bIgnoreDifficulty) const } iProductionNeeded *= iMod; iProductionNeeded /= 100; -#endif if (!bIgnoreDifficulty) { @@ -16359,7 +16041,7 @@ int CvPlayer::getProductionNeeded(BuildingTypes eTheBuilding) const { iProductionModifier += (pkBuildingInfo->GetNumCityCostMod() * getNumCities()); } -#if defined(MOD_BALANCE_CORE_WONDER_COST_INCREASE) + if (MOD_BALANCE_CORE_WONDER_COST_INCREASE && isWorldWonderClass(pkBuildingInfo->GetBuildingClassInfo())) { int iLoop = 0; @@ -16376,7 +16058,7 @@ int CvPlayer::getProductionNeeded(BuildingTypes eTheBuilding) const //This should never happen. continue; } - + // Has this Building if (pLoopCity->GetCityBuildings()->GetNumBuilding(eBuilding) > 0) { @@ -16416,7 +16098,6 @@ int CvPlayer::getProductionNeeded(BuildingTypes eTheBuilding) const } } } -#endif iProductionNeeded *= /*100*/ GD_INT_GET(BUILDING_PRODUCTION_PERCENT); iProductionNeeded /= 100; @@ -16799,11 +16480,9 @@ int CvPlayer::getBuildingClassPrereqBuilding(BuildingTypes eBuilding, BuildingCl { if(pLoopCity && !pLoopCity->IsPuppet()) { -#if defined(MOD_BUILDINGS_NW_EXCLUDE_RAZING) // Don't count this city if it is being razed and doesn't already have the pre-req building if (!(MOD_BUILDINGS_NW_EXCLUDE_RAZING && pLoopCity->IsRazing() && pLoopCity->GetCityBuildings()->GetNumBuildingClass(ePrereqBuildingClass) == 0)) -#endif - iNonPuppetCities++; + iNonPuppetCities++; } } @@ -16826,13 +16505,12 @@ int CvPlayer::getBuildingClassPrereqBuilding(BuildingTypes eBuilding, BuildingCl { iPrereqs = std::min(1, iPrereqs); } -#if defined(MOD_BALANCE_CORE) + //Poor Venice got ignored here... - if (MOD_BALANCE_CORE && OCC || GET_PLAYER(GetID()).GetPlayerTraits()->IsNoAnnexing()) + if (OCC || GET_PLAYER(GetID()).GetPlayerTraits()->IsNoAnnexing()) { iPrereqs = std::min(1, iPrereqs); } -#endif return iPrereqs; } @@ -16867,7 +16545,7 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst { int iI = 0; int iJ = 0; - + CvArea* pArea = pSourceCity->plot()->area(); CvBuildingEntry* pBuildingInfo = GC.getBuildingInfo(eBuilding); @@ -16981,7 +16659,7 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst } } } -#if defined(MOD_BALANCE_CORE) + for(int iDomains = 0; iDomains < NUM_DOMAIN_TYPES; iDomains++) { DomainTypes eDomain = (DomainTypes)iDomains; @@ -17087,7 +16765,6 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst else SetFoodRoutesAllCities(false); } -#endif if(pBuildingInfo->GetFreeBuildingClass() != NO_BUILDINGCLASS) { @@ -17105,13 +16782,9 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst ChangeBorderGrowthRateIncreaseGlobal(pBuildingInfo->GetBorderGrowthRateIncreaseGlobal() * iChange); ChangePlotCultureCostModifier(pBuildingInfo->GetGlobalPlotCultureCostModifier() * iChange); ChangePlotGoldCostMod(pBuildingInfo->GetGlobalPlotBuyCostModifier() * iChange); -#if defined(MOD_BUILDINGS_CITY_WORKING) - ChangeCityWorkingChange(pBuildingInfo->GetGlobalCityWorkingChange() * iChange); -#endif -#if defined(MOD_BUILDINGS_CITY_AUTOMATON_WORKERS) + ChangeCityWorkingChange(pBuildingInfo->GetGlobalCityWorkingChange() * iChange); ChangeCityAutomatonWorkersChange(pBuildingInfo->GetGlobalCityAutomatonWorkersChange() * iChange); -#endif // City Culture Mod ChangeJONSCultureCityModifier(pBuildingInfo->GetGlobalCultureRateModifier() * iChange); @@ -17158,9 +16831,7 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst ChangeSpecialistCultureChange(pBuildingInfo->GetSpecialistExtraCulture() * iChange); changeBorderObstacleCount(pBuildingInfo->IsPlayerBorderObstacle() * iChange); -#if defined(HH_MOD_BUILDINGS_FRUITLESS_PILLAGE) changeBorderGainlessPillageCount(pBuildingInfo->IsPlayerBorderGainlessPillage() * iChange); -#endif changeSpaceProductionModifier(pBuildingInfo->GetGlobalSpaceProductionModifier() * iChange); // Global base pressure mod @@ -17172,14 +16843,11 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst pArea->changeYieldRateModifier(GetID(), ((YieldTypes)iI), (pBuildingInfo->GetAreaYieldModifier(iI) * iChange)); changeYieldRateModifier(((YieldTypes)iI), (pBuildingInfo->GetGlobalYieldModifier(iI) * iChange)); -#if defined(MOD_BALANCE_CORE_POLICIES) changeYieldFromDeath(((YieldTypes)iI), (pBuildingInfo->GetYieldFromDeath(iI) * iChange)); - ChangeYieldFromPillage(((YieldTypes)iI), (pBuildingInfo->GetYieldFromPillageGlobalPlayer(iI) * iChange)); ChangeYieldFromVictory(((YieldTypes)iI), (pBuildingInfo->GetYieldFromVictoryGlobalPlayer(iI) * iChange)); -#endif -#if defined(MOD_BALANCE_CORE) changeYieldGPExpend(((YieldTypes)iI), (pBuildingInfo->GetYieldFromGPExpend(iI) * iChange)); + int iMod = pBuildingInfo->GetGreatWorkYieldChange(iI) * iChange; if(iMod != 0) { @@ -17190,7 +16858,6 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst { changeResourceYieldChange(((ResourceTypes)iJ), ((YieldTypes)iI), (pBuildingInfo->GetResourceYieldChangeGlobal((ResourceTypes)iJ, (YieldTypes)iI) * iChange)); } -#endif } for(iI = 0; iI < GC.getNumSpecialistInfos(); iI++) @@ -17307,11 +16974,10 @@ void CvPlayer::processBuilding(BuildingTypes eBuilding, int iChange, bool bFirst //and update city happiness for all cities, as we may have changed something somewhere... pLoopCity->UpdateHappinessFromBuildingClasses(); } -#if defined(MOD_BALANCE_CORE) + //Refresh cache data. countNumBuildings(eBuilding, true); countNumBuildingsInPuppets(eBuilding, true); -#endif } // -------------------------------------------------------------------------------- @@ -17352,7 +17018,6 @@ int CvPlayer::GetBuildingClassYieldChange(BuildingClassTypes eBuildingClass, Yie } } -#if defined(MOD_BALANCE_CORE) CorporationTypes eCorporation = GetCorporations()->GetFoundedCorporation(); if (eCorporation != NO_CORPORATION) { @@ -17362,7 +17027,6 @@ int CvPlayer::GetBuildingClassYieldChange(BuildingClassTypes eBuildingClass, Yie rtnValue += pkCorporation->GetBuildingClassYieldChange(eBuildingClass, eYieldType); } } -#endif return rtnValue; } @@ -17440,7 +17104,7 @@ bool CvPlayer::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, b } } } -#if defined(MOD_BALANCE_CORE) + if(MOD_BALANCE_CORE && GC.getBuildInfo(eBuild)->getTechObsolete() != NO_TECH) { if((GET_TEAM(getTeam()).GetTeamTechs()->HasTech((TechTypes)GC.getBuildInfo(eBuild)->getTechObsolete()))) @@ -17448,8 +17112,6 @@ bool CvPlayer::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, b return false; } } -#endif - // Is this an improvement that is only useable by a specific civ? ImprovementTypes eImprovement = (ImprovementTypes)GC.getBuildInfo(eBuild)->getImprovement(); @@ -17465,7 +17127,6 @@ bool CvPlayer::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, b } } -#if defined(MOD_IMPROVEMENTS_EXTENSIONS) if (MOD_IMPROVEMENTS_EXTENSIONS && pkEntry && !bTestVisible) { // Check resource requirements @@ -17496,10 +17157,8 @@ bool CvPlayer::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, b } } } -#endif } -#if defined(MOD_IMPROVEMENTS_EXTENSIONS) if (MOD_IMPROVEMENTS_EXTENSIONS && !bTestVisible) { RouteTypes eRoute = (RouteTypes)GC.getBuildInfo(eBuild)->getRoute(); @@ -17535,7 +17194,6 @@ bool CvPlayer::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestEra, b } } } -#endif if(pPlot && !bTestVisible) { @@ -17661,7 +17319,6 @@ RouteTypes CvPlayer::getBestRoute(CvPlot* pPlot) const { if( (pPlot->getRouteType() == eRoute) || canBuild(pPlot, eBuild) ) { -#if defined(MOD_BALANCE_CORE) if(MOD_BALANCE_CORE && pkBuildInfo->getTechObsolete() == NO_TECH) { iValue = pkRouteInfo->getValue(); @@ -17674,9 +17331,6 @@ RouteTypes CvPlayer::getBestRoute(CvPlot* pPlot) const { iValue = 0; } -#else - iValue = pkRouteInfo->getValue(); -#endif if(iValue > iBestValue) { iBestValue = iValue; @@ -18105,8 +17759,7 @@ int CvPlayer::GetNumUnitsOutOfSupply(bool bCheckWarWeariness) const if (!isAlive() || isBarbarian()) return 0; - int iNumUnitsToSupply = getNumMilitaryUnits() - getNumUnitsSupplyFree(); - return std::max(0, iNumUnitsToSupply - GetNumUnitsSupplied(bCheckWarWeariness)); + return std::max(0, GetNumUnitsToSupply() - GetNumUnitsSupplied(bCheckWarWeariness)); } int CvPlayer::GetNumUnitsToSupply() const @@ -18151,9 +17804,8 @@ int CvPlayer::calculateResearchModifier(TechTypes eTech) CvTeam& kLoopTeam = GET_TEAM((TeamTypes)iI); if(kLoopTeam.isAlive() && !kLoopTeam.isMinorCiv() && kLoopTeam.GetID() != getTeam()) { -#if defined(MOD_DIPLOMACY_TECH_BONUSES) bool bCouldBorrowTech = false; - + if (MOD_DIPLOMACY_TECH_BONUSES) { if (GetEspionage()->GetNumSpies() > 0) @@ -18171,11 +17823,8 @@ int CvPlayer::calculateResearchModifier(TechTypes eTech) { bCouldBorrowTech = GET_TEAM(getTeam()).isHasMet((TeamTypes)iI); } - + if(bCouldBorrowTech) -#else - if(GET_TEAM(getTeam()).isHasMet((TeamTypes)iI)) -#endif { if(kLoopTeam.GetTeamTechs()->HasTech(eTech)) { @@ -18800,7 +18449,7 @@ int CvPlayer::GetTotalJONSCulturePerTurn() const // Special bonus which adds excess Happiness to Culture? iCulturePerTurn += GetJONSCulturePerTurnFromExcessHappiness(); - // Trait bonus which adds Culture for trade partners? + // Trait bonus which adds Culture for trade partners? iCulturePerTurn += GetJONSCulturePerTurnFromTraits(); // Free culture that's part of the player @@ -18818,7 +18467,7 @@ int CvPlayer::GetTotalJONSCulturePerTurn() const // Culture from Religion iCulturePerTurn += GetCulturePerTurnFromReligion(); - + // Temporary boost from bonus turns iCulturePerTurn += GetCulturePerTurnFromBonusTurns(); @@ -19059,7 +18708,7 @@ int CvPlayer::GetCulturePerTurnFromBonusTurns() const // Special bonus which adds excess Happiness to Culture? iCulturePerTurn += GetJONSCulturePerTurnFromExcessHappiness(); - // Trait bonus which adds Culture for trade partners? + // Trait bonus which adds Culture for trade partners? iCulturePerTurn += GetJONSCulturePerTurnFromTraits(); // Free culture that's part of the player @@ -19090,12 +18739,11 @@ int CvPlayer::GetCulturePerTurnFromBonusTurns() const { iValue += ((iCulturePerTurn * /*100 in CP, 33 in VP*/ GD_INT_GET(TEMPORARY_CULTURE_BOOST_MOD)) / 100); } -#if defined(MOD_BALANCE_CORE) + if (GetCultureBonusTurnsConquest() > 0) { iValue += ((iCulturePerTurn * GetPlayerTraits()->GetCultureBonusModifierConquest()) / 100); - } -#endif + } return iValue; } @@ -19483,9 +19131,8 @@ void CvPlayer::ChangeReformationFollowerReduction(int iValue) /// Handle earning yields from a combat win void CvPlayer::DoYieldsFromKill(CvUnit* pAttackingUnit, CvUnit* pDefendingUnit, CvCity* pCity) { -#if defined(MOD_BALANCE_CORE) //Bonus resource in a city every time you win a battle. - if (MOD_BALANCE_CORE && pDefendingUnit != NULL && pDefendingUnit->IsCombatUnit()) + if (pDefendingUnit != NULL && pDefendingUnit->IsCombatUnit()) { CvCity* pOriginCity = pCity; CvCity* pCapitalCity = getCapitalCity(); @@ -19516,7 +19163,6 @@ void CvPlayer::DoYieldsFromKill(CvUnit* pAttackingUnit, CvUnit* pDefendingUnit, } } } -#endif } // -------------------------------------------------------------------------------- @@ -19568,7 +19214,6 @@ void CvPlayer::DoTechFromCityConquer(CvCity* pConqueredCity) GET_TEAM(getTeam()).GetTeamTechs()->SetNoTradeTech(eFreeTech, true); } } -#if defined(MOD_BALANCE_CORE) else { int iEra = GetCurrentEra(); @@ -19605,7 +19250,6 @@ void CvPlayer::DoTechFromCityConquer(CvCity* pConqueredCity) } } } -#endif } #if defined(MOD_BALANCE_CORE) // -------------------------------------------------------------------------------- @@ -21064,7 +20708,7 @@ void CvPlayer::DoHealGlobal(int iHealPercent) int iHealHP = pLoopUnit->GetMaxHitPoints() * iHealPercent / 100; pLoopUnit->changeDamage(-iHealHP); } - + } } } @@ -21108,7 +20752,7 @@ int CvPlayer::GetYieldPerTurnFromReligion(YieldTypes) const } // -------------------------------------------------------------------------------- -/// Trait bonus which adds Faith for trade partners? +/// Trait bonus which adds Faith for trade partners? int CvPlayer::GetYieldPerTurnFromTraits(YieldTypes eYield) const { if (!MOD_BALANCE_YIELD_SCALE_ERA) @@ -21132,7 +20776,7 @@ int CvPlayer::GetTotalFaithPerTurn() const // Faith per turn from Cities int iFaithPerTurn = GetFaithPerTurnFromCities(); - // Trait bonus which adds Faith for trade partners? + // Trait bonus which adds Faith for trade partners? iFaithPerTurn += GetYieldPerTurnFromTraits(YIELD_FAITH); // Faith per turn from Minor Civs @@ -21444,7 +21088,7 @@ void CvPlayer::DistributeHappinessToCities() int iScore = iPopulation - iLocalHappiness; if (iScore > 0) CitiesSortedByNeed.push_back(pLoopCity, iScore); - + CitiesSortedByPopulation.push_back(pLoopCity, iPopulation); } @@ -21505,7 +21149,7 @@ int CvPlayer::GetEmpireHappinessFromCities() const int iTotal = 0; int iLoop = 0; for (const CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) - iTotal += pLoopCity->GetLocalHappiness(0,true); + iTotal += pLoopCity->GetLocalHappiness(0,true); return iTotal; } @@ -22409,11 +22053,10 @@ void CvPlayer::DoCityRevolt() PlayerTypes eRecipient = GetMostUnhappyCityRecipient(pMostUnhappyCity); if(pMostUnhappyCity != NULL && eRecipient != NO_PLAYER) { -#if defined(MOD_BALANCE_CORE) GAMEEVENTINVOKE_HOOK(GAMEEVENT_CityFlipped, pMostUnhappyCity, eRecipient, pMostUnhappyCity->getOwner()); -#endif + if (!GET_PLAYER(eRecipient).isAlive()) - { + { if (GET_PLAYER(eRecipient).isEverAlive()) { PlayerTypes eOldPlayer = pMostUnhappyCity->getOriginalOwner(); @@ -22586,7 +22229,7 @@ CvCity *CvPlayer::GetMostUnhappyCity() { CvPlayer &kPlayer = GET_PLAYER((PlayerTypes)iLoopPlayer); if (iLoopPlayer != GetID()) - { + { PolicyBranchTypes eOtherCivIdeology = NO_POLICY_BRANCH_TYPE; int iCulturalDominanceOverUs = 0; if (kPlayer.isAlive() && !kPlayer.isMinorCiv()) @@ -22952,7 +22595,7 @@ int CvPlayer::GetHappinessFromReligion() iHappinessFromReligion += (iPantheon * iHappiness); } } - + int iSpyHappiness = pReligion->m_Beliefs.GetHappinessFromForeignSpies(GetID(), pHolyCity, true); if (iSpyHappiness > 0) { @@ -22998,11 +22641,9 @@ int CvPlayer::GetHappinessFromNaturalWonders() const int iNumWonders = GET_TEAM(getTeam()).GetNumNaturalWondersDiscovered(); int iHappiness = iNumWonders * /*1*/ GD_INT_GET(HAPPINESS_PER_NATURAL_WONDER); - -#if defined(HH_MOD_NATURAL_WONDER_MODULARITY) + int iBonusHappiness = iNumWonders* (m_pPlayerPolicies->GetNumericModifier(POLICYMOD_EXTRA_NATURALWONDER_HAPPINESS)); iHappiness += iBonusHappiness; -#endif // Trait boosts this further? if(m_pTraits->GetNaturalWonderHappinessModifier() > 0) @@ -23117,7 +22758,7 @@ int CvPlayer::GetBonusHappinessFromLuxuriesFlat() const int CvPlayer::GetBonusHappinessFromLuxuriesFlatForUI() const { int iHappiness = 0; - + int iNumResources = 0; for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) { @@ -23299,13 +22940,12 @@ int CvPlayer::GetUnhappinessFromCityForUI(CvCity* pCity) const iPopulationUnhappinessTimes100 *= (100 + GetCapitalUnhappinessMod()); iPopulationUnhappinessTimes100 /= 100; } -#if defined(MOD_BALANCE_CORE) + if(pCity->GetLocalUnhappinessMod() != 0) { iPopulationUnhappinessTimes100 *= (100 + pCity->GetLocalUnhappinessMod()); iPopulationUnhappinessTimes100 /= 100; } -#endif iPopulationUnhappinessTimes100 *= (100 + GetUnhappinessMod()); iPopulationUnhappinessTimes100 /= 100; @@ -23374,8 +23014,7 @@ int CvPlayer::GetUnhappinessFromCityCount(CvCity* pAssumeCityAnnexed, CvCity* pA } } -#if defined(MOD_BALANCE_CORE_POLICIES) - if(MOD_BALANCE_CORE_POLICIES) + if (MOD_BALANCE_CORE_POLICIES) { //Expansion policy bonus - Cities grant no unhappiness from expansion. if(IsNoUnhappinessExpansion()) @@ -23383,7 +23022,7 @@ int CvPlayer::GetUnhappinessFromCityCount(CvCity* pAssumeCityAnnexed, CvCity* pA bCityValid = false; } } -#endif + if(bCityValid) iUnhappiness += iUnhappinessPerCity; } @@ -23510,13 +23149,12 @@ int CvPlayer::GetUnhappinessFromCityPopulation(CvCity* pAssumeCityAnnexed, CvCit iUnhappinessFromThisCity *= (100 + GetCapitalUnhappinessMod()); iUnhappinessFromThisCity /= 100; } -#if defined(MOD_BALANCE_CORE) + if(pLoopCity->GetLocalUnhappinessMod() != 0) { iUnhappinessFromThisCity *= (100 + pLoopCity->GetLocalUnhappinessMod()); iUnhappinessFromThisCity /= 100; } -#endif iUnhappiness += iUnhappinessFromThisCity; } @@ -23649,7 +23287,7 @@ int CvPlayer::GetUnhappinessFromCitySpecialists(CvCity* pAssumeCityAnnexed, CvCi { iNoHappinessSpecialists += GetNoUnhappfromXSpecialistsCapital(); } - //...elsewhere? + //...elsewhere? iNoHappinessSpecialists += GetNoUnhappfromXSpecialists(); iNoHappinessSpecialists += pLoopCity->GetNoUnhappfromXSpecialists(); @@ -24150,7 +23788,7 @@ void CvPlayer::SetNoXPLossUnitPurchase(int iValue) m_iNoXPLossUnitPurchase = iValue; } -// +// void CvPlayer::ChangeNoXPLossUnitPurchase(int iChange) { SetNoXPLossUnitPurchase(m_iNoXPLossUnitPurchase + iChange); @@ -24896,12 +24534,12 @@ void CvPlayer::ChangeDoFToVotes(int iChange) int CvPlayer::TestDoFToVotes(int iChange) { int iDoFToVotes = 0; - + if(iChange > 0) { iDoFToVotes = ((GetDiplomacyAI()->GetNumDoF() / 2) * iChange); } - + return iDoFToVotes; } @@ -24930,12 +24568,12 @@ void CvPlayer::ChangeRAToVotes(int iChange) int CvPlayer::TestRAToVotes(int iChange) { int iRAToVotes = 0; - + if(iChange > 0) { iRAToVotes = (GetDiplomacyAI()->GetNumRA() * iChange); } - + return iRAToVotes; } // -------------------------------------------------------------------------------- @@ -24961,7 +24599,7 @@ void CvPlayer::ChangeDefensePactsToVotes(int iChange) int CvPlayer::TestDefensePactsToVotes(int iChange) { int iDefensePactsToVotes = 0; - + if(iChange > 0) { iDefensePactsToVotes = (GetDiplomacyAI()->GetNumDefensePacts() * iChange); @@ -24971,7 +24609,7 @@ int CvPlayer::TestDefensePactsToVotes(int iChange) iDefensePactsToVotes += GetNumVassals(); } } - + return iDefensePactsToVotes; } @@ -25007,9 +24645,9 @@ int CvPlayer::CalculateReligionExtraVotes(const CvReligion *pReligion) const int CvPlayer::CalculateReligionVotesFromImprovements(const CvReligion *pReligion) const { int iNumImprovementInfos = GC.getNumImprovementInfos(); - + std::pair fTotalVotes = std::make_pair(0, 1); - + for (int jJ = 0; jJ < iNumImprovementInfos; jJ++) { int iNumImprovements = getImprovementCount((ImprovementTypes)jJ); // less expensive function call @@ -25191,7 +24829,7 @@ void CvPlayer::ProcessLeagueResolutions() for(CvCity* pLoopCity = GET_PLAYER(GetID()).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(GetID()).nextCity(&iLoop)) { if(pLoopCity->GetTotalScienceyAid() != 0) - { + { pLoopCity->ChangeBaseYieldRateFromLeague(YIELD_FOOD, (pLoopCity->GetTotalScienceyAid() * -1)); pLoopCity->SetTotalScienceyAid(0); @@ -25211,7 +24849,7 @@ void CvPlayer::ProcessLeagueResolutions() for(CvCity* pLoopCity = GET_PLAYER(GetID()).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(GetID()).nextCity(&iLoop)) { if(pLoopCity->GetTotalScienceyAid() != 0) - { + { pLoopCity->ChangeBaseYieldRateFromLeague(YIELD_FOOD, (pLoopCity->GetTotalScienceyAid() * -1)); pLoopCity->SetTotalScienceyAid(0); @@ -25277,7 +24915,7 @@ PlayerTypes CvPlayer::AidRankGeneric(int eType) { eLoopPlayer = (PlayerTypes) iPlayerLoop; CvPlayer* pMajorLoop = &GET_PLAYER(eLoopPlayer); - + if(pMajorLoop->isAlive() && !pMajorLoop->isMinorCiv()) { switch(eType) @@ -25593,10 +25231,10 @@ bool CvPlayer::grantPolicy(PolicyTypes iPolicy, bool bFree) { if (!HasPolicy(iPolicy)) { setHasPolicy(iPolicy, true, bFree); - + return true; } - + return false; } @@ -25604,21 +25242,21 @@ bool CvPlayer::revokePolicy(PolicyTypes iPolicy) { if (HasPolicy(iPolicy)) { setHasPolicy(iPolicy, false, m_pPlayerPolicies->IsFreePolicy(iPolicy)); - + return true; } - + return false; } bool CvPlayer::swapPolicy(PolicyTypes iNewPolicy, PolicyTypes iOldPolicy) { bool bWasFree = m_pPlayerPolicies->IsFreePolicy(iOldPolicy); - + if (!HasPolicy(iNewPolicy) && revokePolicy(iOldPolicy)) { return grantPolicy(iNewPolicy, bWasFree); } - + return false; } @@ -25627,7 +25265,7 @@ void CvPlayer::setHasPolicy(PolicyTypes eIndex, bool bNewValue, bool bFree) { CvAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)"); CvAssertMsg(eIndex < GC.getNumPolicyInfos(), "eIndex is expected to be within maximum bounds (invalid Index)"); - + if (m_pPlayerPolicies->HasPolicy(eIndex) != bNewValue) { m_pPlayerPolicies->SetPolicy(eIndex, bNewValue, bFree); @@ -25698,7 +25336,7 @@ void CvPlayer::doAdoptPolicy(PolicyTypes ePolicy) { GC.GetEngineUserInterface()->setDirty(Policies_DIRTY_BIT, true); } -#if defined(MOD_BALANCE_CORE) + CvCity* pCapital = getCapitalCity(); int iPolicyGEorGM = GetPlayerTraits()->GetPolicyGEorGM(); if (iPolicyGEorGM > 0 && pCapital != NULL) @@ -25709,11 +25347,10 @@ void CvPlayer::doAdoptPolicy(PolicyTypes ePolicy) doInstantYield(INSTANT_YIELD_TYPE_POLICY_UNLOCK, false, NO_GREATPERSON, NO_BUILDING, 0, false); doInstantGreatPersonProgress(INSTANT_YIELD_TYPE_POLICY_UNLOCK); - for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) + for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { pLoopCity->GetCityCitizens()->SetDirty(true); } -#endif ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if(pkScriptSystem) @@ -25908,7 +25545,7 @@ void CvPlayer::DoProcessVotes() { const BuildingTypes eBuilding = static_cast(iBuildingLoop); CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eBuilding); - + // Has this Building if(pkBuildingInfo && pLoopCity->GetCityBuildings()->GetNumBuilding(eBuilding) > 0) { @@ -25919,22 +25556,22 @@ void CvPlayer::DoProcessVotes() if(pkBuildingInfo->GetCapitalsToVotes() > 0) { iTestCapital += TestCapitalsToVotes(pkBuildingInfo->GetCapitalsToVotes()); - + } if(pkBuildingInfo->GetDoFToVotes() > 0) { iTestDoF += TestDoFToVotes(pkBuildingInfo->GetDoFToVotes()); - + } if(pkBuildingInfo->GetRAToVotes() > 0) { iTestRA += TestRAToVotes(pkBuildingInfo->GetRAToVotes()); - + } if(pkBuildingInfo->GetDPToVotes() > 0) { iTestDP += TestDefensePactsToVotes(pkBuildingInfo->GetDPToVotes()); - + } } } @@ -25993,7 +25630,6 @@ void CvPlayer::DoChangeGreatGeneralRate() } } -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) // mod for civs keeping their pantheon belief forever if (MOD_RELIGION_PERMANENT_PANTHEON) { @@ -26015,7 +25651,6 @@ void CvPlayer::DoChangeGreatGeneralRate() } } } -#endif } } //Check for policies that add Great General points. @@ -26057,7 +25692,7 @@ void CvPlayer::DoChangeGreatAdmiralRate() if(pLoopCity != NULL) { iGreatAdmiralPoints += pLoopCity->getYieldRate(YIELD_GREAT_ADMIRAL_POINTS, false); - + const CvReligion* pReligion = GC.getGame().GetGameReligions()->GetReligion(pLoopCity->GetCityReligions()->GetReligiousMajority(), pLoopCity->getOwner()); BeliefTypes eSecondaryPantheon = NO_BELIEF; if(pReligion) @@ -26083,7 +25718,6 @@ void CvPlayer::DoChangeGreatAdmiralRate() } } -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) // mod for civs keeping their pantheon belief forever if (MOD_RELIGION_PERMANENT_PANTHEON) { @@ -26105,7 +25739,6 @@ void CvPlayer::DoChangeGreatAdmiralRate() } } } -#endif } } //Check for policies that add Great Admiral points. @@ -26139,9 +25772,7 @@ void CvPlayer::DoChangeGreatAdmiralRate() void CvPlayer::DoProcessGoldenAge() { if(GC.getGame().isOption(GAMEOPTION_NO_HAPPINESS)) - { return; - } // Minors and Barbs can't get GAs if(!isMinorCiv() && !isBarbarian()) @@ -26154,46 +25785,37 @@ void CvPlayer::DoProcessGoldenAge() changeGoldenAgeTurns(-1); } } -#if defined(MOD_BALANCE_CORE) + + // VP still keeps the GAP meter running during a GA if (MOD_BALANCE_VP || getGoldenAgeTurns() <= 0) -#else - // Not in GA - else { -#endif // Note: This will actually REDUCE the GA meter if the player is running in the red ChangeGoldenAgeProgressMeter(GetHappinessForGAP()); ChangeGoldenAgeProgressMeter(GetGoldenAgePointsFromEmpire()); -#if defined(MOD_BALANCE_CORE) - if(getGoldenAgeTurns() <= 0) - { -#endif + } + + if(getGoldenAgeTurns() <= 0) + { // Enough GA Progress to trigger new GA? if(GetGoldenAgeProgressMeter() >= GetGoldenAgeProgressThreshold()) { int iOverflow = GetGoldenAgeProgressMeter() - GetGoldenAgeProgressThreshold(); SetGoldenAgeProgressMeter(iOverflow); - changeGoldenAgeTurns(getGoldenAgeLength()); // If it's the active player then show the popup if(GetID() == GC.getGame().getActivePlayer()) { // Don't show in MP - if(!GC.getGame().isNetworkMultiPlayer()) // KWG: Candidate for !GC.getGame().isOption(GAMEOPTION_SIMULTANEOUS_TURNS) + if(!GC.getGame().isNetworkMultiPlayer()) // KWG: Candidate for !GC.getGame().isOption(GAMEOPTION_SIMULTANEOUS_TURNS) { CvPopupInfo kPopupInfo(BUTTONPOPUP_GOLDEN_AGE_REWARD); GC.GetEngineUserInterface()->AddPopup(kPopupInfo); } } } -#if defined(MOD_BALANCE_CORE) - } -#endif -#if !defined(MOD_BALANCE_CORE) } -#endif } } @@ -26204,7 +25826,7 @@ int CvPlayer::GetGoldenAgePointsFromEmpire() // GA points from religion iGAPoints += GetYieldPerTurnFromReligion(YIELD_GOLDEN_AGE_POINTS); - // Trait bonus which adds GA points for trade partners? + // Trait bonus which adds GA points for trade partners? iGAPoints += GetYieldPerTurnFromTraits(YIELD_GOLDEN_AGE_POINTS); iGAPoints += GetGoldenAgePointsFromCities(); @@ -26251,7 +25873,7 @@ int CvPlayer::GetGoldenAgePointsFromCities() { iGAPoints += (GetTreasury()->CalculateGrossGold() * GetPlayerTraits()->GetGoldToGAP()) / 100; } - + return iGAPoints; } @@ -26459,7 +26081,7 @@ void CvPlayer::changeGoldenAgeTurns(int iChange, bool bFree) if (MOD_EVENTS_GOLDEN_AGE) { GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerGoldenAge, GetID(), false, 0); } -#if defined(MOD_BALANCE_CORE) + int iLoop = 0; for(CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { @@ -26467,7 +26089,6 @@ void CvPlayer::changeGoldenAgeTurns(int iChange, bool bFree) pLoopCity->GetCityCulture()->CalculateBaseTourism(); } ChangeGarrisonedCityRangeStrikeModifier(GetPlayerTraits()->GetGoldenAgeGarrisonedCityRangeStrikeModifier() * -1); -#endif } CvNotifications* pNotifications = GetNotifications(); @@ -26498,14 +26119,14 @@ void CvPlayer::changeGoldenAgeTurns(int iChange, bool bFree) { ChangeNumGoldenAges(1); } -#if defined(MOD_BALANCE_CORE) + //Instant Boost CvCity* pCapitalCity = getCapitalCity(); if (pCapitalCity != NULL) { doInstantYield(INSTANT_YIELD_TYPE_INSTANT, false, NO_GREATPERSON, NO_BUILDING, iThreshold, false, NO_PLAYER, NULL, false, pCapitalCity); } - + if (GetGoldenAgeTourism() > 0) { int iTourism = GetHistoricEventTourism(HISTORIC_EVENT_GOLDEN_AGE); @@ -26569,7 +26190,6 @@ void CvPlayer::changeGoldenAgeTurns(int iChange, bool bFree) { ChangeGarrisonedCityRangeStrikeModifier(GetPlayerTraits()->GetGoldenAgeGarrisonedCityRangeStrikeModifier() * 1); } -#endif locString = Localization::Lookup("TXT_KEY_NOTIFICATION_GOLDEN_AGE_BEGUN"); locString << getCivilizationAdjectiveKey(); @@ -26577,17 +26197,17 @@ void CvPlayer::changeGoldenAgeTurns(int iChange, bool bFree) gDLL->GameplayGoldenAgeStarted(); - if (MOD_EVENTS_GOLDEN_AGE) { + if (MOD_EVENTS_GOLDEN_AGE) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerGoldenAge, GetID(), true, iChange); } -#if defined(MOD_BALANCE_CORE) + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { pLoopCity->GetCityCulture()->CalculateBaseTourismBeforeModifiers(); pLoopCity->GetCityCulture()->CalculateBaseTourism(); } -#endif } if(GetID() == GC.getGame().getActivePlayer()) @@ -26649,12 +26269,11 @@ void CvPlayer::changeStrikeTurns(int iChange) int CvPlayer::getGoldenAgeModifier(bool bCheckMonopolies) const { // Player modifier, eg policies and buildings - int iModifier = m_iGoldenAgeModifier; + int iModifier = m_iGoldenAgeModifier; // Trait modifier iModifier += GetPlayerTraits()->GetGoldenAgeDurationModifier(); -#if defined(MOD_BALANCE_CORE_RESOURCE_MONOPOLIES) // Resource monopolies (not cached, so give an option to skip this check) if (MOD_BALANCE_CORE_RESOURCE_MONOPOLIES && bCheckMonopolies) { @@ -26676,7 +26295,6 @@ int CvPlayer::getGoldenAgeModifier(bool bCheckMonopolies) const } } } -#endif return iModifier; } @@ -26687,8 +26305,8 @@ void CvPlayer::changeGoldenAgeModifier(int iChange) m_iGoldenAgeModifier += iChange; } -#if defined(MOD_GLOBAL_TRULY_FREE_GP) // -------------------------------------------------------------------------------- +// For GEMS before counter separation int CvPlayer::getGreatPeopleCreated(bool bExcludeFree) const { int iCount = m_iGreatPeopleCreated; @@ -26733,7 +26351,6 @@ void CvPlayer::incrementGreatAdmiralsCreated(bool bIsFree) if (bIsFree) m_iFreeGreatAdmiralsCreated++; } -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) // -------------------------------------------------------------------------------- int CvPlayer::getGreatMerchantsCreated(bool bExcludeFree) const { @@ -26778,7 +26395,6 @@ void CvPlayer::incrementGreatEngineersCreated(bool bIsFree) m_iGreatEngineersCreated++; if (bIsFree) m_iFreeGreatEngineersCreated++; } -#endif // -------------------------------------------------------------------------------- int CvPlayer::getGreatWritersCreated(bool bExcludeFree) const @@ -26840,7 +26456,6 @@ void CvPlayer::incrementGreatDiplomatsCreated(bool bIsFree) if (bIsFree) m_iFreeGreatDiplomatsCreated++; } -#if defined(MOD_BALANCE_CORE) // -------------------------------------------------------------------------------- int CvPlayer::getGPExtra1Created(bool bExcludeFree) const { @@ -26911,130 +26526,87 @@ void CvPlayer::incrementGPExtra5Created(bool bIsFree) m_iGPExtra5Created++; if (bIsFree) m_iFreeGPExtra5Created++; } -#endif -#else -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatPeopleCreated() const -{ - return m_iGreatPeopleCreated; -} // -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatPeopleCreated() +// Generic function to increment count after spawning a Great Person +void CvPlayer::incrementGreatPersonCount(const CvUnitEntry& kUnitInfo, bool bCountAsProphet, bool bIsFree) { - m_iGreatPeopleCreated++; -} - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatGeneralsCreated() const -{ - return m_iGreatGeneralsCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatGeneralsCreated() -{ - m_iGreatGeneralsCreated++; -} - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatAdmiralsCreated() const -{ - return m_iGreatAdmiralsCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatAdmiralsCreated() -{ - m_iGreatAdmiralsCreated++; -} - -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatMerchantsCreated() const -{ - return m_iGreatMerchantsCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatMerchantsCreated() -{ - m_iGreatMerchantsCreated++; -} - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatScientistsCreated() const -{ - return m_iGreatScientistsCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatScientistsCreated() -{ - m_iGreatScientistsCreated++; -} - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatEngineersCreated() const -{ - return m_iGreatEngineersCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatEngineersCreated() -{ - m_iGreatEngineersCreated++; -} -#endif - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatWritersCreated() const -{ - return m_iGreatWritersCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatWritersCreated() -{ - m_iGreatWritersCreated++; -} - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatArtistsCreated() const -{ - return m_iGreatArtistsCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatArtistsCreated() -{ - m_iGreatArtistsCreated++; -} - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatMusiciansCreated() const -{ - return m_iGreatMusiciansCreated; -} - -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatMusiciansCreated() -{ - m_iGreatMusiciansCreated++; -} - -// -------------------------------------------------------------------------------- -int CvPlayer::getGreatDiplomatsCreated() const -{ - return m_iGreatDiplomatsCreated; -} + // Not a Great Person + if (kUnitInfo.GetSpecialUnitType() != static_cast(GC.getInfoTypeForString("SPECIALUNIT_PEOPLE"))) + return; -// -------------------------------------------------------------------------------- -void CvPlayer::incrementGreatDiplomatsCreated() -{ - m_iGreatDiplomatsCreated++; + const int iUnitClass = kUnitInfo.GetUnitClassType(); + if (bCountAsProphet || kUnitInfo.IsFoundReligion()) + { + GetReligions()->ChangeNumProphetsSpawned(1, bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_GREAT_GENERAL")) + { + incrementGreatGeneralsCreated(bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_GREAT_ADMIRAL")) + { + incrementGreatAdmiralsCreated(bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_WRITER")) + { + incrementGreatWritersCreated(bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_ARTIST")) + { + incrementGreatArtistsCreated(bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_MUSICIAN")) + { + incrementGreatMusiciansCreated(bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT")) + { + incrementGreatDiplomatsCreated(bIsFree); + } + else if (kUnitInfo.IsGPExtra() == 1) + { + incrementGPExtra1Created(bIsFree); + } + else if (kUnitInfo.IsGPExtra() == 2) + { + incrementGPExtra2Created(bIsFree); + } + else if (kUnitInfo.IsGPExtra() == 3) + { + incrementGPExtra3Created(bIsFree); + } + else if (kUnitInfo.IsGPExtra() == 4) + { + incrementGPExtra4Created(bIsFree); + } + else if (kUnitInfo.IsGPExtra() == 5) + { + incrementGPExtra5Created(bIsFree); + } + else + { + if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) + { + if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_MERCHANT")) + { + incrementGreatMerchantsCreated(bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_SCIENTIST")) + { + incrementGreatScientistsCreated(bIsFree); + } + else if (iUnitClass == GC.getInfoTypeForString("UNITCLASS_ENGINEER")) + { + incrementGreatEngineersCreated(bIsFree); + } + } + else + { + incrementGreatPeopleCreated(bIsFree); + } + } } -#endif // -------------------------------------------------------------------------------- int CvPlayer::getMerchantsFromFaith() const @@ -27406,16 +26978,16 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers iNumFollowerCities = GC.getGame().GetGameReligions()->GetNumDomesticCitiesFollowing(eReligion, GetID()); iNumFollowers = GC.getGame().GetGameReligions()->GetNumFollowers(eReligion, GetID()); } - + for(int iI = 0; iI < NUM_YIELD_TYPES; iI++) { YieldTypes eYield = (YieldTypes) iI; if (!MOD_BALANCE_CORE_JFD && eYield >= YIELD_JFD_HEALTH && eYield != ePassYield) continue; - + CvYieldInfo* pYieldInfo = GC.getYieldInfo(eYield); - + //First let's get our values... //Note that many beliefs pass in a city - that's because only holy cities (or capitals for pantheons) should get those bonuses! int iValue = 0; @@ -27520,7 +27092,7 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers iValue = iPassYield; break; } - + case INSTANT_YIELD_TYPE_ERA_UNLOCK: { if(pReligion) @@ -27543,7 +27115,7 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers { iValue += pReligion->m_Beliefs.GetYieldFromPolicyUnlock(eYield, GetID(), pLoopCity, true) * pReligion->m_Beliefs.GetFollowerScalerLimiter(iNumFollowers); } - + break; } case INSTANT_YIELD_TYPE_INSTANT: @@ -27560,7 +27132,7 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers } } } - else + else { if(iPassYield != 0 && !bEvent) { @@ -27570,7 +27142,7 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers { iTemp *= iPercent; iTemp /= 100; - + iValue += iTemp; } } @@ -27593,12 +27165,11 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers } } -#if defined(MOD_BALANCE_CORE_BELIEFS) if (pReligion) { iValue += pReligion->m_Beliefs.GetYieldFromTechUnlock(eYield, bEraScale, GetID(), pLoopCity, true) * pReligion->m_Beliefs.GetFollowerScalerLimiter(iNumFollowers); } -#endif + break; } @@ -27684,8 +27255,8 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers iValue += (getYieldFromDelegateCount(eYield) * iPassYield); } break; - } - + } + case INSTANT_YIELD_TYPE_CONSTRUCTION: { iValue += pLoopCity->GetYieldFromConstruction(eYield) + getYieldFromConstruction(eYield); @@ -28031,15 +27602,15 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers { iValue += GetYieldFromPillage(eYield) + pLoopCity->GetYieldFromPillageGlobal(eYield); } -#if defined(MOD_BALANCE_CORE_BELIEFS) + if (MOD_RELIGION_EXTENSIONS && pReligion) { iValue += pReligion->m_Beliefs.GetYieldFromPillageGlobal(eYield, bEraScale, GetID(), pLoopCity, true); } -#endif + break; } - + case INSTANT_YIELD_TYPE_U_PROD: { if (pLoopCity->GetYieldFromUnitProduction(eYield) > 0) @@ -28197,9 +27768,9 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers } } } - + break; - } + } case INSTANT_YIELD_TYPE_TR_MOVEMENT: { if(eYield == YIELD_GREAT_ADMIRAL_POINTS && !bDomainSea) @@ -28630,7 +28201,7 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers // JFD have no special behavior, but they are still tracked. // Lua scripts can access the tracked information though it // would probably be better to have a Lua hook instead. - break; + break; } //keep track of what we're doing @@ -28641,7 +28212,7 @@ void CvPlayer::doInstantYield(InstantYieldType iType, bool bCityFaith, GreatPers if(GetID() == GC.getGame().getActivePlayer() && iValue > 0) { char text[256] = {0}; - + yieldString.Format("%s+%%d[ENDCOLOR] %s", pYieldInfo->getColorString(), pYieldInfo->getIconString()); sprintf_s(text, yieldString, iValue); switch (iType) @@ -29530,7 +29101,7 @@ void CvPlayer::doInstantGWAM(GreatPersonTypes eGreatPerson, const CvString& strN strMessage << iGPMusician; strMessage << strName.c_str(); } - + Localization::String strSummary = ""; if (bConquest) strSummary = Localization::Lookup("TXT_KEY_TOURISM_EVENT_GWAM_BONUS_CONQUEST_S"); @@ -29787,7 +29358,7 @@ void CvPlayer::doInstantGreatPersonProgress(InstantYieldType iType, bool bSuppre if (GetID() == GC.getGame().getActivePlayer() && iValue > 0) { char text[256] = { 0 }; - + gpString.Format("%s+%%d[ENDCOLOR] %s", "[COLOR_WHITE]", pGreatPerson->GetIconString()); sprintf_s(text, gpString, iGPThresholdString); SHOW_PLOT_POPUP(pLoopCity->plot(), GetID(), text); @@ -29917,12 +29488,7 @@ void CvPlayer::doInstantGreatPersonProgress(InstantYieldType iType, bool bSuppre if (eUnitClass != NO_UNITCLASS) { UnitTypes eUnit = GetSpecificUnitType(eUnitClass); - -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pLoopCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true, false, false); -#else - pLoopCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true, false); -#endif } } } @@ -29983,11 +29549,7 @@ CvString CvPlayer::getInstantGreatPersonProgressText(InstantYieldType iType) con #endif // -------------------------------------------------------------------------------- /// Do effects when a GP is consumed -#if defined(MOD_EVENTS_GREAT_PEOPLE) void CvPlayer::DoGreatPersonExpended(UnitTypes eGreatPersonUnit, CvUnit* pGreatPersonUnit) -#else -void CvPlayer::DoGreatPersonExpended(UnitTypes eGreatPersonUnit) -#endif { // Gold gained int iExpendGold = GetGreatPersonExpendGold(); @@ -30061,9 +29623,8 @@ void CvPlayer::DoGreatPersonExpended(UnitTypes eGreatPersonUnit) } } -#if defined(MOD_BALANCE_CORE_POLICIES) //Influence Gained with all CS per expend - int iExpendInfluence = GetInfluenceGPExpend() + GetGPExpendInfluence(); + int iExpendInfluence = GetInfluenceGPExpend() + GetGPExpendInfluence(); if(iExpendInfluence > 0) { for (int iMinorLoop = MAX_MAJOR_CIVS; iMinorLoop < MAX_CIV_PLAYERS; iMinorLoop++) @@ -30084,26 +29645,24 @@ void CvPlayer::DoGreatPersonExpended(UnitTypes eGreatPersonUnit) } GreatPersonTypes eGreatPerson = GetGreatPersonFromUnitClass(pGreatPersonUnit->getUnitClassType()); doInstantYield(INSTANT_YIELD_TYPE_GP_USE, false, eGreatPerson); -#endif -#if defined(MOD_EVENTS_GREAT_PEOPLE) - if (MOD_EVENTS_GREAT_PEOPLE) { + if (MOD_EVENTS_GREAT_PEOPLE) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_GreatPersonExpended, GetID(), pGreatPersonUnit->GetID(), eGreatPersonUnit, pGreatPersonUnit->getX(), pGreatPersonUnit->getY()); - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + } + else { - CvLuaArgsHandle args; - args->Push(GetID()); - args->Push(eGreatPersonUnit); + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if (pkScriptSystem) + { + CvLuaArgsHandle args; + args->Push(GetID()); + args->Push(eGreatPersonUnit); - bool bResult = false; - LuaSupport::CallHook(pkScriptSystem, "GreatPersonExpended", args.get(), bResult); - } -#if defined(MOD_EVENTS_GREAT_PEOPLE) + bool bResult = false; + LuaSupport::CallHook(pkScriptSystem, "GreatPersonExpended", args.get(), bResult); + } } -#endif } // -------------------------------------------------------------------------------- @@ -30424,11 +29983,7 @@ void CvPlayer::ChangeGreatPeopleSpawnCounter(int iChange) // -------------------------------------------------------------------------------- /// Create a GreatPeople -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void CvPlayer::DoSpawnGreatPerson(PlayerTypes eMinor, bool bIsFree) -#else -void CvPlayer::DoSpawnGreatPerson(PlayerTypes eMinor) -#endif { CvAssertMsg(eMinor >= MAX_MAJOR_CIVS, "eMinor is expected to be non-negative (invalid Index)"); CvAssertMsg(eMinor < MAX_CIV_PLAYERS, "eMinor is expected to be within maximum bounds (invalid Index)"); @@ -30440,6 +29995,7 @@ void CvPlayer::DoSpawnGreatPerson(PlayerTypes eMinor) FAssertMsg(false, "MINOR CIV AI: Trying to spawn a GreatPeople for a major civ but the minor has no capital. Please send Jon this with your last 5 autosaves and what changelist # you're playing."); return; } + // Capital must have a plot CvPlot* pMinorPlot = pMinorCapital->plot(); if(pMinorPlot == NULL) @@ -30467,9 +30023,9 @@ void CvPlayer::DoSpawnGreatPerson(PlayerTypes eMinor) int iBestScore = -1; SpecialUnitTypes eSpecialUnitGreatPerson = (SpecialUnitTypes) GC.getInfoTypeForString("SPECIALUNIT_PEOPLE"); - for(int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) + for (int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) { - UnitTypes eLoopUnit = (UnitTypes)iUnitLoop; + UnitTypes eLoopUnit = static_cast(iUnitLoop); CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eLoopUnit); if(pkUnitEntry && pkUnitEntry->GetSpecialUnitType() == eSpecialUnitGreatPerson) @@ -30494,236 +30050,35 @@ void CvPlayer::DoSpawnGreatPerson(PlayerTypes eMinor) CvUnit* pNewGreatPeople = initUnit(eBestUnit, iX, iY); CvAssert(pNewGreatPeople); - if (pNewGreatPeople) + if (pNewGreatPeople->IsGreatAdmiral()) { -#if defined(MOD_BALANCE_CORE) - if (GetPlayerTraits()->IsGPWLTKD()) - { - CvCity* pCity = pNewGreatPeople->plot()->getOwningCity(); - if (pCity != NULL && pCity->getOwner() == GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - pCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); - strText << pNewGreatPeople->getNameKey() << pCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); - strSummary << pCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pCity->getX(), pCity->getY(), -1); - } - } - } - } - if(pNewGreatPeople->isWLKTKDOnBirth()) + CvPlot* pSpawnPlot = GetBestCoastalSpawnPlot(pNewGreatPeople); + if (pNewGreatPeople->plot() != pSpawnPlot && pSpawnPlot != NULL) { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) - { - if(pLoopCity != NULL && pLoopCity->getOwner() == GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << pNewGreatPeople->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } + pNewGreatPeople->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); } - if(pNewGreatPeople->isGoldenAgeOnBirth()) + } + else + { + if (!pNewGreatPeople->jumpToNearestValidPlot()) { - changeGoldenAgeTurns(getGoldenAgeLength()); + pNewGreatPeople->kill(false); // Could not find a spot! } - if(pNewGreatPeople->isCultureBoost()) - { - int iValue = GetTotalJONSCulturePerTurn() * 4; - changeJONSCulture(iValue); - if (getCapitalCity() != NULL) - getCapitalCity()->ChangeJONSCultureStored(iValue); + } - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << pNewGreatPeople->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << pNewGreatPeople->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pNewGreatPeople->getX(), pNewGreatPeople->getY(), -1); - } - } -#endif - // Bump up the count - if(pNewGreatPeople->IsGreatGeneral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatGeneralsCreated(bIsFree); -#else - incrementGreatGeneralsCreated(); -#endif - } - else if(pNewGreatPeople->IsGreatAdmiral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatAdmiralsCreated(bIsFree); -#else - incrementGreatAdmiralsCreated(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_WRITER")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatWritersCreated(bIsFree); -#else - incrementGreatWritersCreated(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_ARTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatArtistsCreated(bIsFree); -#else - incrementGreatArtistsCreated(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MUSICIAN")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatMusiciansCreated(bIsFree); -#else - incrementGreatMusiciansCreated(); -#endif - } - else if (MOD_BALANCE_VP && pNewGreatPeople->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatDiplomatsCreated(bIsFree); -#else - incrementGreatDiplomatsCreated(); -#endif - } -#if defined(MOD_BALANCE_CORE) - else if (pNewGreatPeople->getUnitInfo().IsGPExtra() == 1) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra1Created(bIsFree); -#else - incrementGPExtra1Created(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().IsGPExtra() == 2) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra2Created(bIsFree); -#else - incrementGPExtra2Created(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().IsGPExtra() == 3) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra3Created(bIsFree); -#else - incrementGPExtra3Created(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().IsGPExtra() == 4) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra4Created(bIsFree); -#else - incrementGPExtra4Created(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().IsGPExtra() == 5) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra5Created(bIsFree); -#else - incrementGPExtra5Created(); -#endif - } -#endif - else - { -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) - if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) - { - if (pNewGreatPeople->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MERCHANT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatMerchantsCreated(bIsFree); -#else - incrementGreatMerchantsCreated(); -#endif - } - else if (pNewGreatPeople->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_SCIENTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatScientistsCreated(bIsFree); -#else - incrementGreatScientistsCreated(); -#endif - } - else - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatEngineersCreated(bIsFree); -#else - incrementGreatEngineersCreated(); -#endif - } - } - else -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatPeopleCreated(bIsFree); -#else - incrementGreatPeopleCreated(); -#endif - } + if (pMajorCity) + pNewGreatPeople->DoGreatPersonSpawnBonus(pMajorCity); - if (pNewGreatPeople->IsGreatAdmiral()) - { - CvPlot* pSpawnPlot = GetBestCoastalSpawnPlot(pNewGreatPeople); - if (pNewGreatPeople->plot() != pSpawnPlot && pSpawnPlot != NULL) - { - pNewGreatPeople->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); - } - } - else - { - if (!pNewGreatPeople->jumpToNearestValidPlot()) - pNewGreatPeople->kill(false); // Could not find a spot! - } + incrementGreatPersonCount(pNewGreatPeople->getUnitInfo(), false, bIsFree); - CvNotifications* pNotifications = GetNotifications(); - if(pNotifications) - { - Localization::String strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_STATE_UNIT_SPAWN"); - strMessage << GET_PLAYER(eMinor).getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_STATE_UNIT_SPAWN"); - strSummary << GET_PLAYER(eMinor).getNameKey(); - pNotifications->Add(NOTIFICATION_MINOR, strMessage.toUTF8(), strSummary.toUTF8(), iX, iY, eMinor); - } + CvNotifications* pNotifications = GetNotifications(); + if (pNotifications) + { + Localization::String strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_STATE_UNIT_SPAWN"); + strMessage << GET_PLAYER(eMinor).getNameKey(); + Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_STATE_UNIT_SPAWN"); + strSummary << GET_PLAYER(eMinor).getNameKey(); + pNotifications->Add(NOTIFICATION_MINOR, strMessage.toUTF8(), strSummary.toUTF8(), iX, iY, eMinor); } } } @@ -30767,11 +30122,7 @@ void CvPlayer::DoGreatPeopleSpawnTurn() } if(eBestMinor != NO_PLAYER) -#if defined(MOD_GLOBAL_TRULY_FREE_GP) DoSpawnGreatPerson(eBestMinor, MOD_GLOBAL_TRULY_FREE_GP); -#else - DoSpawnGreatPerson(eBestMinor); -#endif // Reseed counter DoSeedGreatPeopleSpawnCounter(); @@ -31458,18 +30809,13 @@ int CvPlayer::getNumMilitaryLandUnits() const // -------------------------------------------------------------------------------- -#if defined(MOD_BATTLE_ROYALE) void CvPlayer::changeNumMilitaryUnits(int iChange, DomainTypes eDomain) -#else -void CvPlayer::changeNumMilitaryUnits(int iChange) -#endif { if(iChange != 0) { m_iNumMilitaryUnits = (m_iNumMilitaryUnits + iChange); CvAssert(getNumMilitaryUnits() >= 0); -#if defined(MOD_BATTLE_ROYALE) switch (eDomain) { case NO_DOMAIN: @@ -31493,7 +30839,7 @@ void CvPlayer::changeNumMilitaryUnits(int iChange) default: break; } -#endif + if(GetID() == GC.getGame().getActivePlayer()) { GC.GetEngineUserInterface()->setDirty(GameData_DIRTY_BIT, true); @@ -31764,7 +31110,7 @@ int CvPlayer::GetTradeRouteProductionSiphonPercent(bool bInternationalOnly, CvPl { return 0; } - + int iSiphonPercent = 0; int iOpenBorderPercentIncrease = 0; int iReturn = 0; @@ -32804,7 +32150,7 @@ void CvPlayer::ChangeNumHistoricEvents(HistoricEventTypes eHistoricEvent, int iC //boost the chance if we have a slot for the corresponding great work if ((UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass() == GC.getInfoTypeForString("UNITCLASS_WRITER")) - { + { if (GetCulture()->GetNumAvailableGreatWorkSlots(CvTypes::getGREAT_WORK_SLOT_LITERATURE()) > 0) { vPossibleSpecialists.push_back(eSpecialist); @@ -32841,7 +32187,7 @@ void CvPlayer::ChangeNumHistoricEvents(HistoricEventTypes eHistoricEvent, int iC //Get % of threshold for test. iGPThreshold *= iEventGP; iGPThreshold /= 100; - + pCapital->GetCityCitizens()->ChangeSpecialistGreatPersonProgressTimes100(eBestSpecialist, iGPThreshold, true); if (GetID() == GC.getGame().getActivePlayer()) { @@ -32860,7 +32206,7 @@ void CvPlayer::ChangeNumHistoricEvents(HistoricEventTypes eHistoricEvent, int iC strMessage = GetLocalizedText("TXT_KEY_TOURISM_EVENT_GP_BONUS_SCIENTIST", iGPThreshold); } else if ((UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass() == GC.getInfoTypeForString("UNITCLASS_WRITER")) - { + { strMessage = GetLocalizedText("TXT_KEY_TOURISM_EVENT_GP_BONUS_WRITER", iGPThreshold); } else if ((UnitClassTypes)pkSpecialistInfo->getGreatPeopleUnitClass() == GC.getInfoTypeForString("UNITCLASS_ARTIST")) @@ -33058,7 +32404,7 @@ int CvPlayer::GetHistoricEventTourism(HistoricEventTypes eHistoricEvent, CvCity* strTemp += ", "; CvString strTurn; - + strTurn.Format("%d, ", GC.getGame().getGameTurn()); // turn strTemp += strTurn; @@ -33067,7 +32413,7 @@ int CvPlayer::GetHistoricEventTourism(HistoricEventTypes eHistoricEvent, CvCity* CvString strData; strData.Format(" --- Total Events: %d. Tourism bonus with all civs (before modifiers): %d", GetNumHistoricEvents(), iTotalBonus); strTemp += strData; - + pLog->Msg(strTemp); } @@ -33529,7 +32875,7 @@ void CvPlayer::SetHasLostCapital(bool bValue, PlayerTypes eConqueror) if (!isMajorCiv()) return; - // Calculate who owns the most original capitals by iterating through all civs + // Calculate who owns the most original capitals by iterating through all civs // and finding out who owns their original capital. std::vector OriginalCapitals; CvMap& kMap = GC.getMap(); @@ -34086,7 +33432,7 @@ void CvPlayer::SetHasLostCapital(bool bValue, PlayerTypes eConqueror) CvString translatedMessage = message.toUTF8(); GC.getGame().addReplayMessage(REPLAY_MESSAGE_MAJOR_EVENT, GetID(), translatedMessage, GetOriginalCapitalX(), GetOriginalCapitalY()); - } + } } } @@ -34361,7 +33707,7 @@ int CvPlayer::calculateMilitaryMight(DomainTypes eDomain) const } iSum += iPower; } - + return (iSum / 4); } @@ -34408,15 +33754,10 @@ int CvPlayer::getCombatExperienceTimes100() const } // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_LOCAL_GENERALS) void CvPlayer::setCombatExperienceTimes100(int iExperienceTimes100, CvUnit* pFromUnit) -#else -void CvPlayer::setCombatExperienceTimes100(int iExperienceTimes100) -#endif { - CvAssert(iExperienceTimes100 >= 0); - + if (iExperienceTimes100 != getCombatExperienceTimes100()) { m_iCombatExperienceTimes100 = iExperienceTimes100; @@ -34429,10 +33770,8 @@ void CvPlayer::setCombatExperienceTimes100(int iExperienceTimes100) { // create great person CvCity* pBestCity = NULL; -#if defined(MOD_GLOBAL_LOCAL_GENERALS) if(pFromUnit == NULL) { -#endif int iBestValue = INT_MAX; int iLoop = 0; for(CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) @@ -34451,15 +33790,9 @@ void CvPlayer::setCombatExperienceTimes100(int iExperienceTimes100) iBestValue = iValue; } } -#if defined(MOD_GLOBAL_LOCAL_GENERALS) } -#endif -#if defined(MOD_GLOBAL_LOCAL_GENERALS) if(pBestCity || pFromUnit) -#else - if(pBestCity) -#endif { // Figure out which Promotion is the one which makes a unit a Great General for(int iI = 0; iI < GC.getNumPromotionInfos(); iI++) @@ -34483,39 +33816,22 @@ void CvPlayer::setCombatExperienceTimes100(int iExperienceTimes100) if(eUnit == eLoopUnit) { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) if (pFromUnit && !MOD_LOCAL_GENERALS_NEAREST_CITY) { - CUSTOMLOG("Create Great General at (%d, %d) from unit %s", pFromUnit->plot()->getX(), pFromUnit->plot()->getY(), pFromUnit->getName().GetCString()); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) createGreatGeneral(eUnit, pFromUnit->plot()->getX(), pFromUnit->plot()->getY(), false); -#else - createGreatGeneral(eUnit, pFromUnit->plot()->getX(), pFromUnit->plot()->getY()); -#endif } else if (pFromUnit && MOD_LOCAL_GENERALS_NEAREST_CITY) - { + { CvCity* pNearestCity = GetClosestCityByPathLength(pFromUnit->plot()); CUSTOMLOG("Create Great General at (%d, %d) from unit %s", pNearestCity->plot()->getX(), pNearestCity->plot()->getY(), pFromUnit->getName().GetCString()); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) createGreatGeneral(eUnit, pNearestCity->plot()->getX(), pNearestCity->plot()->getY(), false); -#else - createGreatGeneral(eUnit, pNearestCity->plot()->getX(), pNearestCity->plot()->getY()); -#endif } else { -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pBestCity->createGreatGeneral(eUnit, false); -#else - pBestCity->createGreatGeneral(eUnit); -#endif -#if defined(MOD_GLOBAL_LOCAL_GENERALS) } -#endif setCombatExperienceTimes100(getCombatExperienceTimes100() - iExperienceThresholdTimes100); break; } @@ -34532,11 +33848,7 @@ void CvPlayer::setCombatExperienceTimes100(int iExperienceTimes100) } // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_LOCAL_GENERALS) void CvPlayer::changeCombatExperienceTimes100(int iChangeTimes100, CvUnit* pFromUnit) -#else -void CvPlayer::changeCombatExperienceTimes100(int iChangeTimes100) -#endif { if (getCombatExperienceTimes100() + iChangeTimes100 < 0) { @@ -34544,11 +33856,7 @@ void CvPlayer::changeCombatExperienceTimes100(int iChangeTimes100) } else { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) setCombatExperienceTimes100(getCombatExperienceTimes100() + iChangeTimes100, pFromUnit); -#else - setCombatExperienceTimes100(getCombatExperienceTimes100() + iChangeTimes100); -#endif } m_iLifetimeCombatExperienceTimes100 += iChangeTimes100; @@ -34561,11 +33869,7 @@ int CvPlayer::getNavalCombatExperienceTimes100() const } // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_LOCAL_GENERALS) void CvPlayer::setNavalCombatExperienceTimes100(int iExperienceTimes100, CvUnit* pFromUnit) -#else -void CvPlayer::setNavalCombatExperienceTimes100(int iExperienceTimes100) -#endif { CvAssert(iExperienceTimes100 >= 0); @@ -34581,10 +33885,8 @@ void CvPlayer::setNavalCombatExperienceTimes100(int iExperienceTimes100) { // create great person CvCity* pBestCity = NULL; -#if defined(MOD_GLOBAL_LOCAL_GENERALS) if(pFromUnit == NULL) { -#endif int iBestValue = INT_MAX; int iLoop = 0; for(CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) @@ -34608,15 +33910,9 @@ void CvPlayer::setNavalCombatExperienceTimes100(int iExperienceTimes100) iBestValue = iValue; } } -#if defined(MOD_GLOBAL_LOCAL_GENERALS) } -#endif -#if defined(MOD_GLOBAL_LOCAL_GENERALS) if(pBestCity || pFromUnit) -#else - if(pBestCity) -#endif { for(int iI = 0; iI < GC.getNumPromotionInfos(); iI++) { @@ -34639,22 +33935,15 @@ void CvPlayer::setNavalCombatExperienceTimes100(int iExperienceTimes100) if(eUnit == eLoopUnit) { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) if (pFromUnit && !MOD_LOCAL_GENERALS_NEAREST_CITY) { - CUSTOMLOG("Create Great Admiral at (%d, %d) from unit %s", pFromUnit->plot()->getX(), pFromUnit->plot()->getY(), pFromUnit->getName().GetCString()); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) createGreatAdmiral(eUnit, pFromUnit->plot()->getX(), pFromUnit->plot()->getY(), false); -#else - createGreatAdmiral(eUnit, pFromUnit->plot()->getX(), pFromUnit->plot()->getY()); -#endif -#if defined(MOD_PROMOTIONS_FLAGSHIP) + if (MOD_PROMOTIONS_FLAGSHIP) { pFromUnit->setHasPromotion((PromotionTypes)GD_INT_GET(PROMOTION_FLAGSHIP), true); } -#endif } else if (pFromUnit && MOD_LOCAL_GENERALS_NEAREST_CITY) { @@ -34677,15 +33966,8 @@ void CvPlayer::setNavalCombatExperienceTimes100(int iExperienceTimes100) } else { -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pBestCity->createGreatAdmiral(eUnit, false); -#else - pBestCity->createGreatAdmiral(eUnit); -#endif -#if defined(MOD_GLOBAL_LOCAL_GENERALS) } -#endif setNavalCombatExperienceTimes100(getNavalCombatExperienceTimes100() - iExperienceThresholdTimes100); break; } @@ -34701,11 +33983,7 @@ void CvPlayer::setNavalCombatExperienceTimes100(int iExperienceTimes100) } } // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_LOCAL_GENERALS) void CvPlayer::changeNavalCombatExperienceTimes100(int iChangeTimes100, CvUnit* pFromUnit) -#else -void CvPlayer::changeNavalCombatExperienceTimes100(int iChangeTimes100) -#endif { if (getNavalCombatExperienceTimes100() + iChangeTimes100 < 0) { @@ -34713,11 +33991,7 @@ void CvPlayer::changeNavalCombatExperienceTimes100(int iChangeTimes100) } else { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) setNavalCombatExperienceTimes100(getNavalCombatExperienceTimes100() + iChangeTimes100, pFromUnit); -#else - setNavalCombatExperienceTimes100(getNavalCombatExperienceTimes100() + iChangeTimes100); -#endif } m_iLifetimeCombatExperienceTimes100 += iChangeTimes100; @@ -34733,17 +34007,20 @@ int CvPlayer::getLifetimeCombatExperienceTimes100() const // -------------------------------------------------------------------------------- // Remove all the parts of the spaceship that this player has assembled void CvPlayer::disassembleSpaceship(CvPlot* pPlot) { - if (MOD_GLOBAL_NO_CONQUERED_SPACESHIPS && !isMinorCiv() && !isBarbarian()) { + if (MOD_GLOBAL_NO_CONQUERED_SPACESHIPS && !isMinorCiv() && !isBarbarian()) + { CUSTOMLOG("Disassemble spaceship for player %i", GetID()); CvTeam& thisTeam = GET_TEAM(getTeam()); - if (thisTeam.getProjectCount((ProjectTypes) GD_INT_GET(SPACE_RACE_TRIGGER_PROJECT)) == 1) { + if (thisTeam.getProjectCount((ProjectTypes) GD_INT_GET(SPACE_RACE_TRIGGER_PROJECT)) == 1) + { thisTeam.changeProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_CAPSULE), -1 * thisTeam.getProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_CAPSULE))); thisTeam.changeProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_BOOSTER), -1 * thisTeam.getProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_BOOSTER))); thisTeam.changeProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_STASIS), -1 * thisTeam.getProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_STASIS))); thisTeam.changeProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_ENGINE), -1 * thisTeam.getProjectCount((ProjectTypes) GD_INT_GET(SPACESHIP_ENGINE))); - if (pPlot) { + if (pPlot) + { CUSTOMLOG("Removing launch pad at (%i, %i)", pPlot->getX(), pPlot->getY()); CvInterfacePtr pDllPlot(new CvDllPlot(pPlot)); gDLL->GameplaySpaceshipEdited(pDllPlot.get(), 0x0000); // Remove the launch pad @@ -34886,7 +34163,7 @@ int CvPlayer::GetNumValidMajorsMet(bool bJustMetBuffer) const if (bJustMetBuffer && GET_TEAM(getTeam()).GetTurnsSinceMeetingTeam(GET_PLAYER(eLoopPlayer).getTeam()) < iJustMetBuffer) continue; - + iNumPlayers++; } } @@ -34901,11 +34178,11 @@ bool CvPlayer::HasMetValidMinorCiv() const for (int iPlayerLoop = MAX_MAJOR_CIVS; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++) { PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop; - + if (GET_TEAM(getTeam()).isHasMet(GET_PLAYER(eLoopPlayer).getTeam()) && GET_PLAYER(eLoopPlayer).isMinorCiv() && GET_PLAYER(eLoopPlayer).isAlive() && GET_PLAYER(eLoopPlayer).getNumCities() > 0 && !IsAtWarWith(eLoopPlayer)) return true; } - + return false; } @@ -35059,7 +34336,7 @@ void CvPlayer::setAlive(bool bNewValue, bool bNotify) GET_TEAM(getTeam()).DoEndVassal(eTheirTeam, true, true); GET_TEAM(eTheirTeam).DoEndVassal(getTeam(), true, true); - // put both teams at peace + // put both teams at peace GET_TEAM(getTeam()).setAtWar(eTheirTeam, false, false); GET_TEAM(eTheirTeam).setAtWar(getTeam(), false, false); @@ -35274,11 +34551,12 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default DoUnitAttrition(); -#if defined(MOD_CORE_DELAYED_VISIBILITY) - //force update in case one of our units was killed or moved - for (int iI = 0; iI < theMap.numPlots(); iI++) - theMap.plotByIndexUnchecked(iI)->flipVisibility(getTeam()); -#endif + if (MOD_CORE_DELAYED_VISIBILITY) + { + // Force update in case one of our units was killed or moved + for (int iI = 0; iI < theMap.numPlots(); iI++) + theMap.plotByIndexUnchecked(iI)->flipVisibility(getTeam()); + } if(kGame.getActivePlayer() == m_eID) theMap.updateDeferredFog(); @@ -35302,7 +34580,7 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default infoStream << getName(); kGame.changeNumGameTurnActive(1, infoStream.str()); infoStream << std::endl; - if (isMajorCiv() || isBarbarian()) + if (isMajorCiv() || isBarbarian()) OutputDebugString(infoStream.str().c_str()); */ @@ -35352,8 +34630,7 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default doWarnings(); } -#if defined(MOD_ACTIVE_DIPLOMACY) - if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) + if (GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY) { if (isHuman()) { @@ -35362,7 +34639,6 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default CvDiplomacyRequests::s_aDiploHumans.push_back(GetID()); } } -#endif if(GetID() == kGame.getActivePlayer()) { @@ -35389,19 +34665,18 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default else { -#if defined(MOD_CORE_DELAYED_VISIBILITY) - //visibility expires now! - for (int iI = 0; iI < theMap.numPlots(); iI++) - theMap.plotByIndexUnchecked(iI)->flipVisibility(getTeam()); -#endif + if (MOD_CORE_DELAYED_VISIBILITY) + { + // Visibility expires now! + for (int iI = 0; iI < theMap.numPlots(); iI++) + theMap.plotByIndexUnchecked(iI)->flipVisibility(getTeam()); + } -#if defined(MOD_EVENTS_RED_TURN) if (MOD_EVENTS_RED_TURN) - // RED <<<<< { ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if(pkScriptSystem) - { + { CvLuaArgsHandle args; args->Push(GetID()); @@ -35410,13 +34685,12 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default LuaSupport::CallHook(pkScriptSystem, "PlayerEndTurnInitiated", args.get(), bResult); } } - // RED >>>>> -#endif -#if defined(MOD_EVENTS_PLAYER_TURN) - if (MOD_EVENTS_PLAYER_TURN) { + + if (MOD_EVENTS_PLAYER_TURN) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerDoneTurn, GetID()); } -#endif + CvAssertFmt(GetEndTurnBlockingType() == NO_ENDTURN_BLOCKING_TYPE, "Expecting the end-turn blocking to be NO_ENDTURN_BLOCKING_TYPE, got %d", GetEndTurnBlockingType()); SetEndTurnBlocking(NO_ENDTURN_BLOCKING_TYPE, -1); // Make sure this is clear so the UI doesn't block when it is not our turn. @@ -35452,18 +34726,16 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default infoStream << getName(); kGame.changeNumGameTurnActive(-1, infoStream.str()); infoStream << std::endl; - if (isMajorCiv() || isBarbarian()) + if (isMajorCiv() || isBarbarian()) OutputDebugString(infoStream.str().c_str()); } */ -#if defined(MOD_EVENTS_RED_TURN) if (MOD_EVENTS_RED_TURN) - // RED <<<<< { ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if(pkScriptSystem) - { + { CvLuaArgsHandle args; args->Push(GetID()); @@ -35472,8 +34744,6 @@ void CvPlayer::setTurnActive(bool bNewValue, bool bDoTurn) // R: bDoTurn default LuaSupport::CallHook(pkScriptSystem, "PlayerEndTurnCompleted", args.get(), bResult); } } - // RED >>>>> -#endif DLLUI->PublishPlayerTurnStatus(DLLUIClass::TURN_END, GetID()); } @@ -35525,7 +34795,7 @@ void CvPlayer::setDynamicTurnsSimultMode(bool simultaneousTurns) m_bDynamicTurnsSimultMode = simultaneousTurns; } - + } // ---------------------------------------------------------------------------- @@ -35571,8 +34841,8 @@ void CvPlayer::setEndTurn(bool bNewValue) CvGame& game = GC.getGame(); if(isSimultaneousTurns() - && bNewValue - && game.isNetworkMultiPlayer() + && bNewValue + && game.isNetworkMultiPlayer() && !gDLL->HasReceivedTurnAllCompleteFromAllPlayers()) {//When doing simultaneous turns in multiplayer, we don't want anyone to end their turn until everyone has signalled TurnAllComplete. // No setting end turn to true until all the players have sent the TurnComplete network message @@ -35648,15 +34918,15 @@ void CvPlayer::checkRunAutoMovesForEveryone() for(i = 0; i < MAX_PLAYERS; ++i) { CvPlayer& p = CvPlayerAI::getPlayer((PlayerTypes)i); - if(p.isHuman() && !p.isObserver() - // Check to see if this human player hasn't gotten to the end turn phase of their turn. + if(p.isHuman() && !p.isObserver() + // Check to see if this human player hasn't gotten to the end turn phase of their turn. // This gets tricky because hot joiners can hop into an ai civ that already finished their turn. // When this occurs, the hot joiner will not be turn active, will have already run their automoves, // and not have end turn set. (AIs do not set end turn) *sigh* // To handle that case, we assume that human players who are not endturn and turn inactive after TurnAllComplete // are ready for the human automoves phase. && (!p.isEndTurn() - && (!gDLL->HasReceivedTurnAllCompleteFromAllPlayers() || p.isTurnActive()))) + && (!gDLL->HasReceivedTurnAllCompleteFromAllPlayers() || p.isTurnActive()))) { runAutoMovesForEveryone = false; break; @@ -35976,26 +35246,26 @@ void CvPlayer::setLeaderType(LeaderHeadTypes eNewLeader) if (isMajorCiv()) { LeaderHeadTypes eOldLeader = getLeaderType(); - + // Set the new leader type CvPreGame::setLeaderHead(GetID(), eNewLeader); - + // Update the player's personality setPersonalityType(eNewLeader); - + // Update the player's traits (Leader_Traits) GetPlayerTraits()->Reset(); GetPlayerTraits()->InitPlayerTraits(); recomputePolicyCostModifier(); - - if (!isHuman()) + + if (!isHuman()) { // Update the player's biases (Leader_MajorCivApproachBiases) // Nothing to do as they are not cached in CvPlayer - + // Update the player's flavours (Leader_Flavors) GetFlavorManager()->ChangeLeader(eOldLeader, eNewLeader); - + // Update the player's strategies // Nothing to do as these will auto-update based on the new flavours at the end of the player's turn } @@ -37013,124 +36283,49 @@ void CvPlayer::changeXPopulationConscription(int iChange) { m_iXPopulationConscription += iChange; } + void CvPlayer::DoXPopulationConscription(CvCity* pCity) { - UnitTypes eBestUnit = NO_UNIT; - int iStrengthBest = 0; - // Loop through adding the available units - for (int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) - { - UnitTypes eLoopUnit = (UnitTypes)iUnitLoop; - if (eLoopUnit != NO_UNIT) - { - CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eLoopUnit); - if (pkUnitEntry) - { - if (!pCity->canTrain(eLoopUnit)) - { - continue; - } - - if (pkUnitEntry->GetCombat() <= 0 && pkUnitEntry->GetRangedCombat() <= 0) - continue; - - if (pkUnitEntry->GetDefaultUnitAIType() == UNITAI_EXPLORE) - continue; + UnitTypes eUnit = GetCompetitiveSpawnUnitType(true, false, false, true, pCity, true, false, true); + if (eUnit == NO_UNIT) + return; - if (pkUnitEntry->GetDomainType() != DOMAIN_LAND) - continue; + CvUnit* pUnit = pCity->CreateUnit(eUnit, NO_UNITAI, REASON_GIFT); + if (!pUnit) + return; - bool bBad = false; - ResourceTypes eResource; - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes)iResourceLoop; - int iNumResource = pkUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - bBad = true; - break; - } - if (pkUnitEntry->GetResourceType() == eResource) - { - bBad = true; - break; - } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS && pkUnitEntry->GetResourceQuantityTotal(eResource) > 0) - { - bBad = true; - break; - } -#endif - } + PromotionTypes ePromotionConscript = static_cast(GC.getInfoTypeForString("PROMOTION_CONSCRIPT")); + changeNumUnitsSupplyFree(1); + pUnit->changeNoSupply(1); + pUnit->setHasPromotion(ePromotionConscript, true); - if (bBad) - { - continue; - } + if (!pUnit->jumpToNearestValidPlot()) + { + pUnit->kill(false); // Could not find a valid spot! + return; + } - int iCombatStrength = (pkUnitEntry->GetPower() + GC.getGame().randRangeExclusive(0, pkUnitEntry->GetPower(), pCity->plot()->GetPseudoRandomSeed().mix(getTotalPopulation()))); - if (pkUnitEntry->GetRange() > 0) - { - iCombatStrength *= 50; - iCombatStrength /= 100; - } + pUnit->finishMoves(); + pUnit->SetTurnProcessed(true); - if (iCombatStrength <= 0) - iCombatStrength = 1; - - if (iCombatStrength > iStrengthBest) - { - iStrengthBest = iCombatStrength; - eBestUnit = eLoopUnit; - } - } - } - } - if (eBestUnit != NO_UNIT) + CvNotifications* pNotifications = GetNotifications(); + if (pNotifications) { - CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eBestUnit); - if (pkUnitEntry) - { - UnitAITypes eUnitAI = pkUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCity->CreateUnit(eBestUnit, eUnitAI, REASON_GIFT); - if (pUnit) - { - changeNumUnitsSupplyFree(1); - pUnit->changeNoSupply(1); - PromotionTypes ePromotionConscript = (PromotionTypes)GC.getInfoTypeForString("PROMOTION_CONSCRIPT"); - if (ePromotionConscript != NO_PROMOTION) - pUnit->setHasPromotion(ePromotionConscript, true); + Localization::String localizedText = Localization::Lookup("TXT_KEY_NOTIFICATION_CONSCRIPTION_SPAWN"); + localizedText << pCity->getNameKey() << pCity->getPopulation() << pUnit->getNameKey(); + Localization::String localizedSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_CONSCRIPTION_SPAWN_SUMMARY"); + localizedSummary << getNameKey() << pUnit->getNameKey(); + pNotifications->Add(NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER, localizedText.toUTF8(), localizedSummary.toUTF8(), pUnit->getX(), pUnit->getY(), eUnit); + } - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - else - { - pUnit->finishMoves(); - pUnit->SetTurnProcessed(true); - CvNotifications* pNotifications = GetNotifications(); - if (pUnit && pNotifications) - { - Localization::String localizedText = Localization::Lookup("TXT_KEY_NOTIFICATION_CONSCRIPTION_SPAWN"); - localizedText << pCity->getNameKey() << pCity->getPopulation() << pUnit->getNameKey(); - Localization::String localizedSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_CONSCRIPTION_SPAWN_SUMMARY"); - localizedSummary << getNameKey() << pUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER, localizedText.toUTF8(), localizedSummary.toUTF8(), pUnit->getX(), pUnit->getY(), eBestUnit); - } - if (GC.getLogging() && GC.getAILogging()) - { - CvString strLogString; - strLogString.Format("Conscripted %s spawned at %s. Population: %d", pUnit->getName().GetCString(), pCity->getName().GetCString(), pCity->getPopulation()); - GetHomelandAI()->LogHomelandMessage(strLogString); - } - } - } - } + if (GC.getLogging() && GC.getAILogging()) + { + CvString strLogString; + strLogString.Format("Conscripted %s spawned at %s. Population: %d", pUnit->getName().GetCString(), pCity->getName().GetCString(), pCity->getPopulation()); + GetHomelandAI()->LogHomelandMessage(strLogString); } } + // -------------------------------------------------------------------------------- int CvPlayer::GetExtraMoves() const { @@ -37604,11 +36799,7 @@ void CvPlayer::SetUnitClassReplacement(UnitClassTypes eReplacedUnitClass, UnitCl { if (pLoopUnit->getUnitClassType() == eReplacedUnitClass && pLoopUnit->getUnitType() == eReplacedClassDefault) { -#if defined(MOD_BALANCE_CORE) CvUnit* pNewUnit = initUnit(eReplacementUnit, pLoopUnit->getX(), pLoopUnit->getY(), NO_UNITAI, REASON_UPGRADE, false, false, 0, 0, NO_CONTRACT, true, pLoopUnit); -#else - CvUnit* pNewUnit = initUnit(eReplacementUnit, pLoopUnit->getX(), pLoopUnit->getY(), NO_UNITAI, REASON_UPGRADE, false, false); -#endif if (pNewUnit != NULL) { pNewUnit->convert(pLoopUnit, true); @@ -37661,7 +36852,7 @@ int CvPlayer::GetScalingNationalPopulationRequired(BuildingTypes eBuilding) cons iNationalPop *= iModifier; iNationalPop /= 100; - + return max(0, iNationalPop); } } @@ -37746,7 +36937,7 @@ int CvPlayer::GetScienceTimes100() const // Science from religion iValue += GetYieldPerTurnFromReligion(YIELD_SCIENCE) * 100; - // Trait bonus which adds Science for trade partners? + // Trait bonus which adds Science for trade partners? iValue += GetYieldPerTurnFromTraits(YIELD_SCIENCE) * 100; // Science from other players! @@ -38075,7 +37266,7 @@ int CvPlayer::GetTeamNumTurnsAtWar(TeamTypes eTeam) const iMaxTurns = GetPlayerNumTurnsAtWar(ePlayer); } } - + return iMaxTurns; } @@ -38952,7 +38143,6 @@ void CvPlayer::DoCivilianReturnLogic(bool bReturn, PlayerTypes eToPlayer, int iU GET_PLAYER(eToPlayer).GetDiplomacyAI()->ChangeNumCiviliansReturnedToMe(GetID(), 1); } } -#if defined(MOD_BALANCE_CORE) else if(GET_PLAYER(eToPlayer).isHuman() && pNewUnit) { CvNotifications* pNotification = GET_PLAYER(eToPlayer).GetNotifications(); @@ -38965,7 +38155,6 @@ void CvPlayer::DoCivilianReturnLogic(bool bReturn, PlayerTypes eToPlayer, int iU pNotification->Add(NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER, localizedText.toUTF8(), localizedSummary.toUTF8(), pNewUnit->getX(), pNewUnit->getY(), pNewUnit->getUnitType()); } } -#endif } // Kept for oneself else @@ -38973,14 +38162,14 @@ void CvPlayer::DoCivilianReturnLogic(bool bReturn, PlayerTypes eToPlayer, int iU // Make a new unit because the kind we should capture doesn't match (e.g. Settler to Worker) if(eNewUnitType != pUnit->getUnitType()) { -#if defined(MOD_GLOBAL_GRATEFUL_SETTLERS) // In OCC games, all captured settlers are converted - if ((pUnit->isFound() || pUnit->IsFoundAbroad()) && MOD_GLOBAL_GRATEFUL_SETTLERS && !(GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE) && isHuman())) { + if ((pUnit->isFound() || pUnit->IsFoundAbroad()) && MOD_GLOBAL_GRATEFUL_SETTLERS && !(GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE) && isHuman())) + { int iDefectProb = gCustomMods.getOption("GLOBAL_GRATEFUL_SETTLERS_PERCENT", 20); int iPercent = 0; // Approach is very important - switch (GetDiplomacyAI()->GetCivApproach(eToPlayer)) + switch (GetDiplomacyAI()->GetCivApproach(eToPlayer)) { case CIV_APPROACH_WAR: iPercent = iDefectProb * gCustomMods.getOption("GLOBAL_GRATEFUL_SETTLERS_WAR_MULTIPLIER", 0) / gCustomMods.getOption("GLOBAL_GRATEFUL_SETTLERS_DIVISOR", 8); @@ -39008,7 +38197,7 @@ void CvPlayer::DoCivilianReturnLogic(bool bReturn, PlayerTypes eToPlayer, int iU } // Opinion also matters - switch (GetDiplomacyAI()->GetCivOpinion(eToPlayer)) + switch (GetDiplomacyAI()->GetCivOpinion(eToPlayer)) { case CIV_OPINION_ALLY: iPercent += iDefectProb * 5 / 4; @@ -39049,7 +38238,6 @@ void CvPlayer::DoCivilianReturnLogic(bool bReturn, PlayerTypes eToPlayer, int iU iPercent /= 2; } -#if defined(MOD_GLOBAL_RELIGIOUS_SETTLERS) if (MOD_GLOBAL_RELIGIOUS_SETTLERS) { ReligionTypes eReligion = pUnit->GetReligionData()->GetReligion(); @@ -39071,18 +38259,19 @@ void CvPlayer::DoCivilianReturnLogic(bool bReturn, PlayerTypes eToPlayer, int iU } } } -#endif // Limit the outcome iPercent = std::min(80, iPercent); - + // Use the popularity difference between the players to skew the probability int iSmileRatio = (GetExcessHappiness() * 100) / (std::max(0, GET_PLAYER(eToPlayer).GetExcessHappiness()) + 10); iPercent = iPercent * std::min(150, std::max(75, iSmileRatio)) / 100; CUSTOMLOG("Settler defect percent: %i (Approach=%i, Opinion=%i)", iPercent, GetDiplomacyAI()->GetCivApproach(eToPlayer), GetDiplomacyAI()->GetCivOpinion(eToPlayer)); - if (GC.getGame().randRangeInclusive(1, 100, CvSeeder::fromRaw(0x3710b3a4).mix(GetPseudoRandomSeed())) <= iPercent) { - if (GC.getGame().getActivePlayer() == GetID()) { + if (GC.getGame().randRangeInclusive(1, 100, CvSeeder::fromRaw(0x3710b3a4).mix(GetPseudoRandomSeed())) <= iPercent) + { + if (GC.getGame().getActivePlayer() == GetID()) + { CvPopupInfo kPopupInfo(BUTTONPOPUP_TEXT); strcpy_s(kPopupInfo.szText, "TXT_KEY_GRATEFUL_SETTLERS"); GC.GetEngineUserInterface()->AddPopup(kPopupInfo); @@ -39094,16 +38283,15 @@ void CvPlayer::DoCivilianReturnLogic(bool bReturn, PlayerTypes eToPlayer, int iU if (pNewUnit) pNewUnit->finishMoves(); } - } else { -#endif + } + else + { pUnit->kill(true); CvUnit* pNewUnit = initUnit(eNewUnitType, iX, iY); CvAssert(pNewUnit != NULL); if (pNewUnit) pNewUnit->finishMoves(); -#if defined(MOD_GLOBAL_GRATEFUL_SETTLERS) } -#endif } } } @@ -39264,7 +38452,7 @@ PlayerTypes CvPlayer::GetBestGiftTarget(DomainTypes eUnitDomain) // Skip if not revealed. if (!pCity->isRevealed(getTeam(),false,false)) continue; - + int iFriendship = pMinorCivAI->GetFriendshipFromUnitGift(GetID(), false, true); if (!GET_TEAM(eMinor->getTeam()).isHasMet(getTeam())) @@ -39607,7 +38795,7 @@ void CvPlayer::addResourcesOnPlotToTotal(CvPlot* pPlot, bool bOnlyExtraResources // activate the resource link pPlot->SetResourceLinkedCityActive(true); } - + CvCity* pOwningCity = pPlot->getOwningCity(); if (pOwningCity) { @@ -39637,8 +38825,8 @@ void CvPlayer::removeResourcesOnPlotFromTotal(CvPlot* pPlot, bool bOnlyExtraReso if (!bOnlyExtraResources) { pOwningCity->ChangeNumResourceLocal(pPlot->getResourceType(), -pPlot->getNumResourceForPlayer(GetID(), false, bIgnoreTechPrereq), /*bUnimproved*/ false); - - } + + } } } @@ -39731,7 +38919,7 @@ int CvPlayer::getNumResourcesFromOther(ResourceTypes eIndex) const CvAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)"); CvAssertMsg(eIndex < GC.getNumResourceInfos(), "eIndex is expected to be within maximum bounds (invalid Index)"); - + CvResourceInfo *pkResource = GC.getResourceInfo(eIndex); // exists? @@ -39740,7 +38928,6 @@ int CvPlayer::getNumResourcesFromOther(ResourceTypes eIndex) const int iTotalNumResource = m_paiNumResourceFromTiles[eIndex]; iTotalNumResource += m_paiNumResourceFromBuildings[eIndex]; -#if defined(MOD_BALANCE_CORE) // Additional resources from Corporation CorporationTypes eCorporation = GetCorporations()->GetFoundedCorporation(); if (eCorporation != NO_CORPORATION) @@ -39769,11 +38956,9 @@ int CvPlayer::getNumResourcesFromOther(ResourceTypes eIndex) const //GP resources? ie. Admiral, Diplomat iTotalNumResource += getResourceFromGP(eIndex); -#endif if (pkResource->getResourceUsage() == RESOURCEUSAGE_STRATEGIC) { -#if defined(MOD_BALANCE_CORE) const CvCity* pLoopCity = NULL; int iLoop = 0; int iCityPOPResource = 0; @@ -39789,7 +38974,7 @@ int CvPlayer::getNumResourcesFromOther(ResourceTypes eIndex) const iTotalNumResource += (iFranchises / pLoopCity->GetResourceQuantityPerXFranchises(eIndex)); } } - + if (pLoopCity->GetResourceQuantityFromPOP(eIndex) > 0) { iCityPOPResource += (pLoopCity->getPopulation() * pLoopCity->GetResourceQuantityFromPOP(eIndex)); @@ -39798,7 +38983,7 @@ int CvPlayer::getNumResourcesFromOther(ResourceTypes eIndex) const } iTotalNumResource += iCityPOPResource / 100; -#endif + if (GetStrategicResourceMod() != 0) { iTotalNumResource *= 100 + GetStrategicResourceMod(); @@ -40026,7 +39211,7 @@ void CvPlayer::setResourceFromCSAlliances(ResourceTypes eIndex, int iChange) // -------------------------------------------------------------------------------- bool CvPlayer::IsResourceNotForSale(ResourceTypes eResource) { - // If the find function returns something other than the end iterator, a match was found + // If the find function returns something other than the end iterator, a match was found // and therefore the resource eResource is not for sale return std::find(m_vResourcesNotForSale.begin(), m_vResourcesNotForSale.end(), eResource) != m_vResourcesNotForSale.end(); @@ -40158,10 +39343,8 @@ void CvPlayer::UpdateMonopolyCache() m_iCombatAttackBonusFromMonopolies = 0; m_iCombatDefenseBonusFromMonopolies = 0; -#if defined(MOD_BALANCE_CORE_RESOURCE_MONOPOLIES) if (!MOD_BALANCE_CORE_RESOURCE_MONOPOLIES) return; -#endif for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) { @@ -40179,7 +39362,7 @@ void CvPlayer::UpdateMonopolyCache() CvResourceInfo* pInfo = GC.getResourceInfo(eResourceLoop); if (!pInfo) continue; - + m_iCombatAttackBonusFromMonopolies += pInfo->getMonopolyAttackBonus(); m_iCombatAttackBonusFromMonopolies += pInfo->getMonopolyAttackBonus(MONOPOLY_STRATEGIC); m_iCombatDefenseBonusFromMonopolies += pInfo->getMonopolyDefenseBonus(); @@ -40378,7 +39561,7 @@ void CvPlayer::CheckForMonopoly(ResourceTypes eResource) { iOwnedNumResource += getResourceImportFromMajor(eResource); } - + if (pkResourceInfo->getResourceUsage() == RESOURCEUSAGE_LUXURY && !GC.getGame().GetGameLeagues()->IsLuxuryHappinessBanned(GetID(), eResource)) { int iThreshold = max(GC.getGame().GetGreatestPlayerResourceMonopolyValue(eResource), /*50*/ GD_INT_GET(GLOBAL_RESOURCE_MONOPOLY_THRESHOLD)); @@ -40401,7 +39584,7 @@ void CvPlayer::CheckForMonopoly(ResourceTypes eResource) bGainingBonus = true; GC.getGame().UpdateGreatestPlayerResourceMonopoly(eResource); } - SetHasGlobalMonopoly(eResource, true); + SetHasGlobalMonopoly(eResource, true); } else { @@ -40457,7 +39640,7 @@ void CvPlayer::CheckForMonopoly(ResourceTypes eResource) GC.getGame().UpdateGreatestPlayerResourceMonopoly(eResource); } SetHasGlobalMonopoly(eResource, true); - + } else { @@ -40697,7 +39880,6 @@ bool CvPlayer::IsResourceRevealed(ResourceTypes eResource, bool bCheckTeam) cons TechTypes eDefaultTech = (TechTypes)pResource->getTechReveal(); TechTypes eTech = eDefaultTech; -#if defined(MOD_BALANCE_CORE) if (GetPlayerTraits()->IsAlternateResourceTechs()) { TechTypes eAltTech = GetPlayerTraits()->GetAlternateResourceTechs(eResource).m_eTechReveal; @@ -40706,7 +39888,7 @@ bool CvPlayer::IsResourceRevealed(ResourceTypes eResource, bool bCheckTeam) cons eTech = eAltTech; } } -#endif + // Then, check for the player's policy PolicyTypes ePolicy = (PolicyTypes)pResource->getPolicyReveal(); @@ -40794,12 +39976,12 @@ void CvPlayer::changeSiphonLuxuryCount(PlayerTypes eFromPlayer, int iChange) // -------------------------------------------------------------------------------- -/// Count up the number of resources we have been siphoning from others and compare it to how many +/// Count up the number of resources we have been siphoning from others and compare it to how many /// we are now allowed to siphon. Change our resource count if there is a discrepancy. void CvPlayer::UpdateResourcesSiphoned() { vector vDeltas; - + // Subtract all currently siphoned resources for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) { @@ -41101,6 +40283,66 @@ int CvPlayer::getResourceInOwnedPlots(ResourceTypes eIndex) return iCount; } +// -------------------------------------------------------------------------------- +// Returns whether this player has the resources required to train/upgrade to new eUnit +// If bNoRequirement is true, always return false if eUnit requires any resource +// If eUnit is upgraded from another unit, also pass in eFromUnit +// bContinue is true if eUnit is already being trained (in production) +// You may also use bContinue = true to check whether an existing unit has the required resources (for healing etc.) +bool CvPlayer::HasResourceForNewUnit(const UnitTypes eUnit, const bool bNoRequirement, const bool bCheckAluminum, const UnitTypes eFromUnit, const bool bContinue) const +{ + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnit); + if (!pUnitInfo) + return false; + + CvUnitEntry* pFromUnitInfo = NULL; + if (eFromUnit != NO_UNIT) + pFromUnitInfo = GC.getUnitInfo(eFromUnit); + + for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) + { + const ResourceTypes eResource = static_cast(iResourceLoop); + + int iResourceTotal = pUnitInfo->GetResourceQuantityTotal(eResource); + if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS && iResourceTotal > 0) + { + if (bNoRequirement) + return false; + + if (getNumResourceTotal(eResource) < iResourceTotal || getNumResourceAvailable(eResource) < 0) + return false; + } + + int iResourceRequirement = pUnitInfo->GetResourceQuantityRequirement(eResource); + if (iResourceRequirement > 0) + { + if (bNoRequirement) + return false; + + // This requirement only applies for major civs + if (!isMajorCiv()) + continue; + + int iFreedUpResource = 0; + if (pFromUnitInfo) + iFreedUpResource = pFromUnitInfo->GetResourceQuantityRequirement(eResource); + + // The resource quantity is already on hold, don't need extras + if (bContinue) + iResourceRequirement = 0; + + // Don't use all of our Aluminum, keep some for spaceship parts + if (bCheckAluminum && iResourceLoop == GC.getInfoTypeForString("RESOURCE_ALUMINUM")) + iResourceRequirement += GetNumAluminumStillNeededForSpaceship() + GetNumAluminumStillNeededForCoreCities(); + + if (getNumResourceAvailable(eResource, true) + iFreedUpResource < iResourceRequirement) + return false; + } + } + + return true; +} + // -------------------------------------------------------------------------------- int CvPlayer::getTotalImprovementsBuilt() const { @@ -41132,7 +40374,7 @@ void CvPlayer::changeImprovementCount(ImprovementTypes eIndex, int iChange, bool { CvAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)"); CvAssertMsg(eIndex < GC.getNumImprovementInfos(), "eIndex is expected to be within maximum bounds (invalid Index)"); - + m_paiImprovementCount[eIndex] += iChange; CvAssert(getImprovementCount(eIndex) >= 0); @@ -41185,7 +40427,7 @@ void CvPlayer::changeResponsibleForRouteCount(RouteTypes eIndex, int iChange) { CvAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)"); CvAssertMsg(eIndex < GC.getNumRouteInfos(), "eIndex is expected to be within maximum bounds (invalid Index)"); - + m_piResponsibleForRouteCount[eIndex] += iChange; if (m_piResponsibleForRouteCount[eIndex] == 0) // no point allocating memory since we assume 0 by default @@ -41310,7 +40552,7 @@ int CvPlayer::GetFreePromotionCount(PromotionTypes ePromotion) const // -------------------------------------------------------------------------------- /// Is ePromotion a free promotion? -bool CvPlayer::IsFreePromotion(PromotionTypes ePromotion) const +bool CvPlayer::IsFreePromotion(PromotionTypes ePromotion) const { return (GetFreePromotionCount(ePromotion) > 0); } @@ -42373,7 +41615,7 @@ bool CvPlayer::removeFromArmy(int iArmyID, int iID) // --------------------------------------------------------------------------- // Finds the path length from this tech type to one you already know (FIXED) // This one doesn't count technologies multiple times during recursive calls! -// A temporary buffer is used to mark techs already visited, so they can be +// A temporary buffer is used to mark techs already visited, so they can be // counted only once when the recursive calls end. // DEPRECATED, use findTechPathLength() instead; kept for compatibility with modmods int CvPlayer::findPathLengthNew(TechTypes eTech, int pTechs[]) const @@ -42860,11 +42102,9 @@ void CvPlayer::deleteCity(int iID) GC.getGame().SetClosestCityMapDirty(); -#if defined(MOD_BALANCE_CORE) int iLoop=0; for (CvCity* pCity=firstCity(&iLoop); pCity!=NULL; pCity=nextCity(&iLoop)) pCity->UpdateClosestFriendlyNeighbors(); -#endif } int CvPlayer::GetCityDistancePathLength( const CvPlot* pPlot ) const @@ -43230,13 +42470,9 @@ int CvPlayer::getNumUnits() const // -------------------------------------------------------------------------------- CvUnit* CvPlayer::getUnit(int iID) const { -#if defined(MOD_BALANCE_CORE) //spread it out a little for an easy breakpoint CvUnit* pUnit = m_units.Get(iID); return pUnit; -#else - return (m_units.GetAt(iID)); -#endif } // -------------------------------------------------------------------------------- @@ -43278,7 +42514,7 @@ CvArmyAI* CvPlayer::firstArmyAI(int* pIterIdx, bool bRev) if (bRev) *pIterIdx = m_armyAIs.GetCount()-1; else - *pIterIdx = 0; + *pIterIdx = 0; return m_armyAIs.GetAt(*pIterIdx); } @@ -43578,7 +42814,7 @@ bool CvPlayer::StopAllSeaDefensiveOperationsAgainstPlayer(PlayerTypes ePlayer, A CvAIOperation* CvPlayer::getFirstAIOperationOfType(AIOperationTypes eOperationType, PlayerTypes eTargetPlayer /* optional */, CvPlot* pTarget /* optional */) { int iMaxTargetDistance = 3; - + // loop through all entries looking for match for (size_t i = 0; i < m_AIOperations.size(); i++) { @@ -43775,7 +43011,7 @@ void CvPlayer::updateYieldPerTurnHistory() m_aiYieldHistory[YIELD_CULTURE].push_back(GetTotalJONSCulturePerTurn()); m_aiYieldHistory[YIELD_TOURISM].push_back(GetCulture()->GetTourism() / 100); m_aiYieldHistory[YIELD_GOLDEN_AGE_POINTS].push_back(GetGoldenAgePointsFromEmpire()); - + m_miLocalInstantYieldsTotal[YIELD_PRODUCTION] += GetAverageInstantProduction(); } @@ -44418,17 +43654,14 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) int iI = 0; int iJ = 0; + if (ePolicy == NO_POLICY) + return; + CvPolicyEntry* pPolicy = GC.getPolicyInfo(ePolicy); - if(pPolicy == NULL) - return; + CvAssert(pPolicy); -#if defined(MOD_TRAITS_OTHER_PREREQS) - if (MOD_TRAITS_OTHER_PREREQS) { + if (MOD_TRAITS_OTHER_PREREQS) GetPlayerTraits()->InitPlayerTraits(); - } -#endif - - const CvPolicyEntry& kPolicy = (*pPolicy); ChangeCulturePerWonder(pPolicy->GetCulturePerWonder() * iChange); ChangeCultureWonderMultiplier(pPolicy->GetCultureWonderMultiplier() * iChange); @@ -44443,7 +43676,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) ChangeHappinessPerGarrisonedUnit(pPolicy->GetHappinessPerGarrisonedUnit() * iChange); ChangeHappinessPerTradeRoute(pPolicy->GetHappinessPerTradeRoute() * iChange); ChangeHappinessPerXPopulation(pPolicy->GetHappinessPerXPopulation() * iChange); -#if defined(MOD_BALANCE_CORE_POLICIES) ChangeGreatGeneralCombatBonus(pPolicy->GetGreatGeneralExtraBonus() * iChange); ChangeExtraSupplyPerPopulation(pPolicy->GetExtraSupplyPerPopulation() * iChange); ChangeExtraSupplyFlat(pPolicy->GetExtraSupplyFlat() * iChange); @@ -44560,7 +43792,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) ChangeGreatEngineerHurryMod(pPolicy->GetGreatEngineerHurryModifier() * iChange); ChangeTechCostXCitiesModifier(pPolicy->GetTechCostXCitiesMod() * iChange); ChangeTourismCostXCitiesMod(pPolicy->GetTourismCostXCitiesMod() * iChange); -#endif ChangeExtraHappinessPerLuxury(pPolicy->GetExtraHappinessPerLuxury() * iChange); ChangeUnhappinessFromUnitsMod(pPolicy->GetUnhappinessFromUnitsMod() * iChange); ChangeUnhappinessMod(pPolicy->GetUnhappinessMod() * iChange); @@ -44573,12 +43804,8 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) ChangeAlwaysSeeBarbCampsCount(pPolicy->IsAlwaysSeeBarbCamps() * iChange); ChangeMaxNumBuilders(pPolicy->GetNumExtraBuilders() * iChange); ChangePlotGoldCostMod(pPolicy->GetPlotGoldCostMod() * iChange); -#if defined(MOD_POLICIES_CITY_WORKING) ChangeCityWorkingChange(pPolicy->GetCityWorkingChange() * iChange); -#endif -#if defined(MOD_POLICIES_CITY_AUTOMATON_WORKERS) ChangeCityAutomatonWorkersChange(pPolicy->GetCityAutomatonWorkersChange() * iChange); -#endif ChangePlotCultureCostModifier(pPolicy->GetPlotCultureCostModifier() * iChange); ChangePlotCultureExponentModifier(pPolicy->GetPlotCultureExponentModifier() * iChange); ChangeNumCitiesPolicyCostDiscount(pPolicy->GetNumCitiesPolicyCostDiscount() * iChange); @@ -44594,9 +43821,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) changeSettlerProductionModifier(pPolicy->GetSettlerProductionModifier() * iChange); changeCapitalSettlerProductionModifier(pPolicy->GetCapitalSettlerProductionModifier() * iChange); ChangeImprovementGoldMaintenanceMod(pPolicy->GetImprovementGoldMaintenanceMod() * iChange); -#if defined(MOD_CIV6_WORKER) ChangeRouteBuilderCostMod(pPolicy->GetRouteBuilderCostMod() * iChange); -#endif ChangeBuildingGoldMaintenanceMod(pPolicy->GetBuildingGoldMaintenanceMod() * iChange); ChangeUnitGoldMaintenanceMod(pPolicy->GetUnitGoldMaintenanceMod() * iChange); ChangeUnitSupplyMod(pPolicy->GetUnitSupplyMod() * iChange); @@ -44605,9 +43830,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) changeHappinessToScience(pPolicy->GetHappinessToScience() * iChange); changeHalfSpecialistUnhappinessCount((pPolicy->IsHalfSpecialistUnhappiness()) ? iChange : 0); changeHalfSpecialistFoodCount((pPolicy->IsHalfSpecialistFood()) ? iChange : 0); -#if defined(MOD_BALANCE_CORE) changeHalfSpecialistFoodCapitalCount((pPolicy->IsHalfSpecialistFoodCapital()) ? iChange : 0); -#endif changeMilitaryFoodProductionCount((pPolicy->IsMilitaryFoodProduction()) ? iChange : 0); ChangeGoldenAgeCultureBonusDisabledCount((pPolicy->IsGoldenAgeCultureBonusDisabled()) ? iChange : 0); ChangeSecondReligionPantheonCount((pPolicy->IsSecondReligionPantheon()) ? iChange : 0); @@ -44625,7 +43848,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) ChangeFreeFoodBox(pPolicy->GetFreeFoodBox() * iChange); ChangeStrategicResourceMod(pPolicy->GetStrategicResourceMod() * iChange); -#if defined(MOD_BALANCE_CORE) if(MOD_BALANCE_CORE_RESOURCE_MONOPOLIES_STRATEGIC && pPolicy->GetStrategicResourceMod() > 0) { for(int iLoop = 0; iLoop < GC.getNumResourceInfos(); iLoop++) @@ -44647,8 +43869,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) ChangeUnitClassProductionModifier(eUnitClass, (pPolicy->GetUnitClassProductionModifiers(iI) * iChange)); } } - -#endif + ChangeAbleToAnnexCityStatesCount((pPolicy->IsAbleToAnnexCityStates()) ? iChange : 0); ChangeOnlyTradeSameIdeology((pPolicy->IsOnlyTradeSameIdeology()) ? iChange : 0); if (pPolicy->IsOnlyTradeSameIdeology()) @@ -44724,7 +43945,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) CvPlayerAI& kPlayer = GET_PLAYER(ePlayer); if (ePlayer != NO_PLAYER && kPlayer.isMinorCiv() && kPlayer.isAlive()) { - kPlayer.GetMinorCivAI()->RecalculateRewards(GetID()); + kPlayer.GetMinorCivAI()->RecalculateRewards(GetID()); } } } @@ -44746,12 +43967,11 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) CreateSpies(GetFreeSpy()); changeFreeSpy(GetFreeSpy() * -1); } - + int iLoop = 0; - CvCity* pLoopCity = NULL; - for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) + for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { - if(pPolicy->GetFreePopulation() > 0) + if (pPolicy->GetFreePopulation() > 0) { pLoopCity->changePopulation(pPolicy->GetFreePopulation(), true, true); } @@ -44762,30 +43982,24 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) } changeExtraMoves(pPolicy->GetExtraMoves() * iChange); - if(pPolicy->GetXPopulationConscription() > 0) + if (pPolicy->GetXPopulationConscription() > 0) { changeXPopulationConscription(pPolicy->GetXPopulationConscription() * iChange); int iLoop = 0; - for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) + for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { - if(pLoopCity == NULL) - { + if (pLoopCity->getPopulation() < GetXPopulationConscription()) continue; - } - if(pLoopCity->getPopulation() < GetXPopulationConscription()) - { + if (pLoopCity->IsRazing()) continue; - } - if(pLoopCity->IsRazing()) - { - continue; - } - DoXPopulationConscription(pLoopCity); + + int iNumConscript = pLoopCity->getPopulation() / GetXPopulationConscription(); + for (int iI = 0; iI < iNumConscript; iI++) + DoXPopulationConscription(pLoopCity); } } } -#if defined(MOD_BALANCE_CORE_BUILDING_INVESTMENTS) changeInvestmentModifier(pPolicy->GetInvestmentModifier() * iChange); changeMissionInfluenceModifier(pPolicy->GetMissionInfluenceModifier() * iChange); @@ -44798,8 +44012,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) changeConquestPerEraBuildingProductionMod(pPolicy->GetConquestPerEraBuildingProductionMod() * iChange); changeAdmiralLuxuryBonus(pPolicy->GetAdmiralLuxuryBonus() * iChange); -#endif - if (MOD_POLICIES_UNIT_CLASS_REPLACEMENTS && pPolicy->IsUnitClassReplacements() && iChange != 0) // let's not execute the loop unless we need it { std::map piUnitClassReplacements = pPolicy->GetUnitClassReplacements(); @@ -44842,7 +44054,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) { eYield = (YieldTypes) iI; -#if defined(MOD_BALANCE_CORE_POLICIES) changeYieldFromBirth(eYield, (pPolicy->GetYieldFromBirth(iI) * iChange)); changeYieldFromBirthCapital(eYield, (pPolicy->GetYieldFromBirthCapital(iI) * iChange)); @@ -44899,7 +44110,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) doInstantYield(INSTANT_YIELD_TYPE_BIRTH_RETROACTIVE, false, NO_GREATPERSON, NO_BUILDING, iVal, true, NO_PLAYER, NULL, false, getCapitalCity(), false, false, false, eYield); } } -#endif iMod = pPolicy->GetYieldModifier(iI) * iChange; if(iMod != 0) @@ -45041,7 +44251,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) { changeImprovementYieldChange(((ImprovementTypes)iI), ((YieldTypes)iJ), (pPolicy->GetImprovementYieldChanges(iI, iJ) * iChange)); } - + if (pPolicy->getFranchisesPerImprovement(iI) != 0) { GetCorporations()->ChangeFranchisesPerImprovement((ImprovementTypes)iI, pPolicy->getFranchisesPerImprovement(iI) * iChange); @@ -45106,7 +44316,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) // Don't hurt us or teammates if(GET_PLAYER(ePlayer).getTeam() != getTeam()) { -#if defined(MOD_BALANCE_CORE) if(GET_PLAYER(ePlayer).GetMinorFriendshipDecayMod() <= 0) { // Send notification to affected players @@ -45120,7 +44329,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) pNotifications->Add(NOTIFICATION_DIPLOMACY_DECLARATION, locString.toUTF8(), locSummary.toUTF8(), -1, -1, -1); } } -#endif + GET_PLAYER(ePlayer).changeGetMinorFriendshipDecayMod(iOtherPlayersDecay * iChange); } } @@ -45151,7 +44360,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) if(pLoopCity->getFirstBuildingOrder(eCultureBuilding) == 0) { pLoopCity->clearOrderQueue(); - pLoopCity->chooseProduction(); // Send a notification to the user that what they were building was given to them, and they need to produce something else. + pLoopCity->chooseProduction(); // Send a notification to the user that what they were building was given to them, and they need to produce something else. } } else @@ -45173,7 +44382,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) if(pLoopCity->getFirstBuildingOrder(eFoodBuilding) == 0) { pLoopCity->clearOrderQueue(); - pLoopCity->chooseProduction(); // Send a notification to the user that what they were building was given to them, and they need to produce something else. + pLoopCity->chooseProduction(); // Send a notification to the user that what they were building was given to them, and they need to produce something else. } } else @@ -45226,7 +44435,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) if(iBuildingCount > 0) { - if (::isWorldWonderClass(pkBuilding->GetBuildingClassInfo())) + if (::isWorldWonderClass(pkBuilding->GetBuildingClassInfo())) { iTotalWonders += iBuildingCount; } @@ -45241,7 +44450,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) if (iYieldChange != 0) { pLoopCity->ChangeJONSCulturePerTurnFromPolicies(iYieldChange * iBuildingCount * iChange); -#if defined(MOD_BALANCE_CORE_POLICIES) pLoopCity->changeBuildingClassCultureChange(eBuildingClass, (iYieldChange * iBuildingCount * iChange)); } //Policy-Religion Fusion Yield Changes @@ -45249,7 +44457,6 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) if (MOD_BALANCE_CORE_POLICIES && iYieldChange != 0) { pLoopCity->changeReligionBuildingYieldRateModifier(eBuildingClass, YIELD_CULTURE, (iYieldChange * iBuildingCount * iChange)); -#endif } if (pPolicy->GetBuildingClassSecurityChange(eBuildingClass)) @@ -45276,25 +44483,21 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) { pLoopCity->ChangeFaithPerTurnFromPolicies(iYieldChange * iBuildingCount * iChange); } -#if defined(MOD_BALANCE_CORE_POLICIES) - //Policy-Religion Fusion Yield Changes + + // Policy-Religion Fusion Yield Changes iYieldChange = pPolicy->GetReligionBuildingYieldMod(eBuildingClass, eYield); if (MOD_BALANCE_CORE_POLICIES && iYieldChange != 0) { pLoopCity->changeReligionBuildingYieldRateModifier(eBuildingClass, eYield, (iYieldChange * iBuildingCount * iChange)); } -#endif } break; default: { eYield = (YieldTypes) iJ; iYieldMod = pPolicy->GetBuildingClassYieldModifiers(eBuildingClass, eYield); -#if defined(MOD_BALANCE_CORE) + if (iYieldMod != 0) -#else - if (iYieldMod > 0) -#endif { pLoopCity->changeYieldRateModifier(eYield, iYieldMod * iBuildingCount * iChange); } @@ -45303,14 +44506,13 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) { pLoopCity->ChangeBaseYieldRateFromBuildings(eYield, iYieldChange * iBuildingCount * iChange); } -#if defined(MOD_BALANCE_CORE_POLICIES) - //Policy-Religion Fusion Yield Changes + + // Policy-Religion Fusion Yield Changes iYieldChange = pPolicy->GetReligionBuildingYieldMod(eBuildingClass, eYield); if (MOD_BALANCE_CORE_POLICIES && iYieldChange != 0) { pLoopCity->changeReligionBuildingYieldRateModifier(eBuildingClass, eYield, (iYieldChange * iBuildingCount * iChange)); } -#endif } } } @@ -45493,670 +44695,131 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) ChangeNumFreeGreatPeople(iNumFreeGreatPeople); } - if(getCapitalCity() != NULL) + CvCity* pCapital = getCapitalCity(); + if (pCapital) { - int iX = getCapitalCity()->getX(); - int iY = getCapitalCity()->getY(); - - for(iI = 0; iI < GC.getNumUnitClassInfos(); iI++) + for (iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - int iNumFreeUnits = pPolicy->GetNumFreeUnitsByClass(eUnitClass); - if(iNumFreeUnits > 0) - { - const UnitTypes eUnit = GetSpecificUnitType(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if (isHuman() && pUnitEntry != NULL && pUnitEntry->IsFound() && GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE)) - { - continue; - } - - for(int iUnitLoop = 0; iUnitLoop < iNumFreeUnits; iUnitLoop++) - { - CvUnit* pNewUnit = NULL; - // for venice - if (pUnitEntry->IsFound() && GetPlayerTraits()->IsNoAnnexing()) - { - // drop a merchant of venice instead - // find the eUnit replacement that's the merchant of venice - for(int iVeniceSearch = 0; iVeniceSearch < GC.getNumUnitClassInfos(); iVeniceSearch++) - { - const UnitClassTypes eVeniceUnitClass = static_cast(iVeniceSearch); - CvUnitClassInfo* pkVeniceUnitClassInfo = GC.getUnitClassInfo(eVeniceUnitClass); - if(pkVeniceUnitClassInfo) - { - const UnitTypes eMerchantOfVeniceUnit = GetSpecificUnitType(eVeniceUnitClass); - if (eMerchantOfVeniceUnit != NO_UNIT) - { - CvUnitEntry* pVeniceUnitEntry = GC.getUnitInfo(eMerchantOfVeniceUnit); - if (pVeniceUnitEntry->IsCanBuyCityState()) - { - pNewUnit = initUnit(eMerchantOfVeniceUnit, iX, iY); - break; - } - } - } - } - } - else - { - pNewUnit = initUnit(eUnit, iX, iY); - } + int iNumFreeUnits = pPolicy->GetNumFreeUnitsByClass(eUnitClass); + if (iNumFreeUnits <= 0) + continue; - if (pNewUnit) - { -#if defined(MOD_BALANCE_CORE) - if(pNewUnit->isWLKTKDOnBirth()) - { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) - { - if(pLoopCity != NULL && pLoopCity->getOwner() == GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; + UnitTypes eUnit = GetSpecificUnitType(eUnitClass); + if (eUnit == NO_UNIT) + continue; - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << pNewUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - } - if(pNewUnit->isGoldenAgeOnBirth()) - { - changeGoldenAgeTurns(getGoldenAgeLength()); - } - if (pNewUnit->isCultureBoost()) - { - int iValue = GetTotalJONSCulturePerTurn() * 4; - changeJONSCulture(iValue); - if (getCapitalCity() != NULL) - getCapitalCity()->ChangeJONSCultureStored(iValue); + CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << pNewUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << pNewUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pNewUnit->getX(), pNewUnit->getY(), -1); - } - } -#endif - if(pNewUnit->IsGreatGeneral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatGeneralsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatGeneralsCreated(); -#endif - bool bJumpSuccess = pNewUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - getCapitalCity()->addProductionExperience(pNewUnit); - } - else - { - pNewUnit->kill(false); - } - } - else if(pNewUnit->IsGreatAdmiral()) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatAdmiralsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatAdmiralsCreated(); -#endif - CvPlot *pSpawnPlot = GetBestCoastalSpawnPlot(pNewUnit); - if (pNewUnit->plot() != pSpawnPlot) - { - pNewUnit->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); - getCapitalCity()->addProductionExperience(pNewUnit); - } - } - else if(pNewUnit->getUnitInfo().IsFoundReligion()) - { - ReligionTypes eReligion = GetReligions()->GetStateReligion(); - pNewUnit->GetReligionDataMutable()->SetFullStrength(GetID(),pNewUnit->getUnitInfo(),eReligion); - } - else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_WRITER")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatWritersCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatWritersCreated(); -#endif -#if !defined(MOD_BALANCE_CORE) - if (pNewUnit->getUnitInfo().GetOneShotTourism() > 0) - { - pNewUnit->SetTourismBlastStrength(GetCulture()->GetTourismBlastStrength(pNewUnit->getUnitInfo().GetOneShotTourism())); - } -#endif + // No settling units for One City Challenge + if (isHuman() && pUnitEntry != NULL && pUnitEntry->IsFound() && GC.getGame().isOption(GAMEOPTION_ONE_CITY_CHALLENGE)) + continue; - pNewUnit->jumpToNearestValidPlot(); - } - else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_ARTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatArtistsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatArtistsCreated(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } - else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MUSICIAN")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatMusiciansCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatMusiciansCreated(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } - else if (MOD_BALANCE_VP && pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_GREAT_DIPLOMAT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatDiplomatsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatDiplomatsCreated(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } -#if defined(MOD_BALANCE_CORE) - else if (pNewUnit->getUnitInfo().IsGPExtra() == 1) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra1Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGPExtra1Created(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } - else if (pNewUnit->getUnitInfo().IsGPExtra() == 2) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra2Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGPExtra2Created(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } - else if (pNewUnit->getUnitInfo().IsGPExtra() == 3) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra3Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGPExtra3Created(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } - else if (pNewUnit->getUnitInfo().IsGPExtra() == 4) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra4Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGPExtra4Created(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } - else if (pNewUnit->getUnitInfo().IsGPExtra() == 5) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGPExtra5Created(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGPExtra5Created(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } -#endif - else if(pNewUnit->IsGreatPerson()) - { -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) - if (MOD_GLOBAL_SEPARATE_GP_COUNTERS) - { - if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_MERCHANT")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatMerchantsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatMerchantsCreated(); -#endif - } - else if (pNewUnit->getUnitInfo().GetUnitClassType() == GC.getInfoTypeForString("UNITCLASS_SCIENTIST")) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatScientistsCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatScientistsCreated(); -#endif - } - else - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatEngineersCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatEngineersCreated(); -#endif - } - } - else -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - incrementGreatPeopleCreated(MOD_GLOBAL_TRULY_FREE_GP); -#else - incrementGreatPeopleCreated(); -#endif - pNewUnit->jumpToNearestValidPlot(); - } - else - { - pNewUnit->jumpToNearestValidPlot(); - if (pNewUnit && getCapitalCity() != NULL) - { - getCapitalCity()->addProductionExperience(pNewUnit); - } - } - } - } - } - } - } - int iNumFreeCombatLandUnits = pPolicy->GetBestNumberLandCombatUnitClass(); - CvCity* pCapital = getCapitalCity(); - if(iNumFreeCombatLandUnits > 0) - { - UnitTypes eBestLandUnit = NO_UNIT; - int iStrengthBestLandCombat = 0; - for(iI = 0; iI < GC.getNumUnitClassInfos(); iI++) + // For Venice, replace any spawned settling unit with Merchant of Venice + if (pUnitEntry->IsFound() && GetPlayerTraits()->IsNoAnnexing()) { - const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) + bool bFound = false; + for (int iVeniceSearch = 0; iVeniceSearch < GC.getNumUnitClassInfos(); iVeniceSearch++) { - const UnitTypes eUnit = (UnitTypes) getCivilizationInfo().getCivilizationUnits(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if(pUnitEntry) + const UnitClassTypes eVeniceUnitClass = static_cast(iVeniceSearch); + const UnitTypes eMerchantOfVeniceUnit = GetSpecificUnitType(eVeniceUnitClass); + if (eMerchantOfVeniceUnit != NO_UNIT) { - if(!pCapital->canTrain(eUnit)) + CvUnitEntry* pVeniceUnitEntry = GC.getUnitInfo(eMerchantOfVeniceUnit); + if (pVeniceUnitEntry->IsCanBuyCityState()) { - continue; - } - if(pUnitEntry->GetRangedCombat() > 0) - { - continue; - } - if(pUnitEntry->GetDomainType() == DOMAIN_LAND) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } - -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - iNumResource = pUnitEntry->GetResourceQuantityTotal(eResource); - if (iNumResource > 0) - { - if (getNumResourceTotal(eResource, true) < iNumResource || getNumResourceAvailable(eResource, true) < 0) - { - bBad = true; - break; - } - } - } -#endif - } - if(bBad) - { - continue; - } - int iCombatLandStrength = (std::max(1, pUnitEntry->GetCombat())); - if(iCombatLandStrength > iStrengthBestLandCombat) - { - iStrengthBestLandCombat = iCombatLandStrength; - eBestLandUnit = eUnit; - } + eUnit = eMerchantOfVeniceUnit; + bFound = true; + break; } } } + + // Failed to find a replacement + if (!bFound) + continue; } - if(eBestLandUnit != NO_UNIT) + + for (int iUnitLoop = 0; iUnitLoop < iNumFreeUnits; iUnitLoop++) { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeCombatLandUnits; iUnitLoop++) - { - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eBestLandUnit); - if(pkbUnitEntry) - { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eBestLandUnit, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } - } - } + pCapital->SpawnFreeUnit(eUnit); } - else + } + + int iNumFreeCombatLandUnits = pPolicy->GetBestNumberLandCombatUnitClass(); + if (iNumFreeCombatLandUnits > 0) + { + UnitTypes eUnit = GetCompetitiveSpawnUnitType(false, false, true, true, pCapital); + if (eUnit != NO_UNIT) { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeCombatLandUnits; iUnitLoop++) + for (int iUnitLoop = 0; iUnitLoop < iNumFreeCombatLandUnits; iUnitLoop++) { - UnitTypes eWarrior = (UnitTypes)GC.getInfoTypeForString("UNIT_WARRIOR"); - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eWarrior); - if(pkbUnitEntry) + CvUnit* pUnit = pCapital->CreateUnit(eUnit, NO_UNITAI, REASON_GIFT); + if (pUnit && !pUnit->jumpToNearestValidPlot()) { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eWarrior, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } + pUnit->kill(false); // Could not find a valid spot! } } } } + int iNumFreeRangedLandUnits = pPolicy->GetBestNumberLandRangedUnitClass(); - if(iNumFreeRangedLandUnits > 0) + if (iNumFreeRangedLandUnits > 0) { - UnitTypes eBestLandRangedUnit = NO_UNIT; - int iStrengthBestLandRanged = 0; - for(iI = 0; iI < GC.getNumUnitClassInfos(); iI++) - { - const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - const UnitTypes eUnit = (UnitTypes) getCivilizationInfo().getCivilizationUnits(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if(pUnitEntry) - { - if(!pCapital->canTrain(eUnit)) - { - continue; - } - if(pUnitEntry->GetDomainType() == DOMAIN_LAND && pUnitEntry->GetRangedCombat() > 0) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } - } - if(bBad) - { - continue; - } - int iCombatLandRangedStrength = (std::max(1, pUnitEntry->GetRangedCombat())); - if(iCombatLandRangedStrength > iStrengthBestLandRanged) - { - iStrengthBestLandRanged = iCombatLandRangedStrength; - eBestLandRangedUnit = eUnit; - } - } - } - } - } - if(eBestLandRangedUnit != NO_UNIT) + vector viUnitCombat; + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_ARCHER")); + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_SIEGE")); + + UnitTypes eUnit = GetCompetitiveSpawnUnitType(true, false, false, true, pCapital, false, false, false, NULL, viUnitCombat); + if (eUnit != NO_UNIT) { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeRangedLandUnits; iUnitLoop++) + for (int iUnitLoop = 0; iUnitLoop < iNumFreeRangedLandUnits; iUnitLoop++) { - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eBestLandRangedUnit); - if(pkbUnitEntry) + CvUnit* pUnit = pCapital->CreateUnit(eUnit, NO_UNITAI, REASON_GIFT); + if (pUnit && !pUnit->jumpToNearestValidPlot()) { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eBestLandRangedUnit, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } - } - } - } - else - { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeRangedLandUnits; iUnitLoop++) - { - UnitTypes eArcher = (UnitTypes)GC.getInfoTypeForString("UNIT_ARCHER"); - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eArcher); - if(pkbUnitEntry) - { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eArcher, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } + pUnit->kill(false); // Could not find a valid spot! } } } } + int iNumFreeCombatSeaUnits = pPolicy->GetBestNumberSeaCombatUnitClass(); - if(iNumFreeCombatSeaUnits > 0 && pCapital->isCoastal()) + if (iNumFreeCombatSeaUnits > 0 && pCapital->isCoastal()) { - UnitTypes eBestSeaUnit = NO_UNIT; - int iStrengthBestSeaCombat = 0; - for(iI = 0; iI < GC.getNumUnitClassInfos(); iI++) - { - const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - const UnitTypes eUnit = (UnitTypes) getCivilizationInfo().getCivilizationUnits(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if(pUnitEntry) - { - if(!pCapital->canTrain(eUnit)) - { - continue; - } - if(pUnitEntry->GetRangedCombat() > 0) - { - continue; - } - if(pUnitEntry->GetDomainType() == DOMAIN_SEA) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } - } - if(bBad) - { - continue; - } - int iCombatSeaStrength = (std::max(1, pUnitEntry->GetCombat())); - if(iCombatSeaStrength > iStrengthBestSeaCombat) - { - iStrengthBestSeaCombat = iCombatSeaStrength; - eBestSeaUnit = eUnit; - } - } - } - } - } - if(eBestSeaUnit != NO_UNIT) - { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeCombatSeaUnits; iUnitLoop++) - { - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eBestSeaUnit); - if(pkbUnitEntry) - { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eBestSeaUnit, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } - } - } - } - else + vector viUnitCombat; + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_NAVALMELEE")); + + UnitTypes eUnit = GetCompetitiveSpawnUnitType(false, true, false, true, pCapital, false, false, false, NULL, viUnitCombat); + if (eUnit != NO_UNIT) { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeCombatSeaUnits; iUnitLoop++) + for (int iUnitLoop = 0; iUnitLoop < iNumFreeCombatSeaUnits; iUnitLoop++) { - UnitTypes eCaravel = (UnitTypes)GC.getInfoTypeForString("UNIT_CARAVEL"); - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eCaravel); - if(pkbUnitEntry) + CvUnit* pUnit = pCapital->CreateUnit(eUnit, NO_UNITAI, REASON_GIFT); + if (pUnit && !pUnit->jumpToNearestValidPlot()) { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eCaravel, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } + pUnit->kill(false); // Could not find a valid spot! } } } } + int iNumFreeRangedSeaUnits = pPolicy->GetBestNumberSeaRangedUnitClass(); - if(iNumFreeRangedSeaUnits > 0 && pCapital->isCoastal()) + if (iNumFreeRangedSeaUnits > 0 && pCapital->isCoastal()) { - UnitTypes eBestSeaRangedUnit = NO_UNIT; - int iStrengthBestSeaRanged = 0; - for(iI = 0; iI < GC.getNumUnitClassInfos(); iI++) - { - const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - const UnitTypes eUnit = (UnitTypes) getCivilizationInfo().getCivilizationUnits(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if(pUnitEntry) - { - if(!pCapital->canTrain(eUnit)) - { - continue; - } - if(pUnitEntry->GetDomainType() == DOMAIN_SEA && pUnitEntry->GetRangedCombat() > 0) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } - } - if(bBad) - { - continue; - } - int iCombatSeaRangedStrength = (std::max(1, pUnitEntry->GetRangedCombat())); - if(iCombatSeaRangedStrength > iStrengthBestSeaRanged) - { - iStrengthBestSeaRanged = iCombatSeaRangedStrength; - eBestSeaRangedUnit = eUnit; - } - } - } - } - } - if(eBestSeaRangedUnit != NO_UNIT) + vector viUnitCombat; + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_NAVALRANGED")); + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_SUBMARINE")); + + UnitTypes eUnit = GetCompetitiveSpawnUnitType(true, true, false, true, pCapital, false, false, false, NULL, viUnitCombat); + if (eUnit != NO_UNIT) { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeRangedSeaUnits; iUnitLoop++) + for (int iUnitLoop = 0; iUnitLoop < iNumFreeRangedSeaUnits; iUnitLoop++) { - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eBestSeaRangedUnit); - if(pkbUnitEntry) + CvUnit* pUnit = pCapital->CreateUnit(eUnit, NO_UNITAI, REASON_GIFT); + if (pUnit && !pUnit->jumpToNearestValidPlot()) { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eBestSeaRangedUnit, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } - } - } - } - else - { - for(int iUnitLoop = 0; iUnitLoop < iNumFreeRangedSeaUnits; iUnitLoop++) - { - UnitTypes eGalleass = (UnitTypes)GC.getInfoTypeForString("UNIT_GALLEASS"); - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eGalleass); - if(pkbUnitEntry) - { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - CvUnit* pUnit = pCapital->CreateUnit(eGalleass, eUnitAI, REASON_GIFT); - if (pUnit) - { - if (!pUnit->jumpToNearestValidPlot()) - { - pUnit->kill(false); // Could not find a valid spot! - } - } + pUnit->kill(false); // Could not find a valid spot! } } } @@ -46172,11 +44835,7 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) } // Add a Reformation belief if eligible -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) if (isHuman() && pPolicy->IsAddReformationBelief() && GetReligions()->OwnsReligion(true) && !GetReligions()->HasAddedReformationBelief()) -#else - if (isHuman() && pPolicy->IsAddReformationBelief() && GetReligions()->OwnsReligion() && !GetReligions()->HasAddedReformationBelief()) -#endif { pNotifications = GetNotifications(); if(pNotifications) @@ -46192,12 +44851,11 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) { GetEspionage()->UpdateSpies(); } -#if defined(MOD_BALANCE_CORE) + if (pPolicy->GetStealGWFasterModifier() != 0) { GetEspionage()->UpdateSpies(); } -#endif CvPlot *pLoopPlot = NULL; ResourceTypes eResource; @@ -46222,19 +44880,19 @@ void CvPlayer::processPolicies(PolicyTypes ePolicy, int iChange) recomputeGreatPeopleModifiers(); recomputePolicyCostModifier(); recomputeFreeExperience(); -#if defined(MOD_BALANCE_CORE) + CvCity* pLoopCity2 = NULL; int iLoop2 = 0; for(pLoopCity2 = firstCity(&iLoop2); pLoopCity2 != NULL; pLoopCity2 = nextCity(&iLoop2)) { if(pLoopCity2 != NULL) { - pLoopCity2->UpdateReligion(pLoopCity2->GetCityReligions()->GetReligiousMajority()); + pLoopCity2->UpdateReligion(pLoopCity2->GetCityReligions()->GetReligiousMajority()); pLoopCity2->UpdateHappinessFromBuildingClasses(); pLoopCity2->updateNetHappiness(); } } -#endif + CalculateNetHappiness(); doUpdateBarbarianCampVisibility(); @@ -46300,7 +44958,7 @@ void CvPlayer::processCorporations(CorporationTypes eCorporation, int iChange) for(int iJ = 0; iJ < NUM_YIELD_TYPES; iJ++) { YieldTypes eYield = (YieldTypes)iJ; - + int iYieldChange = pkCorporationEntry->GetBuildingClassYieldChange(eBuildingClass, eYield); if(iYieldChange <= 0) continue; @@ -46501,22 +45159,22 @@ int CvPlayer::AddNotification(NotificationTypes eNotificationType, const char* s int CvPlayer::AddNotification(NotificationTypes eNotificationType, const char* sMessage, const char* sSummary, CvPlot* pPlot, int iGameDataIndex, int iExtraGameData) { - int iNotification = -1; - - CvNotifications* pNotifications = GetNotifications(); + int iNotification = -1; - if (pNotifications) { - const int iPlotX = pPlot ? pPlot->getX() : -1; - const int iPlotY = pPlot ? pPlot->getY() : -1; - - iNotification = pNotifications->Add(eNotificationType, sMessage, sSummary, iPlotX, iPlotY, iGameDataIndex, iExtraGameData); - } - - return iNotification; + CvNotifications* pNotifications = GetNotifications(); + + if (pNotifications) + { + const int iPlotX = pPlot ? pPlot->getX() : -1; + const int iPlotY = pPlot ? pPlot->getY() : -1; + + iNotification = pNotifications->Add(eNotificationType, sMessage, sSummary, iPlotX, iPlotY, iGameDataIndex, iExtraGameData); + } + + return iNotification; } // --------------------------------------------------------------------------------- -#if defined(MOD_WH_MILITARY_LOG) CvEventLog* CvPlayer::GetMilitaryLog() const { return m_pMilitaryLog; @@ -46533,8 +45191,6 @@ bool CvPlayer::AddMilitaryEvent(const char* sMessage, CvPlot* pPlot, PlayerTypes return false; } -#endif - // -------------------------------------------------------------------------------- CvTreasury* CvPlayer::GetTreasury() const @@ -46563,10 +45219,9 @@ bool CvPlayer::HasActiveDiplomacyRequests() const CvDiplomacyRequests* pkDiploRequests = GetDiplomacyRequests(); if(pkDiploRequests && pkDiploRequests->HasActiveRequest()) return true; -#if defined(MOD_ACTIVE_DIPLOMACY) + if (!MOD_ACTIVE_DIPLOMACY || !GC.getGame().isReallyNetworkMultiPlayer()) { -#endif // Do I have any for others? for (int i = 0; i < MAX_PLAYERS; ++i) { @@ -46581,9 +45236,8 @@ bool CvPlayer::HasActiveDiplomacyRequests() const } } } -#if defined(MOD_ACTIVE_DIPLOMACY) } -#endif + return false; } @@ -47035,6 +45689,7 @@ void CvPlayer::Serialize(Player& player, Visitor& visitor) visitor(player.m_iNumFreePoliciesEver); visitor(player.m_iNumFreeTenets); visitor(player.m_iCachedCurrentWarValue); + visitor(player.m_viCoreCitiesForSpaceshipProduction); visitor(player.m_uiStartTime); visitor(player.m_bHasUUPeriod); visitor(player.m_bNoNewWars); @@ -47279,7 +45934,7 @@ void CvPlayer::Serialize(Player& player, Visitor& visitor) if (bLoading) mutAIOperations.clear(); - + uint32 operationCount; if (bSaving) operationCount = player.m_AIOperations.size(); @@ -47453,147 +46108,43 @@ void CvPlayer::Write(FDataStream& kStream) const } // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void CvPlayer::createGreatGeneral(UnitTypes eGreatPersonUnit, int iX, int iY, bool bIsFree) -#else -void CvPlayer::createGreatGeneral(UnitTypes eGreatPersonUnit, int iX, int iY) -#endif { CvUnit* pGreatPeopleUnit = initUnit(eGreatPersonUnit, iX, iY); - if(NULL == pGreatPeopleUnit) - { - CvAssert(false); - return; - } -#if defined(MOD_BALANCE_CORE) - if(GetPlayerTraits()->IsGPWLTKD() && pGreatPeopleUnit != NULL) - { - CvCity* pCity = pGreatPeopleUnit->plot()->getOwningCity(); - if (pCity != NULL && pCity->getOwner() == GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - if (iWLTKD > 0) - { - pCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); - strText << pGreatPeopleUnit->getNameKey() << pCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); - strSummary << pCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pCity->getX(), pCity->getY(), -1); - } - } - } - } - if(pGreatPeopleUnit->isWLKTKDOnBirth()) - { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) - { - if(pLoopCity != NULL && pLoopCity->getOwner() == GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; + CvAssert(pGreatPeopleUnit); - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << pGreatPeopleUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - } - if(pGreatPeopleUnit->getUnitInfo().IsFoundReligion()) - { - ReligionTypes eReligion = GetReligions()->GetOwnedReligion(); - pGreatPeopleUnit->GetReligionDataMutable()->SetFullStrength(GetID(),pGreatPeopleUnit->getUnitInfo(),eReligion); - } - if(pGreatPeopleUnit->isGoldenAgeOnBirth()) - { - changeGoldenAgeTurns(getGoldenAgeLength()); - } - if (pGreatPeopleUnit->isCultureBoost()) - { - int iValue = GetTotalJONSCulturePerTurn() * 4; - changeJONSCulture(iValue); - if (getCapitalCity() != NULL) - getCapitalCity()->ChangeJONSCultureStored(iValue); + CvCity* pOriginCity = pGreatPeopleUnit->getOriginCity(); + if (pOriginCity) + pGreatPeopleUnit->DoGreatPersonSpawnBonus(pGreatPeopleUnit->getOriginCity()); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << pGreatPeopleUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << pGreatPeopleUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pGreatPeopleUnit->getX(), pGreatPeopleUnit->getY(), -1); - } - } - if(pGreatPeopleUnit->IsCombatUnit() && getCapitalCity() != NULL) - { - getCapitalCity()->addProductionExperience(pGreatPeopleUnit); - pGreatPeopleUnit->setOriginCity(getCapitalCity()->GetID()); - } -#endif - ChangeNumGreatPeople(1); + pOriginCity->addProductionExperience(pGreatPeopleUnit); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) + ChangeNumGreatPeople(1); incrementGreatGeneralsCreated(bIsFree); -#else - incrementGreatGeneralsCreated(); -#endif - -#if defined(MOD_GLOBAL_TRULY_FREE_GP) changeGreatGeneralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE) * ((getGreatGeneralsCreated(bIsFree) / 10) + 1)); -#else - changeGreatGeneralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE) * ((getGreatGeneralsCreated() / 10) + 1)); -#endif - for(int iI = 0; iI < MAX_PLAYERS; iI++) + for (int iI = 0; iI < MAX_PLAYERS; iI++) { - if(GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam()) + if (GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam()) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) GET_PLAYER((PlayerTypes)iI).changeGreatGeneralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE_TEAM) * ((getGreatGeneralsCreated(bIsFree) / 10) + 1)); -#else - GET_PLAYER((PlayerTypes)iI).changeGreatGeneralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE_TEAM) * ((getGreatGeneralsCreated() / 10) + 1)); -#endif } } -#if defined(MOD_GLOBAL_LOCAL_GENERALS) CvPlot* pPlot = pGreatPeopleUnit->plot(); // In rare cases we can gain the general from an embarked unit being attacked, or from a hovering unit over coast // so if this plot is water, relocate the Great General - if (pPlot->isWater() || pGreatPeopleUnit->IsCombatUnit()) { + if (pPlot->isWater() || pGreatPeopleUnit->IsCombatUnit()) pGreatPeopleUnit->jumpToNearestValidPlot(); - } -#else - CvPlot* pPlot = GC.getMap().plot(iX, iY); -#endif - //Achievements and Stats + // Achievements and Stats if (MOD_API_ACHIEVEMENTS && pGreatPeopleUnit->isHuman() && !GC.getGame().isGameMultiPlayer()) { gDLL->IncrementSteamStat(ESTEAMSTAT_GREATGENERALS); - const char* strLeader = GET_PLAYER(pGreatPeopleUnit->getOwner()).getLeaderTypeKey(); - if(strLeader && strcmp(strLeader, "LEADER_WU_ZETIAN") == 0) + const char* strLeader = getLeaderTypeKey(); + if (strLeader && strcmp(strLeader, "LEADER_WU_ZETIAN") == 0) { gDLL->UnlockAchievement(ACHIEVEMENT_SPECIAL_SUNTZU); } @@ -47602,7 +46153,7 @@ void CvPlayer::createGreatGeneral(UnitTypes eGreatPersonUnit, int iX, int iY) } // Notification - if(GetNotifications()) + if (GetNotifications()) { Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER"); Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_GREAT_PERSON"); @@ -47611,133 +46162,34 @@ void CvPlayer::createGreatGeneral(UnitTypes eGreatPersonUnit, int iX, int iY) } // -------------------------------------------------------------------------------- -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void CvPlayer::createGreatAdmiral(UnitTypes eGreatPersonUnit, int iX, int iY, bool bIsFree) -#else -void CvPlayer::createGreatAdmiral(UnitTypes eGreatPersonUnit, int iX, int iY) -#endif { CvUnit* pGreatPeopleUnit = initUnit(eGreatPersonUnit, iX, iY); - if(NULL == pGreatPeopleUnit) - { - CvAssert(false); - return; - } -#if defined(MOD_BALANCE_CORE) - if(GetPlayerTraits()->IsGPWLTKD() && pGreatPeopleUnit != NULL) - { - CvCity* pCity = pGreatPeopleUnit->plot()->getOwningCity(); - if (pCity != NULL && pCity->getOwner() == GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; - if (iWLTKD > 0) - { - pCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); - strText << pGreatPeopleUnit->getNameKey() << pCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); - strSummary << pCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pCity->getX(), pCity->getY(), -1); - } - } - } - } - if(pGreatPeopleUnit->isWLKTKDOnBirth()) - { - CvCity* pLoopCity = NULL; - int iLoop = 0; - for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) - { - if(pLoopCity != NULL && pLoopCity->getOwner() == GetID()) - { - int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; - iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); - iWLTKD /= 100; + CvAssert(pGreatPeopleUnit); - if (iWLTKD > 0) - { - pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); - strText << pGreatPeopleUnit->getNameKey() << pLoopCity->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); - strSummary << pLoopCity->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); - } - } - } - } - } - if(pGreatPeopleUnit->isGoldenAgeOnBirth()) - { - changeGoldenAgeTurns(getGoldenAgeLength()); - } - if (pGreatPeopleUnit->isCultureBoost()) - { - int iValue = GetTotalJONSCulturePerTurn() * 4; - changeJONSCulture(iValue); - if (getCapitalCity() != NULL) - getCapitalCity()->ChangeJONSCultureStored(iValue); + CvCity* pOriginCity = pGreatPeopleUnit->getOriginCity(); + if (pOriginCity) + pGreatPeopleUnit->DoGreatPersonSpawnBonus(pGreatPeopleUnit->getOriginCity()); - CvNotifications* pNotifications = GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); - strText << pGreatPeopleUnit->getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); - strSummary << pGreatPeopleUnit->getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pGreatPeopleUnit->getX(), pGreatPeopleUnit->getY(), -1); - } - } - if(pGreatPeopleUnit->IsCombatUnit()) - { - getCapitalCity()->addProductionExperience(pGreatPeopleUnit); - } -#endif - ChangeNumGreatPeople(1); -#if !defined(MOD_GLOBAL_LOCAL_GENERALS) - CvPlot *pSpawnPlot = GetBestCoastalSpawnPlot(pGreatPeopleUnit); - if (pGreatPeopleUnit->plot() != pSpawnPlot) - { - pGreatPeopleUnit->setXY(pSpawnPlot->getX(), pSpawnPlot->getY()); - } -#endif + pOriginCity->addProductionExperience(pGreatPeopleUnit); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) + ChangeNumGreatPeople(1); incrementGreatAdmiralsCreated(bIsFree); -#else - incrementGreatAdmiralsCreated(); -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) changeGreatAdmiralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE) * ((getGreatAdmiralsCreated(bIsFree) / 10) + 1)); -#else - changeGreatAdmiralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE) * ((getGreatAdmiralsCreated() / 10) + 1)); -#endif - for(int iI = 0; iI < MAX_PLAYERS; iI++) + for (int iI = 0; iI < MAX_PLAYERS; iI++) { - if(GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam()) + if (GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam()) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) GET_PLAYER((PlayerTypes)iI).changeGreatAdmiralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE_TEAM) * ((getGreatAdmiralsCreated(bIsFree) / 10) + 1)); -#else - GET_PLAYER((PlayerTypes)iI).changeGreatAdmiralsThresholdModifier(/*50*/ GD_INT_GET(GREAT_GENERALS_THRESHOLD_INCREASE_TEAM) * ((getGreatAdmiralsCreated() / 10) + 1)); -#endif } } CvPlot* pPlot = GC.getMap().plot(iX, iY); // Notification - if(GetNotifications()) + if (GetNotifications()) { Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER"); Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_GREAT_PERSON"); @@ -48458,7 +46910,6 @@ void CvPlayer::ChangePlotGoldCostMod(int iChange) } } -#if defined(MOD_TRAITS_CITY_WORKING) || defined(MOD_BUILDINGS_CITY_WORKING) || defined(MOD_POLICIES_CITY_WORKING) || defined(MOD_TECHS_CITY_WORKING) // -------------------------------------------------------------------------------- /// How many more city rings can we work int CvPlayer::GetCityWorkingChange() const @@ -48474,11 +46925,11 @@ void CvPlayer::ChangeCityWorkingChange(int iChange) { CvCity* pLoopCity = NULL; int iLoop = 0; - + for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { int iOldPlots = pLoopCity->GetNumWorkablePlots(); int iNewPlots = pLoopCity->GetNumWorkablePlots(iChange); - + for (int iI = std::min(iOldPlots, iNewPlots); iI < std::max(iOldPlots, iNewPlots); ++iI) { CvPlot* pLoopPlot = iterateRingPlots(pLoopCity->getX(), pLoopCity->getY(), iI); @@ -48492,9 +46943,7 @@ void CvPlayer::ChangeCityWorkingChange(int iChange) m_iCityWorkingChange += iChange; } } -#endif -#if defined(MOD_TRAITS_CITY_AUTOMATON_WORKERS) || defined(MOD_BUILDINGS_CITY_AUTOMATON_WORKERS) || defined(MOD_POLICIES_CITY_AUTOMATON_WORKERS) || defined(MOD_TECHS_CITY_AUTOMATON_WORKERS) // -------------------------------------------------------------------------------- /// How many more automatons does each city have? int CvPlayer::GetCityAutomatonWorkersChange() const @@ -48518,7 +46967,6 @@ void CvPlayer::ChangeCityAutomatonWorkersChange(int iChange) m_iCityAutomatonWorkersChange += iChange; } } -#endif // -------------------------------------------------------------------------------- /// Bonus to border growth rate in all cities @@ -49360,13 +47808,11 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn std::vector vSettlePlots; //-------- - bool bLogging = (GC.getLogging() && GC.getAILogging()) || bForceLogging; + bool bLogging = (GC.getLogging() && GC.getAILogging()) || bForceLogging; std::stringstream dump; int iDanger=0, iFertility=0; -#if defined(MOD_BALANCE_CORE_MILITARY_LOGGING) bLogging &= MOD_BALANCE_CORE_MILITARY_LOGGING; -#endif //-------- PlayerTypes eOwner = pUnit ? pUnit->getOwner() : GetID(); @@ -49423,7 +47869,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if(!pPlot->isRevealed(eTeam)) { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",0," << iDanger << "," << iFertility << ",-1" << ",0" << std::endl; //-------------- continue; @@ -49432,7 +47878,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if ((pPlot->isOwned() && pPlot->getOwner() != eOwner) || (pPlot->getRevealedImprovementType(eTeam) == (ImprovementTypes)GD_INT_GET(BARBARIAN_CAMP_IMPROVEMENT))) { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",1," << iDanger << "," << iFertility << ",-1" << ",-2" << std::endl; //-------------- continue; @@ -49442,7 +47888,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if (pZone && pZone->GetTerritoryType() == TACTICAL_TERRITORY_ENEMY) //check territory not dominance, the latter is too volatile { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",1," << iDanger << "," << iFertility << ",-1" << ",-2" << std::endl; //-------------- continue; @@ -49453,7 +47899,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if(pPlot->IsCloseToCity(*it)) { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",1," << iDanger << "," << iFertility << ",-1" << ",-2" << std::endl; //-------------- continue; @@ -49463,7 +47909,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if(pUnit && (!pUnit->canFoundCity(pPlot) || !pUnit->canMoveInto(*pPlot))) { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",1," << iDanger << "," << iFertility << ",-1" << ",-1" << std::endl; //-------------- continue; @@ -49472,7 +47918,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if (IsPlotTargetedForCity(pPlot,pOpToIgnore)) { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",1," << iDanger << "," << iFertility << ",-1" << ",-3" << std::endl; //-------------- continue; @@ -49481,7 +47927,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if(pUnit && pPlot->getLandmass() != pUnit->plot()->getLandmass() && !bCanEmbark) { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",1," << iDanger << "," << iFertility << ",-1" << ",-4" << std::endl; //-------------- continue; @@ -49505,7 +47951,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn bool bNewContinent = (pLandmass && pLandmass->getCitiesPerPlayer(GetID()) == 0); if (bNewContinent && getNumCities()>0) { - //there may already be other players here, also minors ... + //there may already be other players here, also minors ... //but this is complex to check, so simply force a coastal plot to avoid isolated cities if (!pPlot->isCoastalLand()) iScale = 0; @@ -49514,7 +47960,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn if (iScale==0) { //-------------- - if (bLogging) + if (bLogging) dump << pPlot << ",1," << iDanger << "," << iFertility << ",0" << ",-5" << std::endl; //-------------- continue; @@ -49522,7 +47968,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn //finally no more obstacles int iValue = 0; - if (bLogging) + if (bLogging) { CvString strDebug; iValue = GC.getGame().GetSettlerSiteEvaluator()->PlotFoundValue(pPlot, this, ignorePlots, bNewContinent, &strDebug); @@ -49545,8 +47991,7 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn vSettlePlots.push_back( SPlotWithScore(pPlot,iValue) ); } -#if defined(MOD_BALANCE_CORE_MILITARY_LOGGING) - if (bLogging) + if (bLogging) { std::stringstream ss; ss << "CitySites_" << getCivilizationAdjective() << "_" << std::setfill('0') << std::setw(3) << GC.getGame().getGameTurn() << ".txt"; @@ -49555,7 +48000,6 @@ CvPlot* CvPlayer::GetBestSettlePlot(const CvUnit* pUnit, CvAIOperation* pOpToIgn pLog->Msg( dump.str().c_str() ); pLog->Close(); } -#endif if (vSettlePlots.empty()) return 0; @@ -49753,7 +48197,7 @@ void CvPlayer::SetBestWonderCities() int iValue = pLoopCity->GetCityStrategyAI()->GetBuildingProductionAI()->CheckBuildingBuildSanity(eBuilding, 1000, true, false, true); if (iValue < 0) continue; - + // We've already started? Massive bonus! bool bAlreadyStarted = pLoopCity->GetCityBuildings()->GetBuildingProduction(eBuilding) > 0; if (pLoopCity->getProductionBuilding() == eBuilding || bAlreadyStarted) @@ -49914,7 +48358,7 @@ CvCity* CvPlayer::GetBestProductionCity(BuildingTypes eBuilding, ProjectTypes eP iProduction += pLoopCity->getProjectProduction(eProject) * 100; } } - + iProduction += pLoopCity->getYieldRateTimes100(YIELD_PRODUCTION, false, true); if (iProduction > iBestProduction) { @@ -50074,25 +48518,25 @@ PromotionTypes CvPlayer::GetEmbarkationPromotion() const return (PromotionTypes)GD_INT_GET(PROMOTION_EMBARKATION); } -#if defined(MOD_PROMOTIONS_DEEP_WATER_EMBARKATION) // -------------------------------------------------------------------------------- PromotionTypes CvPlayer::GetDeepWaterEmbarkationPromotion() const { - if (MOD_PROMOTIONS_DEEP_WATER_EMBARKATION) { - if(GET_TEAM(getTeam()).canDefensiveEmbark()) + if (MOD_PROMOTIONS_DEEP_WATER_EMBARKATION) + { + if (GET_TEAM(getTeam()).canDefensiveEmbark()) { - return (PromotionTypes)GD_INT_GET(PROMOTION_DEFENSIVE_DEEPWATER_EMBARKATION); + return static_cast(GD_INT_GET(PROMOTION_DEFENSIVE_DEEPWATER_EMBARKATION)); } - return (PromotionTypes)GD_INT_GET(PROMOTION_DEEPWATER_EMBARKATION); - } else { + return static_cast(GD_INT_GET(PROMOTION_DEEPWATER_EMBARKATION)); + } + else + { return GetEmbarkationPromotion(); } } -#endif - -void CvPlayer::LogSpaceshipPlanMessage(const CvString& strMsg) +void CvPlayer::LogSpaceshipPlanMessage(const CvString& strMsg) const { if (GC.getLogging() && GC.getAILogging()) { @@ -50123,40 +48567,30 @@ void CvPlayer::LogSpaceshipPlanMessage(const CvString& strMsg) pLog->Msg(strOutBuf); } } - - - // -------------------------------------------------------------------------------- -/// a list of cities which are considered core cities for spaceship building. the AI will try to retain aluminum to build spaceship factories in those cities -vector CvPlayer::GetCoreCitiesForSpaceshipProduction() +void CvPlayer::DoUpdateCoreCitiesForSpaceshipProduction() { - if (GC.getGame().getGameTurn() == m_iCoreCitiesForSpaceshipProductionUpdateTurn) - { - return m_vCoreCitiesForSpaceshipProduction; - } - - m_iCoreCitiesForSpaceshipProductionUpdateTurn = GC.getGame().getGameTurn(); - m_vCoreCitiesForSpaceshipProduction.clear(); + m_viCoreCitiesForSpaceshipProduction.clear(); if (isHuman() || !GetDiplomacyAI()->IsGoingForSpaceshipVictory()) - return m_vCoreCitiesForSpaceshipProduction; + return; int iNumCitiesToConsider = GD_INT_GET(AI_NUM_CORE_CITIES_FOR_SPACESHIP); - // get unit type for one of the spaceship parts (doesn't matter which one) + // Get unit type for one of the spaceship parts (doesn't matter which one) UnitTypes eSpaceshipUnit = NO_UNIT; for (int iUnitLoop = 0; iUnitLoop < GC.getNumUnitInfos(); iUnitLoop++) { - UnitTypes eUnitLoop = (UnitTypes)iUnitLoop; - CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnitLoop); - if (pkUnitInfo && pkUnitInfo->GetSpaceshipProject() != NO_PROJECT) + UnitTypes eUnitLoop = static_cast(iUnitLoop); + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnitLoop); + if (pUnitInfo && pUnitInfo->GetSpaceshipProject() != NO_PROJECT) { eSpaceshipUnit = eUnitLoop; break; } } - // loop through all cities and check if they're useful for spaceship production + // Loop through all cities and check if they're useful for spaceship production CvWeightedVector vCityWeights; CvCity* pCapital = getCapitalCity(); int iLoop = 0; @@ -50168,7 +48602,7 @@ vector CvPlayer::GetCoreCitiesForSpaceshipProduction() if (pLoopCity->isUnderSiege()) continue; - // how much production per turn would the city generate if it were building a spaceship part? + // How much production per turn would the city generate if it were building a spaceship part? int iWeight = pLoopCity->getProductionDifference(0, 0, pLoopCity->getProductionModifier(eSpaceshipUnit), false, false); if (pLoopCity->isCapital()) { @@ -50176,7 +48610,7 @@ vector CvPlayer::GetCoreCitiesForSpaceshipProduction() } else if (!pLoopCity->CanAirlift()) { - // if we can't airlift, reduce weight based on distance to capital + // If we can't airlift, reduce weight based on distance to capital if (pCapital) { iWeight -= 4 * plotDistance(pLoopCity->getX(), pLoopCity->getY(), pCapital->getX(), pCapital->getY()); @@ -50189,25 +48623,31 @@ vector CvPlayer::GetCoreCitiesForSpaceshipProduction() } } if (vCityWeights.size() == 0) - return m_vCoreCitiesForSpaceshipProduction; + return; - // pick the cities with the highest weight + // Pick the cities with the highest weight vCityWeights.StableSortItems(); for (int i = 0; i < min(vCityWeights.size(), iNumCitiesToConsider); i++) { - m_vCoreCitiesForSpaceshipProduction.push_back(vCityWeights.GetElement(i)); + m_viCoreCitiesForSpaceshipProduction.push_back(vCityWeights.GetElement(i)->GetID()); } - return m_vCoreCitiesForSpaceshipProduction; +} + +// -------------------------------------------------------------------------------- +/// a list of cities which are considered core cities for spaceship building. the AI will try to retain aluminum to build spaceship factories in those cities +const vector& CvPlayer::GetCoreCitiesForSpaceshipProduction() const +{ + return m_viCoreCitiesForSpaceshipProduction; } // -------------------------------------------------------------------------------- /// the number of aluminum still needed for buildings in the core cities for spaceship parts (GetCoreCitiesForSpaceshipProduction) -int CvPlayer::GetNumAluminumStillNeededForCoreCities() +int CvPlayer::GetNumAluminumStillNeededForCoreCities() const { ResourceTypes eAluminum = (ResourceTypes)GC.getInfoTypeForString("RESOURCE_ALUMINUM", true); int iTotal = 0; - vector vCoreCities = GetCoreCitiesForSpaceshipProduction(); + const vector& vCoreCities = GetCoreCitiesForSpaceshipProduction(); if (vCoreCities.size() > 0) { // in each core city, we want to build two buildings: spaceship factories and hydro plants (CP) / power plants (VP). @@ -50223,7 +48663,7 @@ int CvPlayer::GetNumAluminumStillNeededForCoreCities() { for (uint ui = 0; ui < vCoreCities.size(); ui++) { - CvCity* pLoopCity = vCoreCities[ui]; + CvCity* pLoopCity = getCity(vCoreCities[ui]); if (pLoopCity->GetCityBuildings()->GetNumBuilding(eBuilding) > 0 || pLoopCity->isBuildingInQueue(eBuilding)) { iTotal -= pkBuildingInfo->GetResourceQuantityRequirement(eAluminum); @@ -50238,7 +48678,7 @@ int CvPlayer::GetNumAluminumStillNeededForCoreCities() // -------------------------------------------------------------------------------- /// the number of aluminum still needed for spaceship parts -int CvPlayer::GetNumAluminumStillNeededForSpaceship() +int CvPlayer::GetNumAluminumStillNeededForSpaceship() const { if (isBarbarian() || isMinorCiv()) return 0; @@ -50255,7 +48695,7 @@ int CvPlayer::GetNumAluminumStillNeededForSpaceship() // spaceship parts currently in production int iCityLoop = 0; - for (CvCity* pLoopCity = firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = nextCity(&iCityLoop)) + for (const CvCity* pLoopCity = firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = nextCity(&iCityLoop)) { if (pLoopCity->isProductionSpaceshipPart()) { @@ -50265,7 +48705,7 @@ int CvPlayer::GetNumAluminumStillNeededForSpaceship() return iTotal; } -int CvPlayer::GetNumSpaceshipPartsBuildableNow(bool bIncludeCurrentlyInProduction) +int CvPlayer::GetNumSpaceshipPartsBuildableNow(bool bIncludeCurrentlyInProduction) const { // space victory disabled? if (!GC.getGame().isVictoryValid((VictoryTypes)GC.getInfoTypeForString("VICTORY_SPACE_RACE", true))) @@ -50296,7 +48736,7 @@ int CvPlayer::GetNumSpaceshipPartsBuildableNow(bool bIncludeCurrentlyInProductio if (!bIncludeCurrentlyInProduction) { int iCityLoop = 0; - for (CvCity* pLoopCity = firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = nextCity(&iCityLoop)) + for (const CvCity* pLoopCity = firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = nextCity(&iCityLoop)) { if (pLoopCity->getProductionUnit() == (UnitTypes)i) { @@ -50882,7 +49322,7 @@ void CvPlayer::disconnected() if(CvPreGame::isPitBoss()){ disconnectString = Localization::Lookup("TXT_KEY_PLAYER_DISCONNECTED_PITBOSS"); - disconnectString << getNameKey(); + disconnectString << getNameKey(); } pNotifications->Add(NOTIFICATION_PLAYER_DISCONNECTED, disconnectString.toUTF8(), disconnectString.toUTF8(), -1, -1, GetID()); @@ -50900,7 +49340,7 @@ void CvPlayer::disconnected() // Load leaderhead for this new AI player gDLL->NotifySpecificAILeaderInGame(GetID()); - + if(!GC.getGame().isOption(GAMEOPTION_DYNAMIC_TURNS) && GC.getGame().isOption(GAMEOPTION_SIMULTANEOUS_TURNS)) {//When in fully simultaneous turn mode, having a player disconnect might trigger the automove phase for all human players. checkRunAutoMovesForEveryone(); @@ -51040,8 +49480,8 @@ void CvPlayer::checkInitialTurnAIProcessed() int turn = GC.getGame().getGameTurn(); if(m_lastGameTurnInitialAIProcessed != turn) { - //Note: Players that are not turn active at the beginning of the game turn will - //process their AI when they are turn active. However, they should still + //Note: Players that are not turn active at the beginning of the game turn will + //process their AI when they are turn active. However, they should still //act like their initial AI has been processed. if(!isTurnActive() || !hasUnitsThatNeedAIUpdate()) { @@ -51093,11 +49533,9 @@ void CvPlayer::GatherPerTurnReplayStats(int iGameTurn) // Culture per turn setReplayDataValue("REPLAYDATASET_CULTUREPERTURN", iGameTurn, GetTotalJONSCulturePerTurn()); - -#if defined(MOD_BALANCE_CORE) + setReplayDataValue("REPLAYDATASET_TOURISMPERTURN", iGameTurn, GetCulture()->GetTourism() / 100); setReplayDataValue("REPLAYDATASET_GAPPERTURN", iGameTurn, GetGoldenAgePointsFromEmpire() + GetHappinessForGAP()); -#endif // Happiness setReplayDataValue("REPLAYDATASET_EXCESSHAPINESS", iGameTurn, GetExcessHappiness()); @@ -51258,7 +49696,7 @@ int CvPlayer::GetYieldPerTurnFromVassals(YieldTypes eYield) const for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++) { PlayerTypes ePlayer = (PlayerTypes) iPlayerLoop; - + // ePlayer vassal of ours? if (GET_TEAM(GET_PLAYER(ePlayer).getTeam()).IsVassal(getTeam())) { @@ -51622,9 +50060,9 @@ CvString CvPlayer::GetVassalIndependenceTooltipAsMaster(PlayerTypes ePlayer) con return ""; CvTeam& kMasterTeam = GET_TEAM(eMaster); - + CvString szTooltip = ""; - + szTooltip += GetLocalizedText("TXT_KEY_VO_INDEPENDENCE_POSSIBLE_TT") + "[NEWLINE][NEWLINE]"; bool bVoluntary = kVassalTeam.IsVoluntaryVassal(getTeam()); @@ -51636,7 +50074,7 @@ CvString CvPlayer::GetVassalIndependenceTooltipAsMaster(PlayerTypes ePlayer) con bSatisfied = (iNumTurnsIsVassal >= iMinimumVassalTurns); szTooltip += (bSatisfied ? "[COLOR_POSITIVE_TEXT]" : "[COLOR_GREY]") + GetLocalizedText("TXT_KEY_VO_INDEPENDENCE_POSSIBLE_TURNS_TT", iMinimumVassalTurns) + "[ENDCOLOR][NEWLINE]"; - + // Rules only for capitulated vassals if(!bVoluntary) { @@ -51658,7 +50096,7 @@ CvString CvPlayer::GetVassalIndependenceTooltipAsMaster(PlayerTypes ePlayer) con bSatisfied = iPopPercent >= /*300*/ GD_INT_GET(VASSALAGE_VASSAL_POPULATION_THRESHOLD); bAnySatisfied |= bSatisfied; szTemp += (bSatisfied ? "[COLOR_POSITIVE_TEXT]" : "[COLOR_GREY]") + GetLocalizedText("TXT_KEY_VO_INDEPENDENCE_POSSIBLE_POP_PERCENT_TT", GD_INT_GET(VASSALAGE_VASSAL_POPULATION_THRESHOLD), iPopPercent) + "[ENDCOLOR][NEWLINE]"; - + int iMasterCityPercent = 0; int iMasterPopPercent = 0; @@ -51686,9 +50124,9 @@ CvString CvPlayer::GetVassalIndependenceTooltipAsVassal() const return ""; CvTeam& kMasterTeam = GET_TEAM(eMaster); - + CvString szTooltip = ""; - + szTooltip += GetLocalizedText("TXT_KEY_VO_INDEPENDENCE_POSSIBLE_MASTER_TT") + "[NEWLINE][NEWLINE]"; bool bVoluntary = kVassalTeam.IsVoluntaryVassal(eMaster); @@ -51700,7 +50138,7 @@ CvString CvPlayer::GetVassalIndependenceTooltipAsVassal() const bSatisfied = (iNumTurnsIsVassal >= iMinimumVassalTurns); szTooltip += (bSatisfied ? "[COLOR_POSITIVE_TEXT]" : "[COLOR_GREY]") + GetLocalizedText("TXT_KEY_VO_INDEPENDENCE_POSSIBLE_TURNS_TT", iMinimumVassalTurns) + "[ENDCOLOR][NEWLINE]"; - + // Rules only for capitulated vassals if(!bVoluntary) { @@ -51722,7 +50160,7 @@ CvString CvPlayer::GetVassalIndependenceTooltipAsVassal() const bSatisfied = iPopPercent >= /*300*/ GD_INT_GET(VASSALAGE_VASSAL_POPULATION_THRESHOLD); bAnySatisfied |= bSatisfied; szTemp += (bSatisfied ? "[COLOR_POSITIVE_TEXT]" : "[COLOR_GREY]") + GetLocalizedText("TXT_KEY_VO_INDEPENDENCE_POSSIBLE_CITY_PERCENT_TT", GD_INT_GET(VASSALAGE_VASSAL_POPULATION_THRESHOLD), iPopPercent) + "[ENDCOLOR][NEWLINE]"; - + int iMasterCityPercent = 0; int iMasterPopPercent = 0; @@ -52232,7 +50670,7 @@ bool CvPlayer::HasUUActive() if (pkInfo) { - for (CvUnit* pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop)) + for (CvUnit* pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop)) { if (pkInfo->isCivilizationUnitOverridden(pLoopUnit->getUnitClassType())) { @@ -52364,120 +50802,120 @@ void CvPlayer::DoForceDefPact(PlayerTypes eOtherPlayer) int CvPlayer::CountAllFeature(FeatureTypes iFeatureType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountFeature(iFeatureType); } - + return iCount; } int CvPlayer::CountAllWorkedFeature(FeatureTypes iFeatureType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountWorkedFeature(iFeatureType); } - + return iCount; } int CvPlayer::CountAllImprovement(ImprovementTypes iImprovementType, bool bOnlyCreated) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountImprovement(iImprovementType, bOnlyCreated); } - + return iCount; } int CvPlayer::CountAllWorkedImprovement(ImprovementTypes iImprovementType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountWorkedImprovement(iImprovementType); } - + return iCount; } int CvPlayer::CountAllPlotType(PlotTypes iPlotType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountPlotType(iPlotType); } - + return iCount; } int CvPlayer::CountAllWorkedPlotType(PlotTypes iPlotType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountWorkedPlotType(iPlotType); } - + return iCount; } int CvPlayer::CountAllResource(ResourceTypes iResourceType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountResource(iResourceType); } - + return iCount; } int CvPlayer::CountAllWorkedResource(ResourceTypes iResourceType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountWorkedResource(iResourceType); } - + return iCount; } int CvPlayer::CountAllTerrain(TerrainTypes iTerrainType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountTerrain(iTerrainType); } - + return iCount; } int CvPlayer::CountAllWorkedTerrain(TerrainTypes iTerrainType) { int iCount = 0; - + int iLoop = 0; for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop)) { iCount += pLoopCity->CountWorkedTerrain(iTerrainType); } - + return iCount; } @@ -52505,7 +50943,7 @@ void CvPlayer::updatePlotFoundValues() // important preparation GC.getGame().GetSettlerSiteEvaluator()->ComputeFlavorMultipliers(this); //these are the plots whose yield we ignore - vector ignoreYieldPlots(GC.getMap().numPlots(), 0); + vector ignoreYieldPlots(GC.getMap().numPlots(), 0); for (int iI = 0; iI < GC.getMap().numPlots(); iI++) { @@ -52568,6 +51006,130 @@ int CvPlayer::GetAvgUnitExp100() const return m_iAvgUnitExp100; } +// -------------------------------------------------------------------------------- +/// Pick a random unit type that is ranked by unit power and restricted to units available to this player +UnitTypes CvPlayer::GetCompetitiveSpawnUnitType(const bool bIncludeRanged, const bool bIncludeShips, const bool bIncludeRecon, const bool bIncludeUUs, + const CvCity* pSpawnCity, const bool bNoResource, const bool bMinorCivGift, const bool bRandom, CvSeeder* pSeed, const vector viUnitCombat) const +{ + CvWeightedVector veUnitRankings; + + // Loop through all Unit Classes + for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) + { + const UnitClassTypes eUnitClass = static_cast(iI); + UnitTypes eUnit = GetSpecificUnitType(eUnitClass); + if (eUnit == NO_UNIT) + continue; + + CvUnitClassInfo* pUnitClassInfo = GC.getUnitClassInfo(eUnitClass); + if (!bIncludeUUs) + eUnit = static_cast(pUnitClassInfo->getDefaultUnitIndex()); + + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnit); + if (!pUnitInfo) + continue; + + if (pUnitInfo->GetCombat() <= 0) + continue; + + // No recon units? + if (!bIncludeRecon && (pUnitInfo->GetDefaultUnitAIType() == UNITAI_EXPLORE || pUnitInfo->GetDefaultUnitAIType() == UNITAI_EXPLORE_SEA)) + continue; + + // No ranged units? + if (!bIncludeRanged && pUnitInfo->GetRangedCombat() > 0) + continue; + + // Unit must be of these UnitCombat IDs + if (!viUnitCombat.empty()) + { + bool bValid = false; + for (vector::const_iterator it = viUnitCombat.begin(); it != viUnitCombat.end(); ++it) + { + if (pUnitInfo->GetUnitCombatType() == *it) + { + bValid = true; + break; + } + } + + if (!bValid) + continue; + } + + // Unit is from City-State? + if (bMinorCivGift && pUnitInfo->IsInvalidMinorCivGift()) + continue; + + if (!HasResourceForNewUnit(eUnit, bNoResource)) + continue; + + // Specified city? + if (pSpawnCity && !pSpawnCity->canTrain(eUnit, false, true)) + continue; + + // Otherwise just check whether the player can train the unit in any city + if (!pSpawnCity && !canTrainUnit(eUnit, false, true, false, /*bIgnoreUniqueUnitStatus*/ true)) + continue; + + // Unit has combat strength, make sure it isn't only defensive (and with no ranged combat ability) + bool bValid = true; + if (pUnitInfo->GetRange() == 0) + { + for (int iJ = 0; iJ < GC.getNumPromotionInfos(); iJ++) + { + const PromotionTypes ePromotion = static_cast(iJ); + CvPromotionEntry* pPromotionInfo = GC.getPromotionInfo(ePromotion); + if (!pPromotionInfo) + continue; + + if (!pPromotionInfo->IsOnlyDefensive()) + continue; + + if (pUnitInfo->GetFreePromotions(iJ)) + { + bValid = false; + break; + } + } + } + + if (!bValid) + continue; + + // Must be land unit, or naval unit must be allowed + if (pUnitInfo->GetDomainType() == DOMAIN_LAND || (pUnitInfo->GetDomainType() == DOMAIN_SEA && bIncludeShips)) + { + veUnitRankings.push_back(eUnit, pUnitInfo->GetPower()); + } + } + + if (veUnitRankings.empty()) + return NO_UNIT; + + veUnitRankings.StableSortItems(); + + if (!bRandom) + { + // Just grab the highest ranked unit + return veUnitRankings.GetElement(0); + } + + CvSeeder seed; + if (pSeed) + { + seed = *pSeed; + } + else + { + seed = bIncludeRanged ? CvSeeder::fromRaw(0xb5272cbd) : CvSeeder::fromRaw(0xdea52530); + seed = seed.mix(GetMilitaryMight()).mix(GetID()).mix(GC.getGame().getGameTurn()); + } + + // Choose from weighted unit types + return veUnitRankings.ChooseFromTopChoices(/*5*/ GD_INT_GET(UNIT_SPAWN_NUM_CHOICES), seed); +} + FDataStream& operator<<(FDataStream& saveTo, const SPlayerActiveEspionageEvent& readFrom) { saveTo << readFrom.eOtherPlayer; diff --git a/CvGameCoreDLL_Expansion2/CvPlayer.h b/CvGameCoreDLL_Expansion2/CvPlayer.h index 684f14815a..bab8fd61ce 100644 --- a/CvGameCoreDLL_Expansion2/CvPlayer.h +++ b/CvGameCoreDLL_Expansion2/CvPlayer.h @@ -20,9 +20,7 @@ #include "CvAchievementUnlocker.h" #include "CvUnitCycler.h" #include "TContainer.h" -#if defined(MOD_BALANCE_CORE) #include "CvMinorCivAI.h" -#endif #include "CvSerialize.h" class CvPlayerPolicies; @@ -43,15 +41,11 @@ class CvDealAI; class CvBuilderTaskingAI; class CvDangerPlots; class CvDistanceMap; -#if defined(MOD_BALANCE_CORE) class CvPlayerCorporations; class CvPlayerContracts; -#endif class CvCityConnections; class CvNotifications; -#if defined(MOD_WH_MILITARY_LOG) class CvEventLog; -#endif class CvTreasury; class CvPlayerTraits; class CvGameInitialItemsOverrides; @@ -388,11 +382,10 @@ class CvPlayer int GetNumUnitsSuppliedByPopulation(bool bIgnoreReduction = false) const; int GetNumUnitsOutOfSupply(bool bCheckWarWeariness = true) const; -#if defined(MOD_BALANCE_CORE) + int GetNumUnitsToSupply() const; int getNumUnitsSupplyFree() const; void changeNumUnitsSupplyFree(int iValue); -#endif int calculateUnitCost() const; int calculateResearchModifier(TechTypes eTech); @@ -982,15 +975,9 @@ class CvPlayer void changeGoldenAgeModifier(int iChange); // Great People Stuff -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void createGreatGeneral(UnitTypes eGreatPersonUnit, int iX, int iY, bool bIsFree); void createGreatAdmiral(UnitTypes eGreatPersonUnit, int iX, int iY, bool bIsFree); -#else - void createGreatGeneral(UnitTypes eGreatPersonUnit, int iX, int iY); - void createGreatAdmiral(UnitTypes eGreatPersonUnit, int iX, int iY); -#endif -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int getGreatPeopleCreated(bool bExcludeFree) const; void incrementGreatPeopleCreated(bool bIsFree); @@ -998,14 +985,14 @@ class CvPlayer void incrementGreatGeneralsCreated(bool bIsFree); int getGreatAdmiralsCreated(bool bExcludeFree) const; void incrementGreatAdmiralsCreated(bool bIsFree); -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) + int getGreatMerchantsCreated(bool bExcludeFree) const; void incrementGreatMerchantsCreated(bool bIsFree); int getGreatScientistsCreated(bool bExcludeFree) const; void incrementGreatScientistsCreated(bool bIsFree); int getGreatEngineersCreated(bool bExcludeFree) const; void incrementGreatEngineersCreated(bool bIsFree); -#endif + int getGreatWritersCreated(bool bExcludeFree) const; void incrementGreatWritersCreated(bool bIsFree); int getGreatArtistsCreated(bool bExcludeFree) const; @@ -1014,63 +1001,19 @@ class CvPlayer void incrementGreatMusiciansCreated(bool bIsFree); int getGreatDiplomatsCreated(bool bExcludeFree) const; void incrementGreatDiplomatsCreated(bool bIsFree); -#if defined(MOD_BALANCE_CORE) + int getGPExtra1Created(bool bExcludeFree) const; void incrementGPExtra1Created(bool bIsFree); - int getGPExtra2Created(bool bExcludeFree) const; void incrementGPExtra2Created(bool bIsFree); - int getGPExtra3Created(bool bExcludeFree) const; void incrementGPExtra3Created(bool bIsFree); - int getGPExtra4Created(bool bExcludeFree) const; void incrementGPExtra4Created(bool bIsFree); - int getGPExtra5Created(bool bExcludeFree) const; void incrementGPExtra5Created(bool bIsFree); -#endif -#else - int getGreatPeopleCreated() const; - void incrementGreatPeopleCreated(); - - int getGreatGeneralsCreated() const; - void incrementGreatGeneralsCreated(); - int getGreatAdmiralsCreated() const; - void incrementGreatAdmiralsCreated(); -#if defined(MOD_GLOBAL_SEPARATE_GP_COUNTERS) - int getGreatMerchantsCreated() const; - void incrementGreatMerchantsCreated(); - int getGreatScientistsCreated() const; - void incrementGreatScientistsCreated(); - int getGreatEngineersCreated() const; - void incrementGreatEngineersCreated(); -#endif - int getGreatWritersCreated() const; - void incrementGreatWritersCreated(); - int getGreatArtistsCreated() const; - void incrementGreatArtistsCreated(); - int getGreatMusiciansCreated() const; - void incrementGreatMusiciansCreated(); - int getGreatDiplomatsCreated() const; - void incrementGreatDiplomatsCreated(); -#if defined(MOD_BALANCE_CORE) - int getGPExtra1Created() const; - void incrementGPExtra1Created(); - - int getGPExtra2Created() const; - void incrementGPExtra2Created(); - - int getGPExtra3Created() const; - void incrementGPExtra3Created(); - int getGPExtra4Created() const; - void incrementGPExtra4Created(); - - int getGPExtra5Created() const; - void incrementGPExtra5Created(); -#endif -#endif + void incrementGreatPersonCount(const CvUnitEntry& kUnitInfo, bool bCountAsProphet, bool bIsFree); int getMerchantsFromFaith() const; void incrementMerchantsFromFaith(); @@ -1090,7 +1033,7 @@ class CvPlayer void incrementEngineersFromFaith(); int getDiplomatsFromFaith() const; void incrementDiplomatsFromFaith(); -#if defined(MOD_BALANCE_CORE) + int getGPExtra1FromFaith() const; void incrementGPExtra1FromFaith(); int getGPExtra2FromFaith() const; @@ -1106,7 +1049,6 @@ class CvPlayer void changeResourceFromGP(ResourceTypes eIndex, byte iChange); int getResourceModFromReligion(ResourceTypes eIndex) const; -#endif int getGreatPeopleThresholdModifier() const; void changeGreatPeopleThresholdModifier(int iChange); @@ -1173,11 +1115,7 @@ class CvPlayer CvString getInstantGreatPersonProgressText(InstantYieldType iType) const; #endif // Great People Expenditure -#if defined(MOD_EVENTS_GREAT_PEOPLE) void DoGreatPersonExpended(UnitTypes eGreatPersonUnit, CvUnit* pGreatPersonUnit); -#else - void DoGreatPersonExpended(UnitTypes eGreatPersonUnit); -#endif int GetGreatPersonExpendGold() const; void ChangeGreatPersonExpendGold(int iChange); @@ -1188,11 +1126,7 @@ class CvPlayer void SetGreatPeopleSpawnCounter(int iValue); void ChangeGreatPeopleSpawnCounter(int iChange); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void DoSpawnGreatPerson(PlayerTypes eMinor, bool bIsFree); -#else - void DoSpawnGreatPerson(PlayerTypes eMinor); -#endif void DoGreatPeopleSpawnTurn(); CvCity* GetGreatPersonSpawnCity(UnitTypes eUnit); @@ -1310,7 +1244,6 @@ class CvPlayer int GetNumMaintenanceFreeUnits(DomainTypes eDomain = NO_DOMAIN, bool bOnlyCombatUnits = false) const; int getNumMilitaryUnits() const; -#if defined(MOD_BATTLE_ROYALE) /*Changes to allow finer details of the Military Units that the Player has*/ int getNumMilitaryLandUnits() const; int getNumMilitarySeaUnits() const; @@ -1319,9 +1252,6 @@ class CvPlayer int GetMilitaryAirMight() const; int GetMilitaryLandMight() const; void changeNumMilitaryUnits(int iChange, DomainTypes eDomain = NO_DOMAIN); -#else - void changeNumMilitaryUnits(int iChange); -#endif int getHappyPerMilitaryUnit() const; void changeHappyPerMilitaryUnit(int iChange); @@ -1660,22 +1590,14 @@ class CvPlayer void ResetMightCalcTurn(); int getCombatExperienceTimes100() const; -#if defined(MOD_GLOBAL_LOCAL_GENERALS) void setCombatExperienceTimes100(int iExperienceTimes100, CvUnit* pFromUnit = NULL); void changeCombatExperienceTimes100(int iChangeTimes100, CvUnit* pFromUnit = NULL); -#else - void setCombatExperienceTimes100(int iExperienceTimes100); - void changeCombatExperienceTimes100(int iChangeTimes100); -#endif + int getLifetimeCombatExperienceTimes100() const; int getNavalCombatExperienceTimes100() const; -#if defined(MOD_GLOBAL_LOCAL_GENERALS) + void setNavalCombatExperienceTimes100(int iExperienceTimes100, CvUnit* pFromUnit = NULL); void changeNavalCombatExperienceTimes100(int iChangeTimes100, CvUnit* pFromUnit = NULL); -#else - void setNavalCombatExperienceTimes100(int iExperienceTimes100); - void changeNavalCombatExperienceTimes100(int iChangeTimes100); -#endif int getBorderObstacleCount() const; bool isBorderObstacle() const; @@ -2170,9 +2092,8 @@ class CvPlayer int getNumResourceFromBuildings(ResourceTypes eIndex) const; int getNumResourceTotal(ResourceTypes eIndex, bool bIncludeImport = true) const; int getNumResourcesFromOther(ResourceTypes eIndex) const; - void changeNumResourceTotal(ResourceTypes eIndex, int iChange, bool bFromBuilding = false, bool bCheckForMonopoly = true, bool bIgnoreResourceWarning = false); -#if defined(MOD_BALANCE_CORE_RESOURCE_MONOPOLIES) + bool HasGlobalMonopoly(ResourceTypes eResource) const; void SetHasGlobalMonopoly(ResourceTypes eResource, bool bNewValue); bool HasStrategicMonopoly(ResourceTypes eResource) const; @@ -2201,8 +2122,6 @@ class CvPlayer void changeResourceFromCSAlliances(ResourceTypes eIndex, int iChange); void setResourceFromCSAlliances(ResourceTypes eIndex, int iChange); -#endif - const std::vector& GetResourcesNotForSale() const { return m_vResourcesNotForSale; } bool IsResourceNotForSale(ResourceTypes eResource); void SetResourceAvailable(ResourceTypes eResource); @@ -2262,6 +2181,8 @@ class CvPlayer int getResourceInOwnedPlots(ResourceTypes eIndex); + bool HasResourceForNewUnit(const UnitTypes eUnit, const bool bNoRequirement = false, const bool bCheckAluminum = false, const UnitTypes eFromUnit = NO_UNIT, const bool bContinue = false) const; + int getTotalImprovementsBuilt() const; void changeTotalImprovementsBuilt(int iChange); int getImprovementCount(ImprovementTypes eIndex, bool bBuiltOnly = false) const; @@ -2702,11 +2623,12 @@ class CvPlayer #endif // spaceship planning - void LogSpaceshipPlanMessage(const CvString& strMsg); - vector GetCoreCitiesForSpaceshipProduction(); - int GetNumAluminumStillNeededForCoreCities(); - int GetNumAluminumStillNeededForSpaceship(); - int GetNumSpaceshipPartsBuildableNow(bool bIncludeCurrentlyInProduction = false); + void LogSpaceshipPlanMessage(const CvString& strMsg) const; + void DoUpdateCoreCitiesForSpaceshipProduction(); + const vector& GetCoreCitiesForSpaceshipProduction() const; + int GetNumAluminumStillNeededForCoreCities() const; + int GetNumAluminumStillNeededForSpaceship() const; + int GetNumSpaceshipPartsBuildableNow(bool bIncludeCurrentlyInProduction = false) const; void DoAnnounceReligionAdoption(); // End New Religion Stuff @@ -2758,13 +2680,11 @@ class CvPlayer void SetEverConqueredBy(PlayerTypes ePlayer, bool bValue); bool IsEverConqueredBy(PlayerTypes ePlayer); - // slewis Tutorial functions - bool GetEverPoppedGoody(void); // has this player ever popped a goody hut - CvPlot* GetClosestGoodyPlot(bool bStopAfterFindingFirst = false); // find the goody plot that has the closest unit that can reach it, null means none could be found - bool GetPlotHasOrder(CvPlot* Plot); // are any of the player's units directed to this plot? + bool GetEverPoppedGoody(void); // has this player ever popped a goody hut + CvPlot* GetClosestGoodyPlot(bool bStopAfterFindingFirst = false); // find the goody plot that has the closest unit that can reach it, null means none could be found + bool GetPlotHasOrder(CvPlot* Plot); // are any of the player's units directed to this plot? bool GetAnyUnitHasOrderToGoody(void); bool GetEverTrainedBuilder(void); - // end Tutorial functions bool CanEmbark() const; bool CanCrossOcean() const; @@ -2982,6 +2902,8 @@ class CvPlayer bool NeedWorkboatToImproveResource(ResourceTypes eResource) const; + UnitTypes GetCompetitiveSpawnUnitType(const bool bIncludeRanged = false, const bool bIncludeShips = false, const bool bIncludeRecon = false, const bool bIncludeUUs = false, const CvCity* pSpawnCity = NULL, const bool bNoResource = false, const bool bMinorCivGift = false, const bool bRandom = false, CvSeeder* pSeed = NULL, const vector viUnitCombat = vector()) const; + protected: class ConqueredByBoolField { @@ -3518,11 +3440,7 @@ class CvPlayer int m_iLastSliceMoved; // not serialized - vector m_vCitiesForSpaceshipParts; // not serialized - int m_iCitiesForSpaceshipPartsUpdateTurn; // not serialized - vector m_vCoreCitiesForSpaceshipProduction; // not serialized - int m_iCoreCitiesForSpaceshipProductionUpdateTurn; // not serialized - + vector m_viCoreCitiesForSpaceshipProduction; uint m_uiStartTime; // XXX save these? @@ -3727,7 +3645,7 @@ class CvPlayer std::map> m_ppiSpecificGreatPersonRateChangeFromMonopoly; #endif - CvUnitCycler m_kUnitCycle; + CvUnitCycler m_kUnitCycle; // slewis's tutorial variables! bool m_bEverPoppedGoody; @@ -4336,6 +4254,7 @@ SYNC_ARCHIVE_VAR(int, m_iNumFreePolicies) SYNC_ARCHIVE_VAR(int, m_iNumFreePoliciesEver) SYNC_ARCHIVE_VAR(int, m_iNumFreeTenets) SYNC_ARCHIVE_VAR(int, m_iCachedCurrentWarValue) +SYNC_ARCHIVE_VAR(vector, m_viCoreCitiesForSpaceshipProduction) SYNC_ARCHIVE_VAR(uint, m_uiStartTime) SYNC_ARCHIVE_VAR(bool, m_bHasUUPeriod) SYNC_ARCHIVE_VAR(bool, m_bNoNewWars) diff --git a/CvGameCoreDLL_Expansion2/CvPlayerAI.cpp b/CvGameCoreDLL_Expansion2/CvPlayerAI.cpp index b5feeb7f78..e0d4a82ce8 100644 --- a/CvGameCoreDLL_Expansion2/CvPlayerAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvPlayerAI.cpp @@ -179,12 +179,13 @@ void CvPlayerAI::AI_doTurnUnitsPre() for (size_t i = 0; i < unitsToDelete.size(); i++) unitsToDelete[i]->doDelayedDeath(); -#if defined(MOD_CORE_DELAYED_VISIBILITY) - //force explicit visibility update for killed units - if (!unitsToDelete.empty()) - for (int iI = 0; iI < GC.getMap().numPlots(); iI++) - GC.getMap().plotByIndexUnchecked(iI)->flipVisibility(getTeam()); -#endif + if (MOD_CORE_DELAYED_VISIBILITY) + { + // Force explicit visibility update for killed units + if (!unitsToDelete.empty()) + for (int iI = 0; iI < GC.getMap().numPlots(); iI++) + GC.getMap().plotByIndexUnchecked(iI)->flipVisibility(getTeam()); + } //army cleanup (two step approach because deleting a unit invalidates the iterator) std::vector itemsToDelete; @@ -535,11 +536,7 @@ void CvPlayerAI::AI_chooseFreeGreatPerson() CvCity* pCapital = getCapitalCity(); if(pCapital) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pCapital->GetCityCitizens()->DoSpawnGreatPerson(eDesiredGreatPerson, true, false, MOD_GLOBAL_TRULY_FREE_GP); -#else - pCapital->GetCityCitizens()->DoSpawnGreatPerson(eDesiredGreatPerson, true, false); -#endif } ChangeNumFreeGreatPeople(-1); } @@ -559,19 +556,18 @@ void CvPlayerAI::AI_chooseFreeTech() clearResearchQueue(); -#if defined(MOD_EVENTS_AI_OVERRIDE_TECH) - if (MOD_EVENTS_AI_OVERRIDE_TECH && eBestTech == NO_TECH) { + if (MOD_EVENTS_AI_OVERRIDE_TECH && eBestTech == NO_TECH) + { int iValue = 0; - if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_AiOverrideChooseNextTech, GetID(), true) == GAMEEVENTRETURN_VALUE) { + if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_AiOverrideChooseNextTech, GetID(), true) == GAMEEVENTRETURN_VALUE) + { // Defend against modder stupidity! - if (iValue >= 0 && iValue < GC.getNumTechInfos() && !GET_TEAM(getTeam()).GetTeamTechs()->HasTech((TechTypes) iValue)) { + if (iValue >= 0 && iValue < GC.getNumTechInfos() && !GET_TEAM(getTeam()).GetTeamTechs()->HasTech((TechTypes) iValue)) + { eBestTech = (TechTypes)iValue; } } } -#else - // TODO: script override -#endif if(eBestTech == NO_TECH) { @@ -616,7 +612,6 @@ void CvPlayerAI::AI_chooseResearch() if(GetPlayerTechs()->GetCurrentResearch() == NO_TECH) { -#if defined(MOD_EVENTS_AI_OVERRIDE_TECH) if (MOD_EVENTS_AI_OVERRIDE_TECH && eBestTech == NO_TECH) { int iValue = 0; @@ -629,9 +624,6 @@ void CvPlayerAI::AI_chooseResearch() } } } -#else - //todo: script override -#endif if(eBestTech == NO_TECH) { @@ -1610,7 +1602,6 @@ GreatPeopleDirectiveTypes CvPlayerAI::GetDirectiveEngineer(CvUnit* pGreatEnginee if (eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && (GC.getGame().getGameTurn() - pGreatEngineer->getGameTurnCreated()) < /*5*/ GD_INT_GET(AI_HOMELAND_GREAT_PERSON_TURNS_TO_WAIT)) return eDirective; -#if defined(MOD_BALANCE_CORE) ImprovementTypes eManufactory = (ImprovementTypes)GC.getInfoTypeForString("IMPROVEMENT_MANUFACTORY"); int iFlavor = GetFlavorManager()->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_PRODUCTION")); iFlavor += GetFlavorManager()->GetPersonalityIndividualFlavor((FlavorTypes)GC.getInfoTypeForString("FLAVOR_GROWTH")); @@ -1623,8 +1614,9 @@ GreatPeopleDirectiveTypes CvPlayerAI::GetDirectiveEngineer(CvUnit* pGreatEnginee iFlavor += GetPlayerTraits()->GetYieldChangePerImprovementBuilt(eManufactory, eYield); } iFlavor -= (GetCurrentEra() + GetCurrentEra() + getGreatEngineersCreated(true)); + // Build manufactories up to your flavor. - if(eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE) + if (eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE) { int iNumImprovement = getImprovementCount(eManufactory); if(iNumImprovement <= iFlavor) @@ -1632,17 +1624,8 @@ GreatPeopleDirectiveTypes CvPlayerAI::GetDirectiveEngineer(CvUnit* pGreatEnginee eDirective = GREAT_PEOPLE_DIRECTIVE_CONSTRUCT_IMPROVEMENT; } } - if(eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && (GC.getGame().getGameTurn() - pGreatEngineer->getGameTurnCreated()) >= (/*5*/ GD_INT_GET(AI_HOMELAND_GREAT_PERSON_TURNS_TO_WAIT) - GetCurrentEra())) -#else - if (eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && GC.getGame().getGameTurn() <= ((GC.getGame().getEstimateEndTurn() * 3) / 4)) - { - if (GetDiplomacyAI()->IsGoingForWorldConquest()) - { - eDirective = GREAT_PEOPLE_DIRECTIVE_CONSTRUCT_IMPROVEMENT; - } - } - if(eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && (GC.getGame().getGameTurn() - pGreatEngineer->getGameTurnCreated()) >= /*5*/ GD_INT_GET(AI_HOMELAND_GREAT_PERSON_TURNS_TO_WAIT)) -#endif + + if (eDirective == NO_GREAT_PEOPLE_DIRECTIVE_TYPE && (GC.getGame().getGameTurn() - pGreatEngineer->getGameTurnCreated()) >= (/*5*/ GD_INT_GET(AI_HOMELAND_GREAT_PERSON_TURNS_TO_WAIT) - GetCurrentEra())) { eDirective = GREAT_PEOPLE_DIRECTIVE_CONSTRUCT_IMPROVEMENT; } @@ -2051,25 +2034,19 @@ CvPlot* CvPlayerAI::FindBestMerchantTargetPlotForCash(CvUnit* pMerchant) // -------------------------------------------------------------------------------- /// planner for AI spaceship production: returns the cities in which the currently available spaceship parts should be built in order to achieve SV as early as possible -vector CvPlayerAI::GetBestCitiesForSpaceshipParts() +const vector& CvPlayerAI::GetBestCitiesForSpaceshipParts() { - if (GC.getGame().getGameTurn() == m_iCitiesForSpaceshipPartsUpdateTurn) - { - return m_vCitiesForSpaceshipParts; - } - - m_iCitiesForSpaceshipPartsUpdateTurn = GC.getGame().getGameTurn(); - m_vCitiesForSpaceshipParts.clear(); + const vector vpEmpty; CvCity* pCapital = getCapitalCity(); if (!pCapital) - return m_vCitiesForSpaceshipParts; + return vpEmpty; int iNumSpaceshipPartsStillNeeded = 6 - GET_TEAM(getTeam()).GetSSProjectCount(/*bIncludeApollo*/ false); int iNumSpaceshipPartsBuildableNow = GetNumSpaceshipPartsBuildableNow(/*bIncludeCurrentlyInProduction*/ true); if (iNumSpaceshipPartsStillNeeded == 0 || iNumSpaceshipPartsBuildableNow == 0) - return m_vCitiesForSpaceshipParts; + return vpEmpty; // get unit type for one of the spaceship parts UnitTypes eSpaceshipUnit = NO_UNIT; @@ -2119,7 +2096,7 @@ vector CvPlayerAI::GetBestCitiesForSpaceshipParts() int iNumCitiesToConsider = vCitiesToConsider.size(); if (iNumCitiesToConsider == 0) - return m_vCitiesForSpaceshipParts; + return vpEmpty; // we want to assign spaceship part to cities in such a way that the total number of turns to bring all spaceship parts to the capital is minimized // to do this, we loop through the spaceship parts we still need and assign each of it to the best city. one city can be considered for multiple parts. @@ -2246,9 +2223,11 @@ vector CvPlayerAI::GetBestCitiesForSpaceshipParts() vCitiesSortedByTurns.StableSortItems(); // for the parts we can produce right now, choose the worst cities. - for (int k = 0; k < min(vCitiesSortedByTurns.size(), iNumSpaceshipPartsBuildableNow); k++) + int iNumCitiesForSpaceship = min(vCitiesSortedByTurns.size(), iNumSpaceshipPartsBuildableNow); + vector vpCitiesForSpaceshipParts(iNumCitiesForSpaceship); + for (int i = 0; i < iNumCitiesForSpaceship; i++) { - m_vCitiesForSpaceshipParts.push_back(vCitiesSortedByTurns.GetElement(k)); + vpCitiesForSpaceshipParts[i] = vCitiesSortedByTurns.GetElement(i); } if (GC.getLogging()) @@ -2269,7 +2248,7 @@ vector CvPlayerAI::GetBestCitiesForSpaceshipParts() } } - return m_vCitiesForSpaceshipParts; + return vpCitiesForSpaceshipParts; } // -------------------------------------------------------------------------------- @@ -2282,9 +2261,8 @@ void CvPlayerAI::AI_doSpaceshipProduction() if (GetNumSpaceshipPartsBuildableNow(true) == 0) return; - // calculate cities to build spaceship parts in - vector vBestCitiesForSpaceshipParts = GetBestCitiesForSpaceshipParts(); + const vector& vBestCitiesForSpaceshipParts = GetBestCitiesForSpaceshipParts(); // cancel spaceship part production in cities that are not considered the best cities (have to do this first to make the parts available) CvString strOutBuf; diff --git a/CvGameCoreDLL_Expansion2/CvPlayerAI.h b/CvGameCoreDLL_Expansion2/CvPlayerAI.h index 4433205f9e..fdaa26cec7 100644 --- a/CvGameCoreDLL_Expansion2/CvPlayerAI.h +++ b/CvGameCoreDLL_Expansion2/CvPlayerAI.h @@ -70,7 +70,7 @@ class CvPlayerAI : public CvPlayer CvPlot* FindBestMerchantTargetPlotForPuppet(CvUnit* pMerchant); //spaceship planning - vector GetBestCitiesForSpaceshipParts(); + const vector& GetBestCitiesForSpaceshipParts(); void AI_doSpaceshipProduction(); //For Great Diplomats diff --git a/CvGameCoreDLL_Expansion2/CvPlot.cpp b/CvGameCoreDLL_Expansion2/CvPlot.cpp index 2e71c08d86..03689a7ebc 100644 --- a/CvGameCoreDLL_Expansion2/CvPlot.cpp +++ b/CvGameCoreDLL_Expansion2/CvPlot.cpp @@ -1496,12 +1496,8 @@ int CvPlot::seeFromLevel(TeamTypes eTeam) const // Plot recon-ed? if(getReconCount() > 0) { -#if defined(MOD_PROMOTIONS_VARIABLE_RECON) // By my reckoning, this just needs to be a big number - iLevel = 4 * /*6*/ GD_INT_GET(RECON_VISIBILITY_RANGE); -#else - iLevel = 2 * /*6*/ GD_INT_GET(RECON_VISIBILITY_RANGE); -#endif + iLevel = 10; } // Normal visibility else @@ -1513,23 +1509,21 @@ int CvPlot::seeFromLevel(TeamTypes eTeam) const { iLevel += /*2*/ GD_INT_GET(MOUNTAIN_SEE_FROM_CHANGE); } - - if (isHills()) + else if (isHills()) { iLevel += /*1*/ GD_INT_GET(HILLS_SEE_FROM_CHANGE); } - - if (isWater()) + else if (isWater()) { iLevel += /*1*/ GD_INT_GET(SEAWATER_SEE_FROM_CHANGE); if (eTeam != NO_TEAM && GET_TEAM(eTeam).isExtraWaterSeeFrom()) - { iLevel++; - } } - else - iLevel++; //land plots are "higher" than water plots, limiting visibility and range attacks from water onto land + + // Land plots are "higher" than water plots, limiting visibility and range attacks from water onto land + if (MOD_BALANCE_VP && !isWater()) + iLevel++; return iLevel; } @@ -1551,18 +1545,18 @@ int CvPlot::seeThroughLevel(bool bIncludeShubbery) const { iLevel += /*2*/ GD_INT_GET(MOUNTAIN_SEE_THROUGH_CHANGE); } - - if (isHills()) + else if (isHills()) { iLevel += /*1*/ GD_INT_GET(HILLS_SEE_THROUGH_CHANGE); } - - if (isWater()) + else if (isWater()) { iLevel += /*1*/ GD_INT_GET(SEAWATER_SEE_THROUGH_CHANGE); } - else - iLevel++; //land plots are "higher" than water plots, limiting visibility and range attacks from water onto land + + // Land plots are "higher" than water plots, limiting visibility and range attacks from water onto land + if (MOD_BALANCE_VP && !isWater()) + iLevel++; return iLevel; } @@ -2298,20 +2292,13 @@ void CvPlot::updateSight(bool bIncrement) if(getReconCount() > 0) { -#if !defined(MOD_PROMOTIONS_VARIABLE_RECON) - int iRange = /*6*/ GD_INT_GET(RECON_VISIBILITY_RANGE); -#endif for(iI = 0; iI < MAX_PLAYERS; ++iI) { for(pLoopUnit = GET_PLAYER((PlayerTypes)iI).firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = GET_PLAYER((PlayerTypes)iI).nextUnit(&iLoop)) { if(pLoopUnit->getReconPlot() == this && pLoopUnit->canChangeVisibility()) { -#if defined(MOD_PROMOTIONS_VARIABLE_RECON) changeAdjacentSight(pLoopUnit->getTeam(), pLoopUnit->reconRange(), bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true), pLoopUnit); -#else - changeAdjacentSight(pLoopUnit->getTeam(), iRange, bIncrement, pLoopUnit->getSeeInvisibleType(), pLoopUnit->getFacingDirection(true), pLoopUnit); -#endif } } } @@ -2343,11 +2330,7 @@ void CvPlot::updateSeeFromSight(bool bIncrement, bool bRecalculate) } } -#if defined(MOD_PROMOTIONS_VARIABLE_RECON) iRange = std::max(iReconRange, iRange); -#else - iRange = std::max(/*6*/ GD_INT_GET(RECON_VISIBILITY_RANGE) + 1, iRange); -#endif iRange = std::min(8, iRange); // I don't care, I'm not looking more than 8 out, deal for(iDX = -iRange; iDX <= iRange; iDX++) @@ -2790,23 +2773,17 @@ bool CvPlot::canHaveImprovement(ImprovementTypes eImprovement, PlayerTypes ePlay if ((YieldTypes)iI > YIELD_GOLDEN_AGE_POINTS && !MOD_BALANCE_CORE_JFD) break; -#if defined(MOD_BALANCE_CORE) if (pkImprovementInfo->GetPrereqNatureYield(iI) > 0 && calculateNatureYield(((YieldTypes)iI), ePlayer, getFeatureType(), getResourceType(GET_PLAYER(ePlayer).getTeam()), NULL) < pkImprovementInfo->GetPrereqNatureYield(iI)) -#else - if(calculateNatureYield(((YieldTypes)iI), ePlayer, getFeatureType(), getResourceType(GET_PLAYER(ePlayer).getTeam()), NULL) < pkImprovementInfo->GetPrereqNatureYield(iI)) -#endif { return false; } } -#if defined(MOD_EVENTS_PLOT) - if (MOD_EVENTS_PLOT) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlotCanImprove, getX(), getY(), eImprovement) == GAMEEVENTRETURN_FALSE) { + if (MOD_EVENTS_PLOT) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlotCanImprove, getX(), getY(), eImprovement) == GAMEEVENTRETURN_FALSE) return false; - } } -#endif if (!bCheckAdjacency) return true; @@ -6312,19 +6289,15 @@ CvPlot* CvPlot::getInlandCorner() const int aiShuffle[4] = {0,1,2,3}; shuffleArray(aiShuffle, 4, GC.getGame().getMapRand()); - for(int iI = 0; iI < 4; ++iI) + for (int iI = 0; iI < 4; ++iI) { - switch(aiShuffle[iI]) + switch (aiShuffle[iI]) { case 0: pRiverPlot = GC.getMap().plotCheckInvalid(getX(), getY()); break; case 1: -#if defined(MOD_BALANCE_CORE) pRiverPlot = plotDirection(getX(), getY(), DIRECTION_NORTHEAST); -#else - pRiverPlot = plotDirection(getX(), getY(), DIRECTION_NORTH); -#endif break; case 2: pRiverPlot = plotDirection(getX(), getY(), DIRECTION_NORTHWEST); @@ -6333,7 +6306,8 @@ CvPlot* CvPlot::getInlandCorner() const pRiverPlot = plotDirection(getX(), getY(), DIRECTION_WEST); break; } - if(pRiverPlot != NULL && !pRiverPlot->hasCoastAtSECorner()) + + if (pRiverPlot != NULL && !pRiverPlot->hasCoastAtSECorner()) { break; } @@ -6908,11 +6882,7 @@ void CvPlot::setOwner(PlayerTypes eNewValue, int iAcquiringCityID, bool bCheckUn if(getFeatureType() != NO_FEATURE) { -#if defined(MOD_PSEUDO_NATURAL_WONDER) if(GC.getFeatureInfo(getFeatureType())->IsNaturalWonder(true)) -#else - if(GC.getFeatureInfo(getFeatureType())->IsNaturalWonder()) -#endif { bShouldUpdateHappiness = true; } @@ -7443,11 +7413,7 @@ void CvPlot::setFeatureType(FeatureTypes eNewValue) if(eNewValue != NO_FEATURE) { // Now a Natural Wonder here -#if defined(MOD_PSEUDO_NATURAL_WONDER) if((eOldFeature == NO_FEATURE || !GC.getFeatureInfo(eOldFeature)->IsNaturalWonder(true)) && GC.getFeatureInfo(eNewValue)->IsNaturalWonder(true)) -#else - if((eOldFeature == NO_FEATURE || !GC.getFeatureInfo(eOldFeature)->IsNaturalWonder()) && GC.getFeatureInfo(eNewValue)->IsNaturalWonder()) -#endif { GC.getMap().ChangeNumNaturalWonders(1); GC.getMap().getAreaById(getArea())->ChangeNumNaturalWonders(1); @@ -7456,11 +7422,7 @@ void CvPlot::setFeatureType(FeatureTypes eNewValue) if(eOldFeature != NO_FEATURE) { // Was a Natural Wonder, isn't any more -#if defined(MOD_PSEUDO_NATURAL_WONDER) if(GC.getFeatureInfo(eOldFeature)->IsNaturalWonder(true) && (eNewValue == NO_FEATURE || !GC.getFeatureInfo(eNewValue)->IsNaturalWonder(true))) -#else - if(GC.getFeatureInfo(eOldFeature)->IsNaturalWonder() && (eNewValue == NO_FEATURE || !GC.getFeatureInfo(eNewValue)->IsNaturalWonder())) -#endif { GC.getMap().ChangeNumNaturalWonders(-1); GC.getMap().getAreaById(getArea())->ChangeNumNaturalWonders(-1); @@ -7522,12 +7484,7 @@ bool CvPlot::IsNaturalWonder(bool orPseudoNatural) const if(eFeature == NO_FEATURE) return false; -#if defined(MOD_PSEUDO_NATURAL_WONDER) return GC.getFeatureInfo(eFeature)->IsNaturalWonder() || (orPseudoNatural && GC.getFeatureInfo(eFeature)->IsPseudoNaturalWonder()); -#else - orPseudoNatural; //ignore this - return GC.getFeatureInfo(eFeature)->IsNaturalWonder(); -#endif } // -------------------------------------------------------------------------------- @@ -8954,20 +8911,16 @@ bool CvPlot::IsImprovementPillaged() const } // -------------------------------------------------------------------------------- -#if defined(MOD_EVENTS_TILE_IMPROVEMENTS) void CvPlot::SetImprovementPillaged(bool bPillaged, bool bEvents) -#else -void CvPlot::SetImprovementPillaged(bool bPillaged) -#endif { bool bWasPillaged = m_bImprovementPillaged; if (bPillaged != bWasPillaged) { m_bImprovementPillaged = bPillaged; -#if defined(MOD_GLOBAL_STACKING_RULES) + calculateAdditionalUnitsFromImprovement(); -#endif + if (getEffectiveOwningCity() != NULL) { if (bPillaged) @@ -9224,11 +9177,7 @@ void CvPlot::setRouteType(RouteTypes eNewValue, PlayerTypes eBuilder) // make sure this plot is not disabled // important to call this because city connection update is hooked up there -#if defined(MOD_EVENTS_TILE_IMPROVEMENTS) SetRoutePillaged(false, false); -#else - SetRoutePillaged(false); -#endif for(iI = 0; iI < MAX_TEAMS; ++iI) { @@ -9258,11 +9207,7 @@ bool CvPlot::IsRoutePillaged() const } // -------------------------------------------------------------------------------- -#if defined(MOD_EVENTS_TILE_IMPROVEMENTS) void CvPlot::SetRoutePillaged(bool bPillaged, bool bEvents) -#else -void CvPlot::SetRoutePillaged(bool bPillaged) -#endif { if(m_bRoutePillaged != bPillaged) { @@ -10616,11 +10561,7 @@ int CvPlot::calculateImprovementYield(YieldTypes eYield, PlayerTypes ePlayer, Im return iYield; } -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) int CvPlot::calculatePlayerYield(YieldTypes eYield, int iCurrentYield, PlayerTypes ePlayer, ImprovementTypes eImprovement, FeatureTypes eFeature, ResourceTypes eResource, RouteTypes eForceCityConnection, const CvCity* pOwningCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon, const CvReligion* pPlayerPantheon, bool bDisplay) const -#else -int CvPlot::calculatePlayerYield(YieldTypes eYield, int iCurrentYield, PlayerTypes ePlayer, ImprovementTypes eImprovement, FeatureTypes eFeature, ResourceTypes eResource, RouteTypes eForceCityConnection, const CvCity* pOwningCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon, bool bDisplay) const -#endif { if (ePlayer == NO_PLAYER) return 0; @@ -10640,11 +10581,7 @@ int CvPlot::calculatePlayerYield(YieldTypes eYield, int iCurrentYield, PlayerTyp if (isMountain()) { -#if defined(MOD_PSEUDO_NATURAL_WONDER) if (!IsNaturalWonder(true)) -#else - if (!IsNaturalWonder()) -#endif { int iRangeYield = pTraits->GetMountainRangeYield(eYield); int iEra = kPlayer.GetCurrentEra(); @@ -10680,12 +10617,10 @@ int CvPlot::calculatePlayerYield(YieldTypes eYield, int iCurrentYield, PlayerTyp } } -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) if (MOD_RELIGION_PERMANENT_PANTHEON && pPlayerPantheon != NULL) { iMod += pPlayerPantheon->m_Beliefs.GetYieldModifierNaturalWonder(eYield, ePlayer, pOwningCity); } -#endif if (iMod != 0) { @@ -10698,11 +10633,7 @@ int CvPlot::calculatePlayerYield(YieldTypes eYield, int iCurrentYield, PlayerTyp } } } -#if defined(MOD_PSEUDO_NATURAL_WONDER) else if (IsNaturalWonder(true)) -#else - else if (IsNaturalWonder()) -#endif { iYield += pTraits->GetYieldChangeNaturalWonder(eYield); @@ -11072,11 +11003,7 @@ int CvPlot::calculateYield(YieldTypes eYield, bool bDisplay, const CvCity* pOwni } // -------------------------------------------------------------------------------- -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) int CvPlot::calculateYieldFast(YieldTypes eYield, bool bDisplay, const CvCity* pOwningCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon, const CvReligion* pPlayerPantheon) -#else -int CvPlot::calculateYieldFast(YieldTypes eYield, bool bDisplay, const CvCity* pOwningCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon) -#endif { ImprovementTypes eImprovement = NO_IMPROVEMENT; RouteTypes eRoute = NO_ROUTE; @@ -11217,11 +11144,7 @@ void CvPlot::updateYield() updateYieldFast(NULL, NULL, NULL); } -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) void CvPlot::updateYieldFast(CvCity* pWorkingCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon, const CvReligion* pPlayerPantheon) -#else -void CvPlot::updateYieldFast(CvCity* pWorkingCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon) -#endif { bool bChange = false; if(getArea() == -1) @@ -11234,11 +11157,7 @@ void CvPlot::updateYieldFast(CvCity* pWorkingCity, const CvReligion* pMajorityRe if (eYield > YIELD_CULTURE_LOCAL && !MOD_BALANCE_CORE_JFD) continue; -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) int iNewYield = calculateYieldFast(eYield,false,pWorkingCity,pMajorityReligion,pSecondaryPantheon,pPlayerPantheon); -#else - int iNewYield = calculateYieldFast(eYield,false,pWorkingCity,pMajorityReligion,pSecondaryPantheon); -#endif if(getYield(eYield) != iNewYield) { @@ -11397,28 +11316,21 @@ PlotVisibilityChangeResult CvPlot::changeVisibilityCount(TeamTypes eTeam, int iC if (iChange == 0) return eResult; - bool bOldVisibility = (m_aiVisibilityCount[eTeam]>0); -#if defined(MOD_CORE_DELAYED_VISIBILITY) - bool bOldMaxVisibility = m_aiVisibilityCountThisTurnMax[eTeam] > 0; -#else - bool bOldMaxVisibility = bOldVisibility; -#endif + bool bOldVisibility = (m_aiVisibilityCount[eTeam] > 0); + bool bOldMaxVisibility = MOD_CORE_DELAYED_VISIBILITY ? (m_aiVisibilityCountThisTurnMax[eTeam] > 0) : bOldVisibility; - //apparently it's legal to decrease sight below zero - so catch that - if (iChange<0 && abs(iChange)>m_aiVisibilityCount[eTeam]) - m_aiVisibilityCount[eTeam] = 0; - else - m_aiVisibilityCount[eTeam] += iChange; + // Apparently it's legal to decrease sight below zero - so catch that + m_aiVisibilityCount[eTeam] = max(0, m_aiVisibilityCount[eTeam] + iChange); - //remember the maximum + // Remember the maximum m_aiVisibilityCountThisTurnMax[eTeam] = max(m_aiVisibilityCountThisTurnMax[eTeam], m_aiVisibilityCount[eTeam]); - if(eSeeInvisible != NO_INVISIBLE) + if (eSeeInvisible != NO_INVISIBLE) { changeInvisibleVisibilityCount(eTeam, eSeeInvisible, iChange); } - if(bAlwaysSeeInvisible) + if (bAlwaysSeeInvisible) { changeInvisibleVisibilityCountUnit(eTeam, iChange); for(int iI = 0; iI < NUM_INVISIBLE_TYPES; iI++) @@ -11433,14 +11345,16 @@ PlotVisibilityChangeResult CvPlot::changeVisibilityCount(TeamTypes eTeam, int iC { eResult = VISIBILITY_CHANGE_TO_VISIBLE; - if (setRevealed(eTeam, true, pUnit)) // Change to revealed, returns true if the visibility was changed + if (setRevealed(eTeam, true, pUnit)) // Change to revealed, returns true if the visibility was changed { - //we are seeing this plot for the first time + // We are seeing this plot for the first time if (bInformExplorationTracking) { vector vPlayers = GET_TEAM(eTeam).getPlayers(); for (size_t i = 0; i < vPlayers.size(); i++) + { GET_PLAYER(vPlayers[i]).GetEconomicAI()->UpdateExplorePlotsLocally(this); + } } } else @@ -11481,8 +11395,7 @@ PlotVisibilityChangeResult CvPlot::changeVisibilityCount(TeamTypes eTeam, int iC if (!loopUnit) continue; -#if defined(MOD_BALANCE_CORE_MILITARY) - //if it is an enemy unit, update the danger plots! + // If it is an enemy unit, update the danger plots! if (GET_TEAM(eTeam).isAtWar(loopUnit->getTeam())) { const std::vector& aePlayers = GET_TEAM(eTeam).getPlayers(); @@ -11496,7 +11409,7 @@ PlotVisibilityChangeResult CvPlot::changeVisibilityCount(TeamTypes eTeam, int iC } } } -#endif + //why shouldn't an AI meet a human? if (!GET_TEAM(eTeam).isHuman() && loopUnit->isHuman()) continue; @@ -11523,10 +11436,9 @@ PlotVisibilityChangeResult CvPlot::changeVisibilityCount(TeamTypes eTeam, int iC } } -//with delayed visibility we do this in setTurnActive() -#if !defined(MOD_CORE_DELAYED_VISIBILITY) // We could se the plot before but not anymore - else if (bOldVisibility == true && !isVisible(eTeam)) + // With delayed visibility we do this in setTurnActive() + else if (!MOD_CORE_DELAYED_VISIBILITY && bOldVisibility == true && !isVisible(eTeam)) { eResult = VISIBILITY_CHANGE_TO_INVISIBLE; if (eTeam == GC.getGame().getActiveTeam()) @@ -11535,7 +11447,6 @@ PlotVisibilityChangeResult CvPlot::changeVisibilityCount(TeamTypes eTeam, int iC updateCenterUnit(); } } -#endif return eResult; } @@ -11900,37 +11811,32 @@ bool CvPlot::setRevealed(TeamTypes eTeam, bool bNewValue, CvUnit* pUnit, bool bT { if(getFeatureType() != NO_FEATURE) { -#if defined(MOD_PSEUDO_NATURAL_WONDER) if(GC.getFeatureInfo(getFeatureType())->IsNaturalWonder(true)) -#else - if(GC.getFeatureInfo(getFeatureType())->IsNaturalWonder()) -#endif { GET_TEAM(eTeam).ChangeNumNaturalWondersDiscovered(1); int iNumNaturalWondersLeft = GC.getMap().GetNumNaturalWonders() - GET_TEAM(eTeam).GetNumNaturalWondersDiscovered(); -#if defined(MOD_EVENTS_NW_DISCOVERY) - if (MOD_EVENTS_NW_DISCOVERY) { + if (MOD_EVENTS_NW_DISCOVERY) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_NaturalWonderDiscovered, eTeam, getFeatureType(), getX(), getY(), (getNumMajorCivsRevealed() == 0), (pUnit?pUnit->getOwner():NO_PLAYER), (pUnit?pUnit->GetID():-1)); - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + } + else { - CvLuaArgsHandle args; - args->Push(eTeam); - args->Push(getFeatureType()); - args->Push(getX()); - args->Push(getY()); - args->Push((getNumMajorCivsRevealed() == 0)); // bFirst + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if (pkScriptSystem) + { + CvLuaArgsHandle args; + args->Push(eTeam); + args->Push(getFeatureType()); + args->Push(getX()); + args->Push(getY()); + args->Push((getNumMajorCivsRevealed() == 0)); // bFirst - bool bResult = false; - LuaSupport::CallHook(pkScriptSystem, "NaturalWonderDiscovered", args.get(), bResult); - } -#if defined(MOD_EVENTS_NW_DISCOVERY) + bool bResult = false; + LuaSupport::CallHook(pkScriptSystem, "NaturalWonderDiscovered", args.get(), bResult); + } } -#endif Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_FOUND_NATURAL_WONDER"); strText << iNumNaturalWondersLeft; @@ -13809,11 +13715,7 @@ void CvPlot::getVisibleResourceState(ResourceTypes& eType, bool& bImproved, bool if(eType != NO_RESOURCE) { ImprovementTypes eRevealedImprovement = getRevealedImprovementType(GC.getGame().getActiveTeam(), true); -#if defined(MOD_BALANCE_CORE) if ((eRevealedImprovement != NO_IMPROVEMENT) && GC.getImprovementInfo(eRevealedImprovement)->IsConnectsResource(eType)) -#else - if((eRevealedImprovement != NO_IMPROVEMENT) && GC.getImprovementInfo(eRevealedImprovement)->IsImprovementResourceTrade(eType)) -#endif { bImproved = true; bWorked = isBeingWorked(); @@ -13822,11 +13724,7 @@ void CvPlot::getVisibleResourceState(ResourceTypes& eType, bool& bImproved, bool } // -------------------------------------------------------------------------------- -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) int CvPlot::getYieldWithBuild(BuildTypes eBuild, YieldTypes eYield, bool bWithUpgrade, RouteTypes eForceCityConnection, PlayerTypes ePlayer, const CvCity* pOwningCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon, const CvReligion* pPlayerPantheon) const -#else -int CvPlot::getYieldWithBuild(BuildTypes eBuild, YieldTypes eYield, bool bWithUpgrade, RouteTypes eForceCityConnection, PlayerTypes ePlayer, const CvCity* pOwningCity, const CvReligion* pMajorityReligion, const CvBeliefEntry* pSecondaryPantheon) const -#endif { int iYield = 0; @@ -13941,29 +13839,23 @@ int CvPlot::getYieldWithBuild(BuildTypes eBuild, YieldTypes eYield, bool bWithUp } iYield += calculateImprovementYield(eYield, ePlayer, eNewImprovement, eNewRoute, eFeature, eResource, eForceCityConnection, pOwningCity, false) + calculateReligionImprovementYield(eYield, ePlayer, eNewImprovement, eResource, pOwningCity, pMajorityReligion, pSecondaryPantheon); -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) if (MOD_RELIGION_PERMANENT_PANTHEON && pPlayerPantheon != NULL) { iYield += calculateReligionImprovementYield(eYield, ePlayer, eNewImprovement, eResource, pOwningCity, pPlayerPantheon, NULL); } -#endif } -#if defined(MOD_RELIGION_PERMANENT_PANTHEON) iYield += calculatePlayerYield(eYield, iYield, ePlayer, eNewImprovement, eFeature, eResource, eForceCityConnection, pOwningCity, pMajorityReligion, pSecondaryPantheon, pPlayerPantheon, false); -#else - iYield += calculatePlayerYield(eYield, iYield, ePlayer, eNewImprovement, eFeature, eResource, eForceCityConnection, pOwningCity, pMajorityReligion, pSecondaryPantheon, false); -#endif //no overhead if empty for (size_t i=0; i= 0, "eTeam is expected to be non-negative (invalid Index)"); CvAssertMsg(eTeam < MAX_TEAMS, "eTeam is expected to be within maximum bounds (invalid Index)"); -#if defined(MOD_CORE_DELAYED_VISIBILITY) - //return the hacked visibility count so plots which were once visible this turn stay that way - return m_aiVisibilityCountThisTurnMax[eTeam]; -#else - return m_aiVisibilityCount[eTeam]; -#endif + //With delayed visibility, return the hacked visibility count so plots which were once visible this turn stay that way + return MOD_CORE_DELAYED_VISIBILITY ? m_aiVisibilityCountThisTurnMax[eTeam] : m_aiVisibilityCount[eTeam]; } void flipVisibility(TeamTypes eTeam); diff --git a/CvGameCoreDLL_Expansion2/CvPolicyAI.cpp b/CvGameCoreDLL_Expansion2/CvPolicyAI.cpp index fa22ef0a4f..c6c166e9cc 100644 --- a/CvGameCoreDLL_Expansion2/CvPolicyAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvPolicyAI.cpp @@ -3723,108 +3723,84 @@ Firaxis::Array< int, NUM_YIELD_TYPES > CvPolicyAI::WeightPolicyAttributes(CvPlay yield[eYield] += PolicyInfo->GetReligionBuildingYieldMod(eBuildingClass, eYield) * iNumCities; } } -#if defined(MOD_BALANCE_CORE_POLICIES) + if (PolicyInfo->GetYieldChangesPerReligionTimes100(i) != 0) { yield[eYield] += PolicyInfo->GetYieldChangesPerReligionTimes100(i) * iNumCities / 100; } -#endif } } - UnitClassTypes eUnitClass; + // Unit related for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { - eUnitClass = (UnitClassTypes)iI; - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (!pkUnitClassInfo) - continue; - + const UnitClassTypes eUnitClass = static_cast(iI); const UnitTypes eUnit = pPlayer->GetSpecificUnitType(eUnitClass); CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); if (!pUnitEntry) continue; + bool bCombat = pUnitEntry->GetCombat() > 0 || pUnitEntry->GetRangedCombat() > 0; - if (PolicyInfo->GetUnitClassProductionModifiers(eUnitClass) != 0) + int iProductionModifier = PolicyInfo->GetUnitClassProductionModifiers(eUnitClass); + if (iProductionModifier != 0) { if (bCombat ? pPlayerTraits->IsWarmonger() : pPlayerTraits->IsExpansionist()) - { - yield[YIELD_GREAT_GENERAL_POINTS] += PolicyInfo->GetUnitClassProductionModifiers(eUnitClass) * 2; - } + yield[YIELD_GREAT_GENERAL_POINTS] += iProductionModifier * 2; else - { - yield[YIELD_GREAT_GENERAL_POINTS] += PolicyInfo->GetUnitClassProductionModifiers(eUnitClass); - } + yield[YIELD_GREAT_GENERAL_POINTS] += iProductionModifier; } - - if (PolicyInfo->GetNumFreeUnitsByClass(eUnitClass) != 0) + + int iNumFreeUnitsByClass = PolicyInfo->GetNumFreeUnitsByClass(eUnitClass); + if (iNumFreeUnitsByClass != 0) { if (bCombat ? pPlayerTraits->IsWarmonger() : pPlayerTraits->IsExpansionist()) - { - yield[YIELD_GREAT_GENERAL_POINTS] += PolicyInfo->GetNumFreeUnitsByClass(eUnitClass) * 25; - } + yield[YIELD_GREAT_GENERAL_POINTS] += iNumFreeUnitsByClass * 25; + if (pUnitEntry->IsFound()) - yield[YIELD_FOOD] += PolicyInfo->GetNumFreeUnitsByClass(eUnitClass) * (50 - (pPlayer->getNumCities() * 5)); + yield[YIELD_FOOD] += iNumFreeUnitsByClass * (50 - (pPlayer->getNumCities() * 5)); else if (pUnitEntry->GetWorkRate() > 0) - yield[YIELD_FOOD] += PolicyInfo->GetNumFreeUnitsByClass(eUnitClass) * 50 * pPlayer->getNumCities(); + yield[YIELD_FOOD] += iNumFreeUnitsByClass * 50 * pPlayer->getNumCities(); else - yield[YIELD_GREAT_GENERAL_POINTS] += PolicyInfo->GetNumFreeUnitsByClass(eUnitClass) * 25; - + yield[YIELD_GREAT_GENERAL_POINTS] += iNumFreeUnitsByClass * 25; } - if (PolicyInfo->GetTourismByUnitClassCreated(eUnitClass) != 0) + + int iTourismByUnitClassCreated = PolicyInfo->GetTourismByUnitClassCreated(eUnitClass); + if (iTourismByUnitClassCreated != 0) { if (pPlayerTraits->IsTourism()) - { - yield[YIELD_TOURISM] += PolicyInfo->GetTourismByUnitClassCreated(eUnitClass) * 5; - } + yield[YIELD_TOURISM] += iTourismByUnitClassCreated * 5; else - { - yield[YIELD_TOURISM] += PolicyInfo->GetTourismByUnitClassCreated(eUnitClass); - } + yield[YIELD_TOURISM] += iTourismByUnitClassCreated; } - if (pPlayer->getCapitalCity() != NULL) + if (pPlayer->getCapitalCity()) { + int iBaseValue = pPlayer->getCapitalCity()->GetCityStrategyAI()->GetUnitProductionAI()->CheckUnitBuildSanity(eUnit, false, 10, true, true); + if (PolicyInfo->IsFaithPurchaseUnitClass(eUnitClass, /*INDUSTRIAL*/ GD_INT_GET(RELIGION_GP_FAITH_PURCHASE_ERA)) != 0) { - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo) + if (iBaseValue > 0) { - const UnitTypes eUnit = pPlayer->GetSpecificUnitType(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if (pUnitEntry) - { - int iValue = pPlayer->getCapitalCity()->GetCityStrategyAI()->GetUnitProductionAI()->CheckUnitBuildSanity(eUnit, false, 10, true, true); - if (iValue > 0) - { - if (pPlayerTraits->IsReligious()) - { - iValue *= 2; - } - yield[YIELD_FAITH] += min(225, iValue); - } - } + int iValue = iBaseValue; + if (pPlayerTraits->IsReligious()) + iValue *= 2; + + yield[YIELD_FAITH] += min(225, iValue); } } - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo) + + if (pUnitEntry->GetPolicyType() == ePolicy) { - const UnitTypes eUnit = pPlayer->GetSpecificUnitType(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if (pUnitEntry && pUnitEntry->GetPolicyType() == ePolicy) + if (iBaseValue > 0) { - int iValue = pPlayer->getCapitalCity()->GetCityStrategyAI()->GetUnitProductionAI()->CheckUnitBuildSanity(eUnit, false, 10, true, true); - if (iValue > 0) - { - if (pPlayerTraits->IsWarmonger()) - { - iValue *= 2; - } - if (pUnitEntry->GetDomainType() == DOMAIN_LAND || pUnitEntry->GetDomainType() == DOMAIN_AIR) - yield[YIELD_GREAT_GENERAL_POINTS] += min(150, iValue); - else - yield[YIELD_GREAT_ADMIRAL_POINTS] += min(150, iValue); - } + int iValue = iBaseValue; + if (pPlayerTraits->IsWarmonger()) + iValue *= 2; + + if (pUnitEntry->GetDomainType() == DOMAIN_LAND || pUnitEntry->GetDomainType() == DOMAIN_AIR) + yield[YIELD_GREAT_GENERAL_POINTS] += min(150, iValue); + else + yield[YIELD_GREAT_ADMIRAL_POINTS] += min(150, iValue); } } } diff --git a/CvGameCoreDLL_Expansion2/CvPreGame.cpp b/CvGameCoreDLL_Expansion2/CvPreGame.cpp index 70edb773af..e0ef4c736e 100644 --- a/CvGameCoreDLL_Expansion2/CvPreGame.cpp +++ b/CvGameCoreDLL_Expansion2/CvPreGame.cpp @@ -300,15 +300,13 @@ GameStartTypes s_gameStartType; StorageLocation s_loadFileStorage; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) // only needed in this file, no need to be public since they are quite specific and kinda nasty void updateKnownPlayersTable(); bool isKnownPlayerReq(PlayerTypes ePlayer); bool handleKnownPlayerReq(PlayerTypes ePlayer); bool isKnownPlayer(PlayerTypes eA, PlayerTypes eB); // only accurate if game option enabled, (indirectly) used in Staging Room to determine if other player details should be shown - + std::vector s_knownPlayersTable; -#endif // ----------------------------------------------------------------------- @@ -465,14 +463,12 @@ void saveSlotHints(FDataStream& saveTo) saveTo << s_civilizationKeys; saveTo << s_leaderKeys; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) // didn't update version number as I am not sure what it means to update it when all the relevant code is stripped out by the preprocessor int iKeepUnmet = 0; GetGameOption(GAMEOPTION_KEEP_UNMET_PLAYERS_UNKNOWN, iKeepUnmet); if(iKeepUnmet) updateKnownPlayersTable(); saveTo << s_knownPlayersTable; -#endif } void ReseatConnectedPlayers() @@ -522,10 +518,8 @@ static void loadSlotsHelper( std::vector& teamTypes, std::vector& handicapTypes, std::vector& civilizationKeys, - std::vector& leaderKeys -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) - , std::vector& metCivs -#endif + std::vector& leaderKeys, + std::vector& metCivs ) { loadFrom >> gameSpeed; @@ -554,9 +548,8 @@ static void loadSlotsHelper( civilizationKeys.clear(); leaderKeys.clear(); } -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) + loadFrom >> metCivs; -#endif } int readActiveSlotCountFromSaveGame(FDataStream& loadFrom, bool bReadVersion) @@ -576,12 +569,8 @@ int readActiveSlotCountFromSaveGame(FDataStream& loadFrom, bool bReadVersion) std::vector dummyHandicapTypes; std::vector civilizationKeys; std::vector leaderKeys; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) std::vector dummyKnownPlayersTable; loadSlotsHelper(loadFrom, uiVersion, dummyGameSpeed, dummyWorldSize, dummyMapScriptName, dummyCivilizations, dummyNicknames, slotStatus, slotClaims, dummyTeamTypes, dummyHandicapTypes, civilizationKeys, leaderKeys, dummyKnownPlayersTable); -#else - loadSlotsHelper(loadFrom, uiVersion, dummyGameSpeed, dummyWorldSize, dummyMapScriptName, dummyCivilizations, dummyNicknames, slotStatus, slotClaims, dummyTeamTypes, dummyHandicapTypes, civilizationKeys, leaderKeys); -#endif return calcActiveSlotCount(slotStatus, slotClaims); } @@ -602,12 +591,9 @@ void loadSlotHints(FDataStream& loadFrom, bool bReadVersion) std::vector handicapTypes; std::vector civilizationKeys; std::vector leaderKeys; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) std::vector knownPlayersTable; loadSlotsHelper(loadFrom, uiVersion, gameSpeed, worldSize, mapScriptName, civilizations, nicknames, slotStatus, slotClaims, teamTypes, handicapTypes, civilizationKeys, leaderKeys, knownPlayersTable); -#else - loadSlotsHelper(loadFrom, uiVersion, gameSpeed, worldSize, mapScriptName, civilizations, nicknames, slotStatus, slotClaims, teamTypes, handicapTypes, civilizationKeys, leaderKeys); -#endif + s_gameSpeed = gameSpeed; s_worldSize = worldSize; s_mapScriptName = mapScriptName; @@ -650,9 +636,8 @@ void loadSlotHints(FDataStream& loadFrom, bool bReadVersion) PlayerTypes p = static_cast(i); setNickname(p, s_nicknames[i]); // fix display names } -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) + s_knownPlayersTable = knownPlayersTable; -#endif ReseatConnectedPlayers(); } @@ -2007,9 +1992,8 @@ void resetGame() s_privateGame = false; s_isInternetGame = false; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) s_knownPlayersTable.clear(); -#endif + ResetMapOptions(); ResetGameOptions(); } @@ -2182,9 +2166,7 @@ std::vector s_savedLeaderPackageID(MAX_PLAYERS); std::vector s_savedLeaderKeysAvailable(MAX_PLAYERS); std::vector s_savedDLCPackagesAvailable(MAX_PLAYERS); -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) std::vector s_savedKnownPlayersTable; -#endif // ------------------------------------------------------------------------------------ void restoreSlots() @@ -2204,11 +2186,9 @@ void restoreSlots() s_leaderKeysAvailable = s_savedLeaderKeysAvailable; s_DLCPackagesAvailable = s_savedDLCPackagesAvailable; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) //not sure if this is necessary but won't hurt s_knownPlayersTable = s_savedKnownPlayersTable; setActivePlayer(s_savedLocalPlayer); -#endif } // ------------------------------------------------------------------------------------ @@ -2232,10 +2212,8 @@ void saveSlots() s_savedLeaderKeysAvailable = s_leaderKeysAvailable; s_savedDLCPackagesAvailable = s_DLCPackagesAvailable; -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) //not sure if this is necessary but won't hurt s_savedKnownPlayersTable = s_knownPlayersTable; -#endif } SeaLevelTypes seaLevel() @@ -3842,7 +3820,6 @@ void setCivilizationKey(PlayerTypes p, const CvString& szKey) // ***ALSO*** hijacked to allow checking if a player is known to the local human player. Seems difficult to expose stuff to the pregame Lua stuff (like the StagingRoom), sorry. This function was being used in exactly one place and has limited utility at least. bool civilizationKeyAvailable(PlayerTypes p) { -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) /////////////////////////////////////// /////////////// HIJACKED ////////////// /////////////////////////////////////// @@ -3853,7 +3830,6 @@ bool civilizationKeyAvailable(PlayerTypes p) /////////////////////////////////////// //////////////////END////////////////// /////////////////////////////////////// -#endif if(p >= 0 && p < MAX_PLAYERS) { @@ -3901,7 +3877,6 @@ bool canReadyLocalPlayer() return true; } -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) const std::vector& GetKnownPlayersTable() { return s_knownPlayersTable; } @@ -3945,7 +3920,8 @@ bool handleKnownPlayerReq(PlayerTypes ePlayer) return isKnownPlayer(ePlayer, activePlayer()); } -bool isKnownPlayer(PlayerTypes eA, PlayerTypes eB) { +bool isKnownPlayer(PlayerTypes eA, PlayerTypes eB) +{ // table will be empty if GAMEOPTION_KEEP_UNMET_PLAYERS_UNKNOWN, i.e. not keeping track of unmet players and consider all to be met for the purposes of PreGame UI. if (s_knownPlayersTable.empty()) return true; if (eA < 0 || eB < 0) return true; // erring on the side of caution @@ -3953,5 +3929,4 @@ bool isKnownPlayer(PlayerTypes eA, PlayerTypes eB) { return (s_knownPlayersTable[eA] & (KnownPlayersBitArray(1) << eB)) != 0; } -#endif } diff --git a/CvGameCoreDLL_Expansion2/CvPreGame.h b/CvGameCoreDLL_Expansion2/CvPreGame.h index 5a75c629fe..fcf1233371 100644 --- a/CvGameCoreDLL_Expansion2/CvPreGame.h +++ b/CvGameCoreDLL_Expansion2/CvPreGame.h @@ -294,8 +294,6 @@ int getActiveSlotCount(); int readActiveSlotCountFromSaveGame(FDataStream& loadFrom, bool bReadVersion); -#if defined(MOD_KEEP_CIVS_UNKNOWN_PREGAME) - #if MAX_MAJOR_CIVS <= 32 typedef uint32 KnownPlayersBitArray; #elif MAX_MAJOR_CIVS <= 64 @@ -308,8 +306,6 @@ typedef uint64 KnownPlayersBitArray; void SetKnownPlayersTable(const std::vector& aiKnownPlayersTable); const std::vector& GetKnownPlayersTable(); -#endif - extern const std::vector& sr_TeamTypes; static inline TeamTypes teamType(PlayerTypes p) diff --git a/CvGameCoreDLL_Expansion2/CvProcessProductionAI.cpp b/CvGameCoreDLL_Expansion2/CvProcessProductionAI.cpp index 82890ad988..04dcb736d9 100644 --- a/CvGameCoreDLL_Expansion2/CvProcessProductionAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvProcessProductionAI.cpp @@ -1,5 +1,5 @@ /* ------------------------------------------------------------------------------------------------------- - © 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. + � 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games. Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software and their respective logos are all trademarks of Take-Two interactive Software, Inc. All other marks and trademarks are the property of their respective owners. @@ -446,17 +446,12 @@ int CvProcessProductionAI::CheckProcessBuildSanity(ProcessTypes eProcess, int iT UnitTypes eUnit = kPlayer.GetSpecificUnitType(pRewardInfo->GetFreeUnitClass()); if (eUnit != NO_UNIT) { - CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit); - if(pkUnitInfo) - { - int iValue = 1500; - if(kPlayer.getCapitalCity() != NULL) - { - iValue = kPlayer.getCapitalCity()->GetCityStrategyAI()->GetUnitProductionAI()->CheckUnitBuildSanity(eUnit, false, iValue); - } - if (iValue > 0) - iModifier += iValue; - } + int iValue = 1500; + if(kPlayer.getCapitalCity()) + iValue = kPlayer.getCapitalCity()->GetCityStrategyAI()->GetUnitProductionAI()->CheckUnitBuildSanity(eUnit, false, iValue); + + if (iValue > 0) + iModifier += iValue; } } EconomicAIStrategyTypes eStrategyConquest = (EconomicAIStrategyTypes) GC.getInfoTypeForString("ECONOMICAISTRATEGY_GS_CONQUEST"); diff --git a/CvGameCoreDLL_Expansion2/CvReligionClasses.cpp b/CvGameCoreDLL_Expansion2/CvReligionClasses.cpp index 5eb2f5e929..40378003a6 100644 --- a/CvGameCoreDLL_Expansion2/CvReligionClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvReligionClasses.cpp @@ -688,19 +688,13 @@ void CvGameReligions::DoPlayerTurn(CvPlayer& kPlayer) break; // Valid option; Just do nothing. case FAITH_PURCHASE_SAVE_PROPHET: { - if (eReligion <= RELIGION_PANTHEON && GetNumReligionsStillToFound() <= 0 && !kPlayer.GetPlayerTraits()->IsAlwaysReligion()) + if ((eReligion <= RELIGION_PANTHEON && GetNumReligionsStillToFound() <= 0 && !kPlayer.GetPlayerTraits()->IsAlwaysReligion()) || + kPlayer.GetCurrentEra() >= GetFaithPurchaseGreatPeopleEra(&kPlayer)) { UnitTypes eProphetType = kPlayer.GetSpecificUnitType("UNITCLASS_PROPHET", true); szItemName = GetLocalizedText("TXT_KEY_RO_AUTO_FAITH_PROPHET_PARAM", GC.getUnitInfo(eProphetType)->GetDescription()); bSelectionStillValid = false; } - else if (kPlayer.GetCurrentEra() >= GetFaithPurchaseGreatPeopleEra(&kPlayer)) - { - UnitTypes eProphetType = kPlayer.GetSpecificUnitType("UNITCLASS_PROPHET", true); - szItemName = GetLocalizedText("TXT_KEY_RO_AUTO_FAITH_PROPHET_PARAM", GC.getUnitInfo(eProphetType)->GetDescription()); - - bSelectionStillValid = false; - } break; } @@ -833,13 +827,15 @@ CvGameReligions::FOUNDING_RESULT CvGameReligions::CanCreatePantheon(PlayerTypes } } -#if defined(MOD_EVENTS_FOUND_RELIGION) - if (MOD_EVENTS_FOUND_RELIGION) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundPantheon, ePlayer) == GAMEEVENTRETURN_FALSE) { + if (MOD_EVENTS_FOUND_RELIGION) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundPantheon, ePlayer) == GAMEEVENTRETURN_FALSE) + { return FOUNDING_INVALID_PLAYER; } - } else { -#endif + } + else + { ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if(pkScriptSystem) { @@ -857,15 +853,9 @@ CvGameReligions::FOUNDING_RESULT CvGameReligions::CanCreatePantheon(PlayerTypes } } } -#if defined(MOD_EVENTS_FOUND_RELIGION) } -#endif -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) if (GetAvailablePantheonBeliefs(ePlayer).size() == 0) -#else - if (GetAvailablePantheonBeliefs().size() == 0) -#endif return FOUNDING_NO_BELIEFS_AVAILABLE; return FOUNDING_OK; @@ -874,45 +864,45 @@ CvGameReligions::FOUNDING_RESULT CvGameReligions::CanCreatePantheon(PlayerTypes /// Get the appropriate religion for this player to found next ReligionTypes CvGameReligions::GetReligionToFound(PlayerTypes ePlayer) { -#if defined(MOD_RELIGION_NO_PREFERRENCES) - if (!MOD_RELIGION_NO_PREFERRENCES) { + if (!MOD_RELIGION_NO_PREFERRENCES) + { // Choose the civs preferred religion if not disabled and available -#endif ReligionTypes eCivReligion; eCivReligion = GET_PLAYER(ePlayer).getCivilizationInfo().GetReligion(); -#if defined(MOD_EVENTS_FOUND_RELIGION) - if (MOD_EVENTS_FOUND_RELIGION) { + if (MOD_EVENTS_FOUND_RELIGION) + { int iValue = 0; - if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_GetReligionToFound, ePlayer, eCivReligion, HasBeenFounded(eCivReligion)) == GAMEEVENTRETURN_VALUE) { + if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_GetReligionToFound, ePlayer, eCivReligion, HasBeenFounded(eCivReligion)) == GAMEEVENTRETURN_VALUE) + { // Defend against modder stupidity! - if (iValue > RELIGION_PANTHEON && iValue < GC.getNumReligionInfos()) { + if (iValue > RELIGION_PANTHEON && iValue < GC.getNumReligionInfos()) + { // CUSTOMLOG("GetReligionToFound: Before=%i, After=%i", eCivReligion, iValue); eCivReligion = (ReligionTypes)iValue; } } - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if(pkScriptSystem) - { - CvLuaArgsHandle args; - args->Push(ePlayer); - args->Push(eCivReligion); - args->Push(HasBeenFounded(eCivReligion)); - - int iValue = 0; - if (LuaSupport::CallAccumulator(pkScriptSystem, "GetReligionToFound", args.get(), iValue)) + } + else { - if (iValue >= 0 && iValue < GC.getNumReligionInfos() && iValue != RELIGION_PANTHEON) + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if(pkScriptSystem) { - eCivReligion = (ReligionTypes)iValue; + CvLuaArgsHandle args; + args->Push(ePlayer); + args->Push(eCivReligion); + args->Push(HasBeenFounded(eCivReligion)); + + int iValue = 0; + if (LuaSupport::CallAccumulator(pkScriptSystem, "GetReligionToFound", args.get(), iValue)) + { + if (iValue >= 0 && iValue < GC.getNumReligionInfos() && iValue != RELIGION_PANTHEON) + { + eCivReligion = (ReligionTypes)iValue; + } + } } } - } -#if defined(MOD_EVENTS_FOUND_RELIGION) - } -#endif if(!HasBeenFounded(eCivReligion)) { @@ -923,14 +913,10 @@ ReligionTypes CvGameReligions::GetReligionToFound(PlayerTypes ePlayer) return eCivReligion; } } -#if defined(MOD_RELIGION_NO_PREFERRENCES) } -#endif -#if defined(MOD_RELIGION_RANDOMISE) // No preferred religion, so find all the possible religions std::vector availableReligions; -#endif // Need to "borrow" from another civ. Loop through all religions looking for one that is eligible for(int iI = 0; iI < GC.getNumReligionInfos(); iI++) @@ -938,114 +924,79 @@ ReligionTypes CvGameReligions::GetReligionToFound(PlayerTypes ePlayer) ReligionTypes eReligion = (ReligionTypes)iI; CvReligionEntry* pEntry = GC.getReligionInfo(eReligion); if(!pEntry) - { continue; - } if(pEntry->GetID() == RELIGION_PANTHEON) - { continue; - } - -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) - if (MOD_RELIGION_LOCAL_RELIGIONS && pEntry->IsLocalReligion()) { + + if (MOD_RELIGION_LOCAL_RELIGIONS && pEntry->IsLocalReligion()) continue; - } -#endif if(HasBeenFounded((ReligionTypes)pEntry->GetID())) - { continue; - } -#if defined(MOD_RELIGION_NO_PREFERRENCES) // Only excluded religions preferred by other civs if not disabled - if (!MOD_RELIGION_NO_PREFERRENCES) { -#endif - if(IsPreferredByCivInGame(eReligion)) - { - continue; - } -#if defined(MOD_RELIGION_NO_PREFERRENCES) - } -#endif + if (!MOD_RELIGION_NO_PREFERRENCES && IsPreferredByCivInGame(eReligion)) + continue; -#if defined(MOD_RELIGION_RANDOMISE) - if (MOD_RELIGION_RANDOMISE) { + if (MOD_RELIGION_RANDOMISE) + { // If we want a random religion, remember this as a possible candidate ... availableReligions.push_back(eReligion); - } else { + } + else + { // ... otherwise just return it -#endif // CUSTOMLOG("GetReligionToFound: Using spare %i", eReligion); return (eReligion); -#if defined(MOD_RELIGION_RANDOMISE) } -#endif } -#if defined(MOD_RELIGION_RANDOMISE) - if (availableReligions.empty()) { -#endif - + if (availableReligions.empty()) + { // Will have to use a religion that someone else prefers for(int iI = 0; iI < GC.getNumReligionInfos(); iI++) { ReligionTypes eReligion = (ReligionTypes)iI; CvReligionEntry* pEntry = GC.getReligionInfo(eReligion); if(!pEntry) - { continue; - } if(pEntry->GetID() == RELIGION_PANTHEON) - { continue; - } -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) - if (MOD_RELIGION_LOCAL_RELIGIONS && pEntry->IsLocalReligion()) { + if (MOD_RELIGION_LOCAL_RELIGIONS && pEntry->IsLocalReligion()) continue; - } -#endif if(HasBeenFounded((ReligionTypes)pEntry->GetID())) - { continue; - } -#if defined(MOD_RELIGION_RANDOMISE) - if (MOD_RELIGION_RANDOMISE) { + if (MOD_RELIGION_RANDOMISE) + { // If we want a random religion, remember this as a possible candidate ... availableReligions.push_back(eReligion); - } else { + } + else + { // ... otherwise just return it -#endif - // CUSTOMLOG("GetReligionToFound: Using borrowed %i", eReligion); - return (eReligion); -#if defined(MOD_RELIGION_RANDOMISE) + // CUSTOMLOG("GetReligionToFound: Using borrowed %i", eReligion); + return (eReligion); } -#endif } - -#if defined(MOD_RELIGION_RANDOMISE) } -#endif -#if defined(MOD_RELIGION_RANDOMISE) // Pick a random religion - if (!availableReligions.empty()) { + if (!availableReligions.empty()) + { uint index = 0; // Pick a random one if required - if (MOD_RELIGION_RANDOMISE) { + if (MOD_RELIGION_RANDOMISE) index = GC.getGame().urandLimitExclusive(availableReligions.size(), CvSeeder(ePlayer)); - } // CUSTOMLOG("GetReligionToFound: Using random %i", availableReligions[index]); return availableReligions[index]; } -#endif // CUSTOMLOG("GetReligionToFound: Using NO_RELIGION"); return NO_RELIGION; @@ -1063,12 +1014,10 @@ void CvGameReligions::FoundPantheon(PlayerTypes ePlayer, BeliefTypes eBelief) // Found it newReligion.m_Beliefs.SetReligion(RELIGION_PANTHEON); m_CurrentReligions.push_back(newReligion); -#if defined(MOD_TRAITS_OTHER_PREREQS) - if (MOD_TRAITS_OTHER_PREREQS) { + + if (MOD_TRAITS_OTHER_PREREQS) kPlayer.GetPlayerTraits()->InitPlayerTraits(); - } -#endif -#if defined(MOD_BALANCE_CORE) + if(kPlayer.GetPlayerTraits()->IsAdoptionFreeTech()) { if (!kPlayer.isHuman()) @@ -1081,8 +1030,7 @@ void CvGameReligions::FoundPantheon(PlayerTypes ePlayer, BeliefTypes eBelief) kPlayer.chooseTech(1, strBuffer.GetCString()); } } - -#endif + // Update game systems kPlayer.UpdateReligion(); kPlayer.ChangeFaith(-GetMinimumFaithNextPantheon()); @@ -1092,22 +1040,20 @@ void CvGameReligions::FoundPantheon(PlayerTypes ePlayer, BeliefTypes eBelief) iIncrement /= 100; SetMinimumFaithNextPantheon(GetMinimumFaithNextPantheon() + iIncrement); -#if defined(MOD_EVENTS_FOUND_RELIGION) - if (MOD_EVENTS_FOUND_RELIGION) { + if (MOD_EVENTS_FOUND_RELIGION) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_PantheonFounded, ePlayer, GET_PLAYER(ePlayer).getCapitalCity()->GetID(), RELIGION_PANTHEON, eBelief); - } else { -#endif + } + else + { ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); -#if defined(MOD_BALANCE_CORE) + //Bugfix? if(pkScriptSystem && ePlayer != NO_PLAYER && !kPlayer.isMinorCiv() && !kPlayer.isBarbarian()) -#else - if (pkScriptSystem) -#endif { CvLuaArgsHandle args; args->Push(ePlayer); -#if defined(MOD_BALANCE_CORE) + CvCity* pCapital = kPlayer.getCapitalCity(); if (!pCapital) { @@ -1116,18 +1062,13 @@ void CvGameReligions::FoundPantheon(PlayerTypes ePlayer, BeliefTypes eBelief) pCapital = kPlayer.firstCity(&iIdx); } args->Push(pCapital ? pCapital->GetID() : 0); -#else - args->Push(GET_PLAYER(ePlayer).getCapitalCity()->GetID()); -#endif args->Push(RELIGION_PANTHEON); args->Push(eBelief); bool bResult = false; LuaSupport::CallHook(pkScriptSystem, "PantheonFounded", args.get(), bResult); } -#if defined(MOD_EVENTS_FOUND_RELIGION) } -#endif // Spread the pantheon into each of their cities int iLoop = 0; @@ -1154,7 +1095,8 @@ void CvGameReligions::FoundPantheon(PlayerTypes ePlayer, BeliefTypes eBelief) kGame.addReplayMessage(REPLAY_MESSAGE_PANTHEON_FOUNDED, newReligion.m_eFounder, replayText.toUTF8()); - for(int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop){ + for(int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop) + { PlayerTypes eNotifyPlayer = (PlayerTypes) iNotifyLoop; CvPlayerAI& kCurNotifyPlayer = GET_PLAYER(eNotifyPlayer); CvNotifications* pNotifications = kCurNotifyPlayer.GetNotifications(); @@ -1220,7 +1162,6 @@ void CvGameReligions::FoundReligion(PlayerTypes ePlayer, ReligionTypes eReligion } } -#if defined(MOD_BALANCE_CORE) if(kPlayer.GetPlayerTraits()->IsAdoptionFreeTech()) { if (!kPlayer.isHuman()) @@ -1234,7 +1175,7 @@ void CvGameReligions::FoundReligion(PlayerTypes ePlayer, ReligionTypes eReligion } } kReligion.m_Beliefs.SetReligion(eReligion); -#endif + kReligion.m_Beliefs.AddBelief(eBelief1); kReligion.m_Beliefs.AddBelief(eBelief2); @@ -1277,11 +1218,8 @@ void CvGameReligions::FoundReligion(PlayerTypes ePlayer, ReligionTypes eReligion } } -#if defined(MOD_TRAITS_OTHER_PREREQS) - if (MOD_TRAITS_OTHER_PREREQS) { + if (MOD_TRAITS_OTHER_PREREQS) kPlayer.GetPlayerTraits()->InitPlayerTraits(); - } -#endif // Update game systems kPlayer.UpdateReligion(); @@ -1305,41 +1243,36 @@ void CvGameReligions::FoundReligion(PlayerTypes ePlayer, ReligionTypes eReligion pLoopUnit->GetReligionDataMutable()->IncrementSpreadsUsed(); if (pLoopUnit->GetReligionData() != NULL && pLoopUnit->GetReligionData()->GetSpreadsLeft(pLoopUnit) <= 0) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(pLoopUnit->getUnitType(), pLoopUnit); -#else - kPlayer.DoGreatPersonExpended(pLoopUnit->getUnitType()); -#endif pLoopUnit->kill(true); } } } } -#if defined(MOD_EVENTS_FOUND_RELIGION) - if (MOD_EVENTS_FOUND_RELIGION) { + if (MOD_EVENTS_FOUND_RELIGION) + { GAMEEVENTINVOKE_HOOK(GAMEEVENT_ReligionFounded, ePlayer, pkHolyCity->GetID(), eReligion, eBelief, eBelief1, eBelief2, eBelief3, eBelief4); - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if(pkScriptSystem) + } + else { - CvLuaArgsHandle args; - args->Push(ePlayer); - args->Push(pkHolyCity->GetID()); - args->Push(eReligion); - args->Push(eBelief); - args->Push(eBelief1); - args->Push(eBelief2); - args->Push(eBelief3); - args->Push(eBelief4); + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if(pkScriptSystem) + { + CvLuaArgsHandle args; + args->Push(ePlayer); + args->Push(pkHolyCity->GetID()); + args->Push(eReligion); + args->Push(eBelief); + args->Push(eBelief1); + args->Push(eBelief2); + args->Push(eBelief3); + args->Push(eBelief4); - bool bResult = false; - LuaSupport::CallHook(pkScriptSystem, "ReligionFounded", args.get(), bResult); - } -#if defined(MOD_EVENTS_FOUND_RELIGION) + bool bResult = false; + LuaSupport::CallHook(pkScriptSystem, "ReligionFounded", args.get(), bResult); + } } -#endif // Send out messaging CvReligionEntry* pEntry = GC.getReligionInfo(kReligion.m_eReligion); @@ -1353,17 +1286,18 @@ void CvGameReligions::FoundReligion(PlayerTypes ePlayer, ReligionTypes eReligion GC.getGame().addReplayMessage(REPLAY_MESSAGE_RELIGION_FOUNDED, kReligion.m_eFounder, replayText.toUTF8(), kReligion.m_iHolyCityX, kReligion.m_iHolyCityY); -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) // Local religions are intended to be "super-pantheons" so typically are founded immediately a pantheon is founded // As founding the pantheon sent a notification, don't send another here (if the modded wants one, they can always send it manually) - if (!(MOD_RELIGION_LOCAL_RELIGIONS && pEntry->IsLocalReligion())) { -#endif + if (!(MOD_RELIGION_LOCAL_RELIGIONS && pEntry->IsLocalReligion())) + { //Notify the masses - for(int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop){ + for (int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop) + { PlayerTypes eNotifyPlayer = (PlayerTypes) iNotifyLoop; CvPlayerAI& kNotifyPlayer = GET_PLAYER(eNotifyPlayer); CvNotifications* pNotifications = kNotifyPlayer.GetNotifications(); - if(pNotifications){ + if (pNotifications) + { // Message slightly different for founder player if(kReligion.m_eFounder == eNotifyPlayer) { @@ -1388,9 +1322,7 @@ void CvGameReligions::FoundReligion(PlayerTypes ePlayer, ReligionTypes eReligion } } } -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) } -#endif // Logging if(GC.getLogging()) @@ -1471,7 +1403,7 @@ CvGameReligions::FOUNDING_RESULT CvGameReligions::CanFoundReligion(PlayerTypes e for(int iDestBelief = kReligion.m_Beliefs.GetNumBeliefs(); iDestBelief--;) { BeliefTypes eDestBelief = kReligion.m_Beliefs.GetBelief(iDestBelief); -#if defined(MOD_BALANCE_CORE) + if(eDestBelief != NO_BELIEF && eDestBelief == eSrcBelief) { CvBeliefEntry* pBelief = GC.getBeliefInfo(eDestBelief); @@ -1484,10 +1416,6 @@ CvGameReligions::FOUNDING_RESULT CvGameReligions::CanFoundReligion(PlayerTypes e return FOUNDING_BELIEF_IN_USE; } } -#else - if(eDestBelief != NO_BELIEF && eDestBelief == eSrcBelief) - return FOUNDING_BELIEF_IN_USE; -#endif } } } @@ -1928,12 +1856,8 @@ const CvReligion* CvGameReligions::GetReligion(ReligionTypes eReligion, PlayerTy } /// Has some religion already claimed this belief? -#if defined(MOD_TRAITS_ANY_BELIEF) // We don't care if either ePlayer has the "can have any belief" trait or it's in the "religion" of a player with that trait bool CvGameReligions::IsInSomeReligion(BeliefTypes eBelief, PlayerTypes ePlayer) const -#else -bool CvGameReligions::IsInSomeReligion(BeliefTypes eBelief) const -#endif { #if defined(MOD_TRAITS_ANY_BELIEF) if(ePlayer == NO_PLAYER) @@ -2050,17 +1974,13 @@ int CvGameReligions::GetNumPantheonsPossible(bool bExcludeUnique) const return iRtnValue; } /// List of beliefs that can be adopted by pantheons -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) std::vector CvGameReligions::GetAvailablePantheonBeliefs(PlayerTypes ePlayer) -#else -std::vector CvGameReligions::GetAvailablePantheonBeliefs() -#endif { std::vector availableBeliefs; CvBeliefXMLEntries* pkBeliefs = GC.GetGameBeliefs(); const int iNumBeleifs = pkBeliefs->GetNumBeliefs(); -#if defined(MOD_BALANCE_CORE) + bool bUniqueExists = false; if(ePlayer != NO_PLAYER && GET_PLAYER(ePlayer).GetPlayerTraits()->IsUniqueBeliefsOnly()) { @@ -2078,25 +1998,16 @@ std::vector CvGameReligions::GetAvailablePantheonBeliefs() } } } -#endif + availableBeliefs.reserve(iNumBeleifs); for(int iI = 0; iI < iNumBeleifs; iI++) { const BeliefTypes eBelief(static_cast(iI)); -#if defined(MOD_TRAITS_ANY_BELIEF) -#if defined(MOD_ANY_PANTHEON) if (MOD_ANY_PANTHEON || !IsInSomeReligion(eBelief, ePlayer)) -#else - if (!IsInSomeReligion(eBelief, ePlayer)) -#endif -#else - if(!IsInSomeReligion(eBelief)) -#endif { CvBeliefEntry* pEntry = pkBeliefs->GetEntry(eBelief); if(pEntry && pEntry->IsPantheonBelief()) { -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) bool bAvailable = true; if (MOD_EVENTS_ACQUIRE_BELIEFS) { @@ -2104,7 +2015,7 @@ std::vector CvGameReligions::GetAvailablePantheonBeliefs() bAvailable = false; } } -#if defined(MOD_BALANCE_CORE) + if(ePlayer != NO_PLAYER && GET_PLAYER(ePlayer).GetPlayerTraits()->IsUniqueBeliefsOnly()) { if(bUniqueExists) @@ -2123,13 +2034,10 @@ std::vector CvGameReligions::GetAvailablePantheonBeliefs() bAvailable = false; } } -#endif - if (bAvailable) { -#endif + if (bAvailable) + { availableBeliefs.push_back(eBelief); -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) } -#endif } } } @@ -2178,23 +2086,11 @@ std::vector CvGameReligions::GetAvailablePantheonBeliefs() } // Is the supplied belief available to a pantheon? -#if defined(MOD_TRAITS_ANY_BELIEF) bool CvGameReligions::IsPantheonBeliefAvailable(BeliefTypes eBelief, PlayerTypes ePlayer) -#else -bool CvGameReligions::IsPantheonBeliefAvailable(BeliefTypes eBelief) -#endif { CvBeliefXMLEntries* pkBeliefs = GC.GetGameBeliefs(); -#if defined(MOD_TRAITS_ANY_BELIEF) -#if defined(MOD_ANY_PANTHEON) if (MOD_ANY_PANTHEON || !IsInSomeReligion(eBelief, ePlayer)) -#else - if(!IsInSomeReligion(eBelief, ePlayer)) -#endif -#else - if(!IsInSomeReligion(eBelief)) -#endif { CvBeliefEntry* pEntry = pkBeliefs->GetEntry(eBelief); if(pEntry && pEntry->IsPantheonBelief()) @@ -2202,6 +2098,7 @@ bool CvGameReligions::IsPantheonBeliefAvailable(BeliefTypes eBelief) return true; } } + #if defined(MOD_GLOBAL_MAX_MAJOR_CIVS) if (GC.getGame().GetGameReligions()->GetNumPantheonsCreated() >= GC.getGame().GetGameReligions()->GetNumPantheonsPossible(true)) { @@ -2213,11 +2110,7 @@ bool CvGameReligions::IsPantheonBeliefAvailable(BeliefTypes eBelief) } /// Number of followers of this religion -#if defined(MOD_BALANCE_CORE) int CvGameReligions::GetNumFollowers(ReligionTypes eReligion, PlayerTypes ePlayer) const -#else -int CvGameReligions::GetNumFollowers(ReligionTypes eReligion) const -#endif { int iRtnValue = 0; // Loop through all the players @@ -2396,11 +2289,7 @@ ReligionTypes CvGameReligions::GetOriginalReligionCreatedByPlayer(PlayerTypes eP } /// Number of religions founded so far (does not include pantheons) -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) int CvGameReligions::GetNumReligionsFounded(bool bIgnoreLocal) const -#else -int CvGameReligions::GetNumReligionsFounded() const -#endif { int iRtnValue = 0; @@ -2440,13 +2329,8 @@ int CvGameReligions::GetNumReligionsEnhanced() const } /// Number of religions that still can be founded on this size map -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) int CvGameReligions::GetNumReligionsStillToFound(bool bIgnoreLocal, PlayerTypes ePlayer) const -#else -int CvGameReligions::GetNumReligionsStillToFound() const -#endif { -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) if (ePlayer != NO_PLAYER) { if (GET_PLAYER(ePlayer).GetPlayerTraits()->IsAlwaysReligion() && GET_PLAYER(ePlayer).GetReligions()->GetStateReligion() <= RELIGION_PANTHEON) @@ -2465,17 +2349,10 @@ int CvGameReligions::GetNumReligionsStillToFound() const } return (GC.getMap().getWorldInfo().getMaxActiveReligions() - GetNumReligionsFounded(bIgnoreLocal)); -#else - return (GC.getMap().getWorldInfo().getMaxActiveReligions() - GetNumReligionsFounded()); -#endif } /// List of beliefs that can be adopted by religion founders -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) std::vector CvGameReligions::GetAvailableFounderBeliefs(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -std::vector CvGameReligions::GetAvailableFounderBeliefs() -#endif { std::vector availableBeliefs; @@ -2504,11 +2381,7 @@ std::vector CvGameReligions::GetAvailableFounderBeliefs() for(int iI = 0; iI < iNumBeleifs; iI++) { const BeliefTypes eBelief(static_cast(iI)); -#if defined(MOD_TRAITS_ANY_BELIEF) if(!IsInSomeReligion(eBelief, ePlayer)) -#else - if(!IsInSomeReligion(eBelief)) -#endif { CvBeliefEntry* pEntry = pkBeliefs->GetEntry(eBelief); if(pEntry && pEntry->IsFounderBelief()) @@ -2559,11 +2432,7 @@ std::vector CvGameReligions::GetAvailableFounderBeliefs() } /// List of beliefs that can be adopted by religion followers -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) std::vector CvGameReligions::GetAvailableFollowerBeliefs(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -std::vector CvGameReligions::GetAvailableFollowerBeliefs() -#endif { std::vector availableBeliefs; @@ -2592,11 +2461,7 @@ std::vector CvGameReligions::GetAvailableFollowerBeliefs() for(int iI = 0; iI < iNumBeleifs; iI++) { const BeliefTypes eBelief(static_cast(iI)); -#if defined(MOD_TRAITS_ANY_BELIEF) if(!IsInSomeReligion(eBelief, ePlayer)) -#else - if(!IsInSomeReligion(eBelief)) -#endif { CvBeliefEntry* pEntry = pkBeliefs->GetEntry(eBelief); if(pEntry && pEntry->IsFollowerBelief()) @@ -2647,11 +2512,7 @@ std::vector CvGameReligions::GetAvailableFollowerBeliefs() } /// List of beliefs that enhance religions -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) std::vector CvGameReligions::GetAvailableEnhancerBeliefs(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -std::vector CvGameReligions::GetAvailableEnhancerBeliefs() -#endif { std::vector availableBeliefs; @@ -2680,11 +2541,7 @@ std::vector CvGameReligions::GetAvailableEnhancerBeliefs() for(int iI = 0; iI < iNumBeleifs; iI++) { const BeliefTypes eBelief(static_cast(iI)); -#if defined(MOD_TRAITS_ANY_BELIEF) if(!IsInSomeReligion(eBelief, ePlayer)) -#else - if(!IsInSomeReligion(eBelief)) -#endif { CvBeliefEntry* pEntry = pkBeliefs->GetEntry(eBelief); if(pEntry && pEntry->IsEnhancerBelief()) @@ -2735,11 +2592,7 @@ std::vector CvGameReligions::GetAvailableEnhancerBeliefs() } /// List of all beliefs still available -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) std::vector CvGameReligions::GetAvailableBonusBeliefs(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -std::vector CvGameReligions::GetAvailableBonusBeliefs() -#endif { std::vector availableBeliefs; @@ -2768,11 +2621,7 @@ std::vector CvGameReligions::GetAvailableBonusBeliefs() for(int iI = 0; iI < iNumBeleifs; iI++) { const BeliefTypes eBelief(static_cast(iI)); -#if defined(MOD_TRAITS_ANY_BELIEF) if(!IsInSomeReligion(eBelief, ePlayer)) -#else - if(!IsInSomeReligion(eBelief)) -#endif { CvBeliefEntry* pEntry = pkBeliefs->GetEntry(eBelief); if(pEntry && (pEntry->IsEnhancerBelief() || pEntry->IsFollowerBelief() || pEntry->IsFounderBelief() || pEntry->IsPantheonBelief())) @@ -2823,11 +2672,7 @@ std::vector CvGameReligions::GetAvailableBonusBeliefs() } /// List of beliefs that are added with Reformation social policy -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) std::vector CvGameReligions::GetAvailableReformationBeliefs(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -std::vector CvGameReligions::GetAvailableReformationBeliefs() -#endif { std::vector availableBeliefs; @@ -2856,11 +2701,7 @@ std::vector CvGameReligions::GetAvailableReformationBeliefs() for(int iI = 0; iI < iNumBeleifs; iI++) { const BeliefTypes eBelief(static_cast(iI)); -#if defined(MOD_TRAITS_ANY_BELIEF) if(!IsInSomeReligion(eBelief, ePlayer)) -#else - if(!IsInSomeReligion(eBelief)) -#endif { CvBeliefEntry* pEntry = pkBeliefs->GetEntry(eBelief); if(pEntry && pEntry->IsReformationBelief()) @@ -3238,16 +3079,10 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) return false; } -#if defined(MOD_NO_AUTO_SPAWN_PROPHET) bool prophetboughtwithfaith = false; -#endif const CvReligion* pReligion = NULL; const int iFaith = kPlayer.GetFaith(); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int iCost = kPlayer.GetReligions()->GetCostNextProphet(true /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/, MOD_GLOBAL_TRULY_FREE_GP); -#else - int iCost = kPlayer.GetReligions()->GetCostNextProphet(true /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/); -#endif ReligionTypes ePlayerReligion = GET_PLAYER(kPlayer.GetID()).GetReligions()->GetOwnedReligion(); if (ePlayerReligion != NO_RELIGION) @@ -3272,10 +3107,7 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) int iChance = /*5 in CP, 100 in VP*/ GD_INT_GET(RELIGION_BASE_CHANCE_PROPHET_SPAWN); -#if defined(MOD_RELIGION_KEEP_PROPHET_OVERFLOW) int iBaseChance = iChance; -#endif - iChance += (iFaith - iCost); int iRand = GC.getGame().randRangeInclusive(1, 100, CvSeeder::fromRaw(0x88a8fa44).mix(kPlayer.GetID())); @@ -3285,8 +3117,6 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) CvCity* pSpawnCity = pReligion ? pReligion->GetHolyCity() : NULL; if(pSpawnCity != NULL && pSpawnCity->getOwner() == kPlayer.GetID()) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) -#if defined(MOD_NO_AUTO_SPAWN_PROPHET) if(MOD_NO_AUTO_SPAWN_PROPHET) { if (kPlayer.isHuman()) @@ -3313,22 +3143,17 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) } } else - { + { pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, false); } } else + { pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, false); -#else - pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, false); -#endif -#else - pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true); -#endif -#if defined(MOD_RELIGION_KEEP_PROPHET_OVERFLOW) + } + if (MOD_RELIGION_KEEP_PROPHET_OVERFLOW && iBaseChance >= 100) { -#if defined(MOD_NO_AUTO_SPAWN_PROPHET) if(MOD_NO_AUTO_SPAWN_PROPHET) { if (!kPlayer.isHuman() || prophetboughtwithfaith) @@ -3338,13 +3163,9 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) } else kPlayer.ChangeFaith(-1 * iCost); -#else - kPlayer.ChangeFaith(-1 * iCost); -#endif } else { -#if defined(MOD_NO_AUTO_SPAWN_PROPHET) if(MOD_NO_AUTO_SPAWN_PROPHET) { if (!kPlayer.isHuman() || prophetboughtwithfaith) @@ -3354,13 +3175,9 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) } else kPlayer.SetFaith(0); -#endif -#endif kPlayer.SetFaith(0); -#if defined(MOD_RELIGION_KEEP_PROPHET_OVERFLOW) } -#endif } else { @@ -3398,8 +3215,6 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) if(pSpawnCity != NULL) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) -#if defined(MOD_NO_AUTO_SPAWN_PROPHET) if(MOD_NO_AUTO_SPAWN_PROPHET) { if (kPlayer.isHuman()) @@ -3426,53 +3241,44 @@ bool CvGameReligions::CheckSpawnGreatProphet(CvPlayer& kPlayer) } } else - { + { pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, false); } } else + { pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, false); -#else - pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true, false); -#endif -#else - pSpawnCity->GetCityCitizens()->DoSpawnGreatPerson(eUnit, true /*bIncrementCount*/, true); -#endif -#if defined(MOD_RELIGION_KEEP_PROPHET_OVERFLOW) - if (MOD_RELIGION_KEEP_PROPHET_OVERFLOW && iBaseChance >= 100) - { -#if defined(MOD_NO_AUTO_SPAWN_PROPHET) - if(MOD_NO_AUTO_SPAWN_PROPHET) - { - if (!kPlayer.isHuman() || prophetboughtwithfaith) + } + + if (MOD_RELIGION_KEEP_PROPHET_OVERFLOW && iBaseChance >= 100) + { + if(MOD_NO_AUTO_SPAWN_PROPHET) + { + if (!kPlayer.isHuman() || prophetboughtwithfaith) + { + kPlayer.ChangeFaith(-1 * iCost); + } + } + else { kPlayer.ChangeFaith(-1 * iCost); } } else - kPlayer.ChangeFaith(-1 * iCost); - } -#else - kPlayer.ChangeFaith(-1 * iCost); -#endif - else - { -#if defined(MOD_NO_AUTO_SPAWN_PROPHET) - if(MOD_NO_AUTO_SPAWN_PROPHET) { - if (!kPlayer.isHuman() || prophetboughtwithfaith) + if(MOD_NO_AUTO_SPAWN_PROPHET) + { + if (!kPlayer.isHuman() || prophetboughtwithfaith) + { + kPlayer.SetFaith(0); + } + } + else { kPlayer.SetFaith(0); } + kPlayer.SetFaith(0); } - else - kPlayer.SetFaith(0); -#endif -#endif - kPlayer.SetFaith(0); -#if defined(MOD_RELIGION_KEEP_PROPHET_OVERFLOW) - } -#endif } } @@ -3670,19 +3476,11 @@ void CvPlayerReligions::Write(FDataStream& kStream) const } /// How many prophets have we spawned -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int CvPlayerReligions::GetNumProphetsSpawned(bool bExcludeFree) const -#else -int CvPlayerReligions::GetNumProphetsSpawned() const -#endif { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int iCount = m_iNumProphetsSpawned; if (bExcludeFree) iCount -= m_iNumFreeProphetsSpawned; return iCount; -#else - return m_iNumProphetsSpawned; -#endif } FDataStream& operator>>(FDataStream& stream, CvPlayerReligions& playerReligions) @@ -3697,30 +3495,16 @@ FDataStream& operator<<(FDataStream& stream, const CvPlayerReligions& playerReli } /// Change count of prophets spawned -#if defined(MOD_GLOBAL_TRULY_FREE_GP) void CvPlayerReligions::ChangeNumProphetsSpawned(int iValue, bool bIsFree) -#else -void CvPlayerReligions::ChangeNumProphetsSpawned(int iValue) -#endif { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) if (bIsFree) m_iNumFreeProphetsSpawned += iValue; -#endif m_iNumProphetsSpawned += iValue; } /// How much will the next prophet cost this player? -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int CvPlayerReligions::GetCostNextProphet(bool bIncludeBeliefDiscounts, bool bAdjustForSpeedDifficulty, bool bExcludeFree) const -#else -int CvPlayerReligions::GetCostNextProphet(bool bIncludeBeliefDiscounts, bool bAdjustForSpeedDifficulty) const -#endif { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int iCost = GC.getGame().GetGameReligions()->GetFaithGreatProphetNumber(GetNumProphetsSpawned(bExcludeFree) + 1); -#else - int iCost = GC.getGame().GetGameReligions()->GetFaithGreatProphetNumber(m_iNumProphetsSpawned + 1); -#endif // Boost to faith due to belief? ReligionTypes ePlayerReligion = GetStateReligion(); @@ -3780,17 +3564,9 @@ bool CvPlayerReligions::HasCreatedPantheon() const } /// Has this player created a religion? -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) bool CvPlayerReligions::HasCreatedReligion(bool bIgnoreLocal) const -#else -bool CvPlayerReligions::HasCreatedReligion() const -#endif { -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) return GC.getGame().GetGameReligions()->HasCreatedReligion(m_pPlayer->GetID(), bIgnoreLocal); -#else - return GC.getGame().GetGameReligions()->HasCreatedReligion(m_pPlayer->GetID()); -#endif } /// Has this player reformed his religion @@ -5049,14 +4825,12 @@ void CvCityReligions::AddReligiousPressure(CvReligiousFollowChangeReason eReason // If this is pressure from a real religion, reduce presence of pantheon by the same amount else if(eReligion > RELIGION_PANTHEON && it->m_eReligion == RELIGION_PANTHEON && it->m_iPressure > 0) { -#if defined(MOD_CORE_RESILIENT_PANTHEONS) - //do it a bit more slowly - it->m_iPressure = max(0, (it->m_iPressure - iPressureChange/2)); - LogPressureChange(eReason, it->m_eReligion, -iPressureChange/2, it->m_iPressure, eResponsiblePlayer); -#else - it->m_iPressure = max(0, (it->m_iPressure - iPressureChange)); - LogPressureChange(eReason, it->m_eReligion, iPressureChange, it->m_iPressure, eResponsiblePlayer); -#endif + int iPantheonPressureChange = -iPressureChange; + if (MOD_CORE_RESILIENT_PANTHEONS) + iPantheonPressureChange /= 2; + + it->m_iPressure = max(0, (it->m_iPressure + iPantheonPressureChange)); + LogPressureChange(eReason, it->m_eReligion, iPantheonPressureChange, it->m_iPressure, eResponsiblePlayer); } } @@ -5226,12 +5000,11 @@ void CvCityReligions::SimulateReligiousPressure(ReligionTypes eReligion, int iPr // If this is pressure from a real religion, reduce presence of pantheon by the same amount else if(eReligion > RELIGION_PANTHEON && it->m_eReligion == RELIGION_PANTHEON) { -#if defined(MOD_CORE_RESILIENT_PANTHEONS) - //don't need to check for CvReligiousFollowChangeReason - this method is only used for prophets/missionaries - it->m_iPressure = max(0, (it->m_iPressure - iPressure/2)); -#else - it->m_iPressure = max(0, (it->m_iPressure - iPressure)); -#endif + int iPantheonPressureChange = -iPressure; + if (MOD_CORE_RESILIENT_PANTHEONS) + iPantheonPressureChange /= 2; + + it->m_iPressure = max(0, (it->m_iPressure + iPantheonPressureChange)); } else if (it->m_eReligion > RELIGION_PANTHEON) @@ -5708,21 +5481,17 @@ void CvCityReligions::CityConvertsReligion(ReligionTypes eMajority, ReligionType if(eMajority > RELIGION_PANTHEON) { const CvReligion* pNewReligion = pReligions->GetReligion(eMajority, NO_PLAYER); -#if defined(MOD_BALANCE_CORE) + PlayerTypes eReligionController = NO_PLAYER; CvCity* pHolyCity = pNewReligion->GetHolyCity(); if(pHolyCity != NULL) eReligionController = pHolyCity->getOwner(); -#endif + //bonuses might change ... GET_PLAYER(pNewReligion->m_eFounder).UpdateReligion(); // Pay adoption bonuses (if any) -#if defined(MOD_BALANCE_CORE) if(!m_pCity->HasPaidAdoptionBonus(eMajority)) -#else - if(!m_bHasPaidAdoptionBonus) -#endif { int iGoldBonus = 0; if(eResponsibleParty != NO_PLAYER) @@ -5744,11 +5513,7 @@ void CvCityReligions::CityConvertsReligion(ReligionTypes eMajority, ReligionType if (iGoldBonus > 0) { GET_PLAYER(eReligionController).GetTreasury()->ChangeGold(iGoldBonus); -#if defined(MOD_BALANCE_CORE) paid = true; -#else - SetPaidAdoptionBonus(true); -#endif if (eReligionController == GC.getGame().getActivePlayer()) { @@ -5757,7 +5522,7 @@ void CvCityReligions::CityConvertsReligion(ReligionTypes eMajority, ReligionType SHOW_PLOT_POPUP(m_pCity->plot(), NO_PLAYER, text); } } -#if defined(MOD_BALANCE_CORE_BELIEFS) + GET_PLAYER(eReligionController).doInstantYield(INSTANT_YIELD_TYPE_CONVERSION, false, NO_GREATPERSON, NO_BUILDING, 0, false, NO_PLAYER, NULL, false, pHolyCity); GET_PLAYER(eReligionController).doInstantYield(INSTANT_YIELD_TYPE_CONVERSION_EXPO, false, NO_GREATPERSON, NO_BUILDING, 0, false, NO_PLAYER, NULL, false, pHolyCity); @@ -5778,7 +5543,6 @@ void CvCityReligions::CityConvertsReligion(ReligionTypes eMajority, ReligionType if (paid) m_pCity->SetPaidAdoptionBonus(eMajority, true); } -#endif } // Notification if the player's city was converted to a religion they didn't found @@ -6260,20 +6024,12 @@ void CvReligionAI::DoTurn() } /// Select the belief most helpful to this pantheon -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) BeliefTypes CvReligionAI::ChoosePantheonBelief(PlayerTypes ePlayer) -#else -BeliefTypes CvReligionAI::ChoosePantheonBelief() -#endif { CvGameReligions* pGameReligions = GC.getGame().GetGameReligions(); CvWeightedVector beliefChoices; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) std::vector availableBeliefs = pGameReligions->GetAvailablePantheonBeliefs(ePlayer); -#else - std::vector availableBeliefs = pGameReligions->GetAvailablePantheonBeliefs(); -#endif CvWeightedVector viPlotWeights = CalculatePlotWeightsForBeliefSelection(/*bConsiderExpansion*/ true); for(std::vector::iterator it = availableBeliefs.begin(); @@ -6301,20 +6057,12 @@ BeliefTypes CvReligionAI::ChoosePantheonBelief() } /// Select the belief most helpful to this pantheon -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) BeliefTypes CvReligionAI::ChooseFounderBelief(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -BeliefTypes CvReligionAI::ChooseFounderBelief() -#endif { CvGameReligions* pGameReligions = GC.getGame().GetGameReligions(); CvWeightedVector beliefChoices; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) std::vector availableBeliefs = pGameReligions->GetAvailableFounderBeliefs(ePlayer, eReligion); -#else - std::vector availableBeliefs = pGameReligions->GetAvailableFounderBeliefs(); -#endif CvWeightedVector viPlotWeights = CalculatePlotWeightsForBeliefSelection(/*bConsiderExpansion*/ false); @@ -6343,20 +6091,12 @@ BeliefTypes CvReligionAI::ChooseFounderBelief() } /// Select the belief most helpful to this pantheon -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) BeliefTypes CvReligionAI::ChooseFollowerBelief(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -BeliefTypes CvReligionAI::ChooseFollowerBelief() -#endif { CvGameReligions* pGameReligions = GC.getGame().GetGameReligions(); CvWeightedVector beliefChoices; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) std::vector availableBeliefs = pGameReligions->GetAvailableFollowerBeliefs(ePlayer, eReligion); -#else - std::vector availableBeliefs = pGameReligions->GetAvailableFollowerBeliefs(); -#endif CvWeightedVector viPlotWeights = CalculatePlotWeightsForBeliefSelection(/*bConsiderExpansion*/ false); @@ -6385,20 +6125,12 @@ BeliefTypes CvReligionAI::ChooseFollowerBelief() } /// Select the belief most helpful to enhance this religion -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) BeliefTypes CvReligionAI::ChooseEnhancerBelief(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -BeliefTypes CvReligionAI::ChooseEnhancerBelief() -#endif { CvGameReligions* pGameReligions = GC.getGame().GetGameReligions(); CvWeightedVector beliefChoices; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) std::vector availableBeliefs = pGameReligions->GetAvailableEnhancerBeliefs(ePlayer, eReligion); -#else - std::vector availableBeliefs = pGameReligions->GetAvailableEnhancerBeliefs(); -#endif CvWeightedVector viPlotWeights = CalculatePlotWeightsForBeliefSelection(/*bConsiderExpansion*/ false); @@ -6427,20 +6159,12 @@ BeliefTypes CvReligionAI::ChooseEnhancerBelief() } /// Select the belief most helpful to enhance this religion -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) BeliefTypes CvReligionAI::ChooseBonusBelief(PlayerTypes ePlayer, ReligionTypes eReligion, int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3) -#else -BeliefTypes CvReligionAI::ChooseBonusBelief(int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3) -#endif { CvGameReligions* pGameReligions = GC.getGame().GetGameReligions(); CvWeightedVector beliefChoices; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) std::vector availableBeliefs = pGameReligions->GetAvailableBonusBeliefs(ePlayer, eReligion); -#else - std::vector availableBeliefs = pGameReligions->GetAvailableBonusBeliefs(); -#endif CvWeightedVector viPlotWeights = CalculatePlotWeightsForBeliefSelection(/*bConsiderExpansion*/ false); @@ -6472,20 +6196,12 @@ BeliefTypes CvReligionAI::ChooseBonusBelief(int iExcludeBelief1, int iExcludeBel } /// Select the belief most helpful to gain from Reformation social policy -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) BeliefTypes CvReligionAI::ChooseReformationBelief(PlayerTypes ePlayer, ReligionTypes eReligion) -#else -BeliefTypes CvReligionAI::ChooseReformationBelief() -#endif { CvGameReligions* pGameReligions = GC.getGame().GetGameReligions(); CvWeightedVector beliefChoices; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) std::vector availableBeliefs = pGameReligions->GetAvailableReformationBeliefs(ePlayer, eReligion); -#else - std::vector availableBeliefs = pGameReligions->GetAvailableReformationBeliefs(); -#endif CvWeightedVector viPlotWeights = CalculatePlotWeightsForBeliefSelection(/*bConsiderExpansion*/ false); @@ -11436,9 +11152,7 @@ BuildingClassTypes CvReligionAI::FaithBuildingAvailable(ReligionTypes eReligion, CvGameReligions* pReligions = GC.getGame().GetGameReligions(); const CvReligion* pMyReligion = pReligions->GetReligion(eReligion, m_pPlayer->GetID()); -#if defined(MOD_BALANCE_CORE_BELIEFS) std::vector choices; -#endif if (pMyReligion) { @@ -11454,20 +11168,15 @@ BuildingClassTypes CvReligionAI::FaithBuildingAvailable(ReligionTypes eReligion, CvBuildingEntry* pBuildingEntry = GC.getBuildingInfo(eBuilding); if (pBuildingEntry && (pBuildingEntry->GetYieldChange(YIELD_FAITH) > 0 || pBuildingEntry->GetConversionModifier() != 0)) { -#if defined(MOD_BALANCE_CORE_BELIEFS) //Let's not do this for the national wonders, okay? if(!pBuildingEntry->IsReformation()) choices.push_back((BuildingClassTypes)iI); -#else - return (BuildingClassTypes)iI; -#endif } } } } } -#if defined(MOD_BALANCE_CORE_BELIEFS) //pick a random building class if (choices.size() > 1) { @@ -11504,11 +11213,10 @@ BuildingClassTypes CvReligionAI::FaithBuildingAvailable(ReligionTypes eReligion, } else if (choices.size()==1) return choices[0]; -#endif return NO_BUILDINGCLASS; } -#if defined(MOD_BALANCE_CORE_BELIEFS) + bool CvReligionAI::IsProphetGainRateAcceptable() { int iFaithPerTurn = m_pPlayer->GetTotalFaithPerTurn(); @@ -11574,7 +11282,7 @@ bool CvReligionAI::CanBuyNonFaithUnit() const } return false; } -#endif + /// Can we buy a non-Faith generating building? bool CvReligionAI::CanBuyNonFaithBuilding() const { @@ -11591,13 +11299,8 @@ bool CvReligionAI::CanBuyNonFaithBuilding() const { CvBuildingEntry* pBuildingEntry = GC.GetGameBuildings()->GetEntry(eBuilding); - // Check to make sure this isn't a Faith-generating building -#if defined(MOD_BALANCE_CORE) - //Changed - let's make sure it costs faith, and isn't a religious-specific building + // Make sure it costs faith, and isn't a religious-specific building if(pBuildingEntry && pBuildingEntry->GetFaithCost() > 0 && pBuildingEntry->GetReligiousPressureModifier() <= 0) -#else - if(pBuildingEntry && pBuildingEntry->GetYieldChange(YIELD_FAITH) == 0) -#endif { if(pLoopCity->IsCanPurchase(true, true, (UnitTypes)-1, eBuilding, (ProjectTypes)-1, YIELD_FAITH)) { diff --git a/CvGameCoreDLL_Expansion2/CvReligionClasses.h b/CvGameCoreDLL_Expansion2/CvReligionClasses.h index 8ea4436403..27ae0f234a 100644 --- a/CvGameCoreDLL_Expansion2/CvReligionClasses.h +++ b/CvGameCoreDLL_Expansion2/CvReligionClasses.h @@ -203,11 +203,8 @@ class CvGameReligions // General religion information functions const CvReligion* GetReligion(ReligionTypes eReligion, PlayerTypes ePlayer) const; -#if defined(MOD_TRAITS_ANY_BELIEF) + bool IsInSomeReligion(BeliefTypes eBelief, PlayerTypes ePlayer=NO_PLAYER) const; -#else - bool IsInSomeReligion(BeliefTypes eBelief) const; -#endif // Pantheon information functions void SetMinimumFaithNextPantheon(int iMinFaith) @@ -222,60 +219,31 @@ class CvGameReligions bool HasCreatedPantheon(PlayerTypes ePlayer) const; int GetNumPantheonsCreated() const; int GetNumPantheonsPossible(bool bExcludeUnique = false) const; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) + std::vector GetAvailablePantheonBeliefs(PlayerTypes ePlayer=NO_PLAYER); -#else - std::vector GetAvailablePantheonBeliefs(); -#endif -#if defined(MOD_TRAITS_ANY_BELIEF) bool IsPantheonBeliefAvailable(BeliefTypes eBelief, PlayerTypes ePlayer=NO_PLAYER); -#else - bool IsPantheonBeliefAvailable(BeliefTypes eBelief); -#endif // Main religion information functions -#if defined(MOD_BALANCE_CORE) int GetNumFollowers(ReligionTypes eReligion, PlayerTypes ePlayer = NO_PLAYER) const; -#else - int GetNumFollowers(ReligionTypes eReligion) const; -#endif int GetNumCitiesFollowing(ReligionTypes eReligion) const; int GetNumDomesticCitiesFollowing(ReligionTypes eReligion, PlayerTypes ePlayer) const; -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) + bool HasCreatedReligion(PlayerTypes ePlayer, bool bIgnoreLocal = false) const; -#else - bool HasCreatedReligion(PlayerTypes ePlayer) const; -#endif bool HasAddedReformationBelief(PlayerTypes ePlayer) const; bool IsCityStateFriendOfReligionFounder(ReligionTypes eReligion, PlayerTypes ePlayer); ReligionTypes GetReligionCreatedByPlayer(PlayerTypes ePlayer, bool bIncludePantheon = false) const; ReligionTypes GetPantheonCreatedByPlayer(PlayerTypes ePlayer) const; ReligionTypes GetOriginalReligionCreatedByPlayer(PlayerTypes ePlayer) const; -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) int GetNumReligionsFounded(bool bIgnoreLocal = false) const; -#else - int GetNumReligionsFounded() const; -#endif int GetNumReligionsEnhanced() const; -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) int GetNumReligionsStillToFound(bool bIgnoreLocal = false, PlayerTypes ePlayer = NO_PLAYER) const; -#else - int GetNumReligionsStillToFound() const; -#endif -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) || defined(MOD_TRAITS_ANY_BELIEF) + std::vector GetAvailableFounderBeliefs(PlayerTypes ePlayer=NO_PLAYER, ReligionTypes eReligion=NO_RELIGION); std::vector GetAvailableFollowerBeliefs(PlayerTypes ePlayer=NO_PLAYER, ReligionTypes eReligion=NO_RELIGION); std::vector GetAvailableEnhancerBeliefs(PlayerTypes ePlayer=NO_PLAYER, ReligionTypes eReligion=NO_RELIGION); std::vector GetAvailableBonusBeliefs(PlayerTypes ePlayer=NO_PLAYER, ReligionTypes eReligion=NO_RELIGION); std::vector GetAvailableReformationBeliefs(PlayerTypes ePlayer=NO_PLAYER, ReligionTypes eReligion=NO_RELIGION); -#else - std::vector GetAvailableFounderBeliefs(); - std::vector GetAvailableFollowerBeliefs(); - std::vector GetAvailableEnhancerBeliefs(); - std::vector GetAvailableBonusBeliefs(); - std::vector GetAvailableReformationBeliefs(); -#endif int GetAdjacentCityReligiousPressure(ReligionTypes eReligion, CvCity *pFromCity, CvCity *pToCity, int& iNumTradeRoutesInfluencing, bool bActualValue, bool bPretendTradeConnection, bool bConnectedWithTrade, int iRelativeDistancePercent); @@ -356,15 +324,10 @@ class CvPlayerReligions void Write(FDataStream& kStream) const; // Data accessors -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int GetNumProphetsSpawned(bool bExcludeFree) const; void ChangeNumProphetsSpawned(int iValue, bool bIsFree); int GetCostNextProphet(bool bIncludeBeliefDiscounts, bool bAdjustForSpeedDifficulty, bool bExcludeFree) const; -#else - int GetNumProphetsSpawned() const; - void ChangeNumProphetsSpawned(int iValue); - int GetCostNextProphet(bool bIncludeBeliefDiscounts, bool bAdjustForSpeedDifficulty) const; -#endif + bool IsFoundingReligion() const { return m_bFoundingReligion; @@ -376,11 +339,7 @@ class CvPlayerReligions // State information bool HasCreatedPantheon() const; -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) bool HasCreatedReligion(bool bIgnoreLocal = false) const; -#else - bool HasCreatedReligion() const; -#endif bool HasAddedReformationBelief() const; ReligionTypes GetReligionCreatedByPlayer(bool bIncludePantheon = false) const; ReligionTypes GetOriginalReligionCreatedByPlayer() const; @@ -560,21 +519,13 @@ class CvReligionAI void DoTurn(); -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) BeliefTypes ChoosePantheonBelief(PlayerTypes ePlayer/*=NO_PLAYER*/); BeliefTypes ChooseFounderBelief(PlayerTypes ePlayer/*=NO_PLAYER*/, ReligionTypes eReligion/*=NO_RELIGION*/); BeliefTypes ChooseFollowerBelief(PlayerTypes ePlayer/*=NO_PLAYER*/, ReligionTypes eReligion/*=NO_RELIGION*/); BeliefTypes ChooseEnhancerBelief(PlayerTypes ePlayer/*=NO_PLAYER*/, ReligionTypes eReligion/*=NO_RELIGION*/); BeliefTypes ChooseBonusBelief(PlayerTypes ePlayer/*=NO_PLAYER*/, ReligionTypes eReligion/*=NO_RELIGION*/, int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3); BeliefTypes ChooseReformationBelief(PlayerTypes ePlayer/*=NO_PLAYER*/, ReligionTypes eReligion/*=NO_RELIGION*/); -#else - BeliefTypes ChoosePantheonBelief(); - BeliefTypes ChooseFounderBelief(); - BeliefTypes ChooseFollowerBelief(); - BeliefTypes ChooseEnhancerBelief(); - BeliefTypes ChooseBonusBelief(int iExcludeBelief1, int iExcludeBelief2, int iExcludeBelief3); - BeliefTypes ChooseReformationBelief(); -#endif + #if defined(MOD_BALANCE_CORE) int GetNumCitiesWithReligionCalculator(ReligionTypes eReligion = NO_RELIGION, bool bForPantheon = false) const; #endif diff --git a/CvGameCoreDLL_Expansion2/CvTeam.cpp b/CvGameCoreDLL_Expansion2/CvTeam.cpp index cca77972dc..9a39d20b1a 100644 --- a/CvGameCoreDLL_Expansion2/CvTeam.cpp +++ b/CvGameCoreDLL_Expansion2/CvTeam.cpp @@ -1640,7 +1640,7 @@ void CvTeam::DoDeclareWar(PlayerTypes eOriginatingPlayer, bool bAggressor, TeamT // Update City Specializations. kDefendingPlayer.GetCitySpecializationAI()->SetSpecializationsDirty(SPECIALIZATION_UPDATE_NOW_AT_WAR); -#if defined(MOD_BALANCE_CORE) + //Do a golden age on war if we can if(kAttackingPlayer.GetPlayerTraits()->IsGoldenAgeOnWar()) { @@ -1669,67 +1669,40 @@ void CvTeam::DoDeclareWar(PlayerTypes eOriginatingPlayer, bool bAggressor, TeamT kDefendingPlayer.GetPlayerTraits()->SpawnBestUnitsOnImprovementDOW(pLoopCity); } } + // Get a free unit on DOW? - for(int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) + for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) + const UnitTypes eLoopUnit = kAttackingPlayer.GetSpecificUnitType(eUnitClass); + if (eLoopUnit == NO_UNIT) + continue; + + const CvUnitEntry* pLoopUnitInfo = GC.getUnitInfo(eLoopUnit); + if (!pLoopUnitInfo) + continue; + + const UnitAITypes eDefaultAI = pLoopUnitInfo->GetDefaultUnitAIType(); + bool bWarOnly = pLoopUnitInfo->IsWarOnly(); + bool bCombat = (pLoopUnitInfo->GetCombat() > 0); + const TechTypes ePrereqTech = static_cast(pLoopUnitInfo->GetPrereqAndTech()); + + int iUnitAttackerClass = kAttackingPlayer.GetPlayerTraits()->GetFreeUnitClassesDOW(eUnitClass); + bool bAttackerPrereqTech = kAttackingPlayer.HasTech(ePrereqTech); + for (int iJ = 0; iJ < iUnitAttackerClass; iJ++) { - CvPlot* pNewUnitPlot = NULL; - UnitTypes eLoopUnit; - int iDefaultAI = 0; - int iUnitAttackerClass = kAttackingPlayer.GetPlayerTraits()->GetFreeUnitClassesDOW(eUnitClass); - int iUnitDefenderClass = kDefendingPlayer.GetPlayerTraits()->GetFreeUnitClassesDOW(eUnitClass); - for(int iJ = 0; iJ < iUnitAttackerClass; iJ++) - { - eLoopUnit = kAttackingPlayer.GetSpecificUnitType(eUnitClass); - iDefaultAI = GC.GetGameUnits()->GetEntry(eLoopUnit)->GetDefaultUnitAIType(); - bool bWarOnly = GC.GetGameUnits()->GetEntry(eLoopUnit)->IsWarOnly(); - bool bCombat = GC.GetGameUnits()->GetEntry(eLoopUnit)->GetCombat() > 0; - bool bPrereqTech = GET_TEAM(kAttackingPlayer.getTeam()).GetTeamTechs()->HasTech((TechTypes)GC.GetGameUnits()->GetEntry(eLoopUnit)->GetPrereqAndTech()); - if(!bCombat) - { - pNewUnitPlot = kAttackingPlayer.addFreeUnit(eLoopUnit,false,(UnitAITypes)iDefaultAI); - } - else if(bWarOnly && bPrereqTech) - { - pNewUnitPlot = kAttackingPlayer.addFreeUnit(eLoopUnit,false,(UnitAITypes)iDefaultAI); - } - else - { - if(kAttackingPlayer.canTrainUnit(eLoopUnit, false, false, true)) - { - pNewUnitPlot = kAttackingPlayer.addFreeUnit(eLoopUnit,false,(UnitAITypes)iDefaultAI); - } - } - } - for(int iK = 0; iK < iUnitDefenderClass; iK++) - { - eLoopUnit = kDefendingPlayer.GetSpecificUnitType(eUnitClass); - iDefaultAI = GC.GetGameUnits()->GetEntry(eLoopUnit)->GetDefaultUnitAIType(); - bool bWarOnly = GC.GetGameUnits()->GetEntry(eLoopUnit)->IsWarOnly(); - bool bCombat = GC.GetGameUnits()->GetEntry(eLoopUnit)->GetCombat() > 0; - bool bPrereqTech = GET_TEAM(kDefendingPlayer.getTeam()).GetTeamTechs()->HasTech((TechTypes)GC.GetGameUnits()->GetEntry(eLoopUnit)->GetPrereqAndTech()); - if(!bCombat) - { - pNewUnitPlot = kDefendingPlayer.addFreeUnit(eLoopUnit,false,(UnitAITypes)iDefaultAI); - } - else if(bWarOnly && bPrereqTech) - { - pNewUnitPlot = kDefendingPlayer.addFreeUnit(eLoopUnit,false,(UnitAITypes)iDefaultAI); - } - else - { - if(kDefendingPlayer.canTrainUnit(eLoopUnit, false, false, true)) - { - pNewUnitPlot = kDefendingPlayer.addFreeUnit(eLoopUnit,false,(UnitAITypes)iDefaultAI); - } - } - } + if (!bCombat || (bWarOnly && bAttackerPrereqTech) || kAttackingPlayer.canTrainUnit(eLoopUnit, false, false, true)) + kAttackingPlayer.addFreeUnit(eLoopUnit, false, eDefaultAI); + } + + int iUnitDefenderClass = kDefendingPlayer.GetPlayerTraits()->GetFreeUnitClassesDOW(eUnitClass); + bool bDefenderPrereqTech = kDefendingPlayer.HasTech(ePrereqTech); + for (int iJ = 0; iJ < iUnitDefenderClass; iJ++) + { + if (!bCombat || (bWarOnly && bDefenderPrereqTech) || kDefendingPlayer.canTrainUnit(eLoopUnit, false, false, true)) + kDefendingPlayer.addFreeUnit(eLoopUnit, false, eDefaultAI); } } -#endif } } } @@ -7012,35 +6985,29 @@ void CvTeam::setHasTech(TechTypes eIndex, bool bNewValue, PlayerTypes ePlayer, b SetTradeTech(eIndex, true); } - if(bFirst) + if (bFirst) { - if(GC.getGame().countKnownTechNumTeams(eIndex) == 1) + if (GC.getGame().countKnownTechNumTeams(eIndex) == 1) { - if (pkTechInfo->GetFirstFreeUnitClass() != NO_UNITCLASS) + UnitClassTypes eFreeUnitClass = static_cast(pkTechInfo->GetFirstFreeUnitClass()); + if (eFreeUnitClass != NO_UNITCLASS) { bFirstResource = true; - - for (int iI = 0; iI < MAX_PLAYERS; iI++) + CivsList veMembers = getPlayers(); + for (CivsList::iterator it = veMembers.begin(); it != veMembers.end(); ++it) { - const PlayerTypes eLoopPlayer = static_cast(iI); - CvPlayerAI& kPlayer = GET_PLAYER(eLoopPlayer); - if (kPlayer.isAlive() && kPlayer.getTeam() == GetID()) - { - eFreeUnit = (GET_PLAYER(eLoopPlayer).GetSpecificUnitType((UnitClassTypes)GC.getTechInfo(eIndex)->GetFirstFreeUnitClass())); + CvPlayerAI& kPlayer = GET_PLAYER(*it); + if (!kPlayer.isAlive()) + continue; - if (eFreeUnit != NO_UNIT) - { - pCapitalCity = GET_PLAYER(eLoopPlayer).getCapitalCity(); + eFreeUnit = kPlayer.GetSpecificUnitType(eFreeUnitClass); + if (eFreeUnit == NO_UNIT) + continue; - if (pCapitalCity != NULL) - { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) - pCapitalCity->GetCityCitizens()->DoSpawnGreatPerson(eFreeUnit, true, false, MOD_GLOBAL_TRULY_FREE_GP); -#else - pCapitalCity->GetCityCitizens()->DoSpawnGreatPerson(eFreeUnit, true, false); -#endif - } - } + pCapitalCity = kPlayer.getCapitalCity(); + if (pCapitalCity) + { + pCapitalCity->GetCityCitizens()->DoSpawnGreatPerson(eFreeUnit, true, false, MOD_GLOBAL_TRULY_FREE_GP); } } } @@ -8011,7 +7978,7 @@ void CvTeam::processTech(TechTypes eTech, int iChange, bool bNoBonus) } } #endif - CvPlot* pNewUnitPlot = NULL; + for(iI = 0; iI < MAX_PLAYERS; iI++) { CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iI); @@ -8038,32 +8005,31 @@ void CvTeam::processTech(TechTypes eTech, int iChange, bool bNoBonus) } // Free promotion from this tech? - for(int iPromotion = 0; iPromotion < GC.getNumPromotionInfos(); iPromotion++) + for (int iPromotion = 0; iPromotion < GC.getNumPromotionInfos(); iPromotion++) { PromotionTypes ePromotion = (PromotionTypes) iPromotion; -#if defined(MOD_BALANCE_CORE) - if(pTech->IsFreePromotion(ePromotion)) + if (pTech->IsFreePromotion(ePromotion)) { kPlayer.ChangeFreePromotionCount(ePromotion, iChange); - - //For civilians - int iLoop = 0; - CvUnit* pLoopUnit = NULL; + // Loop through existing units, because they have no way to earn it later - for(int iI = 0; iI < MAX_PLAYERS; iI++) + CivsList veMembers = getPlayers(); + for (CivsList::iterator it = veMembers.begin(); it != veMembers.end(); ++it) { - if(GET_PLAYER((PlayerTypes)iI).isAlive() && GET_PLAYER((PlayerTypes)iI).getTeam() == GetID()) + CvPlayer& kPlayer = GET_PLAYER(*it); + if (!kPlayer.isAlive()) + continue; + + int iLoop = 0; + for (CvUnit* pLoopUnit = kPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = kPlayer.nextUnit(&iLoop)) { - for(pLoopUnit = GET_PLAYER((PlayerTypes)iI).firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = GET_PLAYER((PlayerTypes)iI).nextUnit(&iLoop)) + // If we're in friendly territory and we can embark, give the promotion for free + if (pLoopUnit->plot()->IsFriendlyTerritory(*it)) { - // If we're in friendly territory and we can embark, give the promotion for free - if(pLoopUnit->plot()->IsFriendlyTerritory((PlayerTypes)iI)) + // Civilian unit or the unit can acquire this promotion + if (IsPromotionValidForUnitCombatType(ePromotion, pLoopUnit->getUnitType()) || IsPromotionValidForCivilianUnitType(ePromotion, pLoopUnit->getUnitType())) { - // Civilian unit or the unit can acquire this promotion - if(IsPromotionValidForUnitCombatType(ePromotion, pLoopUnit->getUnitType()) || IsPromotionValidForCivilianUnitType(ePromotion, pLoopUnit->getUnitType())) - { - pLoopUnit->setHasPromotion(ePromotion, true); - } + pLoopUnit->setHasPromotion(ePromotion, true); } } } @@ -8075,10 +8041,6 @@ void CvTeam::processTech(TechTypes eTech, int iChange, bool bNoBonus) kPlayer.SetWorkersIgnoreImpassable(true); } } -#else - if(pTech->IsFreePromotion(ePromotion)) - kPlayer.ChangeFreePromotionCount(ePromotion, iChange); -#endif } // Update our traits (some may have become obsolete) @@ -8087,32 +8049,36 @@ void CvTeam::processTech(TechTypes eTech, int iChange, bool bNoBonus) kPlayer.recomputePolicyCostModifier(); // Does our trait give us a new unit when we reach this tech? - UnitTypes eLoopUnit; - int iDefaultAI = 0; - int iUnitClass = kPlayer.GetPlayerTraits()->GetFirstFreeUnit(eTech); - while(iUnitClass != NO_UNITCLASS) + UnitClassTypes eUnitClass = static_cast(kPlayer.GetPlayerTraits()->GetFirstFreeUnit(eTech)); + while (eUnitClass != NO_UNITCLASS) { - eLoopUnit = kPlayer.GetSpecificUnitType((UnitClassTypes)iUnitClass); - iDefaultAI = GC.GetGameUnits()->GetEntry(eLoopUnit)->GetDefaultUnitAIType(); - pNewUnitPlot = kPlayer.addFreeUnit(eLoopUnit,false,(UnitAITypes)iDefaultAI); - - // Notification below only tells user if their civ gets a Great Person from their trait. But trait code allows ANY unit to be received from reaching a tech. - // So in the future we should use a different notification ("you received a new unit from your trait since you reached this tech") instead. - SpecialUnitTypes eSpecialUnitGreatPerson = (SpecialUnitTypes) GC.getInfoTypeForString("SPECIALUNIT_PEOPLE"); - if(pNewUnitPlot && kPlayer.GetNotifications() && GC.GetGameUnits()->GetEntry(eLoopUnit)->GetSpecialUnitType() == eSpecialUnitGreatPerson) + UnitTypes eUnit = kPlayer.GetSpecificUnitType(eUnitClass); + if (eUnit != NO_UNIT) { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER"); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_GREAT_PERSON"); - kPlayer.GetNotifications()->Add(NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER, strText.toUTF8(), strSummary.toUTF8(), pNewUnitPlot->getX(), pNewUnitPlot->getY(), eLoopUnit); + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnit); + if (pUnitInfo) + { + UnitAITypes eDefaultAI = static_cast(pUnitInfo->GetDefaultUnitAIType()); + CvPlot* pNewUnitPlot = kPlayer.addFreeUnit(eUnit, false, eDefaultAI); + + // Notification below only tells user if their civ gets a Great Person from their trait. But trait code allows ANY unit to be received from reaching a tech. + // So in the future we should use a different notification ("you received a new unit from your trait since you reached this tech") instead. + SpecialUnitTypes eSpecialUnitGreatPerson = static_cast(GC.getInfoTypeForString("SPECIALUNIT_PEOPLE")); + if (pNewUnitPlot && kPlayer.GetNotifications() && pUnitInfo->GetSpecialUnitType() == eSpecialUnitGreatPerson) + { + Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER"); + Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_GREAT_PERSON"); + kPlayer.GetNotifications()->Add(NOTIFICATION_GREAT_PERSON_ACTIVE_PLAYER, strText.toUTF8(), strSummary.toUTF8(), pNewUnitPlot->getX(), pNewUnitPlot->getY(), eUnit); + } + } } // Another? - iUnitClass = kPlayer.GetPlayerTraits()->GetNextFreeUnit(); + eUnitClass = static_cast(kPlayer.GetPlayerTraits()->GetNextFreeUnit()); } -#if defined(MOD_BALANCE_CORE) + int iLoop = 0; - CvUnit* pLoopUnit = NULL; - for(pLoopUnit = kPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = kPlayer.nextUnit(&iLoop)) + for(CvUnit* pLoopUnit = kPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = kPlayer.nextUnit(&iLoop)) { if(pLoopUnit->isFreeUpgrade() || kPlayer.GetPlayerTraits()->IsFreeUpgrade()) { @@ -8176,7 +8142,7 @@ void CvTeam::processTech(TechTypes eTech, int iChange, bool bNoBonus) } } } -#endif + #if defined(MOD_BALANCE_CORE) // Free buildings (once unlocked via tech) CvCity* pLoopCity = NULL; diff --git a/CvGameCoreDLL_Expansion2/CvTradeClasses.cpp b/CvGameCoreDLL_Expansion2/CvTradeClasses.cpp index d084f78551..2bc2113dca 100644 --- a/CvGameCoreDLL_Expansion2/CvTradeClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvTradeClasses.cpp @@ -7270,10 +7270,10 @@ void CvTradeAI::GetPrioritizedTradeRoutes(TradeConnectionList& aTradeConnectionL else if (m_pPlayer->GetDiplomacyAI()->IsGoingForSpaceshipVictory() && m_pPlayer->GetDiplomacyAI()->IsCloseToSpaceshipVictory()) { // is this a city in which we want to build spaceship parts in the near future? - vector vCitiesForSpaceship = m_pPlayer->GetCoreCitiesForSpaceshipProduction(); + const vector& vCitiesForSpaceship = m_pPlayer->GetCoreCitiesForSpaceshipProduction(); if (vCitiesForSpaceship.size() > 0) { - if (find(vCitiesForSpaceship.begin(), vCitiesForSpaceship.end(), pCity) != vCitiesForSpaceship.end()) + if (find(vCitiesForSpaceship.begin(), vCitiesForSpaceship.end(), pCity->GetID()) != vCitiesForSpaceship.end()) { apProductionTargetCities.push_back(pCity); } diff --git a/CvGameCoreDLL_Expansion2/CvTraitClasses.cpp b/CvGameCoreDLL_Expansion2/CvTraitClasses.cpp index cc3eb640e7..d5b1155df2 100644 --- a/CvGameCoreDLL_Expansion2/CvTraitClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvTraitClasses.cpp @@ -6460,7 +6460,7 @@ BuildingTypes CvPlayerTraits::GetFreeBuildingOnConquest() const return NO_BUILDING; } -#if defined(MOD_BALANCE_CORE) + /// Should unique luxuries appear around this tile? bool CvPlayerTraits::AddUniqueLuxuriesAround(CvCity *pCity, int iNumResourceToGive) { @@ -6561,111 +6561,38 @@ bool CvPlayerTraits::AddUniqueLuxuriesAround(CvCity *pCity, int iNumResourceToGi void CvPlayerTraits::SpawnBestUnitsOnImprovementDOW(CvCity *pCity) { - CvPlot* pLoopPlot = NULL; - UnitTypes eBestLandUnit = NO_UNIT; - int iStrengthBestLandCombat = 0; - UnitTypes eWarrior = (UnitTypes)GC.getInfoTypeForString("UNIT_WARRIOR"); - for(int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) - { - const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - const UnitTypes eUnit = m_pPlayer->GetSpecificUnitType(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if(pUnitEntry) - { - if(!pCity->canTrain(eUnit)) - { - continue; - } - if(pUnitEntry->GetRangedCombat() > 0) - { - continue; - } - if (pUnitEntry->GetCombat() == 0) - { - continue; - } - if (m_pPlayer->GetNumUnitsOutOfSupply() > 0) - { - continue; - } - if(pUnitEntry->GetDomainType() == DOMAIN_LAND && m_pPlayer->GetNumUnitsToSupply() > m_pPlayer->GetNumUnitsSupplied()) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(m_pPlayer->getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - iNumResource = pUnitEntry->GetResourceQuantityTotal(eResource); - if (iNumResource > 0) - { - if (m_pPlayer->getNumResourceTotal(eResource, true) < iNumResource || m_pPlayer->getNumResourceAvailable(eResource, true) < 0) - { - bBad = true; - break; - } - } - } -#endif - } - if(bBad) - { - continue; - } - int iCombatLandStrength = (std::max(1, pUnitEntry->GetCombat())); - if(iCombatLandStrength > iStrengthBestLandCombat) - { - iStrengthBestLandCombat = iCombatLandStrength; - eBestLandUnit = eUnit; - } - } - } - } - } - if(eBestLandUnit == NO_UNIT) - { - eBestLandUnit = eWarrior; - } - if(eBestLandUnit != NO_UNIT) + // No supply? Forget about it + if (m_pPlayer->GetNumUnitsToSupply() >= m_pPlayer->GetNumUnitsSupplied()) + return; + + UnitTypes eUnit = m_pPlayer->GetCompetitiveSpawnUnitType(false, false, true, true, pCity); + if (eUnit == NO_UNIT) + return; + + for (int iCityPlotLoop = 0; iCityPlotLoop < pCity->GetNumWorkablePlots(); iCityPlotLoop++) { - for(int iCityPlotLoop = 0; iCityPlotLoop < pCity->GetNumWorkablePlots(); iCityPlotLoop++) + // It's possible that the player runs out of supply mid loop + if (m_pPlayer->GetNumUnitsToSupply() >= m_pPlayer->GetNumUnitsSupplied()) + return; + + CvPlot* pLoopPlot = iterateRingPlots(pCity->getX(), pCity->getY(), iCityPlotLoop); + if (!pLoopPlot) + continue; + + ImprovementTypes eImprovement = pLoopPlot->getImprovementType(); + if (eImprovement == NO_IMPROVEMENT) + continue; + + if (eImprovement == GetBestSpawnUnitImprovement()) { - if (m_pPlayer->GetNumUnitsOutOfSupply() > 0) - { - continue; - } - pLoopPlot = iterateRingPlots(pCity->getX(), pCity->getY(), iCityPlotLoop); - if(pLoopPlot != NULL) - { - if(pLoopPlot->getImprovementType() != NO_IMPROVEMENT) - { - if(pLoopPlot->getImprovementType() == this->GetBestSpawnUnitImprovement()) - { - CvUnit* pkUnit = m_pPlayer->initUnit(eBestLandUnit, pLoopPlot->getX(), pLoopPlot->getY()); - pCity->addProductionExperience(pkUnit); - if (!pkUnit->jumpToNearestValidPlot()) - pkUnit->kill(false); - } - } - } + CvUnit* pkUnit = m_pPlayer->initUnit(eUnit, pLoopPlot->getX(), pLoopPlot->getY()); + pCity->addProductionExperience(pkUnit); + if (!pkUnit->jumpToNearestValidPlot()) + pkUnit->kill(false); } } } -#endif + /// Should unique luxuries appear beneath this tile? void CvPlayerTraits::AddUniqueLuxuries(CvCity *pCity) { @@ -7132,18 +7059,13 @@ void CvPlayerTraits::ChooseMayaBoost() if(GetUnitBaktun(ePossibleGreatPerson) == 0) { eDesiredGreatPerson = ePossibleGreatPerson; -#if defined(MOD_BALANCE_CORE_MAYA_CHANGE) if(MOD_BALANCE_CORE_MAYA_CHANGE && (eDesiredGreatPerson == ePossibleGreatPerson) && !bHasReligion) { eDesiredGreatPerson = NO_UNIT; } -#endif } -#if defined(MOD_BALANCE_CORE_MAYA_CHANGE) + if(eDesiredGreatPerson == NO_UNIT) -#else - else -#endif { ePossibleGreatPerson = m_pPlayer->GetSpecificUnitType("UNITCLASS_ENGINEER"); @@ -7232,11 +7154,7 @@ void CvPlayerTraits::ChooseMayaBoost() CvCity* pCity = m_pPlayer->GetGreatPersonSpawnCity(eDesiredGreatPerson); if(pCity) { -#if defined(MOD_GLOBAL_TRULY_FREE_GP) pCity->GetCityCitizens()->DoSpawnGreatPerson(eDesiredGreatPerson, true, false, MOD_GLOBAL_TRULY_FREE_GP); -#else - pCity->GetCityCitizens()->DoSpawnGreatPerson(eDesiredGreatPerson, true, false); -#endif SetUnitBaktun(eDesiredGreatPerson); } m_pPlayer->ChangeNumMayaBoosts(-1); @@ -7333,32 +7251,20 @@ bool CvPlayerTraits::IsFreeMayaGreatPersonChoice() const for(int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) + const UnitTypes eUnit = m_pPlayer->GetSpecificUnitType(eUnitClass); + if (eUnit != NO_UNIT) { - const UnitTypes eUnit = m_pPlayer->GetSpecificUnitType(eUnitClass); - if (eUnit != NO_UNIT) + CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); + if (pUnitEntry) { - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if (pUnitEntry) + if (pUnitEntry->GetSpecialUnitType() == eSpecialUnitGreatPerson) { - if (pUnitEntry->GetSpecialUnitType() == eSpecialUnitGreatPerson) - { -#if defined(MOD_BALANCE_CORE_MAYA_CHANGE) - if(MOD_BALANCE_CORE_MAYA_CHANGE && pUnitEntry->IsFoundReligion() && !IsProphetValid()) - { - continue; - } - else - { -#endif - iNumGreatPeopleTypes++; -#if defined(MOD_BALANCE_CORE_MAYA_CHANGE) - } -#endif - } + if (MOD_BALANCE_CORE_MAYA_CHANGE && pUnitEntry->IsFoundReligion() && !IsProphetValid()) + continue; + + iNumGreatPeopleTypes++; } - } + } } } diff --git a/CvGameCoreDLL_Expansion2/CvUnit.cpp b/CvGameCoreDLL_Expansion2/CvUnit.cpp index e24765e546..90c576ca2e 100644 --- a/CvGameCoreDLL_Expansion2/CvUnit.cpp +++ b/CvGameCoreDLL_Expansion2/CvUnit.cpp @@ -547,25 +547,12 @@ CvUnit::~CvUnit() // -------------------------------------------------------------------------------- -#if defined(MOD_BALANCE_CORE) void CvUnit::init(int iID, UnitTypes eUnit, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason eReason, bool bNoMove, bool bSetupGraphical, int iMapLayer /*= DEFAULT_UNIT_MAP_LAYER*/, int iNumGoodyHutsPopped, ContractTypes eContract, bool bHistoric, CvUnit* pPassUnit) -#else -void CvUnit::init(int iID, UnitTypes eUnit, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason eReason, bool bNoMove, bool bSetupGraphical, int iMapLayer /*= DEFAULT_UNIT_MAP_LAYER*/, int iNumGoodyHutsPopped, ContractTypes eContract, bool bHistoric) -#endif { -#if defined(MOD_BALANCE_CORE) initWithNameOffset(iID, eUnit, -1, eUnitAI, eOwner, iX, iY, eReason, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped, eContract, bHistoric, false, pPassUnit); -#else - initWithNameOffset(iID, eUnit, -1, eUnitAI, eOwner, iX, iY, eReason, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped, eContract, bHistoric); -#endif } // -------------------------------------------------------------------------------- - -#if defined(MOD_BALANCE_CORE) void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason eReason, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped, ContractTypes eContract, bool bHistoric, bool bSkipNaming, CvUnit* pPassUnit) -#else -void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason /*eReason*/, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped, ContractTypes eContract, bool bHistoric, bool bSkipNaming) -#endif { VALIDATE_OBJECT CvString strBuffer; @@ -588,7 +575,6 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA PromotionTypes ePromotion; for(iI = 0; iI < GC.getNumPromotionInfos(); iI++) { -#if defined(MOD_BALANCE_CORE) ePromotion = (PromotionTypes)iI; // If upgrading, transfer memory of the promotions the old unit has ever obtained (this is in initWithNamedOffset() instead of convert() because promotions can get granted here, and the game needs to know if the promotion is ever obtained before promotions are granted) @@ -596,12 +582,8 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA { SetPromotionEverObtained(ePromotion, true); } -#endif if(getUnitInfo().GetFreePromotions(iI)) { -#if !defined(MOD_BALANCE_CORE) - ePromotion = (PromotionTypes)iI; -#endif if(GC.getPromotionInfo(ePromotion)->IsHoveringUnit()) setHasPromotion(ePromotion, true); @@ -629,15 +611,16 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA //-------------------------------- // Init non-saved data -#if defined(MOD_BALANCE_CORE_MILITARY_LOGGING) - //if (GC.getLogging() && GC.getAILogging()) - //{ - // CvString info = CvString::format( "%03d;%s;id;0x%08X;owner;%02d;army;0x%08X;%s;arg1;%d;arg2;%d;flags;0x%08X;at;%d;%d\n", - // GC.getGame().getElapsedGameTurns(),this->getNameKey(),this->GetID(),this->getOwner(),this->getArmyID(),"NEW_UNIT",-1,-1,0,iX,iY); - // FILogFile* pLog=LOGFILEMGR.GetLog( "unit-missions.csv", FILogFile::kDontTimeStamp | FILogFile::kDontFlushOnWrite ); - // pLog->Msg( info.c_str() ); - //} -#endif + if (MOD_BALANCE_CORE_MILITARY_LOGGING) + { + if (GC.getLogging() && GC.getAILogging()) + { + CvString info = CvString::format( "%03d;%s;id;0x%08X;owner;%02d;army;0x%08X;%s;arg1;%d;arg2;%d;flags;0x%08X;at;%d;%d\n", + GC.getGame().getElapsedGameTurns(),this->getNameKey(),this->GetID(),this->getOwner(),this->getArmyID(),"NEW_UNIT",-1,-1,0,iX,iY); + FILogFile* pLog=LOGFILEMGR.GetLog( "unit-missions.csv", FILogFile::kDontTimeStamp | FILogFile::kDontFlushOnWrite ); + pLog->Msg( info.c_str() ); + } + } //-------------------------------- // Init other game data @@ -646,17 +629,13 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA SetGreatWork(NO_GREAT_WORK); iUnitName = GC.getGame().getUnitCreatedCount(getUnitType()); int iNumNames = getUnitInfo().GetNumUnitNames(); -#if defined(MOD_BALANCE_CORE) if (!bSkipNaming && iNumNames > 0) { std::vector vfPossibleUnits; -#endif - { if(iNameOffset == -1) { iNameOffset = GC.getGame().randRangeExclusive(0, iNumNames, CvSeeder(plot()->GetPseudoRandomSeed())); } -#if defined(MOD_BALANCE_CORE) CvString strName = NULL; //Look for units from previous and current eras. for(iI = 0; iI < iNumNames; iI++) @@ -718,7 +697,6 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA //If still no valid GPs, do the old random method. if (vfPossibleUnits.size() <= 0) { -#endif for (iI = 0; iI < iNumNames; iI++) { int iIndex = (iNameOffset + iI) % iNumNames; @@ -755,10 +733,7 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA break; } } -#if defined(MOD_BALANCE_CORE) - } } -#endif } setGameTurnCreated(GC.getGame().getGameTurn()); @@ -835,7 +810,6 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA kPlayer.changeExtraUnitCost(getUnitInfo().GetExtraMaintenanceCost()); // Add Resource Quantity to Used -#if defined(MOD_BALANCE_CORE) if(MOD_BALANCE_CORE_JFD) { if(eContract != NO_CONTRACT) @@ -855,17 +829,14 @@ void CvUnit::initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitA } else { -#endif - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - if(getUnitInfo().GetResourceQuantityRequirement(iResourceLoop) > 0) + for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) { - kPlayer.changeNumResourceUsed((ResourceTypes) iResourceLoop, GC.getUnitInfo(getUnitType())->GetResourceQuantityRequirement(iResourceLoop)); + if(getUnitInfo().GetResourceQuantityRequirement(iResourceLoop) > 0) + { + kPlayer.changeNumResourceUsed((ResourceTypes) iResourceLoop, GC.getUnitInfo(getUnitType())->GetResourceQuantityRequirement(iResourceLoop)); + } } } -#if defined(MOD_BALANCE_CORE) - } -#endif if(getUnitInfo().GetNukeDamageLevel() != -1) { kPlayer.changeNumNukeUnits(1); @@ -1915,7 +1886,6 @@ void CvUnit::setupGraphical() void CvUnit::uninitInfos() { VALIDATE_OBJECT -#if defined(MOD_PROMOTIONS_HALF_MOVE) m_terrainIgnoreCostCount.clear(); m_terrainDoubleMoveCount.clear(); // BUG FIX m_featureIgnoreCostCount.clear(); @@ -1924,9 +1894,6 @@ void CvUnit::uninitInfos() m_featureHalfMoveCount.clear(); m_terrainExtraMoveCount.clear(); m_featureExtraMoveCount.clear(); -#else - m_featureDoubleMoveCount.clear(); -#endif #if defined(MOD_BALANCE_CORE) m_PromotionDuration.clear(); m_TurnPromotionGained.clear(); @@ -2264,8 +2231,7 @@ void CvUnit::kill(bool bDelay, PlayerTypes ePlayer /*= NO_PLAYER*/) bool bCheckForMurder = ePlayer != NO_PLAYER && !GET_PLAYER(eUnitOwner).isBarbarian() && GET_PLAYER(eUnitOwner).getNumCities() <= 0 && (GET_PLAYER(eUnitOwner).getNumUnits() <= 1 || canFoundCity(NULL, true, true, true)); -#if defined(MOD_UNIT_KILL_STATS) - if (ePlayer != NO_PLAYER && !bDelay) + if (MOD_UNIT_KILL_STATS && ePlayer != NO_PLAYER && !bDelay) { AITacticalMove move = getTacticalMove(); saiTaskWhenKilled[(int)move + 1]++; @@ -2273,22 +2239,6 @@ void CvUnit::kill(bool bDelay, PlayerTypes ePlayer /*= NO_PLAYER*/) if (GET_PLAYER(m_eOwner).isMajorCiv() && plot()) GC.getMap().IncrementUnitKillCount(m_eOwner, plot()->GetPlotIndex()); } -#endif - - /* - //callstack logging to investigate mysterious vanishing units - if (getDomainType() == DOMAIN_AIR && !isSuicide()) - { - FILogFile* pLog=LOGFILEMGR.GetLog( "AirUnitKills.log", FILogFile::kDontTimeStamp ); - if (pLog) - { - pLog->Msg(CvString::format("\n%s %d killed by %d\n",getName().c_str(),GetID(),ePlayer).c_str()); - gStackWalker.SetLog(pLog); - gStackWalker.ShowCallstack(5,GetCurrentThread()); - gStackWalker.SetLog(NULL); - } - } - */ CvInterfacePtr pDllThisUnit = GC.WrapUnitPointer(this); @@ -2744,11 +2694,7 @@ void CvUnit::kill(bool bDelay, PlayerTypes ePlayer /*= NO_PLAYER*/) if(getUnitInfo().IsMilitarySupport()) { -#if defined(MOD_BATTLE_ROYALE) GET_PLAYER(eUnitOwner).changeNumMilitaryUnits(-1, getUnitInfo().GetDomainType()); -#else - GET_PLAYER(eUnitOwner).changeNumMilitaryUnits(-1); -#endif } if (getUnitInfo().IsMilitarySupport() && (isNoSupply() || isContractUnit())) @@ -5151,16 +5097,12 @@ bool CvUnit::canMoveInto(const CvPlot& plot, int iMoveFlags) const { if(isOutOfAttacks()) { -#if defined(MOD_GLOBAL_CAPTURE_AFTER_ATTACKING) // If there are only enemy civilians in the plot, then we don't need remaining attacks to capture them // eg a worker in a barbarian camp where we just killed the defender if (plot.getBestDefender(NO_PLAYER) != NULL) { return false; } -#else - return false; -#endif } // Does unit only attack cities? @@ -6716,13 +6658,9 @@ void CvUnit::ChangeRangeAttackIgnoreLOSCount(int iChange) bool CvUnit::IsCityAttackSupport() const { VALIDATE_OBJECT -#if defined(MOD_BALANCE_CORE) //In VP city attack support units are civilians with a sapper bonus //sapper is a separate promotion that can theoretically apply to combat units as well return (getUnitInfo().IsCityAttackSupport() || m_iCityAttackOnlyCount > 0); -#else - return m_iCityAttackOnlyCount > 0; -#endif } // -------------------------------------------------------------------------------- @@ -7602,64 +7540,27 @@ bool CvUnit::canHeal(const CvPlot* pPlot, bool bCheckMovement) const { VALIDATE_OBJECT - if(!IsHurt()) - { + if (!IsHurt()) return false; - } // No healing after movement, except for exceptions - if(bCheckMovement && hasMoved() && !isAlwaysHeal()) - { + if (bCheckMovement && hasMoved() && !isAlwaysHeal()) return false; - } // No barb healing - if(isBarbarian()) - { + if (isBarbarian()) return false; - } -#if defined(MOD_BALANCE_CORE_MILITARY_RESOURCES) - if (MOD_BALANCE_CORE_MILITARY_RESOURCES && !GET_PLAYER(getOwner()).isMinorCiv()) + CvPlayer& kPlayer = GET_PLAYER(getOwner()); + if (MOD_BALANCE_CORE_MILITARY_RESOURCES && kPlayer.isMajorCiv()) { - CvPlayerAI& kPlayer = GET_PLAYER(getOwner()); - - // Loop through all resources - ResourceTypes eResource; - int iNumResourceInfos = GC.getNumResourceInfos(); - for(int iResourceLoop = 0; iResourceLoop < iNumResourceInfos; iResourceLoop++) + // No healing if lacking required resources + if (!kPlayer.HasResourceForNewUnit(getUnitType(), false, false, NO_UNIT, /*bContinue*/ true)) { - eResource = (ResourceTypes) iResourceLoop; - - if(m_pUnitInfo->GetResourceQuantityRequirement(eResource) > 0) - { - int iAvailable = kPlayer.getNumResourceAvailable(eResource); - if(iAvailable < 0) - { - return false; - } - } - -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - int iNumResource = m_pUnitInfo->GetResourceQuantityTotal(eResource); - if (iNumResource > 0) - { - int iTotal = kPlayer.getNumResourceTotal(eResource); - int iAvailable = kPlayer.getNumResourceAvailable(eResource); - if (iTotal < iNumResource || iAvailable < 0) - { - return false; - } - } - } -#endif + return false; } } -#endif -#if defined(MOD_UNITS_HOVERING_LAND_ONLY_HEAL) if (MOD_UNITS_HOVERING_LAND_ONLY_HEAL) { // Hovering units can only heal over land @@ -7668,36 +7569,33 @@ bool CvUnit::canHeal(const CvPlot* pPlot, bool bCheckMovement) const return false; } } -#endif -#if defined(MOD_NO_HEALING_ON_MOUNTAINS) - if(MOD_NO_HEALING_ON_MOUNTAINS) + if (MOD_NO_HEALING_ON_MOUNTAINS) { - //no healing on mountains outside of cities (inca) + // No healing on mountains outside of cities if (pPlot->isMountain() && !pPlot->isCity()) + { return false; + } } -#endif // Embarked Units can't heal - if(pPlot->needsEmbarkation(this) && !isCargo()) - { + if (pPlot->needsEmbarkation(this) && !isCargo()) return false; - } // Boats can only heal in friendly territory (without promotion) - if(getDomainType() == DOMAIN_SEA) + if (getDomainType() == DOMAIN_SEA) { - if(!pPlot->IsFriendlyTerritory(getOwner()) && !isHealOutsideFriendly()) + if (!pPlot->IsFriendlyTerritory(getOwner()) && !isHealOutsideFriendly()) { return false; } } - if(healRate(pPlot) <= 0) + if (healRate(pPlot) <= 0) return false; - //can't heal in a blockaded city + // Can't heal in a blockaded city CvCity* pCity = pPlot->getPlotCity(); return !(pCity && pCity->IsBlockadedWaterAndLand()); } @@ -8031,12 +7929,7 @@ void CvUnit::doHeal() { if (IsCombatUnit()) { -#if defined(MOD_BARBARIANS_HEAL_EVERYWHERE) if (IsHurt() && !hasMoved() && getDomainType()==DOMAIN_LAND && isNativeDomain(plot()) && (plot()->isBarbarian() || !plot()->isOwned())) -#else - ImprovementTypes eCamp = (ImprovementTypes)GD_INT_GET(BARBARIAN_CAMP_IMPROVEMENT); - if (IsHurt() && !hasMoved() && (plot()->getImprovementType() == eCamp || plot()->getOwner() == BARBARIAN_PLAYER)) -#endif { //barbarians consider all territory as neutral int iHealRate = getExtraNeutralHeal() + /*0 in CP, 10 in VP*/ GD_INT_GET(BALANCE_BARBARIAN_HEAL_RATE); @@ -8261,21 +8154,19 @@ int CvUnit::GetDanger(const CvPlot* pAtPlot, const UnitIdContainer& unitsToIgnor // -------------------------------------------------------------------------------- bool CvUnit::canAirlift(const CvPlot* pPlot) const -#if defined(MOD_GLOBAL_RELOCATION) { return (getAirliftFromPlot(pPlot) != NULL); } const CvPlot* CvUnit::getAirliftToPlot(const CvPlot* pPlot, bool bIncludeCities) const { - -#if defined(MOD_EVENTS_AIRLIFT) - if (MOD_EVENTS_AIRLIFT) { - if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_CanAirliftTo, getOwner(), GetID(), pPlot->getX(), pPlot->getY()) == GAMEEVENTRETURN_TRUE) { + if (MOD_EVENTS_AIRLIFT) + { + if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_CanAirliftTo, getOwner(), GetID(), pPlot->getX(), pPlot->getY()) == GAMEEVENTRETURN_TRUE) + { return pPlot; } } -#endif // Is there a friendly improvement that AllowsAirliftTo ImprovementTypes eImprovement = pPlot->getImprovementType(); @@ -8288,11 +8179,8 @@ const CvPlot* CvUnit::getAirliftToPlot(const CvPlot* pPlot, bool bIncludeCities) } } -#if defined(MOD_EVENTS_AIRLIFT) - if (!bIncludeCities) { + if (!bIncludeCities) return NULL; - } -#endif CvCity* pEndCity = pPlot->getPlotCity(); if (pEndCity == NULL) @@ -8316,45 +8204,33 @@ const CvPlot* CvUnit::getAirliftToPlot(const CvPlot* pPlot, bool bIncludeCities) } const CvPlot* CvUnit::getAirliftFromPlot(const CvPlot* pPlot) const -#endif { VALIDATE_OBJECT -#if defined(MOD_GLOBAL_RELOCATION) // Early out if we're a trade unit if (isTrade()) { return NULL; } -#endif -#if defined(MOD_EVENTS_AIRLIFT) - if (MOD_EVENTS_AIRLIFT) { - if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_CanAirliftFrom, getOwner(), GetID(), pPlot->getX(), pPlot->getY()) == GAMEEVENTRETURN_TRUE) { + if (MOD_EVENTS_AIRLIFT) + { + if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_CanAirliftFrom, getOwner(), GetID(), pPlot->getX(), pPlot->getY()) == GAMEEVENTRETURN_TRUE) + { return pPlot; } } -#endif if(getDomainType() != DOMAIN_LAND) { -#if defined(MOD_GLOBAL_RELOCATION) return NULL; -#else - return false; -#endif } if(hasMoved()) { -#if defined(MOD_GLOBAL_RELOCATION) return NULL; -#else - return false; -#endif } -#if defined(MOD_GLOBAL_RELOCATION) // Are we stood on a friendly improvement that AllowsAirliftFrom ImprovementTypes eImprovement = pPlot->getImprovementType(); if (eImprovement != NO_IMPROVEMENT) @@ -8367,15 +8243,10 @@ const CvPlot* CvUnit::getAirliftFromPlot(const CvPlot* pPlot) const } const CvPlot* pFromPlot = pPlot; -#endif if (pPlot->isWater()) { -#if defined(MOD_GLOBAL_RELOCATION) return NULL; -#else - return false; -#endif } CvCity* pCity = pPlot->getPlotCity(); @@ -8384,59 +8255,25 @@ const CvPlot* CvUnit::getAirliftFromPlot(const CvPlot* pPlot) const pCity = pPlot->GetAdjacentCity(); if (pCity == NULL) { -#if defined(MOD_GLOBAL_RELOCATION) return NULL; -#else - return false; -#endif } -#if defined(MOD_GLOBAL_RELOCATION) else { pFromPlot = pCity->plot(); } -#endif - } - -#if defined(MOD_GLOBAL_RELOCATION) - // First thing checked for above -#else - if (isTrade()) - { - return false; } -#endif -#if defined(MOD_GLOBAL_RELOCATION) if(pCity->getTeam() != getTeam()) { return NULL; } -#endif if (!pCity->CanAirlift()) { -#if defined(MOD_GLOBAL_RELOCATION) return NULL; -#else - return false; -#endif } -#if defined(MOD_GLOBAL_RELOCATION) - // Moved earlier on -#else - if(pCity->getTeam() != getTeam()) - { - return false; - } -#endif - -#if defined(MOD_GLOBAL_RELOCATION) return pFromPlot; -#else - return true; -#endif } @@ -8444,25 +8281,10 @@ const CvPlot* CvUnit::getAirliftFromPlot(const CvPlot* pPlot) const bool CvUnit::canAirliftAt(const CvPlot* pPlot, int iX, int iY) const { VALIDATE_OBJECT -#if defined(MOD_GLOBAL_RELOCATION) const CvPlot* pFromPlot = getAirliftFromPlot(pPlot); if(pFromPlot == NULL) return false; -#else - if(!canAirlift(pPlot)) - return false; - - CvCity* pStartCity = pPlot->getPlotCity(); - if(pStartCity == NULL) - { - pStartCity = pPlot->GetAdjacentCity(); - if (pStartCity == NULL) - { - return false; - } - } -#endif CvPlot* pTargetPlot = GC.getMap().plot(iX, iY); int iMoveFlags = CvUnit::MOVEFLAG_DESTINATION; @@ -8471,7 +8293,6 @@ bool CvUnit::canAirliftAt(const CvPlot* pPlot, int iX, int iY) const return false; } -#if defined(MOD_GLOBAL_RELOCATION) const CvPlot* pToPlot = getAirliftToPlot(pTargetPlot, pFromPlot->isCity()); if(pToPlot == NULL) return false; @@ -8479,32 +8300,6 @@ bool CvUnit::canAirliftAt(const CvPlot* pPlot, int iX, int iY) const if (pToPlot == pFromPlot) return false; -#else - CvCity* pTargetCity = pTargetPlot->getPlotCity(); - if(pTargetCity == NULL) - { - pTargetCity = pTargetPlot->GetAdjacentFriendlyCity(getTeam()); - if (pTargetCity == NULL) - { - return false; - } - } - if (pTargetCity == pStartCity) - { - return false; - } - - if (!pTargetCity->CanAirlift()) - { - return false; - } - - if(pTargetCity->getTeam() != getTeam()) - { - return false; - } -#endif - // No enemy units adjacent for(int iI = 0; iI < NUM_DIRECTION_TYPES; ++iI) { @@ -9093,13 +8888,9 @@ bool CvUnit::changeTradeUnitHomeCity(int iX, int iY) // -------------------------------------------------------------------------------- bool CvUnit::canChangeAdmiralPort(const CvPlot* pPlot) const { -#if defined(MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL) bool bHasSkill = !MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL && IsGreatAdmiral(); bHasSkill = bHasSkill || (MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL && m_pUnitInfo->IsCanChangePort()); if (!bHasSkill) -#else - if (!IsGreatAdmiral()) -#endif { return false; } @@ -9509,11 +9300,7 @@ bool CvUnit::createGreatWork() #endif if(IsGreatPerson()) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -9657,11 +9444,7 @@ bool CvUnit::createFreeLuxury() } } } -#if defined(MOD_EVENTS_GREAT_PEOPLE) kOwner.DoGreatPersonExpended(getUnitType(), this); -#else - kOwner.DoGreatPersonExpended(getUnitType()); -#endif kill(true); bResult = true; } @@ -10343,11 +10126,7 @@ bool CvUnit::canPillage(const CvPlot* pPlot) const { if (pImprovementInfo->IsPermanent()) { -#if defined(MOD_PILLAGE_PERMANENT_IMPROVEMENTS) - return MOD_PILLAGE_PERMANENT_IMPROVEMENTS; -#else - return false; -#endif + return MOD_PILLAGE_PERMANENT_IMPROVEMENTS; } if (pImprovementInfo->IsGoody()) @@ -10712,7 +10491,6 @@ bool CvUnit::pillage() DoAdjacentPlotDamage(pPlot, getAOEDamageOnPillage(), "TXT_KEY_MISC_YOU_UNIT_WAS_DAMAGED_AOE_STRIKE_PILLAGE"); -#if defined(HH_MOD_BUILDINGS_FRUITLESS_PILLAGE) //if the plot isn't guarded by a gainless pillage building for this player, nor this city if (!(pPlot->getOwner() != NO_PLAYER && GET_PLAYER(pPlot->getOwner()).isBorderGainlessPillage()) ) { @@ -10732,18 +10510,6 @@ bool CvUnit::pillage() } } } -#else - if (hasHealOnPillage()) - { - // completely heal unit - changeDamage(-getDamage()); - } - else - { - int iHealAmount = min(getDamage(), /*25*/ GD_INT_GET(PILLAGE_HEAL_AMOUNT)); - changeDamage(-iHealAmount); - } -#endif } return true; @@ -10992,11 +10758,8 @@ bool CvUnit::CanFoundReligion(const CvPlot* pPlot) const { return false; } -#if defined(MOD_BALANCE_CORE) + if(pReligions->GetNumReligionsStillToFound() <= 0 && !GET_PLAYER(getOwner()).GetPlayerTraits()->IsAlwaysReligion()) -#else - if(pReligions->GetNumReligionsStillToFound() <= 0) -#endif { return false; } @@ -11006,41 +10769,37 @@ bool CvUnit::CanFoundReligion(const CvPlot* pPlot) const return false; } -#if defined(MOD_EVENTS_FOUND_RELIGION) CvCity* pCity = pPlot->getPlotCity(); - if (MOD_EVENTS_FOUND_RELIGION ) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundReligion, getOwner(), pCity->GetID()) == GAMEEVENTRETURN_FALSE) { + if (MOD_EVENTS_FOUND_RELIGION) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundReligion, getOwner(), pCity->GetID()) == GAMEEVENTRETURN_FALSE) + { return false; } - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + } + else { - CvLuaArgsHandle args; - args->Push(getOwner()); - args->Push(pCity->GetID()); - - // Attempt to execute the game events. - // Will return false if there are no registered listeners. - bool bResult = false; - if (LuaSupport::CallTestAll(pkScriptSystem, "PlayerCanFoundReligion", args.get(), bResult)) + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if (pkScriptSystem) { - if (!bResult) + CvLuaArgsHandle args; + args->Push(getOwner()); + args->Push(pCity->GetID()); + + // Attempt to execute the game events. + // Will return false if there are no registered listeners. + bool bResult = false; + if (LuaSupport::CallTestAll(pkScriptSystem, "PlayerCanFoundReligion", args.get(), bResult)) { - return false; + if (!bResult) + { + return false; + } } } } -#if defined(MOD_EVENTS_FOUND_RELIGION) - } -#endif -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) if (pReligions->GetAvailableFounderBeliefs(getOwner(), NO_RELIGION).size() < 1 || pReligions->GetAvailableFollowerBeliefs(getOwner(), NO_RELIGION).size() < 1) -#else - if (pReligions->GetAvailableFounderBeliefs().size() < 1 || pReligions->GetAvailableFollowerBeliefs().size() < 1) -#endif { return false; } @@ -11084,11 +10843,7 @@ bool CvUnit::DoFoundReligion() if (!bIndiaException) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kOwner.DoGreatPersonExpended(getUnitType(), this); -#else - kOwner.DoGreatPersonExpended(getUnitType()); -#endif kill(true); } } @@ -11104,35 +10859,19 @@ bool CvUnit::DoFoundReligion() int iIndex = 0; if(!kOwner.GetReligions()->HasCreatedPantheon()) { -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) eBeliefs[iIndex] = kOwner.GetReligionAI()->ChoosePantheonBelief(kOwner.GetID()); -#else - eBeliefs[iIndex] = kOwner.GetReligionAI()->ChoosePantheonBelief(); -#endif iIndex++; } -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) eBeliefs[iIndex] = kOwner.GetReligionAI()->ChooseFounderBelief(kOwner.GetID(), eReligion); -#else - eBeliefs[iIndex] = kOwner.GetReligionAI()->ChooseFounderBelief(); -#endif iIndex++; -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) eBeliefs[iIndex] = kOwner.GetReligionAI()->ChooseFollowerBelief(kOwner.GetID(), eReligion); -#else - eBeliefs[iIndex] = kOwner.GetReligionAI()->ChooseFollowerBelief(); -#endif iIndex++; if(kOwner.GetPlayerTraits()->IsBonusReligiousBelief()) { -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) eBeliefs[iIndex] = kOwner.GetReligionAI()->ChooseBonusBelief(kOwner.GetID(), eReligion, eBeliefs[0], eBeliefs[1], eBeliefs[2]); -#else - eBeliefs[iIndex] = kOwner.GetReligionAI()->ChooseBonusBelief(eBeliefs[0], eBeliefs[1], eBeliefs[2]); -#endif } #if defined(MOD_EVENTS_FOUND_RELIGION) @@ -11152,11 +10891,7 @@ bool CvUnit::DoFoundReligion() if (!bIndiaException) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kOwner.DoGreatPersonExpended(getUnitType(), this); -#else - kOwner.DoGreatPersonExpended(getUnitType()); -#endif kill(true); } } @@ -11220,11 +10955,7 @@ bool CvUnit::CanEnhanceReligion(const CvPlot* pPlot) const return false; } -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) if (pReligions->GetAvailableEnhancerBeliefs(getOwner(), eReligion).size() < 1 || pReligions->GetAvailableFollowerBeliefs(getOwner(), eReligion).size() < 1) -#else - if (pReligions->GetAvailableEnhancerBeliefs().size() < 1 || pReligions->GetAvailableFollowerBeliefs().size() < 1) -#endif { return false; } @@ -11269,11 +11000,7 @@ bool CvUnit::DoEnhanceReligion() if (!bIndiaException) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kOwner.DoGreatPersonExpended(getUnitType(), this); -#else - kOwner.DoGreatPersonExpended(getUnitType()); -#endif kill(true); } } @@ -11283,23 +11010,14 @@ bool CvUnit::DoEnhanceReligion() if (eReligion != NO_RELIGION) { // Pick a belief for this religion -#if defined(MOD_EVENTS_ACQUIRE_BELIEFS) - BeliefTypes eBelief1 = kOwner.GetReligionAI()->ChooseFollowerBelief(kOwner.GetID(), eReligion); // temporary - BeliefTypes eBelief2 = kOwner.GetReligionAI()->ChooseEnhancerBelief(kOwner.GetID(), eReligion); // temporary -#else - BeliefTypes eBelief1 = kOwner.GetReligionAI()->ChooseFollowerBelief(); // temporary - BeliefTypes eBelief2 = kOwner.GetReligionAI()->ChooseEnhancerBelief(); // temporary -#endif + BeliefTypes eBelief1 = kOwner.GetReligionAI()->ChooseFollowerBelief(kOwner.GetID(), eReligion); // temporary + BeliefTypes eBelief2 = kOwner.GetReligionAI()->ChooseEnhancerBelief(kOwner.GetID(), eReligion); // temporary pReligions->EnhanceReligion(getOwner(), eReligion, eBelief1, eBelief2); if (!bIndiaException) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kOwner.DoGreatPersonExpended(getUnitType(), this); -#else - kOwner.DoGreatPersonExpended(getUnitType()); -#endif kill(true); } } @@ -11404,11 +11122,8 @@ bool CvUnit::DoSpreadReligion() if(CanSpreadReligion(plot())) { int iPreSpreadFollowers = 0; -#if defined(MOD_RELIGION_CONVERSION_MODIFIERS) int iConversionStrength = GetConversionStrength(pCity); -#else - int iConversionStrength = GetConversionStrength(); -#endif + CvGameReligions* pReligions = GC.getGame().GetGameReligions(); ReligionTypes eReligion = GetReligionData()->GetReligion(); if (eReligion <= RELIGION_PANTHEON) @@ -11488,11 +11203,7 @@ bool CvUnit::DoSpreadReligion() if(IsGreatPerson()) { CvPlayer& kPlayer = GET_PLAYER(getOwner()); -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -11661,19 +11372,11 @@ int CvUnit::GetNumFollowersAfterSpread() const { if(IsGreatPerson()) { -#if defined(MOD_RELIGION_CONVERSION_MODIFIERS) - iRtnValue = pCity->GetCityReligions()->GetNumFollowersAfterProphetSpread (GetReligionData()->GetReligion(), GetConversionStrength(pCity)); -#else - iRtnValue = pCity->GetCityReligions()->GetNumFollowersAfterProphetSpread (GetReligionData()->GetReligion(), GetConversionStrength()); -#endif + iRtnValue = pCity->GetCityReligions()->GetNumFollowersAfterProphetSpread(GetReligionData()->GetReligion(), GetConversionStrength(pCity)); } else { -#if defined(MOD_RELIGION_CONVERSION_MODIFIERS) - iRtnValue = pCity->GetCityReligions()->GetNumFollowersAfterSpread (GetReligionData()->GetReligion(), GetConversionStrength(pCity)); -#else - iRtnValue = pCity->GetCityReligions()->GetNumFollowersAfterSpread (GetReligionData()->GetReligion(), GetConversionStrength()); -#endif + iRtnValue = pCity->GetCityReligions()->GetNumFollowersAfterSpread(GetReligionData()->GetReligion(), GetConversionStrength(pCity)); } } @@ -11690,19 +11393,11 @@ ReligionTypes CvUnit::GetMajorityReligionAfterSpread() const { if(IsGreatPerson()) { -#if defined(MOD_RELIGION_CONVERSION_MODIFIERS) - eRtnValue = pCity->GetCityReligions()->GetMajorityReligionAfterProphetSpread (GetReligionData()->GetReligion(), GetConversionStrength(pCity)); -#else - eRtnValue = pCity->GetCityReligions()->GetMajorityReligionAfterProphetSpread (GetReligionData()->GetReligion(), GetConversionStrength()); -#endif + eRtnValue = pCity->GetCityReligions()->GetMajorityReligionAfterProphetSpread(GetReligionData()->GetReligion(), GetConversionStrength(pCity)); } else { -#if defined(MOD_RELIGION_CONVERSION_MODIFIERS) - eRtnValue = pCity->GetCityReligions()->GetMajorityReligionAfterSpread (GetReligionData()->GetReligion(), GetConversionStrength(pCity)); -#else - eRtnValue = pCity->GetCityReligions()->GetMajorityReligionAfterSpread (GetReligionData()->GetReligion(), GetConversionStrength()); -#endif + eRtnValue = pCity->GetCityReligions()->GetMajorityReligionAfterSpread(GetReligionData()->GetReligion(), GetConversionStrength(pCity)); } } @@ -11812,11 +11507,7 @@ bool CvUnit::greatperson() if(IsGreatPerson()) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) pPlayer->DoGreatPersonExpended(getUnitType(), this); -#else - pPlayer->DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -11922,11 +11613,7 @@ bool CvUnit::discover() if (!pTeam) return false; // Beakers boost based on previous turns -#if defined(MOD_BALANCE_CORE) int iBeakersBonus = GetScienceBlastStrength(); -#else - int iBeakersBonus = getDiscoverAmount(); -#endif TechTypes eCurrentTech = pPlayer->GetPlayerTechs()->GetCurrentResearch(); if(eCurrentTech == NO_TECH) { @@ -11960,11 +11647,7 @@ bool CvUnit::discover() if(IsGreatPerson()) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) pPlayer->DoGreatPersonExpended(getUnitType(), this); -#else - pPlayer->DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -12198,11 +11881,7 @@ bool CvUnit::hurry() if(IsGreatPerson()) { CvPlayer& kPlayer = GET_PLAYER(getOwner()); -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -12545,11 +12224,7 @@ bool CvUnit::buyCityState() if (IsGreatPerson()) { CvPlayer& kPlayer = GET_PLAYER(getOwner()); -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -12568,13 +12243,9 @@ bool CvUnit::canRepairFleet(const CvPlot* /*pPlot*/, bool /*bTestVisible*/) cons return false; } -#if defined(MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL) bool bHasSkill = !MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL && IsGreatAdmiral(); bHasSkill = bHasSkill || (MOD_GLOBAL_SEPARATE_GREAT_ADMIRAL && m_pUnitInfo->IsCanRepairFleet()); if (!bHasSkill) -#else - if (!IsGreatAdmiral()) -#endif { return false; } @@ -12633,11 +12304,7 @@ bool CvUnit::repairFleet() if (IsGreatPerson()) { CvPlayer& kPlayer = GET_PLAYER(getOwner()); -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -12805,11 +12472,7 @@ bool CvUnit::DoCultureBomb() { if (IsGreatPerson()) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); } @@ -13381,12 +13044,7 @@ bool CvUnit::givePolicies() CvPlayerAI& kPlayer = GET_PLAYER(getOwner()); // Culture boost based on previous turns -#if defined(MOD_BALANCE_CORE) int iCultureBonus = GetCultureBlastStrength(); -#else - int iCultureBonus = getGivePoliciesCulture(); -#endif - if (iCultureBonus != 0) { kPlayer.changeJONSCulture(iCultureBonus); @@ -13411,11 +13069,7 @@ bool CvUnit::givePolicies() if(IsGreatPerson()) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -13673,11 +13327,7 @@ bool CvUnit::blastTourism() if(IsGreatPerson()) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) kUnitOwner.DoGreatPersonExpended(getUnitType(), this); -#else - kUnitOwner.DoGreatPersonExpended(getUnitType()); -#endif } kill(true); @@ -13718,26 +13368,16 @@ bool CvUnit::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestVisible, { VALIDATE_OBJECT CvAssertMsg(eBuild < GC.getNumBuildInfos() && eBuild >= 0, "Index out of bounds"); -#if defined(MOD_CIV6_WORKER) + if (MOD_CIV6_WORKER && getBuilderStrength() <= 0) - { return false; - } -#endif -#if defined(MOD_BALANCE_CORE) + if (!GET_PLAYER(getOwner()).GetPlayerTraits()->HasUnitClassCanBuild(eBuild, getUnitClassType()) && (!m_pUnitInfo->GetBuilds(eBuild) || GET_PLAYER(getOwner()).GetPlayerTraits()->IsNoBuild(eBuild))) -#else - if (!(m_pUnitInfo->GetBuilds(eBuild))) -#endif - { return false; - } CvBuildInfo* pkBuildInfo = GC.getBuildInfo(eBuild); if (!pkBuildInfo) - { return false; - } // If prophet has started spreading religion, can't do other functions if (m_pUnitInfo->IsSpreadReligion()) @@ -13752,18 +13392,14 @@ bool CvUnit::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestVisible, return true; if (!(GET_PLAYER(getOwner()).canBuild(pPlot, eBuild, bTestEra, bTestVisible, bTestGold, true, this))) - { return false; - } bool bValidBuildPlot = isNativeDomain(pPlot); bValidBuildPlot |= (pkBuildInfo->IsWater() && getDomainType() == DOMAIN_LAND && pPlot->isWater() && IsHasEmbarkAbility()); if(!bValidBuildPlot) - { return false; - } if (pPlot->isWater()) { @@ -13795,13 +13431,13 @@ bool CvUnit::canBuild(const CvPlot* pPlot, BuildTypes eBuild, bool bTestVisible, } } -#if defined(MOD_EVENTS_PLOT) - if (MOD_EVENTS_PLOT) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanBuild, getOwner(), GetID(), getX(), getY(), eBuild) == GAMEEVENTRETURN_FALSE) { + if (MOD_EVENTS_PLOT) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanBuild, getOwner(), GetID(), getX(), getY(), eBuild) == GAMEEVENTRETURN_FALSE) + { return false; } } -#endif return true; } @@ -13867,14 +13503,11 @@ bool CvUnit::build(BuildTypes eBuild) NewBuild = true; } - if(!MOD_CIV6_WORKER) + if (!MOD_CIV6_WORKER) bFinished = pPlot->changeBuildProgress(eBuild, iWorkRateWithMoves, getOwner(), NewBuild); -#if defined(MOD_EVENTS_PLOT) - if (MOD_EVENTS_PLOT) { + if (MOD_EVENTS_PLOT) GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerBuilding, getOwner(), GetID(), getX(), getY(), eBuild, (iStartedYet == 0)); - } -#endif finishMoves(); // needs to be at bottom because movesLeft() can affect workRate()... @@ -13886,194 +13519,48 @@ bool CvUnit::build(BuildTypes eBuild) ImprovementTypes eImprovement = NO_IMPROVEMENT; RouteTypes eRoute = NO_ROUTE; - if(pkBuildInfo->getImprovement() != NO_IMPROVEMENT) + if (pkBuildInfo->getImprovement() != NO_IMPROVEMENT) { eImprovement = (ImprovementTypes) pkBuildInfo->getImprovement(); CvImprovementEntry* pkImprovementInfo = GC.getImprovementInfo(eImprovement); - if(pkImprovementInfo) + if (pkImprovementInfo) { if (pkImprovementInfo->GetCultureBombRadius() > 0) { -#if defined(MOD_BALANCE_CORE_POLICIES) int iCultureBomb = pkImprovementInfo->GetCultureBombRadius(); iCultureBomb += GET_PLAYER(getOwner()).GetCultureBombBoost(); PerformCultureBomb(iCultureBomb); -#else - PerformCultureBomb(pkImprovementInfo->GetCultureBombRadius()); -#endif } } -#if defined(MOD_BALANCE_CORE) + UnitTypes eBestUnit = NO_UNIT; - int iStrengthBestLandCombat = 0; - UnitTypes eWarrior = (UnitTypes)GC.getInfoTypeForString("UNIT_WARRIOR"); - UnitTypes eTrireme = (UnitTypes)GC.getInfoTypeForString("UNIT_TRIREME"); - if(pkBuildInfo->IsFreeBestDomainUnit()) + int iStrengthBestCombat = 0; + if (pkBuildInfo->IsFreeBestDomainUnit() && kPlayer.GetNumUnitsToSupply() > kPlayer.GetNumUnitsSupplied()) { - bool bWater = false; - for(int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) + bool bWater = pkBuildInfo->IsWater(); + UnitTypes eUnit = NO_UNIT; + if (bWater) { - const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - const UnitTypes eUnit = kPlayer.GetSpecificUnitType(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if(pUnitEntry) - { - if(pkBuildInfo->IsWater()) - { - bWater = true; - } - if(bWater) - { - if(pUnitEntry->GetDomainType() != DOMAIN_SEA) - { - continue; - } - if(!kPlayer.canTrainUnit(eUnit)) - { - continue; - } - if (pUnitEntry->GetCombat() == 0) - { - continue; - } - if (kPlayer.GetNumUnitsOutOfSupply() > 0) - { - continue; - } - if(!pUnitEntry->GetRangedCombat()) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(kPlayer.getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - iNumResource = pUnitEntry->GetResourceQuantityTotal(eResource); - if (iNumResource > 0) - { - if (kPlayer.getNumResourceTotal(eResource, true) < iNumResource || kPlayer.getNumResourceAvailable(eResource, true) < 0) - { - bBad = true; - break; - } - } - } -#endif - } - if(bBad) - { - continue; - } - int iCombatLandStrength = (std::max(1, pUnitEntry->GetCombat())); - if(iCombatLandStrength > iStrengthBestLandCombat) - { - iStrengthBestLandCombat = iCombatLandStrength; - eBestUnit = eUnit; - } - } - } - else if(!bWater) - { - if(!kPlayer.canTrainUnit(eUnit)) - { - continue; - } - if(pUnitEntry->GetRangedCombat() > 0) - { - continue; - } - if (pUnitEntry->GetCombat() == 0) - { - continue; - } - if (kPlayer.GetNumUnitsOutOfSupply() > 0) - { - continue; - } - if(pUnitEntry->GetDomainType() == DOMAIN_LAND) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(kPlayer.getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - iNumResource = pUnitEntry->GetResourceQuantityTotal(eResource); - if (iNumResource > 0) - { - if (kPlayer.getNumResourceTotal(eResource, true) < iNumResource || kPlayer.getNumResourceAvailable(eResource, true) < 0) - { - bBad = true; - break; - } - } - } -#endif - } - if(bBad) - { - continue; - } - int iCombatLandStrength = (std::max(1, pUnitEntry->GetCombat())); - if(iCombatLandStrength > iStrengthBestLandCombat) - { - iStrengthBestLandCombat = iCombatLandStrength; - eBestUnit = eUnit; - } - } - } - } - } - } - if(eBestUnit == NO_UNIT && bWater) - { - eBestUnit = eTrireme; + vector viUnitCombat; + viUnitCombat.push_back(GC.getInfoTypeForString("UNITCOMBAT_NAVALMELEE")); + eUnit = kPlayer.GetCompetitiveSpawnUnitType(false, true, true, true, NULL, false, false, false, NULL, viUnitCombat); } - else if(eBestUnit == NO_UNIT && !bWater) + else { - eBestUnit = eWarrior; + eUnit = kPlayer.GetCompetitiveSpawnUnitType(false, false, true, true); } - if(eBestUnit != NO_UNIT) + + if (eUnit != NO_UNIT) { - CvUnit* pkUnit = kPlayer.initUnit(eBestUnit, pPlot->getX(), pPlot->getY()); - bool bJumpSuccess = pkUnit->jumpToNearestValidPlot(); - if (bJumpSuccess) - { - kPlayer.getCapitalCity()->addProductionExperience(pkUnit); - } - else - { - pkUnit->kill(false); - } + CvUnit* pUnit = kPlayer.initUnit(eUnit, pPlot->getX(), pPlot->getY()); + kPlayer.getCapitalCity()->addProductionExperience(pUnit); + if (!pUnit->jumpToNearestValidPlot()) + pUnit->kill(false); } } + if (pkBuildInfo->IsCultureBoost()) { int iValue = kPlayer.GetTotalJONSCulturePerTurn() * 2; @@ -14088,16 +13575,12 @@ bool CvUnit::build(BuildTypes eBuild) SHOW_PLOT_POPUP(plot(),kPlayer.GetID(), text); } } -#endif } -#if defined(GLOBAL_ALPINE_PASSES) + // Can be both an improvement and a route - if(pkBuildInfo->getRoute() != NO_ROUTE) -#else - else if(pkBuildInfo->getRoute() != NO_ROUTE) -#endif + if (pkBuildInfo->getRoute() != NO_ROUTE) { - eRoute = (RouteTypes) pkBuildInfo->getRoute(); + eRoute = static_cast(pkBuildInfo->getRoute()); } if(pkBuildInfo->isKill()) @@ -14128,7 +13611,6 @@ bool CvUnit::build(BuildTypes eBuild) { if (IsGreatPerson()) { -#if defined(MOD_EVENTS_GREAT_PEOPLE) if (MOD_CIV6_WORKER && getBuilderStrength() > 0) { int iBuildCost = pkBuildInfo->getBuilderCost(); @@ -14140,10 +13622,9 @@ bool CvUnit::build(BuildTypes eBuild) } } else + { kPlayer.DoGreatPersonExpended(getUnitType(), this); -#else - kPlayer.DoGreatPersonExpended(getUnitType()); -#endif + } } if (MOD_CIV6_WORKER) @@ -14153,7 +13634,7 @@ bool CvUnit::build(BuildTypes eBuild) kill(true); } } - else if (!MOD_CIV6_WORKER) + else { if (!pkBuildInfo->isKillOnlyCivilian() || (pkBuildInfo->isKillOnlyCivilian() && IsCivilianUnit())) { @@ -14163,7 +13644,6 @@ bool CvUnit::build(BuildTypes eBuild) } } -#if defined(MOD_CIV6_WORKER) //if we are a builder (something with builderstrength) if (MOD_CIV6_WORKER && getBuilderStrength() > 0) { @@ -14180,10 +13660,10 @@ bool CvUnit::build(BuildTypes eBuild) } } } -#endif + // invalidate trade paths because plot was changed and it can affect trade route length GC.getGame().GetGameTrade()->InvalidateTradePathCache(); -#if defined(MOD_BALANCE_CORE) + if (eImprovement != NO_IMPROVEMENT) { kPlayer.changeTotalImprovementsBuilt(1); @@ -14193,13 +13673,6 @@ bool CvUnit::build(BuildTypes eBuild) { kPlayer.changeTotalImprovementsBuilt(1); // This is here even though routes are not technically improvements, because Firaxis put this here (don't change behaviour of existing tables!) } -#else - // Add to player's Improvement count, which will increase cost of future Improvements - if (pkBuildInfo->getImprovement() != NO_IMPROVEMENT || pkBuildInfo->getRoute() != NO_ROUTE) // Prevents chopping Forest or Jungle from counting - { - kPlayer.changeTotalImprovementsBuilt(1); - } -#endif if(GC.getLogging() && GC.getAILogging()) { @@ -14207,11 +13680,9 @@ bool CvUnit::build(BuildTypes eBuild) } } -#if defined(MOD_EVENTS_PLOT) - if (MOD_EVENTS_PLOT) { + + if (MOD_EVENTS_PLOT) GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerBuilt, getOwner(), GetID(), getX(), getY(), eBuild); - } -#endif } else // we are not done doing this { @@ -14623,15 +14094,9 @@ bool CvUnit::CanUpgradeTo(UnitTypes eUpgradeUnitType, bool bOnlyTestVisible) con if (!canEndTurnAtPlot(pPlot)) return false; -#if defined(MOD_GLOBAL_CS_UPGRADES) if (!CanUpgradeInTerritory(bOnlyTestVisible)) return false; -#else - // Must be in territory owned by the player - if(pPlot->getOwner() != getOwner()) - return false; -#endif -#if defined(MOD_BALANCE_CORE) + if(isEmbarked() || ((plot()->isWater() && getDomainType() != DOMAIN_SEA) && !isCargo())) { return false; @@ -14680,7 +14145,6 @@ bool CvUnit::CanUpgradeTo(UnitTypes eUpgradeUnitType, bool bOnlyTestVisible) con } } } -#endif CvPlayerAI& kPlayer = GET_PLAYER(getOwner()); @@ -14689,51 +14153,9 @@ bool CvUnit::CanUpgradeTo(UnitTypes eUpgradeUnitType, bool bOnlyTestVisible) con return false; // Resource Requirements -#if defined(MOD_BALANCE_CORE) - if (!isBarbarian() && !kPlayer.isMinorCiv()) - { -#endif - - for (int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - ResourceTypes eResource = (ResourceTypes)iResourceLoop; - int iNumResourceNeeded = pUpgradeUnitInfo->GetResourceQuantityRequirement(eResource); - - if (iNumResourceNeeded > 0) - { - // Amount we have lying around - int iNumOfThisResourceAvailable = kPlayer.getNumResourceAvailable(eResource); - // Amount this old unit is using - int iNumOfThisResourceFreed = m_pUnitInfo->GetResourceQuantityRequirement(eResource); - - //do we need more than before? - if (iNumResourceNeeded > iNumOfThisResourceFreed) - //can't go negative in total - if (iNumOfThisResourceAvailable - iNumResourceNeeded + iNumOfThisResourceFreed < 0) - return false; - } - -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - int iNumResourceNeeded = pUpgradeUnitInfo->GetResourceQuantityTotal(eResource); - - if (iNumResourceNeeded > 0) - { - int iResourceTotal = kPlayer.getNumResourceTotal(eResource); - int iResourceAvailable = kPlayer.getNumResourceAvailable(eResource); + if (kPlayer.isMajorCiv() && !kPlayer.HasResourceForNewUnit(eUpgradeUnitType, false, false, getUnitType())) + return false; - if (iNumResourceNeeded > iResourceTotal || iResourceAvailable < 0) - { - return false; - } - } - } -#endif - } -#if defined(MOD_BALANCE_CORE) - } -#endif if(getDomainType() == DOMAIN_AIR) { // Yes! upgrade if in territory and on a carrier. Community Patch knows how to Retrofit bitch on a Carrier! @@ -14760,17 +14182,16 @@ bool CvUnit::CanUpgradeTo(UnitTypes eUpgradeUnitType, bool bOnlyTestVisible) con } } -#if defined(MOD_EVENTS_UNIT_UPGRADES) - if (MOD_EVENTS_UNIT_UPGRADES) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CanHaveAnyUpgrade, getOwner(), GetID()) == GAMEEVENTRETURN_FALSE) { + if (MOD_EVENTS_UNIT_UPGRADES) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CanHaveAnyUpgrade, getOwner(), GetID()) == GAMEEVENTRETURN_FALSE) return false; - } - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_UnitCanHaveAnyUpgrade, getOwner(), GetID()) == GAMEEVENTRETURN_FALSE) { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_UnitCanHaveAnyUpgrade, getOwner(), GetID()) == GAMEEVENTRETURN_FALSE) return false; - } - } else { -#endif + } + else + { ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if (pkScriptSystem) { @@ -14785,9 +14206,7 @@ bool CvUnit::CanUpgradeTo(UnitTypes eUpgradeUnitType, bool bOnlyTestVisible) con } } } -#if defined(MOD_EVENTS_UNIT_UPGRADES) } -#endif return true; } @@ -14840,36 +14259,32 @@ UnitTypes CvUnit::GetUpgradeUnitType() const { VALIDATE_OBJECT UnitTypes eUpgradeUnitType = NO_UNIT; + CvPlayer& kOwner = GET_PLAYER(getOwner()); // Determine what we're going to upgrade into for(int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) + if (m_pUnitInfo->GetUpgradeUnitClass(iI)) { - if(m_pUnitInfo->GetUpgradeUnitClass(iI)) - { - eUpgradeUnitType = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); - -#if defined(MOD_EVENTS_UNIT_UPGRADES) - if (MOD_EVENTS_UNIT_UPGRADES) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CanHaveUpgrade, getOwner(), GetID(), iI, eUpgradeUnitType) == GAMEEVENTRETURN_FALSE) { - eUpgradeUnitType = NO_UNIT; - continue; - } + eUpgradeUnitType = kOwner.GetSpecificUnitType(eUnitClass); - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_UnitCanHaveUpgrade, getOwner(), GetID(), iI, eUpgradeUnitType) == GAMEEVENTRETURN_FALSE) { - eUpgradeUnitType = NO_UNIT; - continue; - } - } else { -#endif + if (MOD_EVENTS_UNIT_UPGRADES) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CanHaveUpgrade, getOwner(), GetID(), iI, eUpgradeUnitType) == GAMEEVENTRETURN_FALSE || + GAMEEVENTINVOKE_TESTALL(GAMEEVENT_UnitCanHaveUpgrade, getOwner(), GetID(), iI, eUpgradeUnitType) == GAMEEVENTRETURN_FALSE) + { + eUpgradeUnitType = NO_UNIT; + continue; + } + } + else + { ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); if (pkScriptSystem) { CvLuaArgsHandle args; - args->Push(((int)getOwner())); + args->Push(getOwner()); args->Push(GetID()); args->Push(iI); args->Push(eUpgradeUnitType); @@ -14884,25 +14299,18 @@ UnitTypes CvUnit::GetUpgradeUnitType() const } } } -#if defined(MOD_EVENTS_UNIT_UPGRADES) - } -#endif - - break; } + + break; } } for (int iI = 0; iI < GC.getNumUnitClassInfos(); iI++) { const UnitClassTypes eUnitClass = static_cast(iI); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if (pkUnitClassInfo) + if (kOwner.GetPlayerTraits()->HasSpecialUnitUpgrade(eUnitClass, getUnitType())) { - if (GET_PLAYER(getOwner()).GetPlayerTraits()->HasSpecialUnitUpgrade(eUnitClass, getUnitType())) - { - eUpgradeUnitType = GET_PLAYER(getOwner()).GetSpecificUnitType(eUnitClass); - break; - } + eUpgradeUnitType = kOwner.GetSpecificUnitType(eUnitClass); + break; } } @@ -15012,11 +14420,7 @@ CvUnit* CvUnit::DoUpgradeTo(UnitTypes eUnitType, bool bFree) } // Add newly upgraded Unit & kill the old one -#if defined(MOD_BALANCE_CORE) CvUnit* pNewUnit = thisPlayer.initUnit(eUnitType, getX(), getY(), NO_UNITAI, REASON_UPGRADE, false, false, 0, 0, NO_CONTRACT, true, this); -#else - CvUnit* pNewUnit = thisPlayer.initUnit(eUnitType, getX(), getY(), NO_UNITAI, REASON_UPGRADE, false, false); -#endif if(NULL != pNewUnit) { @@ -15087,7 +14491,7 @@ CvUnit* CvUnit::DoUpgradeTo(UnitTypes eUnitType, bool bFree) pNewUnit->m_bHasWithdrawnThisTurn = m_bHasWithdrawnThisTurn; pNewUnit->m_bFortified = m_bFortified; } - else + else #endif pNewUnit->finishMoves(); @@ -15157,25 +14561,29 @@ UnitTypes CvUnit::getCaptureUnitType(PlayerTypes eCapturingPlayer) const if (eCapturingPlayer == NO_PLAYER) return NO_UNIT; - CivilizationTypes eCivilization = GET_PLAYER(eCapturingPlayer).getCivilizationType(); - CvAssert(eCivilization != NO_CIVILIZATION); - CvCivilizationInfo* pkCivilizationInfo = GC.getCivilizationInfo(eCivilization); - if(pkCivilizationInfo == NULL) + CvPlayer& kCapturingPlayer = GET_PLAYER(eCapturingPlayer); + + // Event override + CivilizationTypes eCivilization = kCapturingPlayer.getCivilizationType(); + if (MOD_EVENTS_UNIT_CAPTURE) { - return NO_UNIT; - } - - if (MOD_EVENTS_UNIT_CAPTURE) { int iValue = 0; - if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_UnitCaptureType, eCapturingPlayer, GetID(), getUnitType(), eCivilization) == GAMEEVENTRETURN_VALUE) { + if (GAMEEVENTINVOKE_VALUE(iValue, GAMEEVENT_UnitCaptureType, eCapturingPlayer, GetID(), getUnitType(), eCivilization) == GAMEEVENTRETURN_VALUE) + { // Defend against modder stupidity! - if (iValue >= NO_UNIT && GC.getUnitInfo((UnitTypes) iValue) != NULL) { - return (UnitTypes) iValue; + UnitTypes eUnit = static_cast(iValue); + if (eUnit != NO_UNIT && GC.getUnitInfo(eUnit) != NULL) + { + return eUnit; } } } - return ((m_pUnitInfo->GetUnitCaptureClassType() == NO_UNITCLASS) ? NO_UNIT : GET_PLAYER(eCapturingPlayer).GetSpecificUnitType((UnitClassTypes)getUnitInfo().GetUnitCaptureClassType())); + UnitClassTypes eUnitClass = static_cast(getUnitInfo().GetUnitCaptureClassType()); + if (eUnitClass == NO_UNITCLASS) + return NO_UNIT; + + return kCapturingPlayer.GetSpecificUnitType(eUnitClass); } @@ -16224,12 +15632,9 @@ bool CvUnit::canBuildRoute() const for(int iI = 0; iI < iNumBuildInfos; iI++) { CvBuildInfo* thisBuildInfo = GC.getBuildInfo((BuildTypes)iI); -#if defined(MOD_GLOBAL_ALPINE_PASSES) + // Don't count routes that come as part of an improvement if(NULL != thisBuildInfo && thisBuildInfo->getImprovement() == NO_IMPROVEMENT && thisBuildInfo->getRoute() != NO_ROUTE) -#else - if(NULL != thisBuildInfo && thisBuildInfo->getRoute() != NO_ROUTE) -#endif { if(m_pUnitInfo->GetBuilds(iI)) { @@ -16610,22 +16015,16 @@ bool CvUnit::IsDead() const /// Over strategic resource limit? int CvUnit::GetStrategicResourceCombatPenalty() const { -#if defined(MOD_BALANCE_CORE_MILITARY_RESOURCES) if (MOD_BALANCE_CORE_MILITARY_RESOURCES) { // units cannot heal anymore, but strength is unaffected return 0; } -#endif + int iPenalty = 0; -#if defined(MOD_BALANCE_CORE) // barbs and city states don't require resources - if(isBarbarian() || GET_PLAYER(getOwner()).isMinorCiv()) -#else - // barbs don't have resources - if(isBarbarian()) -#endif + if (isBarbarian() || GET_PLAYER(getOwner()).isMinorCiv()) return iPenalty; CvPlayerAI& kPlayer = GET_PLAYER(getOwner()); @@ -16638,12 +16037,6 @@ int CvUnit::GetStrategicResourceCombatPenalty() const eResource = (ResourceTypes) iResourceLoop; int iAvailable = kPlayer.getNumResourceAvailable(eResource); -#if !defined(MOD_BALANCE_CORE) - if (kPlayer.isMinorCiv()) - { - iAvailable += kPlayer.getResourceExport(eResource); - } -#endif // Over resource limit? if(iAvailable < 0) @@ -19203,11 +18596,7 @@ void CvUnit::ChangeCapturedUnitsConscriptedCount(int iValue) // -------------------------------------------------------------------------------- bool CvUnit::IsHoveringUnit() const { -#if defined (MOD_CORE_HOVERING_UNITS) - return (GetHoveringUnitCount()>0) || (getDomainType()==DOMAIN_HOVER); -#else - return false; -#endif + return (MOD_CORE_HOVERING_UNITS && (GetHoveringUnitCount() > 0 || getDomainType() == DOMAIN_HOVER)); } // -------------------------------------------------------------------------------- @@ -20215,54 +19604,17 @@ bool CvUnit::isFull() const int CvUnit::cargoSpaceAvailable(SpecialUnitTypes eSpecialCargo, DomainTypes eDomainCargo) const { VALIDATE_OBJECT -#if defined(MOD_CARGO_SHIPS) - if(MOD_CARGO_SHIPS) - { - if(specialCargo() != NO_SPECIALUNIT && specialUnitCargoLoad() == NO_SPECIALUNIT) - { - if(specialCargo() != eSpecialCargo) - { - return 0; - } - } - if(specialCargo() != NO_SPECIALUNIT && specialUnitCargoLoad() != NO_SPECIALUNIT) - { - if(eSpecialCargo != specialCargo()) - { - if(eSpecialCargo != specialUnitCargoLoad()) - { - return 0; - } - } - } - } - else - { - if(specialCargo() != NO_SPECIALUNIT) - { - if(specialCargo() != eSpecialCargo) - { - return 0; - } - } - } -#else - if(specialCargo() != NO_SPECIALUNIT) + if (specialCargo() != NO_SPECIALUNIT && specialCargo() != eSpecialCargo) { - if(specialCargo() != eSpecialCargo) - { - return 0; - } - } -#endif - if(domainCargo() != NO_DOMAIN) - { - if(domainCargo() != eDomainCargo) + if (!MOD_CARGO_SHIPS || specialUnitCargoLoad() == NO_SPECIALUNIT || specialUnitCargoLoad() != eSpecialCargo) { return 0; } } + if (domainCargo() != NO_DOMAIN && domainCargo() != eDomainCargo) + return 0; + return std::max(0, (cargoSpace() - getCargo())); } @@ -21324,11 +20676,7 @@ void CvUnit::setXY(int iX, int iY, bool bGroup, bool bUpdate, bool bShow, bool b setInfoBarDirty(true); // if there is an enemy city nearby, alert any scripts to this -#if defined(MOD_EVENTS_CITY_BOMBARD) - int iAttackRange = (MOD_EVENTS_CITY_BOMBARD ? /*2*/ GD_INT_GET(MAX_CITY_ATTACK_RANGE) : /*2*/ GD_INT_GET(CITY_ATTACK_RANGE)); -#else - int iAttackRange = /*2*/ GD_INT_GET(CITY_ATTACK_RANGE); -#endif + int iAttackRange = MOD_EVENTS_CITY_BOMBARD ? /*2*/ GD_INT_GET(MAX_CITY_ATTACK_RANGE) : /*2*/ GD_INT_GET(CITY_ATTACK_RANGE); for(int iDX = -iAttackRange; iDX <= iAttackRange; iDX++) { for(int iDY = -iAttackRange; iDY <= iAttackRange; iDY++) @@ -21340,15 +20688,11 @@ void CvUnit::setXY(int iX, int iY, bool bGroup, bool bUpdate, bool bShow, bool b { // do it CvCity* pkPlotCity = pTargetPlot->getPlotCity(); -#if defined(MOD_EVENTS_CITY_BOMBARD) if (!MOD_EVENTS_CITY_BOMBARD || plotXYWithRangeCheck(getX(), getY(), iDX, iDY, pkPlotCity->getBombardRange())) { -#endif CvInterfacePtr pPlotCity = GC.WrapCityPointer(pkPlotCity); DLLUI->SetSpecificCityInfoDirty(pPlotCity.get(), CITY_UPDATE_TYPE_ENEMY_IN_RANGE); -#if defined(MOD_EVENTS_CITY_BOMBARD) } -#endif } } } @@ -21564,11 +20908,8 @@ void CvUnit::setReconPlot(CvPlot* pNewValue) if(pOldPlot != NULL) { if (canChangeVisibility()) -#if defined(MOD_PROMOTIONS_VARIABLE_RECON) pOldPlot->changeAdjacentSight(getTeam(), reconRange(), false, getSeeInvisibleType(), getFacingDirection(true), this); -#else - pOldPlot->changeAdjacentSight(getTeam(), /*6*/ GD_INT_GET(RECON_VISIBILITY_RANGE), false, getSeeInvisibleType(), getFacingDirection(true), *this); -#endif + pOldPlot->changeReconCount(-1); // changeAdjacentSight() tests for getReconCount() } @@ -21584,11 +20925,7 @@ void CvUnit::setReconPlot(CvPlot* pNewValue) pNewValue->changeReconCount(1); // changeAdjacentSight() tests for getReconCount() if (canChangeVisibility()) -#if defined(MOD_PROMOTIONS_VARIABLE_RECON) pNewValue->changeAdjacentSight(getTeam(), reconRange(), true, getSeeInvisibleType(), getFacingDirection(true), this); -#else - pNewValue->changeAdjacentSight(getTeam(), /*6*/ GD_INT_GET(RECON_VISIBILITY_RANGE), true, getSeeInvisibleType(), getFacingDirection(true), *this); -#endif } } } @@ -21838,11 +21175,7 @@ void CvUnit::changeMoves(int iChange) // -------------------------------------------------------------------------------- void CvUnit::restoreFullMoves() { -#if defined(MOD_PROMOTIONS_FLAGSHIP) if (IsGreatGeneral() || (MOD_PROMOTIONS_FLAGSHIP && IsGreatAdmiral())) -#else - if (IsGreatGeneral()) -#endif { setMoves( GetGreatGeneralStackMovement() ); } @@ -22075,19 +21408,11 @@ void CvUnit::changeExperienceTimes100(int iChangeTimes100, int iMax, bool bFromC { if(getDomainType() == DOMAIN_SEA) { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) kPlayer.changeNavalCombatExperienceTimes100((iChangeTimes100 * iCombatExperienceMod) / 100, (MOD_GLOBAL_LOCAL_GENERALS ? this : NULL)); -#else - kPlayer.changeNavalCombatExperienceTimes100((iChangeTimes100 * iCombatExperienceMod) / 100); -#endif } else { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) kPlayer.changeCombatExperienceTimes100((iChangeTimes100 * iCombatExperienceMod) / 100, (MOD_GLOBAL_LOCAL_GENERALS ? this : NULL)); -#else - kPlayer.changeCombatExperienceTimes100((iChangeTimes100 * iCombatExperienceMod) / 100); -#endif } } else @@ -22097,19 +21422,11 @@ void CvUnit::changeExperienceTimes100(int iChangeTimes100, int iMax, bool bFromC { if(getDomainType() == DOMAIN_SEA) { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) kPlayer.changeNavalCombatExperienceTimes100((iModdedChangeTimes100 * iCombatExperienceMod) / 100, (MOD_GLOBAL_LOCAL_GENERALS ? this : NULL)); -#else - kPlayer.changeNavalCombatExperienceTimes100((iModdedChangeTimes100 * iCombatExperienceMod) / 100); -#endif } else { -#if defined(MOD_GLOBAL_LOCAL_GENERALS) kPlayer.changeCombatExperienceTimes100((iModdedChangeTimes100 * iCombatExperienceMod) / 100, (MOD_GLOBAL_LOCAL_GENERALS ? this : NULL)); -#else - kPlayer.changeCombatExperienceTimes100((iModdedChangeTimes100 * iCombatExperienceMod) / 100); -#endif } } } @@ -23224,10 +22541,6 @@ void CvUnit::changeEnemyDamage(int iChange) { VALIDATE_OBJECT m_iEnemyDamage = (m_iEnemyDamage + iChange); -#if defined(MOD_BALANCE_CORE) -#else - CvAssert(getEnemyDamage() >= 0); -#endif } // -------------------------------------------------------------------------------- @@ -24313,11 +23626,7 @@ int CvUnit::GetGreatGeneralStackMovement(const CvPlot* pLoopPlot) const // Same domain if(pLoopUnit->getDomainType() == getDomainType()) { -#if defined(MOD_PROMOTIONS_FLAGSHIP) iRtnValue = std::max(iRtnValue, pLoopUnit->maxMoves()); -#else - iRtnValue = pLoopUnit->maxMoves(); -#endif break; } } @@ -24389,7 +23698,6 @@ int CvUnit::GetReverseGreatGeneralModifier(const CvPlot* pAtPlot) const #endif // -------------------------------------------------------------------------------- -#if defined(MOD_PROMOTIONS_IMPROVEMENT_BONUS) int CvUnit::GetNearbyImprovementModifier(const CvPlot* pAtPlot) const { if(pAtPlot == NULL) @@ -24398,13 +23706,11 @@ int CvUnit::GetNearbyImprovementModifier(const CvPlot* pAtPlot) const return std::max(GetNearbyImprovementModifierFromTraits(pAtPlot), GetNearbyImprovementModifierFromPromotions(pAtPlot)); } -int CvUnit::GetNearbyImprovementModifierFromTraits(const CvPlot* pAtPlot)const +int CvUnit::GetNearbyImprovementModifierFromTraits(const CvPlot* pAtPlot) const { CvPlayer& kPlayer = GET_PLAYER(m_eOwner); CvPlayerTraits* playerTraits = kPlayer.GetPlayerTraits(); -#if defined(MOD_BALANCE_CORE_MILITARY) - int iImprovementRange = playerTraits->GetNearbyImprovementBonusRange(); int iImprovementModifier = playerTraits->GetNearbyImprovementCombatBonus(); @@ -24429,31 +23735,15 @@ int CvUnit::GetNearbyImprovementModifierFromTraits(const CvPlot* pAtPlot)const } return 0; - -#else - - return GetNearbyImprovementModifier(playerTraits->GetCombatBonusImprovementType(), playerTraits->GetNearbyImprovementBonusRange(), playerTraits->GetNearbyImprovementCombatBonus(), pAtPlot); - -#endif } -int CvUnit::GetNearbyImprovementModifierFromPromotions(const CvPlot* pAtPlot)const +int CvUnit::GetNearbyImprovementModifierFromPromotions(const CvPlot* pAtPlot) const { return GetNearbyImprovementModifier(GetCombatBonusImprovement(), GetNearbyImprovementBonusRange(), GetNearbyImprovementCombatBonus(), pAtPlot); } -int CvUnit::GetNearbyImprovementModifier(ImprovementTypes eBonusImprovement, int iImprovementRange, int iImprovementModifier, const CvPlot* pAtPlot)const -{ -#else - -int CvUnit::GetNearbyImprovementModifier()const +int CvUnit::GetNearbyImprovementModifier(ImprovementTypes eBonusImprovement, int iImprovementRange, int iImprovementModifier, const CvPlot* pAtPlot) const { - VALIDATE_OBJECT - CvPlayer& kPlayer = GET_PLAYER(m_eOwner); - int iImprovementRange = kPlayer.GetPlayerTraits()->GetNearbyImprovementBonusRange(); - int iImprovementModifier = kPlayer.GetPlayerTraits()->GetNearbyImprovementCombatBonus(); -#endif - if(iImprovementModifier != 0) { if (pAtPlot == NULL) @@ -24474,11 +23764,7 @@ int CvUnit::GetNearbyImprovementModifier()const if(pLoopPlot != NULL) { // Is the right improvement here? -#if defined(MOD_PROMOTIONS_IMPROVEMENT_BONUS) if(pLoopPlot->getImprovementType() == eBonusImprovement) -#else - if(pLoopPlot->getImprovementType() == kPlayer.GetPlayerTraits()->GetCombatBonusImprovementType()) -#endif { return iImprovementModifier; } @@ -24786,8 +24072,9 @@ void CvUnit::DoConvertEnemyUnitToBarbarian(const CvPlot* pPlot) void CvUnit::DoConvertReligiousUnitsToMilitary(const CvPlot* pPlot) { - if (pPlot == NULL) + if (!pPlot) pPlot = plot(); + if (!pPlot) return; @@ -24797,120 +24084,31 @@ void CvUnit::DoConvertReligiousUnitsToMilitary(const CvPlot* pPlot) if (pPlot->getOwner() == NO_PLAYER) return; - if(GET_PLAYER(pPlot->getOwner()).GetPlayerTraits()->GetChanceToConvertReligiousUnits() > 0) + CvPlayer& kPlayer = GET_PLAYER(pPlot->getOwner()); + int iChanceToConvertReligiousUnit = kPlayer.GetPlayerTraits()->GetChanceToConvertReligiousUnits(); + if (iChanceToConvertReligiousUnit <= 0) + return; + + if (getTeam() == kPlayer.getTeam()) + return; + + if (GC.getGame().randRangeInclusive(1, 100, CvSeeder(pPlot->GetPseudoRandomSeed())) <= iChanceToConvertReligiousUnit) { - CvPlayer& kPlayer = GET_PLAYER(pPlot->getOwner()); - int iChanceToConvertReligiousUnit = kPlayer.GetPlayerTraits()->GetChanceToConvertReligiousUnits() > 0; - if (getTeam() != GET_TEAM(kPlayer.getTeam()).GetID()) + UnitTypes eUnit = kPlayer.GetCompetitiveSpawnUnitType(false, false, true, true); + if (eUnit == NO_UNIT) + return; + + CvUnit* pConvertUnit = kPlayer.initUnit(eUnit, this->getX(), this->getY(), NO_UNITAI, REASON_CONVERT, true); + pConvertUnit->convert(this, false); + CvNotifications* pNotifications = kPlayer.GetNotifications(); + if (pNotifications) { - CvUnit* pConvertUnit = NULL; - if (GC.getGame().randRangeInclusive(1, 100, CvSeeder(pPlot->GetPseudoRandomSeed())) <= iChanceToConvertReligiousUnit) - { - UnitTypes eBestLandUnit = NO_UNIT; - int iStrengthBestLandCombat = 0; - for(int iJ = 0; iJ < GC.getNumUnitClassInfos(); iJ++) - { - const UnitClassTypes eUnitClass = static_cast(iJ); - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo) - { - const UnitTypes eUnit = kPlayer.GetSpecificUnitType(eUnitClass); - CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnit); - if(pUnitEntry) - { - if(!kPlayer.canTrainUnit(eUnit)) - { - continue; - } - if(pUnitEntry->GetRangedCombat() > 0) - { - continue; - } - if(pUnitEntry->GetDomainType() == DOMAIN_LAND) - { - bool bBad = false; - ResourceTypes eResource; - for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++) - { - eResource = (ResourceTypes) iResourceLoop; - int iNumResource = pUnitEntry->GetResourceQuantityRequirement(eResource); - if (iNumResource > 0) - { - if(kPlayer.getNumResourceAvailable(eResource, true) < iNumResource) - { - bBad = true; - break; - } - } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - if (MOD_UNITS_RESOURCE_QUANTITY_TOTALS) - { - iNumResource = pUnitEntry->GetResourceQuantityTotal(eResource); - if (iNumResource > 0) - { - if (kPlayer.getNumResourceTotal(eResource, true) < iNumResource || kPlayer.getNumResourceAvailable(eResource, true) < 0) - { - bBad = true; - break; - } - } - } -#endif - } - if(bBad) - { - continue; - } - int iCombatLandStrength = (std::max(1, pUnitEntry->GetCombat())); - if(iCombatLandStrength > iStrengthBestLandCombat) - { - iStrengthBestLandCombat = iCombatLandStrength; - eBestLandUnit = eUnit; - } - } - } - } - } - if(eBestLandUnit != NO_UNIT) - { - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eBestLandUnit); - if(pkbUnitEntry) - { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - pConvertUnit = kPlayer.initUnit(eBestLandUnit, this->getX(), this->getY(), eUnitAI, REASON_CONVERT, true); - pConvertUnit->convert(this, false); - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_HUSSITE_CONVERSION"); - strText << pConvertUnit->getNameKey() << kPlayer.getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_HUSSITE_CONVERSION"); - strSummary << kPlayer.getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pConvertUnit->getX(), pConvertUnit->getY(), -1); - } - } - } - else - { - UnitTypes eWarrior = (UnitTypes)GC.getInfoTypeForString("UNIT_WARRIOR"); - CvUnitEntry* pkbUnitEntry = GC.getUnitInfo(eWarrior); - if(pkbUnitEntry) - { - UnitAITypes eUnitAI = pkbUnitEntry->GetDefaultUnitAIType(); - pConvertUnit = kPlayer.initUnit(eWarrior, this->getX(), this->getY(), eUnitAI, REASON_CONVERT, true); - pConvertUnit->convert(this, false); - CvNotifications* pNotifications = kPlayer.GetNotifications(); - if (pNotifications) - { - Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_HUSSITE_CONVERSION"); - strText << pConvertUnit->getNameKey() << kPlayer.getNameKey(); - Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_HUSSITE_CONVERSION"); - strSummary << kPlayer.getNameKey(); - pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pConvertUnit->getX(), pConvertUnit->getY(), -1); - } - } - } - } + // These text keys don't even exist! Please add before use + Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_HUSSITE_CONVERSION"); + strText << pConvertUnit->getNameKey() << kPlayer.getNameKey(); + Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_HUSSITE_CONVERSION"); + strSummary << kPlayer.getNameKey(); + pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pConvertUnit->getX(), pConvertUnit->getY(), -1); } } } @@ -24947,12 +24145,11 @@ bool CvUnit::IsGreatGeneral() const { VALIDATE_OBJECT -#if defined(MOD_BALANCE_CORE_MILITARY) - if(IsCombatUnit()) + if (IsCombatUnit()) return false; - if(getUnitInfo().GetUnitAIType(UNITAI_GENERAL)) + + if (getUnitInfo().GetUnitAIType(UNITAI_GENERAL)) return true; -#endif return GetGreatGeneralCount() > 0; } @@ -24976,12 +24173,11 @@ bool CvUnit::IsGreatAdmiral() const { VALIDATE_OBJECT -#if defined(MOD_BALANCE_CORE_MILITARY) - if(IsCombatUnit()) + if (IsCombatUnit()) return false; - if(getUnitInfo().GetUnitAIType(UNITAI_ADMIRAL)) + + if (getUnitInfo().GetUnitAIType(UNITAI_ADMIRAL)) return true; -#endif return GetGreatAdmiralCount() > 0; } @@ -26101,36 +25297,16 @@ void CvUnit::setTransportUnit(CvUnit* pTransportUnit) CvAssertMsg(pTransportUnit->cargoSpaceAvailable(getSpecialUnitType(), getDomainType()) > 0, "Cargo space is expected to be available"); m_transportUnit = pTransportUnit->GetIDInfo(); -#if defined(MOD_CARGO_SHIPS) - if(!MOD_CARGO_SHIPS) - { - if(getDomainType() != DOMAIN_AIR) - { - SetActivityType(ACTIVITY_SLEEP); - } - } -#else - if(getDomainType() != DOMAIN_AIR) + + if (!MOD_CARGO_SHIPS && getDomainType() != DOMAIN_AIR) { SetActivityType(ACTIVITY_SLEEP); } -#endif -#if defined(MOD_CARGO_SHIPS) - if(MOD_CARGO_SHIPS) - { - if(GC.getGame().isFinalInitialized() && getDomainType() == DOMAIN_AIR) - { - finishMoves(); - } - } - else + + if(GC.getGame().isFinalInitialized() && (!MOD_CARGO_SHIPS || getDomainType() == DOMAIN_AIR)) { - if(GC.getGame().isFinalInitialized()) - { - finishMoves(); - } + finishMoves(); } -#endif pTransportUnit->changeCargo(1); pTransportUnit->SetActivityType(ACTIVITY_AWAKE); } @@ -26212,21 +25388,13 @@ const CvString CvUnit::getName() const if(m_strName.IsEmpty()) { -#if defined(MOD_PROMOTIONS_UNIT_NAMING) // For units, getUnitInfo().GetTextKey() (ie getNameKey()) and getUnitInfo().GetDescription() are the same return GetLocalizedText(getNameKey()); -#else - return getUnitInfo().GetDescription(); -#endif } Localization::String name = Localization::Lookup(m_strName); -#if defined(MOD_PROMOTIONS_UNIT_NAMING) - // For units, getUnitInfo().GetTextKey() (ie getNameKey()) and getUnitInfo().GetDescription() are the same + // For units, getUnitInfo().GetTextKey() (ie getNameKey()) and getUnitInfo().GetDescription() are the same strBuffer.Format("%s (%s)", name.toUTF8(), GetLocalizedText(getNameKey()).c_str()); -#else - strBuffer.Format("%s (%s)", name.toUTF8(), getUnitInfo().GetDescription()); -#endif return strBuffer; } @@ -27514,38 +26682,35 @@ bool CvUnit::canAcquirePromotion(PromotionTypes ePromotion) const { return false; } - -#if defined(MOD_EVENTS_UNIT_UPGRADES) - if (MOD_EVENTS_UNIT_UPGRADES) { - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CanHavePromotion, getOwner(), GetID(), ePromotion) == GAMEEVENTRETURN_FALSE) { + + if (MOD_EVENTS_UNIT_UPGRADES) + { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CanHavePromotion, getOwner(), GetID(), ePromotion) == GAMEEVENTRETURN_FALSE) return false; - } - if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_UnitCanHavePromotion, getOwner(), GetID(), ePromotion) == GAMEEVENTRETURN_FALSE) { + if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_UnitCanHavePromotion, getOwner(), GetID(), ePromotion) == GAMEEVENTRETURN_FALSE) return false; - } - } else { -#endif - ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); - if (pkScriptSystem) + } + else { - CvLuaArgsHandle args; - args->Push(((int)getOwner())); - args->Push(GetID()); - args->Push(ePromotion); - - bool bResult = false; - if (LuaSupport::CallTestAll(pkScriptSystem, "CanHavePromotion", args.get(), bResult)) + ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem(); + if (pkScriptSystem) { - if (!bResult) + CvLuaArgsHandle args; + args->Push(((int)getOwner())); + args->Push(GetID()); + args->Push(ePromotion); + + bool bResult = false; + if (LuaSupport::CallTestAll(pkScriptSystem, "CanHavePromotion", args.get(), bResult)) { - return false; + if (!bResult) + { + return false; + } } } } -#if defined(MOD_EVENTS_UNIT_UPGRADES) - } -#endif return true; } @@ -33630,7 +32795,7 @@ bool CvUnit::IsCargoCombatUnit() const } // -------------------------------------------------------------------------------- #endif -#if defined(MOD_CARGO_SHIPS) + void CvUnit::DoCargoPromotions(CvUnit& cargounit) { if(cargounit.IsCargoCombatUnit() && cargounit.hasCargo()) @@ -33739,4 +32904,90 @@ void CvUnit::RemoveCargoPromotions(CvUnit& cargounit) cargounit.SetBaseCombatStrength(cargounit.getUnitInfo().GetCombat()); } } -#endif + +void CvUnit::DoGreatPersonSpawnBonus(CvCity* pSpawnCity) +{ + CvAssert(pSpawnCity); + + if (!IsGreatPerson()) + return; + + CvPlayer& kPlayer = GET_PLAYER(getOwner()); + + // Start local WLTKD + if (kPlayer.GetPlayerTraits()->IsGPWLTKD()) + { + int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; + iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); + iWLTKD /= 100; + + if (iWLTKD > 0) + { + pSpawnCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); + CvNotifications* pNotifications = kPlayer.GetNotifications(); + if (pNotifications) + { + Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UA"); + strText << getNameKey() << pSpawnCity->getNameKey(); + Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UA"); + strSummary << pSpawnCity->getNameKey(); + pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pSpawnCity->getX(), pSpawnCity->getY(), -1); + } + } + } + + // Start global WLTKD + if (isWLKTKDOnBirth()) + { + CvCity* pLoopCity = NULL; + int iLoop = 0; + for (pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop)) + { + int iWLTKD = /*6*/ GD_INT_GET(CITY_RESOURCE_WLTKD_TURNS) / 3; + iWLTKD *= GC.getGame().getGameSpeedInfo().getTrainPercent(); + iWLTKD /= 100; + + if (iWLTKD > 0) + { + pLoopCity->ChangeWeLoveTheKingDayCounter(iWLTKD, true); + CvNotifications* pNotifications = kPlayer.GetNotifications(); + if (pNotifications) + { + Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_WLTKD_UNIT"); + strText << getNameKey() << pLoopCity->getNameKey(); + Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_WLTKD_UNIT"); + strSummary << pLoopCity->getNameKey(); + pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), pLoopCity->getX(), pLoopCity->getY(), -1); + } + } + } + } + + // Start Golden Age + if (isGoldenAgeOnBirth()) + { + kPlayer.changeGoldenAgeTurns(kPlayer.getGoldenAgeLength()); + } + + // Give Culture to Capital + // TODO: Change it to an instant yield? + if (isCultureBoost()) + { + // Can't possibly have no capital when there's a spawn city + CvAssert(kPlayer.getCapitalCity()); + + int iValue = kPlayer.GetTotalJONSCulturePerTurn() * 4; + kPlayer.changeJONSCulture(iValue); + kPlayer.getCapitalCity()->ChangeJONSCultureStored(iValue); + + CvNotifications* pNotifications = kPlayer.GetNotifications(); + if (pNotifications) + { + Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_CULTURE_UNIT"); + strText << getNameKey(); + Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CULTURE_UNIT"); + strSummary << getNameKey(); + pNotifications->Add(NOTIFICATION_GENERIC, strText.toUTF8(), strSummary.toUTF8(), getX(), getY(), -1); + } + } +} diff --git a/CvGameCoreDLL_Expansion2/CvUnit.h b/CvGameCoreDLL_Expansion2/CvUnit.h index 04626cd092..826931f9e6 100644 --- a/CvGameCoreDLL_Expansion2/CvUnit.h +++ b/CvGameCoreDLL_Expansion2/CvUnit.h @@ -31,9 +31,7 @@ class CvPlot; class CvUnitEntry; class CvUnitReligion; -#if defined(MOD_BALANCE_CORE_MILITARY) class CvTacticalMove; -#endif typedef std::vector UnitIdContainer; //use a vector as most of the time this will be empty typedef std::vector> TerrainTypeCounter; @@ -237,13 +235,8 @@ class CvUnit MOVE_RESULT_NO_TARGET = 0xFFFFFFFB, //attack not required }; -#if defined(MOD_BALANCE_CORE) void init(int iID, UnitTypes eUnit, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason eReason, bool bNoMove, bool bSetupGraphical = true, int iMapLayer = DEFAULT_UNIT_MAP_LAYER, int iNumGoodyHutsPopped = 0, ContractTypes eContract = NO_CONTRACT, bool bHistoric = true, CvUnit* pPassUnit = NULL); void initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason eReason, bool bNoMove, bool bSetupGraphical = true, int iMapLayer = DEFAULT_UNIT_MAP_LAYER, int iNumGoodyHutsPopped = 0, ContractTypes eContract = NO_CONTRACT, bool bHistoric = true, bool bSkipNaming = false, CvUnit* pPassUnit = NULL); -#else - void init(int iID, UnitTypes eUnit, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason eReason, bool bNoMove, bool bSetupGraphical = true, int iMapLayer = DEFAULT_UNIT_MAP_LAYER, int iNumGoodyHutsPopped = 0, ContractTypes eContract = NO_CONTRACT, bool bHistoric = true); - void initWithNameOffset(int iID, UnitTypes eUnit, int iNameOffset, UnitAITypes eUnitAI, PlayerTypes eOwner, int iX, int iY, UnitCreationReason eReason, bool bNoMove, bool bSetupGraphical = true, int iMapLayer = DEFAULT_UNIT_MAP_LAYER, int iNumGoodyHutsPopped = 0, ContractTypes eContract = NO_CONTRACT, bool bHistoric = true, bool bSkipNaming = false); -#endif void uninit(); @@ -256,11 +249,7 @@ class CvUnit static int CalcExperienceTimes100ForConvert(PlayerTypes eFromPlayer, PlayerTypes eToPlayer, int iExperienceTimes100); void grantExperienceFromLostPromotions(int iNumLost); -#if defined(MOD_BALANCE_CORE) void convert(CvUnit* pUnit, bool bIsUpgrade); -#else - void convert(CvUnit* pUnit, bool bIsUpgrade); -#endif void kill(bool bDelay, PlayerTypes ePlayer = NO_PLAYER); void doTurn(); @@ -418,10 +407,9 @@ class CvUnit int GetDanger(const CvPlot* pAtPlot=NULL) const; int GetDanger(const CvPlot* pAtPlot, const UnitIdContainer& unitsToIgnore, int iExtraDamage) const; -#if defined(MOD_GLOBAL_RELOCATION) const CvPlot* getAirliftFromPlot(const CvPlot* pPlot) const; const CvPlot* getAirliftToPlot(const CvPlot* pPlot, bool bIncludeCities) const; -#endif + bool canAirlift(const CvPlot* pPlot) const; bool canAirliftAt(const CvPlot* pPlot, int iX, int iY) const; bool airlift(int iX, int iY); @@ -1030,11 +1018,6 @@ class CvUnit int unitCombatModifier(UnitCombatTypes eUnitCombat) const; int domainModifier(DomainTypes eDomain) const; -#if defined(MOD_BALANCE_CORE) - //int combatModPerAdjacentUnitCombatAttackMod(UnitCombatTypes eIndex) const; - int combatModPerAdjacentUnitCombatDefenseMod(UnitCombatTypes eIndex) const; -#endif - int GetYieldModifier(YieldTypes eYield) const; void SetYieldModifier(YieldTypes eYield, int iValue); @@ -1405,11 +1388,9 @@ class CvUnit int GetGreatGeneralStackMovement(const CvPlot* pLoopPlot = NULL) const; int GetReverseGreatGeneralModifier(const CvPlot* pAtPlot = NULL) const; int GetNearbyImprovementModifier(const CvPlot* pAtPlot = NULL) const; -#if defined(MOD_PROMOTIONS_IMPROVEMENT_BONUS) int GetNearbyImprovementModifierFromTraits(const CvPlot* pAtPlot = NULL) const; int GetNearbyImprovementModifierFromPromotions(const CvPlot* pAtPlot = NULL) const; int GetNearbyImprovementModifier(ImprovementTypes eBonusImprovement, int iImprovementRange, int iImprovementModifier, const CvPlot* pAtPlot = NULL) const; -#endif bool IsCombatSupportUnit() const; @@ -1683,7 +1664,6 @@ class CvUnit inline bool isFeatureDoubleMove(FeatureTypes eIndex) const { return getFeatureDoubleMoveCount(eIndex) > 0; } void changeFeatureDoubleMoveCount(FeatureTypes eIndex, int iChange); -#if defined(MOD_PROMOTIONS_HALF_MOVE) int getTerrainHalfMoveCount(TerrainTypes eIndex) const; inline bool isTerrainHalfMove(TerrainTypes eIndex) const { return getTerrainHalfMoveCount(eIndex) > 0; } void changeTerrainHalfMoveCount(TerrainTypes eIndex, int iChange); @@ -1699,7 +1679,7 @@ class CvUnit int getFeatureExtraMoveCount(FeatureTypes eIndex) const; inline bool isFeatureExtraMove(FeatureTypes eIndex) const { return getFeatureExtraMoveCount(eIndex) > 0; } void changeFeatureExtraMoveCount(FeatureTypes eIndex, int iChange); -#endif + #if defined(MOD_BALANCE_CORE) int getTerrainDoubleHeal(TerrainTypes eIndex) const; bool isTerrainDoubleHeal(TerrainTypes eIndex) const; @@ -2010,6 +1990,8 @@ class CvUnit bool getCaptureDefinition(CvUnitCaptureDefinition* pkCaptureDef, PlayerTypes eCapturingPlayer = NO_PLAYER); static CvUnit* createCaptureUnit(const CvUnitCaptureDefinition& kCaptureDef, bool ForcedCapture = false); + void DoGreatPersonSpawnBonus(CvCity* pSpawnCity); + protected: const MissionData* HeadMissionData() const; MissionData* HeadMissionData(); @@ -2361,13 +2343,13 @@ class CvUnit TerrainTypeCounter m_terrainDoubleMoveCount; FeatureTypeCounter m_featureIgnoreCostCount; FeatureTypeCounter m_featureDoubleMoveCount; -#if defined(MOD_PROMOTIONS_HALF_MOVE) + TerrainTypeCounter m_terrainHalfMoveCount; FeatureTypeCounter m_featureHalfMoveCount; TerrainTypeCounter m_terrainExtraMoveCount; FeatureTypeCounter m_featureExtraMoveCount; -#endif + #if defined(MOD_BALANCE_CORE) TerrainTypeCounter m_terrainDoubleHeal; FeatureTypeCounter m_featureDoubleHeal; diff --git a/CvGameCoreDLL_Expansion2/CvUnitClasses.cpp b/CvGameCoreDLL_Expansion2/CvUnitClasses.cpp index 5a3b78aad9..65327a89ac 100644 --- a/CvGameCoreDLL_Expansion2/CvUnitClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvUnitClasses.cpp @@ -194,9 +194,9 @@ CvUnitEntry::CvUnitEntry(void) : m_ppiEraUnitCombatType(NULL), m_ppiEraUnitPromotions(NULL), #endif -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) + m_piResourceQuantityTotals(), -#endif + #if defined(MOD_GLOBAL_STACKING_RULES) m_iNumberStackingUnits(0), #endif @@ -233,9 +233,9 @@ CvUnitEntry::~CvUnitEntry(void) SAFE_DELETE_ARRAY(m_paszMiddleArtDefineTags); SAFE_DELETE_ARRAY(m_paszUnitNames); SAFE_DELETE_ARRAY(m_paeGreatWorks); -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) + m_piResourceQuantityTotals.clear(); -#endif + #if defined(MOD_BALANCE_CORE) SAFE_DELETE_ARRAY(m_paeGreatPersonEra); SAFE_DELETE_ARRAY(m_piEraCombatStrength); @@ -1642,7 +1642,6 @@ int* CvUnitEntry::GetUnitNewEraPromotionsChangesArray(int i) } #endif -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) /// Player must have gross number of resources to build (does not consume) int CvUnitEntry::GetResourceQuantityTotal(int i) const { @@ -1657,7 +1656,6 @@ int CvUnitEntry::GetResourceQuantityTotal(int i) const return 0; } -#endif /// Initial set of promotions for this unit bool CvUnitEntry::GetFreePromotions(int i) const @@ -2113,11 +2111,7 @@ void CvUnitXMLEntries::DeleteArray() /// Get a specific entry CvUnitEntry* CvUnitXMLEntries::GetEntry(int index) { -#if defined(MOD_BALANCE_CORE) - return (index!=NO_UNIT) ? m_paUnitEntries[index] : NULL; -#else - return m_paUnitEntries[index]; -#endif + return (index != NO_UNIT) ? m_paUnitEntries[index] : NULL; } /// Helper function to read in an integer array of data sized according to number of unit types diff --git a/CvGameCoreDLL_Expansion2/CvUnitClasses.h b/CvGameCoreDLL_Expansion2/CvUnitClasses.h index be0bfedb96..1e495f4322 100644 --- a/CvGameCoreDLL_Expansion2/CvUnitClasses.h +++ b/CvGameCoreDLL_Expansion2/CvUnitClasses.h @@ -242,9 +242,9 @@ class CvUnitEntry: public CvBaseInfo int GetUnitNewEraPromotions(int i, int j) const; int* GetUnitNewEraPromotionsChangesArray(int i); #endif -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) + int GetResourceQuantityTotal(int i) const; -#endif + bool GetFreePromotions(int i) const; // Derived fields (not in XML) @@ -459,9 +459,9 @@ class CvUnitEntry: public CvBaseInfo int** m_ppiEraUnitCombatType; int** m_ppiEraUnitPromotions; #endif -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) + std::map m_piResourceQuantityTotals; -#endif + bool* m_pbFreePromotions; CvString* m_paszEarlyArtDefineTags; diff --git a/CvGameCoreDLL_Expansion2/CvUnitCombat.cpp b/CvGameCoreDLL_Expansion2/CvUnitCombat.cpp index 29665b8fe3..13a1c89db8 100644 --- a/CvGameCoreDLL_Expansion2/CvUnitCombat.cpp +++ b/CvGameCoreDLL_Expansion2/CvUnitCombat.cpp @@ -3761,14 +3761,10 @@ CvUnitCombat::ATTACK_RESULT CvUnitCombat::Attack(CvUnit& kAttacker, CvPlot& targ kAttacker.SetAutomateType(NO_AUTOMATE); pDefender->SetAutomateType(NO_AUTOMATE); -#if !defined(NO_TUTORIALS) - // slewis - tutorial'd if(kAttacker.getOwner() == GC.getGame().getActivePlayer()) { GC.getGame().SetEverAttackedTutorial(true); } - // end tutorial'd -#endif // handle the Zulu special thrown spear first attack ATTACK_RESULT eFireSupportResult = ATTACK_ABORTED; diff --git a/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp b/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp index 5cd8f553c1..7b8d77395f 100644 --- a/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvVotingClasses.cpp @@ -8814,7 +8814,9 @@ void CvLeague::DoProjectReward(PlayerTypes ePlayer, LeagueProjectTypes eLeaguePr { CvLeagueProjectEntry* pProjectInfo = GC.getLeagueProjectInfo(eLeagueProject); CvAssert(pProjectInfo); - if (!pProjectInfo) return; + + CvPlayer& kPlayer = GET_PLAYER(ePlayer); + CvTeam& kTeam = GET_TEAM(kPlayer.getTeam()); // Which rewards do we get? //antonjs: A switch statement in its natural habitat without break statements...a rare sight indeed @@ -8839,23 +8841,23 @@ void CvLeague::DoProjectReward(PlayerTypes ePlayer, LeagueProjectTypes eLeaguePr } } - for (uint i = 0; i < veRewards.size(); i++) + for (vector::iterator it = veRewards.begin(); it != veRewards.end(); ++it) { - CvLeagueProjectRewardEntry* pRewardInfo = GC.getLeagueProjectRewardInfo(veRewards[i]); + CvLeagueProjectRewardEntry* pRewardInfo = GC.getLeagueProjectRewardInfo(*it); CvAssert(pRewardInfo); - if (!pRewardInfo) continue; // Free Building in Capital - if (pRewardInfo->GetBuilding() != NO_BUILDING) + BuildingTypes eBuilding = pRewardInfo->GetBuilding(); + if (eBuilding != NO_BUILDING) { - CvCity* pCapital = GET_PLAYER(ePlayer).getCapitalCity(); + CvCity* pCapital = kPlayer.getCapitalCity(); CvAssertMsg(pCapital, "Player does not have a capital city. Please send Anton your save file and version."); if (pCapital) { - CvBuildingEntry* pBuildingInfo = GC.getBuildingInfo(pRewardInfo->GetBuilding()); + CvBuildingEntry* pBuildingInfo = GC.getBuildingInfo(eBuilding); if (pBuildingInfo) { - pCapital->CreateBuilding(pRewardInfo->GetBuilding()); + pCapital->CreateBuilding(eBuilding); pCapital->CleanUpQueue(); // cleans out items from the queue that may be invalidated by the recent construction } } @@ -8864,32 +8866,32 @@ void CvLeague::DoProjectReward(PlayerTypes ePlayer, LeagueProjectTypes eLeaguePr // Happiness if (pRewardInfo->GetHappiness() != 0) { - GET_PLAYER(ePlayer).ChangeHappinessFromLeagues(pRewardInfo->GetHappiness()); - GET_PLAYER(ePlayer).CalculateNetHappiness(); + kPlayer.ChangeHappinessFromLeagues(pRewardInfo->GetHappiness()); + kPlayer.CalculateNetHappiness(); } // Free Social Policy if (pRewardInfo->GetFreeSocialPolicies() > 0) { - GET_PLAYER(ePlayer).ChangeNumFreePolicies(pRewardInfo->GetFreeSocialPolicies()); + kPlayer.ChangeNumFreePolicies(pRewardInfo->GetFreeSocialPolicies()); } // Temporary Culture Modifier if (pRewardInfo->GetCultureBonusTurns() > 0) { - GET_PLAYER(ePlayer).ChangeCultureBonusTurns(pRewardInfo->GetCultureBonusTurns()); + kPlayer.ChangeCultureBonusTurns(pRewardInfo->GetCultureBonusTurns()); } // Temporary Tourism Modifier if (pRewardInfo->GetTourismBonusTurns() > 0) { - GET_PLAYER(ePlayer).ChangeTourismBonusTurns(pRewardInfo->GetTourismBonusTurns()); + kPlayer.ChangeTourismBonusTurns(pRewardInfo->GetTourismBonusTurns()); } // Golden Age Points if (pRewardInfo->GetGoldenAgePoints() > 0) { - GET_PLAYER(ePlayer).ChangeGoldenAgeProgressMeter(pRewardInfo->GetGoldenAgePoints()); + kPlayer.ChangeGoldenAgeProgressMeter(pRewardInfo->GetGoldenAgePoints()); } // City-State Influence Boost @@ -8898,72 +8900,72 @@ void CvLeague::DoProjectReward(PlayerTypes ePlayer, LeagueProjectTypes eLeaguePr { for (int iMinorCivLoop = MAX_MAJOR_CIVS; iMinorCivLoop < MAX_CIV_PLAYERS; iMinorCivLoop++) { - PlayerTypes eMinorCivLoop = (PlayerTypes) iMinorCivLoop; - if (GET_PLAYER(eMinorCivLoop).isAlive() && GET_TEAM(GET_PLAYER(ePlayer).getTeam()).isHasMet(GET_PLAYER(eMinorCivLoop).getTeam())) + PlayerTypes eMinorCivLoop = static_cast(iMinorCivLoop); + CvPlayer& kMinorCivLoop = GET_PLAYER(eMinorCivLoop); + if (kMinorCivLoop.isAlive() && kTeam.isHasMet(kMinorCivLoop.getTeam())) { - GET_PLAYER(eMinorCivLoop).GetMinorCivAI()->ChangeFriendshipWithMajor(ePlayer, pRewardInfo->GetCityStateInfluenceBoost()); + kMinorCivLoop.GetMinorCivAI()->ChangeFriendshipWithMajor(ePlayer, pRewardInfo->GetCityStateInfluenceBoost()); } } } // Beaker boost based on previous turns + // TODO: Turn this into an instant yield if (pRewardInfo->GetBaseBeakersTurnsToCount() > 0) { int iPreviousTurnsToCount = pRewardInfo->GetBaseBeakersTurnsToCount(); - int iBeakersBonus = GET_PLAYER(ePlayer).getYieldPerTurnHistory(YIELD_SCIENCE, iPreviousTurnsToCount); - TechTypes eCurrentTech = GET_PLAYER(ePlayer).GetPlayerTechs()->GetCurrentResearch(); - if(eCurrentTech == NO_TECH) + int iBeakersBonus = kPlayer.getYieldPerTurnHistory(YIELD_SCIENCE, iPreviousTurnsToCount); + TechTypes eCurrentTech = kPlayer.GetPlayerTechs()->GetCurrentResearch(); + if (eCurrentTech == NO_TECH) { - GET_PLAYER(ePlayer).changeOverflowResearch(iBeakersBonus); + kPlayer.changeOverflowResearch(iBeakersBonus); } else { - GET_TEAM(GET_PLAYER(ePlayer).getTeam()).GetTeamTechs()->ChangeResearchProgress(eCurrentTech, iBeakersBonus, ePlayer); + kTeam.GetTeamTechs()->ChangeResearchProgress(eCurrentTech, iBeakersBonus, ePlayer); } } // Free unit class - if (pRewardInfo->GetFreeUnitClass() != NO_UNITCLASS) + const UnitClassTypes eUnitClass = pRewardInfo->GetFreeUnitClass(); + const UnitTypes eUnit = kPlayer.GetSpecificUnitType(eUnitClass); + if (eUnit != NO_UNIT) { - UnitTypes eUnit = GET_PLAYER(ePlayer).GetSpecificUnitType(pRewardInfo->GetFreeUnitClass()); - if (eUnit != NO_UNIT) + CvCity* pCapital = kPlayer.getCapitalCity(); + if (pCapital) { - CvCity* pCapital = GET_PLAYER(ePlayer).getCapitalCity(); - if (pCapital) + CvPlot* pSpawnPlot = pCapital->plot(); + CvUnitEntry* pUnitInfo = GC.getUnitInfo(eUnit); + if (pUnitInfo) { - CvPlot* pSpawnPlot = pCapital->plot(); - - CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit); - if (pkUnitInfo) + if (pUnitInfo->GetDomainType() == DOMAIN_SEA) { - if (pkUnitInfo->GetDomainType() == DOMAIN_SEA) - { - CvPlot* pWaterSpawnPlot = GET_PLAYER(ePlayer).GetBestCoastalSpawnPlot(NULL); - if (pWaterSpawnPlot) - pSpawnPlot = pWaterSpawnPlot; - } + CvPlot* pWaterSpawnPlot = kPlayer.GetBestCoastalSpawnPlot(NULL); + if (pWaterSpawnPlot) + pSpawnPlot = pWaterSpawnPlot; } - - CvUnit* pUnit = GET_PLAYER(ePlayer).initUnit(eUnit, pSpawnPlot->getX(), pSpawnPlot->getY()); - pCapital->addProductionExperience(pUnit); - pUnit->jumpToNearestValidPlot(); } + + CvUnit* pUnit = kPlayer.initUnit(eUnit, pSpawnPlot->getX(), pSpawnPlot->getY()); + pCapital->addProductionExperience(pUnit); + if (!pUnit->jumpToNearestValidPlot()) + pUnit->kill(false); } } - //CSD Project Rewards if (pRewardInfo->GetAttackBonusTurns() > 0) { - GET_PLAYER(ePlayer).ChangeAttackBonusTurns(pRewardInfo->GetAttackBonusTurns()); + kPlayer.ChangeAttackBonusTurns(pRewardInfo->GetAttackBonusTurns()); } + if (pRewardInfo->GetBaseFreeUnits() > 0) { - GET_PLAYER(ePlayer).changeBaseFreeUnits(pRewardInfo->GetBaseFreeUnits()); + kPlayer.changeBaseFreeUnits(pRewardInfo->GetBaseFreeUnits()); } - // Temporary Culture Modifier + if (pRewardInfo->GetNumFreeGreatPeople() > 0) { - GET_PLAYER(ePlayer).ChangeNumFreeGreatPeople(pRewardInfo->GetNumFreeGreatPeople()); + kPlayer.ChangeNumFreeGreatPeople(pRewardInfo->GetNumFreeGreatPeople()); } } } diff --git a/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.cpp b/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.cpp index 639f9d7c77..a5ba4ce7e1 100644 --- a/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.cpp +++ b/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.cpp @@ -291,9 +291,7 @@ void CvLuaGame::RegisterMembers(lua_State* L) Method(GetResourceUsageType); -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) Method(GetNumResourceTotalRequiredForUnit); -#endif Method(GetNumResourceRequiredForUnit); Method(GetNumResourceRequiredForBuilding); @@ -2002,7 +2000,7 @@ int CvLuaGame::lGetResourceUsageType(lua_State* L) return 1; } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) + //------------------------------------------------------------------------------ int CvLuaGame::lGetNumResourceTotalRequiredForUnit(lua_State* L) { @@ -2021,7 +2019,6 @@ int CvLuaGame::lGetNumResourceTotalRequiredForUnit(lua_State* L) return 1; } -#endif //------------------------------------------------------------------------------ int CvLuaGame::lGetNumResourceRequiredForUnit(lua_State* L) { diff --git a/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.h b/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.h index 440b44e88a..df52dc8724 100644 --- a/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.h +++ b/CvGameCoreDLL_Expansion2/Lua/CvLuaGame.h @@ -274,10 +274,7 @@ class CvLuaGame : public CvLuaStaticInstance static int lGetResourceUsageType(lua_State* L); -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) static int lGetNumResourceTotalRequiredForUnit(lua_State* L); -#endif - static int lGetNumResourceRequiredForUnit(lua_State* L); static int lGetNumResourceRequiredForBuilding(lua_State* L); diff --git a/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp b/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp index 3a34d8cf22..08af8b14bf 100644 --- a/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp +++ b/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp @@ -3350,17 +3350,13 @@ int CvLuaPlayer::lGetInfluenceTradeRouteGoldBonus(lua_State* L) { CvPlayerAI* pkPlayer = GetInstance(L); PlayerTypes eOtherPlayer = (PlayerTypes)lua_tointeger(L, 2); - -#if defined(MOD_BALANCE_CORE_GOLD_INTERNAL_TRADE_ROUTES) + int iResult = 0; PlayerTypes ePlayer = pkPlayer->GetID(); if (ePlayer != eOtherPlayer) { iResult = pkPlayer->GetCulture()->GetInfluenceTradeRouteGoldBonus(eOtherPlayer); } -#else - const int iResult = pkPlayer->GetCulture()->GetInfluenceTradeRouteGoldBonus(eOtherPlayer); -#endif lua_pushinteger(L, iResult); return 1; } @@ -3516,16 +3512,13 @@ int CvLuaPlayer::lGetInfluenceTradeRouteScienceBonus(lua_State* L) { CvPlayerAI* pkPlayer = GetInstance(L); PlayerTypes eOtherPlayer = (PlayerTypes)lua_tointeger(L, 2); -#if defined(MOD_BALANCE_CORE) && defined(MOD_BALANCE_CORE_GOLD_INTERNAL_TRADE_ROUTES) + int iResult = 0; PlayerTypes ePlayer = pkPlayer->GetID(); if (ePlayer != eOtherPlayer) { iResult = pkPlayer->GetCulture()->GetInfluenceTradeRouteScienceBonus(eOtherPlayer); } -#else - const int iResult = pkPlayer->GetCulture()->GetInfluenceTradeRouteScienceBonus(eOtherPlayer); -#endif lua_pushinteger(L, iResult); return 1; } @@ -3673,12 +3666,8 @@ int CvLuaPlayer::lChangeInfluenceOnPlayer(lua_State* L) int CvLuaPlayer::lDoSwapGreatWorks(lua_State* L) { CvPlayerAI* pkPlayer = GetInstance(L); -#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES) YieldTypes eFocusYield = static_cast(lua_tointeger(L, 2)); pkPlayer->GetCulture()->DoSwapGreatWorks(eFocusYield); -#else - pkPlayer->GetCulture()->DoSwapGreatWorks(); -#endif return 0; } //------------------------------------------------------------------------------ @@ -3905,12 +3894,8 @@ int CvLuaPlayer::lCanCreatePantheon(lua_State* L) int CvLuaPlayer::lHasCreatedReligion(lua_State* L) { CvPlayerAI* pkPlayer = GetInstance(L); -#if defined(MOD_RELIGION_LOCAL_RELIGIONS) const bool bIgnoreLocal = luaL_optbool(L, 2, false); const bool bResult = pkPlayer->GetReligions()->HasCreatedReligion(bIgnoreLocal); -#else - const bool bResult = pkPlayer->GetReligions()->HasCreatedReligion(); -#endif lua_pushboolean(L, bResult); return 1; @@ -4038,11 +4023,7 @@ int CvLuaPlayer::lGetMinimumFaithNextGreatProphet(lua_State* L) { CvPlayerAI* pkPlayer = GetInstance(L); -#if defined(MOD_GLOBAL_TRULY_FREE_GP) int iFaith = pkPlayer->GetReligions()->GetCostNextProphet(true /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/, MOD_GLOBAL_TRULY_FREE_GP); -#else - int iFaith = pkPlayer->GetReligions()->GetCostNextProphet(true /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/); -#endif lua_pushinteger(L, iFaith); return 1; @@ -6874,15 +6855,11 @@ int CvLuaPlayer::lGetPolicyBranchChosen(lua_State* L) int CvLuaPlayer::lGetNumPolicies(lua_State* L) { CvPlayerAI* pkPlayer = GetInstance(L); -#if defined(MOD_BALANCE_CORE) bool bIgnoreFinishers = luaL_optbool(L, 2, false); bool bIgnoreDummy = luaL_optbool(L, 3, false); if(pkPlayer->GetPlayerPolicies()) { const int iResult = pkPlayer->GetPlayerPolicies()->GetNumPoliciesOwned(bIgnoreFinishers, bIgnoreDummy); -#else - const int iResult = pkPlayer->GetPlayerPolicies()->GetNumPoliciesOwned(); -#endif lua_pushinteger(L, iResult); return 1; } @@ -7210,15 +7187,11 @@ int CvLuaPlayer::lGetAttackBonusTurns(lua_State* L) //int GetCultureBonusTurns(); int CvLuaPlayer::lGetCultureBonusTurns(lua_State* L) { -#if defined(MOD_BALANCE_CORE) CvPlayerAI* pkPlayer = GetInstance(L); const int iResult = (pkPlayer->GetCultureBonusTurns() + pkPlayer->GetCultureBonusTurnsConquest()); lua_pushinteger(L, iResult); return 1; -#else - return BasicLuaMethod(L, &CvPlayerAI::GetCultureBonusTurns); -#endif } //------------------------------------------------------------------------------ @@ -7429,13 +7402,8 @@ int CvLuaPlayer::lCreateGreatGeneral(lua_State* L) const UnitTypes eGreatPersonUnit = (UnitTypes)lua_tointeger(L, 2); const int x = lua_tointeger(L, 3); const int y = lua_tointeger(L, 4); - -#if defined(MOD_GLOBAL_TRULY_FREE_GP) const bool bIsFree = luaL_optint(L, 5, 0); pkPlayer->createGreatGeneral(eGreatPersonUnit, x, y, bIsFree); -#else - pkPlayer->createGreatGeneral(eGreatPersonUnit, x, y); -#endif return 0; } //------------------------------------------------------------------------------ @@ -9097,22 +9065,15 @@ int CvLuaPlayer::lGetBullyUnit(lua_State* L) { CvPlayerAI* pkPlayer = GetInstance(L); - UnitClassTypes eUnitClass = pkPlayer->GetMinorCivAI()->GetBullyUnit(); - if(eUnitClass != NO_UNITCLASS) + const UnitClassTypes eUnitClass = pkPlayer->GetMinorCivAI()->GetBullyUnit(); + const UnitTypes eUnit = pkPlayer->GetSpecificUnitType(eUnitClass); + if (eUnit != NO_UNIT) { - CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass); - if(pkUnitClassInfo != NULL) - { - const UnitTypes eUnit = ((UnitTypes)(pkPlayer->GetSpecificUnitType(eUnitClass))); - if(eUnit != NO_UNIT) - { - lua_pushinteger(L, eUnit); - return 1; - } - } - } + lua_pushinteger(L, eUnit); + return 1; + } - lua_pushinteger(L, (UnitTypes) GC.getInfoTypeForString("UNIT_WORKER")); + lua_pushinteger(L, GC.getInfoTypeForString("UNIT_WORKER")); return 1; } //------------------------------------------------------------------------------ diff --git a/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp b/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp index 96fdef6781..080fd9c0c4 100644 --- a/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp +++ b/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.cpp @@ -163,10 +163,7 @@ void CvLuaUnit::PushMethods(lua_State* L, int t) Method(CanUpgradeInTerritory); #endif Method(GetNumResourceNeededToUpgrade); - -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) Method(GetNumResourceTotalNeededToUpgrade); -#endif Method(GetHandicapType); Method(GetCivilizationType); @@ -2267,7 +2264,6 @@ int CvLuaUnit::lGetNumResourceNeededToUpgrade(lua_State* L) lua_pushinteger(L, iResult); return 1; } -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) //------------------------------------------------------------------------------ int CvLuaUnit::lGetNumResourceTotalNeededToUpgrade(lua_State* L) { @@ -2287,7 +2283,6 @@ int CvLuaUnit::lGetNumResourceTotalNeededToUpgrade(lua_State* L) lua_pushinteger(L, iResult); return 1; } -#endif //------------------------------------------------------------------------------ //int /*HandicapTypes*/ getHandicapType(); int CvLuaUnit::lGetHandicapType(lua_State* L) diff --git a/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.h b/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.h index d7ff65b489..ac7d90ca65 100644 --- a/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.h +++ b/CvGameCoreDLL_Expansion2/Lua/CvLuaUnit.h @@ -159,10 +159,7 @@ class CvLuaUnit : public CvLuaScopedInstance LUAAPIEXTN(CanUpgradeInTerritory, bool, bTestVisible); #endif static int lGetNumResourceNeededToUpgrade(lua_State* L); - -#if defined(MOD_UNITS_RESOURCE_QUANTITY_TOTALS) static int lGetNumResourceTotalNeededToUpgrade(lua_State* L); -#endif static int lGetHandicapType(lua_State* L); static int lGetCivilizationType(lua_State* L);