diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 6e2de64e36..6802317440 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -214,12 +214,15 @@ class CivilizationInfo { viewableTiles.asSequence().map { it.position } .filterNot { exploredTiles.contains(it) }.toCollection(exploredTiles) - val viewedCivs = viewableTiles - .flatMap { it.getUnits().map { unit->unit.civInfo }.union(listOf(it.getOwner())) } - // we can meet a civ either by meeting its unit, or its tile - .asSequence().filterNotNull().filterNot { it==this || it.isBarbarianCivilization() } - for(otherCiv in viewedCivs) + val viewedCivs = HashSet() + for(tile in viewableTiles){ + val tileOwner = tile.getOwner() + if(tileOwner!=null) viewedCivs+=tileOwner + for(unit in tile.getUnits()) viewedCivs+=unit.civInfo + } + + for(otherCiv in viewedCivs.filterNot { it==this || it.isBarbarianCivilization() }) if(!diplomacy.containsKey(otherCiv.civName)){ meetCivilization(otherCiv) addNotification("We have encountered [${otherCiv.civName}]!".tr(),null, Color.GOLD) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 50045cc805..93d4ab5a07 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -12,6 +12,7 @@ import com.unciv.ui.utils.getRandom import java.text.DecimalFormat import java.util.* import kotlin.collections.ArrayList +import kotlin.collections.HashSet class MapUnit { @Transient lateinit var civInfo: CivilizationInfo @@ -63,14 +64,14 @@ class MapUnit { return movementAlgs().getDistanceToTilesWithinTurn(tile.position,currentMovement) } - @Transient var tempUniques: List = ArrayList() + @Transient var tempUniques= HashSet() - fun getUniques(): List { + fun getUniques(): HashSet { return tempUniques } fun updateUniques(){ - val uniques = ArrayList() + val uniques = HashSet() val baseUnit = baseUnit() uniques.addAll(baseUnit.uniques) uniques.addAll(promotions.promotions.map { GameBasics.UnitPromotions[it]!!.effect }) @@ -274,7 +275,7 @@ class MapUnit { currentMovement -= distanceToTiles[otherTile]!! if (currentMovement < 0.1) currentMovement = 0f // silly floats which are "almost zero" - if(isFortified() || action=="Set Up") action=null // unfortify/setup after moving + if(isFortified() || action=="Set Up" || action=="Sleep") action=null // unfortify/setup after moving removeFromTile() putInTile(otherTile) }