Update civ resources when a researched tech reveals a resource (#9467)

This commit is contained in:
SomeTroglodyte
2023-05-28 07:39:36 +02:00
committed by GitHub
parent ef193babee
commit 9739374e17

View File

@ -312,11 +312,22 @@ class TechManager : IsPartOfGameInfoSerialization {
if (isNewTech)
civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched, techName))
val revealedResources = getRuleset().tileResources.values.filter { techName == it.revealedBy }
var mayNeedUpdateResources = revealedResources.isNotEmpty() // default for AI
if (civInfo.playerType == PlayerType.Human) {
for (revealedResource in getRuleset().tileResources.values.filter { techName == it.revealedBy }) {
mayNeedUpdateResources = false
for (revealedResource in revealedResources) {
// notifyExploredResources scans the player's owned tiles and returns false if none
// found with a revealed resource - keep this knowledge to avoid the update call.
mayNeedUpdateResources = mayNeedUpdateResources ||
civInfo.gameInfo.notifyExploredResources(civInfo, revealedResource.name, 5, false)
}
}
// At least in the case of a human player hurrying research, this civ's resource availability
// may now be out of date - e.g. when an owned tile by luck already has an appropriate improvement.
// That can be seen on WorldScreenTopBar, so better update unless we know there's no resource change.
if (mayNeedUpdateResources)
civInfo.cache.updateCivResources()
obsoleteOldUnits(techName)