From 827313328d18bdefc3c12688ea1db16f1384a7f6 Mon Sep 17 00:00:00 2001 From: RecursiveVision <66801010+RecursiveVision@users.noreply.github.com> Date: Sun, 7 Jul 2024 03:12:46 -0400 Subject: [PATCH] Fix a few small bugs --- CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp | 9 +++++++++ CvGameCoreDLL_Expansion2/CvPlayer.cpp | 8 ++++++++ CvGameCoreDLL_Expansion2/CvSiteEvaluationClasses.cpp | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp index bf735469f3..8e6931b282 100644 --- a/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp @@ -6349,7 +6349,11 @@ bool CvDiplomacyAI::IsPlayerBrokenExpansionPromise(PlayerTypes ePlayer) const /// Which players have we agreed to avoid settling near? vector CvDiplomacyAI::GetPlayersWithNoSettlePolicy() const { + // If AI has no cities, ignore the promise - they need a capital vector result; + if (GetPlayer()->getNumCities() == 0) + return result; + for (int iPlayer = 0; iPlayer < MAX_MAJOR_CIVS; iPlayer++) { PlayerTypes ePlayer = (PlayerTypes) iPlayer; @@ -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)) diff --git a/CvGameCoreDLL_Expansion2/CvPlayer.cpp b/CvGameCoreDLL_Expansion2/CvPlayer.cpp index d573470eb8..fd58dc0b15 100644 --- a/CvGameCoreDLL_Expansion2/CvPlayer.cpp +++ b/CvGameCoreDLL_Expansion2/CvPlayer.cpp @@ -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; diff --git a/CvGameCoreDLL_Expansion2/CvSiteEvaluationClasses.cpp b/CvGameCoreDLL_Expansion2/CvSiteEvaluationClasses.cpp index adea58eed5..86c640fb8a 100644 --- a/CvGameCoreDLL_Expansion2/CvSiteEvaluationClasses.cpp +++ b/CvGameCoreDLL_Expansion2/CvSiteEvaluationClasses.cpp @@ -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)) {