Minor cleanups

This commit is contained in:
Yair Morgenstern 2020-02-24 19:33:37 +02:00
parent 7b13a48d74
commit 252f8b23cc
2 changed files with 4 additions and 4 deletions

View file

@ -18,7 +18,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){
setNewViewableTiles()
val newViewableInvisibleTiles = HashSet<TileInfo>()
newViewableInvisibleTiles.addAll(civInfo.getCivUnits().asSequence()
newViewableInvisibleTiles.addAll(civInfo.getCivUnits()
.filter { it.hasUnique("Can attack submarines") }
.flatMap { it.viewableTiles.asSequence() })
civInfo.viewableInvisibleUnitsTiles = newViewableInvisibleTiles
@ -59,11 +59,11 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){
// There are a LOT of tiles usually.
// And making large lists of them just as intermediaries before we shove them into the hashset is very space-inefficient.
// Ans so, sequences to the rescue!
val ownedTiles = civInfo.cities.asSequence().flatMap { it.getTiles().asSequence() }
val ownedTiles = civInfo.cities.asSequence().flatMap { it.getTiles() }
newViewableTiles.addAll(ownedTiles)
val neighboringUnownedTiles = ownedTiles.flatMap { it.neighbors.asSequence().filter { it.getOwner() != civInfo } }
newViewableTiles.addAll(neighboringUnownedTiles)
newViewableTiles.addAll(civInfo.getCivUnits().asSequence().flatMap { it.viewableTiles.asSequence() })
newViewableTiles.addAll(civInfo.getCivUnits().flatMap { it.viewableTiles.asSequence() })
if (!civInfo.isCityState()) {
for (otherCiv in civInfo.getKnownCivs()) {

View file

@ -387,7 +387,7 @@ class CivilizationInfo {
transients().setCitiesConnectedToCapitalTransients()
for (city in cities) city.startTurn()
getCivUnits().toList().forEach { it.startTurn() }
for (unit in getCivUnits()) unit.startTurn()
for(tradeRequest in tradeRequests.toList()) { // remove trade requests where one of the sides can no longer supply
val offeringCiv = gameInfo.getCivilization(tradeRequest.requestingCiv)