Fix for games saved during 4.12.15

This commit is contained in:
yairm210
2024-08-03 23:14:58 +03:00
parent e10652964b
commit 6bafab3c71
2 changed files with 15 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import com.unciv.logic.civilization.managers.TurnManager
import com.unciv.logic.civilization.managers.VictoryManager
import com.unciv.logic.github.Github.repoNameToFolderName
import com.unciv.logic.map.CityDistanceData
import com.unciv.logic.map.MapShape
import com.unciv.logic.map.TileMap
import com.unciv.logic.map.tile.Tile
import com.unciv.models.Religion
@ -652,6 +653,18 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
tileMap.setTransients(ruleset)
// Temporary - All games saved in 4.12.15 turned into 'hexagonal non world wrapped'
// Here we attempt to fix that
// How do we recognize a rectangle? By having many tiles at the lowest edge
val tilesWithLowestRow = tileMap.tileList.groupBy { it.getRow() }.minBy { it.key }.value
if (tilesWithLowestRow.size > 2) tileMap.mapParameters.shape = MapShape.rectangular
// Set all to worldwrap if we have a good number of columns for it
// TODO REMOVE THIS SOON since this means default rectangle maps are world-wrap-ified!
val columns = tileMap.tileList.groupBy { it.getColumn() }.size
tileMap.mapParameters.worldWrap = columns % 2 == 0
if (currentPlayer == "") currentPlayer =
if (gameParameters.isOnlineMultiplayer) civilizations.first { it.isHuman() && !it.isSpectator() }.civName // For MP, spectator doesn't get a 'turn'
else civilizations.first { it.isHuman() }.civName // for non-MP games, you can be a spectator of an AI-only match, and you *do* get a turn, sort of

View File

@ -41,11 +41,13 @@ object MapType {
class MapParameters : IsPartOfGameInfoSerialization {
var name = ""
var type = MapType.pangaea
// DO NOT CHANGE DEFAULTS since that changes all existing games to new default!
var shape = MapShape.hexagonal
var mapSize = MapSize.Medium
var mapResources = MapResourceSetting.default.label
var noRuins = false
var noNaturalWonders = false
// DO NOT CHANGE DEFAULTS since that changes all existing games to new default!
var worldWrap = false
var strategicBalance = false
var legendaryStart = false