Skip to content

Commit

Permalink
New Improvement Restriction - NoAdjacentCity: (#11232)
Browse files Browse the repository at this point in the history
- forbids an improvement from being built next to a city
  • Loading branch information
LessRekkless authored Aug 25, 2024
1 parent 80d157f commit 10f41c7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1101,12 +1101,15 @@ ALTER TABLE Builds ADD COLUMN 'KillOnlyCivilian' BOOLEAN DEFAULT 0;
-- Grants obsoletion tech to improvement (tie to build above for AI)
ALTER TABLE Improvements ADD COLUMN 'ObsoleteTech' TEXT DEFAULT NULL;

-- Improvements can be made valid by being adjacent to a lake
ALTER TABLE Improvements ADD COLUMN 'Lakeside' BOOLEAN DEFAULT 0;
-- Improvement can not be built adjacent to a city
ALTER TABLE Improvements ADD COLUMN 'NoAdjacentCity' BOOLEAN DEFAULT 0;

-- Improvements can be made valid by being adjacent to a city
ALTER TABLE Improvements ADD COLUMN 'Cityside' BOOLEAN DEFAULT 0;

-- Improvements can be made valid by being adjacent to a lake
ALTER TABLE Improvements ADD COLUMN 'Lakeside' BOOLEAN DEFAULT 0;

-- Improvements can be made valid by being adjacent to X of the same improvement
ALTER TABLE Improvements ADD COLUMN 'XSameAdjacentMakesValid' INTEGER DEFAULT 0;

Expand Down
14 changes: 10 additions & 4 deletions CvGameCoreDLL_Expansion2/CvImprovementClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ CvImprovementEntry::CvImprovementEntry(void):
m_bIsEmbassy(false),
#if defined(MOD_BALANCE_CORE)
m_iGetObsoleteTech(NO_TECH),
m_bAdjacentLake(false),
m_bNoAdjacentCity(false),
m_bAdjacentCity(false),
m_bAdjacentLake(false),
m_iGrantsVision(0),
m_iMovesChange(0),
m_bRestoreMoves(false),
Expand Down Expand Up @@ -329,8 +330,9 @@ bool CvImprovementEntry::CacheResults(Database::Results& kResults, CvDatabaseUti
#if defined(MOD_BALANCE_CORE)
const char* szObsoleteTech = kResults.GetText("ObsoleteTech");
m_iGetObsoleteTech = GC.getInfoTypeForString(szObsoleteTech, true);
m_bAdjacentLake = kResults.GetBool("Lakeside");
m_bNoAdjacentCity = kResults.GetBool("NoAdjacentCity");
m_bAdjacentCity = kResults.GetBool("Cityside");
m_bAdjacentLake = kResults.GetBool("Lakeside");
m_iGrantsVision = kResults.GetInt("GrantsVisionXTiles");
m_iUnitPlotExperience = kResults.GetInt("UnitPlotExperience");
m_iGAUnitPlotExperience = kResults.GetInt("GAUnitPlotExperience");
Expand Down Expand Up @@ -1174,14 +1176,18 @@ int CvImprovementEntry::GetObsoleteTech() const
{
return m_iGetObsoleteTech;
}
bool CvImprovementEntry::IsAdjacentLake() const
bool CvImprovementEntry::IsNoAdjacentCity() const
{
return m_bAdjacentLake;
return m_bNoAdjacentCity;
}
bool CvImprovementEntry::IsAdjacentCity() const
{
return m_bAdjacentCity;
}
bool CvImprovementEntry::IsAdjacentLake() const
{
return m_bAdjacentLake;
}
int CvImprovementEntry::GetGrantsVision() const
{
return m_iGrantsVision;
Expand Down
6 changes: 4 additions & 2 deletions CvGameCoreDLL_Expansion2/CvImprovementClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ class CvImprovementEntry: public CvBaseInfo
bool IsEmbassy() const;
#if defined(MOD_BALANCE_CORE)
int GetObsoleteTech() const;
bool IsAdjacentLake() const;
bool IsNoAdjacentCity() const;
bool IsAdjacentCity() const;
bool IsAdjacentLake() const;
int GetGrantsVision() const;
#endif
bool IsNoTwoAdjacent() const;
Expand Down Expand Up @@ -318,8 +319,9 @@ class CvImprovementEntry: public CvBaseInfo
bool m_bIsEmbassy;
#if defined(MOD_BALANCE_CORE)
int m_iGetObsoleteTech;
bool m_bAdjacentLake;
bool m_bNoAdjacentCity;
bool m_bAdjacentCity;
bool m_bAdjacentLake;
int m_iGrantsVision;
#endif
bool m_bNoTwoAdjacent;
Expand Down
5 changes: 5 additions & 0 deletions CvGameCoreDLL_Expansion2/CvPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,11 @@ bool CvPlot::canHaveImprovement(ImprovementTypes eImprovement, PlayerTypes ePlay
}
}

if(pkImprovementInfo->IsNoAdjacentCity() && IsAdjacentCity())
{
return false;
}

if(pkImprovementInfo->IsNoFreshWater() && isFreshWater())
{
return false;
Expand Down

0 comments on commit 10f41c7

Please sign in to comment.