Skip to content

Commit

Permalink
Solved defaults changing *existing games* due to no serialization of …
Browse files Browse the repository at this point in the history
…defaults in json. (#12049)

Only new installations get rectangular and world wrap by default
  • Loading branch information
yairm210 authored Aug 1, 2024
1 parent efb2118 commit 9f0abbd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/civilization/Civilization.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import com.unciv.models.stats.Stats
import com.unciv.models.translations.tr
import com.unciv.ui.components.extensions.toPercent
import com.unciv.ui.screens.victoryscreen.RankingType
import com.unciv.utils.Log
import org.jetbrains.annotations.VisibleForTesting
import kotlin.math.max
import kotlin.math.min
Expand Down Expand Up @@ -561,6 +560,7 @@ class Civilization : IsPartOfGameInfoSerialization {
}.toList() // Triggers can e.g. add buildings which contain triggers, causing concurrent modification errors


@Transient
private val cachedMatchesFilterResult = HashMap<String, Boolean>()

/** Implements [UniqueParameterType.CivFilter][com.unciv.models.ruleset.unique.UniqueParameterType.CivFilter] */
Expand Down
4 changes: 2 additions & 2 deletions core/src/com/unciv/logic/map/MapParameters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ object MapType {
class MapParameters : IsPartOfGameInfoSerialization {
var name = ""
var type = MapType.pangaea
var shape = MapShape.rectangular
var shape = MapShape.hexagonal
var mapSize = MapSize.Medium
var mapResources = MapResourceSetting.default.label
var noRuins = false
var noNaturalWonders = false
var worldWrap = true
var worldWrap = false
var strategicBalance = false
var legendaryStart = false

Expand Down
3 changes: 3 additions & 0 deletions core/src/com/unciv/models/metadata/GameSetupInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.badlogic.gdx.files.FileHandle
import com.unciv.UncivGame
import com.unciv.logic.GameInfo
import com.unciv.logic.map.MapParameters
import com.unciv.logic.map.MapShape

class GameSetupInfo(
val gameParameters: GameParameters = GameParameters(),
Expand All @@ -26,6 +27,8 @@ class GameSetupInfo(
fun fromSettings(defaultDifficulty: String? = null) = UncivGame.Current.settings.run {
if (lastGameSetup == null) GameSetupInfo().apply {
if (defaultDifficulty != null) gameParameters.difficulty = defaultDifficulty
mapParameters.shape = MapShape.rectangular
mapParameters.worldWrap = true
}
else GameSetupInfo(lastGameSetup!!).apply {
mapParameters.reseed()
Expand Down

0 comments on commit 9f0abbd

Please sign in to comment.