Skip to content

Commit

Permalink
Remove hardcoding of GPTIs connecting resources
Browse files Browse the repository at this point in the history
It's still enabled by default for modmod GPTIs using a trigger, but can be shut off manually with an SQL update
  • Loading branch information
RecursiveVision committed Aug 7, 2024
1 parent f1150c7 commit 4ad3a9c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
14 changes: 14 additions & 0 deletions (1) Community Patch/Core Files/Core Changes/CoreChanges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,20 @@ SET MilitaryRatingDecayPercent = 20 WHERE Type = 'GAMESPEED_STANDARD';
UPDATE Gamespeeds
SET MilitaryRatingDecayPercent = 30 WHERE Type = 'GAMESPEED_QUICK';


-- Unhardcode GPTIs connecting all resources, but still make it do so by default
UPDATE Improvements SET ConnectsAllResources = 1 WHERE CreatedByGreatPerson = 1;

CREATE TRIGGER Improvements_GPTIConnectsResources
AFTER INSERT ON Improvements
WHERE EXISTS ( SELECT Type FROM Improvements WHERE Type = NEW.Type )
BEGIN

UPDATE Improvements SET ConnectsAllResources = 1 WHERE Type = NEW.Type AND CreatedByGreatPerson = 1;

END;


-- IF the Vox Populi mod is enabled, this code will override all custom civs' non-diplomacy flavors (if they're loaded afterwards)!
-- To use the non-diplomacy flavors (Expansion, Offense, Religion, etc.) specified by the custom civ's XML instead, comment it out.
CREATE TRIGGER Leaders_Personality
Expand Down
1 change: 1 addition & 0 deletions (2) Vox Populi/Database Changes/Civilizations/Mongolia.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ UPDATE Improvements
SET
InAdjacentFriendly = 1,
BuildableOnResources = 1,
ConnectsAllResources = 1,
NoTwoAdjacent = 1,
CreatedByGreatPerson = 1,
CultureBombRadius = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ImprovementLeagueVotes>1</ImprovementLeagueVotes>
<CreatedByGreatPerson>true</CreatedByGreatPerson>
<BuildableOnResources>true</BuildableOnResources>
<ConnectsAllResources>true</ConnectsAllResources>
<PortraitIndex>0</PortraitIndex>
<IconAtlas>TERRAIN_IMPROVEMENT_EMBASSY</IconAtlas>
</Row>
Expand Down
6 changes: 1 addition & 5 deletions CvGameCoreDLL_Expansion2/CvImprovementClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1623,11 +1623,7 @@ bool CvImprovementEntry::IsConnectsResource(int i) const
else
return false;

if (IsCreatedByGreatPerson() || ConnectsAllResources())
return true;

return false;

return ConnectsAllResources();
}

/// the chance of the specified Resource appearing randomly when the Improvement is present with no current Resource
Expand Down
5 changes: 2 additions & 3 deletions CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17746,8 +17746,7 @@ bool CvMinorCivAI::IsLackingGiftableTileImprovementAtPlot(PlayerTypes eMajor, in
if (pImprovementInfo != NULL)
{
// Existing improvement that connects the resource? If it's pillaged, we can repair it. Otherwise, we can't improve this tile.
// todo: remove yucky hardcoding of GPTIs connecting resources
if (pImprovementInfo->IsConnectsResource(eResource) || pImprovementInfo->IsCreatedByGreatPerson())
if (pImprovementInfo->IsConnectsResource(eResource))
return pPlot->IsImprovementPillaged();
else if (pImprovementInfo->IsPermanent())
return false;
Expand Down Expand Up @@ -17796,7 +17795,7 @@ void CvMinorCivAI::DoTileImprovementGiftFromMajor(PlayerTypes eMajor, int iPlotX
ImprovementTypes eImprovement = NO_IMPROVEMENT;
ImprovementTypes eCurrentImprovement = pPlot->getImprovementType();
CvImprovementEntry* pImprovementInfo = GC.getImprovementInfo(eCurrentImprovement);
if (eCurrentImprovement != NO_IMPROVEMENT && pImprovementInfo != NULL && (pImprovementInfo->IsConnectsResource(eResource) || pImprovementInfo->IsCreatedByGreatPerson()))
if (eCurrentImprovement != NO_IMPROVEMENT && pImprovementInfo != NULL && pImprovementInfo->IsConnectsResource(eResource))
{
// If we got here, IsLackingGiftableTileImprovementAtPlot() has verified that there is an existing improvement which connects the resource on the tile, and it's pillaged.
// So unpillage it instead of building something new. Calling setImprovementType() will unpillage it.
Expand Down

0 comments on commit 4ad3a9c

Please sign in to comment.