From 25a57c37c14e92e571e261ecd21e46d1b326fc8a Mon Sep 17 00:00:00 2001 From: KungCheops Date: Wed, 11 Dec 2024 14:03:14 +0100 Subject: [PATCH] Fix city states being able to have one embassy of each type (#11418) --- CvGameCoreDLL_Expansion2/CvHomelandAI.cpp | 15 +++++++++------ CvGameCoreDLL_Expansion2/CvPlot.cpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp b/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp index de56fdfa26..6aaefba687 100644 --- a/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp +++ b/CvGameCoreDLL_Expansion2/CvHomelandAI.cpp @@ -6404,13 +6404,16 @@ CvPlot* HomelandAIHelpers::GetPlotForEmbassy(CvUnit* pUnit, CvCity* pCity) if (!pCity->plot()->isAdjacentRevealed(kPlayer.getTeam())) return NULL; - ImprovementTypes eEmbassyImprovement = static_cast(GD_INT_GET(EMBASSY_IMPROVEMENT)); - if (eEmbassyImprovement == NO_IMPROVEMENT) - return NULL; - // Does somebody already have an embassy here? - if (kCityPlayer.getImprovementCount(eEmbassyImprovement, false) > 0) - return NULL; + for (int iI = 0; iI < GC.getNumImprovementInfos(); iI++) + { + ImprovementTypes eEmbassyImprovement = (ImprovementTypes)iI; + if (!GC.getImprovementInfo(eEmbassyImprovement)->IsEmbassy()) + continue; + + if (kCityPlayer.getImprovementCount(eEmbassyImprovement, false) > 0) + return NULL; + } //Are we planning on conquering them? if (kPlayer.GetDiplomacyAI()->GetCivApproach(kCityPlayer.GetID()) == CIV_APPROACH_WAR || kPlayer.GetNumOurCitiesOwnedBy(kCityPlayer.GetID()) > 0) diff --git a/CvGameCoreDLL_Expansion2/CvPlot.cpp b/CvGameCoreDLL_Expansion2/CvPlot.cpp index 80c24238f0..22f819951b 100644 --- a/CvGameCoreDLL_Expansion2/CvPlot.cpp +++ b/CvGameCoreDLL_Expansion2/CvPlot.cpp @@ -3121,8 +3121,15 @@ bool CvPlot::canBuild(BuildTypes eBuild, PlayerTypes ePlayer, bool bTestVisible, // If this is an embassy, check for existing embassies if (GC.getImprovementInfo(eImprovement)->IsEmbassy()) { - if (GET_PLAYER(getOwner()).getImprovementCount(eImprovement, false) > 0) - return false; + for (int iI = 0; iI < GC.getNumImprovementInfos(); iI++) + { + ImprovementTypes eOtherEmbassyImprovement = (ImprovementTypes)iI; + if (!GC.getImprovementInfo(eOtherEmbassyImprovement)->IsEmbassy()) + continue; + + if (GET_PLAYER(getOwner()).getImprovementCount(eOtherEmbassyImprovement, false) > 0) + return false; + } } } else