Skip to content

Commit

Permalink
Fix city states being able to have one embassy of each type (#11418)
Browse files Browse the repository at this point in the history
  • Loading branch information
KungCheops authored Dec 11, 2024
1 parent 4dbeb21 commit 25a57c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
15 changes: 9 additions & 6 deletions CvGameCoreDLL_Expansion2/CvHomelandAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6404,13 +6404,16 @@ CvPlot* HomelandAIHelpers::GetPlotForEmbassy(CvUnit* pUnit, CvCity* pCity)
if (!pCity->plot()->isAdjacentRevealed(kPlayer.getTeam()))
return NULL;

ImprovementTypes eEmbassyImprovement = static_cast<ImprovementTypes>(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)
Expand Down
11 changes: 9 additions & 2 deletions CvGameCoreDLL_Expansion2/CvPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 25a57c3

Please sign in to comment.