Skip to content

Commit

Permalink
Proposal (4-05)
Browse files Browse the repository at this point in the history
Fix #9810
  • Loading branch information
RecursiveVision committed May 13, 2023
1 parent 6a3c22f commit 0ff45e2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
1 change: 0 additions & 1 deletion CvGameCoreDLL_Expansion2/CvCultureClasses.cpp
Expand Up @@ -3102,7 +3102,6 @@ void CvPlayerCulture::MoveWorkIntoSlot (CvGreatWorkInMyEmpire kWork, int iCityID
BuildingClassTypes eToBuildingClass = (BuildingClassTypes)pkToEntry->GetBuildingClassType();
if(eToBuildingClass != NO_BUILDINGCLASS)
{
int iFromWork = pToCity->GetCityBuildings()->GetBuildingGreatWork(eToBuildingClass, iSlot);
CvCity *pFromCity = m_pPlayer->getCity(iFromCityID);
BuildingClassTypes eFromBuildingClass = (BuildingClassTypes)pkFromEntry->GetBuildingClassType();
if(pFromCity && eFromBuildingClass != NO_BUILDINGCLASS)
Expand Down
20 changes: 11 additions & 9 deletions CvGameCoreDLL_Expansion2/CvMinorCivAI.cpp
Expand Up @@ -16871,8 +16871,16 @@ bool CvMinorCivAI::IsLackingGiftableTileImprovementAtPlot(PlayerTypes eMajor, in
if (eImprovement != NO_IMPROVEMENT)
{
CvImprovementEntry* pImprovementInfo = GC.getImprovementInfo(eImprovement);
if (pImprovementInfo != NULL && pImprovementInfo->IsConnectsResource(eResource))
return false;
if (pImprovementInfo != NULL)
{
// Current improvement connecting this resource is already there, and not pillaged?
if (pImprovementInfo != NULL && pImprovementInfo->IsConnectsResource(eResource) && !pPlot->IsImprovementPillaged())
return false;

// Embassy already there?
if (pImprovementInfo->IsPermanent())
return false;
}
}

eImprovement = pPlot->getImprovementTypeNeededToImproveResource(eMajor, /*bTestOwner*/ false, true);
Expand Down Expand Up @@ -16949,13 +16957,7 @@ void CvMinorCivAI::DoTileImprovementGiftFromMajor(PlayerTypes eMajor, int iPlotX
}
}
#endif
// Clear the pillage state on this plot (eg Minor builds a farm, barbs pillage it,
// minor discovers iron on the plot, player pays to build a mine, but the plot is still pillaged!)
#if defined(MOD_EVENTS_TILE_IMPROVEMENTS)
pPlot->SetImprovementPillaged(false, false);
#else
pPlot->SetImprovementPillaged(false);
#endif

#if defined(MOD_BALANCE_CORE)
for(int iI = 0; iI < pPlot->getNumUnits(); iI++)
{
Expand Down
22 changes: 10 additions & 12 deletions CvGameCoreDLL_Expansion2/CvPlot.cpp
Expand Up @@ -7479,6 +7479,11 @@ void CvPlot::setImprovementType(ImprovementTypes eNewValue, PlayerTypes eBuilder
if (eNewValue < NO_IMPROVEMENT) return;
if (eNewValue > NO_IMPROVEMENT && GC.getImprovementInfo(eNewValue) == NULL) return;

// Clear the pillage state if the improvement was replaced by any means
bool bPillageStateChanged = IsImprovementPillaged();
if (bPillageStateChanged)
SetImprovementPillaged(false, false);

// new farm resources: generic farm textures for asia and american are replaced with rice and maize farm texs.
// when a farm is built on those continents, check for plot's resource. if it's a generic, non-resource farm, change the art to another continent to get diverse generic graphics.
// if it's built on rice or maize, change the continent art if needed. america 1, asia 2, africa 3, europe 4 (ocean 0, don't use that)
Expand Down Expand Up @@ -7723,13 +7728,6 @@ void CvPlot::setImprovementType(ImprovementTypes eNewValue, PlayerTypes eBuilder

setUpgradeProgress(0);

// make sure this plot is not disabled
#if defined(MOD_EVENTS_TILE_IMPROVEMENTS)
SetImprovementPillaged(false, false);
#else
SetImprovementPillaged(false);
#endif

for(iI = 0; iI < MAX_TEAMS; ++iI)
{
if (GET_TEAM((TeamTypes)iI).isObserver() || GET_TEAM((TeamTypes)iI).isAlive())
Expand Down Expand Up @@ -8445,14 +8443,15 @@ void CvPlot::setImprovementType(ImprovementTypes eNewValue, PlayerTypes eBuilder
{
setLayoutDirty(true);
}

#if defined(MOD_EVENTS_TILE_IMPROVEMENTS)
}

if (eOldImprovement != eNewValue || bPillageStateChanged)
{
if (MOD_EVENTS_TILE_IMPROVEMENTS)
{
GAMEEVENTINVOKE_HOOK(GAMEEVENT_TileImprovementChanged, getX(), getY(), getOwner(), eOldImprovement, eNewValue, IsImprovementPillaged());
}
#endif
#if defined(MOD_IMPROVEMENTS_EXTENSIONS)

if (MOD_IMPROVEMENTS_EXTENSIONS && eNewValue != NO_IMPROVEMENT)
{
// this should be called last
Expand All @@ -8461,7 +8460,6 @@ void CvPlot::setImprovementType(ImprovementTypes eNewValue, PlayerTypes eBuilder
setImprovementType(NO_IMPROVEMENT);
}
}
#endif
}
}

Expand Down

0 comments on commit 0ff45e2

Please sign in to comment.