Skip to content

Commit

Permalink
Massive code cleanup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
azum4roll authored and RecursiveVision committed Jun 10, 2024
1 parent 74f0e5c commit e632da6
Show file tree
Hide file tree
Showing 75 changed files with 2,960 additions and 9,511 deletions.
16 changes: 13 additions & 3 deletions (1) Community Patch/Core Files/Core Tables/CustomModOptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@
<Row Class="6" Name="BALANCE_FLIPPED_TOURISM_MODIFIER_OPEN_BORDERS" Value="0"/>
<!-- Ranged attacks on injured units no longer get a bonus for the unit being injured -->
<Row Class="6" Name="BALANCE_CORE_RANGED_ATTACK_PENALTY" Value="0"/>
<!-- Inquisitors don't block spread, make 50% -->
<Row Class="6" Name="BALANCE_CORE_INQUISITOR_TWEAKS" Value="0"/>
<!-- Inquisitors don't block spread, make 50% -->
<Row Class="6" Name="BALANCE_CORE_INQUISITOR_TWEAKS" Value="0"/>
<!-- If true, no lua hooks are called from the game core, increasing performance and stability -->
<Row Class="6" Name="CORE_DISABLE_LUA_HOOKS" Value="0"/>
<!-- If true, additional promotions are enabled which may cause a significant slowdown if there are many units in the game -->
Expand All @@ -970,13 +970,23 @@
<Row Class="6" Name="ANY_PANTHEON" Value="0"/>
<!-- Only recon units (and city border growth) can take ancient ruins. -->
<Row Class="6" Name="BALANCE_CORE_GOODY_RECON_ONLY" Value="0"/>

<!-- Pantheon presure is only reduced by half of incoming active spread pressure. -->
<Row Class="5" Name="CORE_RESILIENT_PANTHEONS" Value="0"/>
<!-- Enables hovercraft. -->
<Row Class="5" Name="CORE_HOVERING_UNITS" Value="0"/>
<!-- Visible tiles stay visible until the end of the turn. -->
<Row Class="6" Name="CORE_DELAYED_VISIBILITY" Value="1"/>
<!-- Danger plot valuation: ignore ZOC only for those units which are likely to be killed by the enemy (alternatively ignore ZOC for all owned units) -->
<Row Class="1" Name="CORE_TWO_PASS_DANGER" Value="0"/>

<Row Class="6" Name="YIELD_MODIFIER_FROM_UNITS" Value="0"/>

<Row Class="6" Name="ISKA_HERITAGE" Value="0"/>
<!-- If you enable this, you can do an 'observer' mode human player (i.e. submarine in ice) to do the battle royale! Also game to calculate the military might for each domain. -->
<Row Class="6" Name="BATTLE_ROYALE" Value="0"/>

<Row Class="0" Name="UNIT_KILL_STATS" Value="0"/>

</CustomModOptions>

<!-- Events for JFD Piety -->
Expand Down
2 changes: 2 additions & 0 deletions (2) Vox Populi/Database Changes/CustomModOptionChanges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 0 additions & 2 deletions CvGameCoreDLLUtil/include/CvEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
7 changes: 7 additions & 0 deletions CvGameCoreDLL_Expansion2/CustomMods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 13 additions & 9 deletions CvGameCoreDLL_Expansion2/CustomMods.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,28 @@
#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

/// 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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions CvGameCoreDLL_Expansion2/CvAdvisorCounsel.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down
168 changes: 10 additions & 158 deletions CvGameCoreDLL_Expansion2/CvBeliefClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1856,130 +1856,37 @@ 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;
}

//=====================================
// CvReligionBeliefs
//=====================================
/// 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<int>(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;
Expand All @@ -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?
Expand Down Expand Up @@ -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<int> CvReligionBeliefs::GetFreePromotions(PlayerTypes ePlayer, const CvCity* pCity, bool bHolyCityOnly) const
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions CvGameCoreDLL_Expansion2/CvBeliefClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,7 @@ class CvReligionBeliefs
{
public:
CvReligionBeliefs(void);
~CvReligionBeliefs(void);
CvReligionBeliefs(const CvReligionBeliefs& source);
void Uninit();
void Reset();
void AddBelief(BeliefTypes eBelief);

Expand Down
Loading

0 comments on commit e632da6

Please sign in to comment.