Skip to content

Commit

Permalink
Remove yields from pillaged adjacent improvements (#10965)
Browse files Browse the repository at this point in the history
Also slight performance and readability fix.
  • Loading branch information
KungCheops authored Jun 10, 2024
1 parent 1b5dc6a commit d549415
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions CvGameCoreDLL_Expansion2/CvPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5884,7 +5884,7 @@ int CvPlot::ComputeYieldFromAdjacentImprovement(CvImprovementEntry& kImprovement
for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));
if(pAdjacentPlot && pAdjacentPlot->getImprovementType() == eValue)
if(pAdjacentPlot && pAdjacentPlot->getImprovementType() == eValue && !pAdjacentPlot->IsImprovementPillaged())
{
iRtnValue += kImprovement.GetYieldAdjacentSameType(eYield);
}
Expand All @@ -5904,7 +5904,7 @@ int CvPlot::ComputeYieldFromTwoAdjacentImprovement(CvImprovementEntry& kImprovem
for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));
if(pAdjacentPlot && pAdjacentPlot->getImprovementType() == eValue)
if(pAdjacentPlot && pAdjacentPlot->getImprovementType() == eValue && !pAdjacentPlot->IsImprovementPillaged())
{
iRtnValue += kImprovement.GetYieldAdjacentTwoSameType(eYield);
}
Expand All @@ -5920,21 +5920,15 @@ int CvPlot::ComputeYieldFromOtherAdjacentImprovement(CvImprovementEntry& kImprov
CvPlot* pAdjacentPlot = NULL;
int iRtnValue = 0;

for(int iJ = 0; iJ < GC.getNumImprovementInfos(); iJ++)
for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
ImprovementTypes eImprovement = (ImprovementTypes)iJ;
if(eImprovement != NO_IMPROVEMENT)
pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));
if(pAdjacentPlot && pAdjacentPlot->getImprovementType() != NO_IMPROVEMENT && !pAdjacentPlot->IsImprovementPillaged())
{
if(kImprovement.GetAdjacentImprovementYieldChanges(eImprovement, eYield) > 0)
int iChange = kImprovement.GetAdjacentImprovementYieldChanges(pAdjacentPlot->getImprovementType(), eYield);
if (iChange > 0)
{
for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));
if(pAdjacentPlot && pAdjacentPlot->getImprovementType() == eImprovement)
{
iRtnValue += kImprovement.GetAdjacentImprovementYieldChanges(eImprovement, eYield);
}
}
iRtnValue += iChange;
}
}
}
Expand Down

0 comments on commit d549415

Please sign in to comment.