mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-19 20:28:56 +07:00
Tile.terrainUniqueMap doesn't need to have an initial value set - this is a bogus value that just takes init time and memory (and a lot of memory at that)
Still needs to be set for display purposes though
This commit is contained in:
@ -284,8 +284,9 @@ class MapGenerator(val ruleset: Ruleset, private val coroutineScope: CoroutineSc
|
||||
// Floodfill to cluster water tiles
|
||||
while (tilesToCheck.isNotEmpty()) {
|
||||
val tileWeAreChecking = tilesToCheck.removeFirst()
|
||||
for (vector in tileWeAreChecking.neighbors
|
||||
.filter { !tilesInArea.contains(it) and waterTiles.contains(it) }) {
|
||||
for (vector in tileWeAreChecking.neighbors){
|
||||
if (tilesInArea.contains(vector)) continue
|
||||
if (!waterTiles.contains(vector)) continue
|
||||
tilesInArea += vector
|
||||
tilesToCheck += vector
|
||||
waterTiles -= vector
|
||||
|
@ -155,7 +155,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
||||
private set
|
||||
|
||||
@Transient
|
||||
var terrainUniqueMap = UniqueMap()
|
||||
var terrainUniqueMap = UniqueMap.EMPTY
|
||||
private set
|
||||
|
||||
@Transient
|
||||
|
@ -316,6 +316,10 @@ open class UniqueMap() {
|
||||
unique.hasModifier(trigger) && unique.conditionalsApply(stateForConditionals)
|
||||
}.flatMap { it.getMultiplied(stateForConditionals) }
|
||||
}
|
||||
|
||||
companion object{
|
||||
val EMPTY = UniqueMap()
|
||||
}
|
||||
}
|
||||
|
||||
class TemporaryUnique() : IsPartOfGameInfoSerialization {
|
||||
|
@ -112,7 +112,10 @@ class TileGroupMap<T: TileGroup>(
|
||||
val cityButtonLayers = ArrayList<TileLayerCityButton>()
|
||||
|
||||
// Apparently the sortedByDescending is kinda memory-intensive because it needs to sort ALL the tiles
|
||||
for (group in tileGroups.sortedByDescending { it.tile.position.x + it.tile.position.y }) {
|
||||
// So instead we group by and then sort on the groups
|
||||
// Profiling is a bit iffy if this is actually better but...probably?
|
||||
for (group in tileGroups.groupBy { it.tile.position.x + it.tile.position.y }
|
||||
.entries.sortedByDescending { it.key }.flatMap { it.value }) {
|
||||
// now, we steal the subgroups from all the tilegroups, that's how we form layers!
|
||||
baseLayers.add(group.layerTerrain.apply { setPosition(group.x, group.y) })
|
||||
featureLayers.add(group.layerFeatures.apply { setPosition(group.x, group.y) })
|
||||
|
Reference in New Issue
Block a user