Skip to content

Commit

Permalink
Fix a few small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveVision committed Jul 7, 2024
1 parent ed38c38 commit 8273133
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6349,7 +6349,11 @@ bool CvDiplomacyAI::IsPlayerBrokenExpansionPromise(PlayerTypes ePlayer) const
/// Which players have we agreed to avoid settling near?
vector<PlayerTypes> CvDiplomacyAI::GetPlayersWithNoSettlePolicy() const
{
// If AI has no cities, ignore the promise - they need a capital
vector<PlayerTypes> result;
if (GetPlayer()->getNumCities() == 0)
return result;

for (int iPlayer = 0; iPlayer < MAX_MAJOR_CIVS; iPlayer++)
{
PlayerTypes ePlayer = (PlayerTypes) iPlayer;
Expand Down Expand Up @@ -43094,6 +43098,11 @@ bool CvDiplomacyAI::IsDontSettleAcceptable(PlayerTypes ePlayer)
// Debug mode
if (GET_PLAYER(ePlayer).isHuman() && GC.getGame().IsAIMustAcceptHumanDiscussRequests())
return true;

// Don't agree if AI has no cities, as AI will break the promise in order to settle their capital
// Also prevents a cheesy exploit: trying to get the AI to settle their initial capital in a worse position
if (GetPlayer()->getNumCities() == 0)
return false;

// Always acceptable if they resurrected or liberated us
if (IsLiberator(ePlayer, true, true))
Expand Down
8 changes: 8 additions & 0 deletions CvGameCoreDLL_Expansion2/CvPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2792,6 +2792,14 @@ CvPlot* CvPlayer::addFreeUnit(UnitTypes eUnit, bool bGameStart, UnitAITypes eUni
if (pLoopPlot->getNumUnits() > 0 || pLoopPlot->IsEnemyUnitAdjacent(getTeam()))
continue;

// To avoid a bug, AI will not settle on Antiquity Sites even if they have no other options
if (!isHuman())
{
ResourceTypes ePlotResource = pLoopPlot->getResourceType(NO_TEAM);
if (ePlotResource == (ResourceTypes)GD_INT_GET(ARTIFACT_RESOURCE) || ePlotResource == (ResourceTypes)GD_INT_GET(HIDDEN_ARTIFACT_RESOURCE))
continue;
}

if (!canFoundCity(pLoopPlot->getX(), pLoopPlot->getY()))
continue;

Expand Down
4 changes: 2 additions & 2 deletions CvGameCoreDLL_Expansion2/CvSiteEvaluationClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ int CvSiteEvaluatorForSettler::PlotFoundValue(CvPlot* pPlot, const CvPlayer* pPl

TeamTypes eTeam = pPlayer ? pPlayer->getTeam() : NO_TEAM;

// AI does not settle on Antiquity Sites
ResourceTypes ePlotResource = pPlot->getResourceType(eTeam);
// To avoid a bug, AI does not settle on Antiquity Sites
ResourceTypes ePlotResource = pPlot->getResourceType(pPlayer->isHuman() ? eTeam : NO_TEAM);
if (ePlotResource == (ResourceTypes)GD_INT_GET(ARTIFACT_RESOURCE) ||
ePlotResource == (ResourceTypes)GD_INT_GET(HIDDEN_ARTIFACT_RESOURCE))
{
Expand Down

0 comments on commit 8273133

Please sign in to comment.