mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-07 17:43:54 +07:00
Fix automatedRoadConnectionPath serialization errors (#12097)
This commit is contained in:
parent
49fa691d7e
commit
cf202c28a4
@ -2,7 +2,6 @@ package com.unciv.json
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.badlogic.gdx.utils.Json
|
||||
import com.badlogic.gdx.utils.JsonWriter
|
||||
import com.badlogic.gdx.utils.SerializationException
|
||||
@ -23,7 +22,6 @@ fun json() = Json(JsonWriter.OutputType.json).apply {
|
||||
|
||||
setSerializer(Duration::class.java, DurationSerializer())
|
||||
setSerializer(KeyCharAndCode::class.java, KeyCharAndCode.Serializer())
|
||||
setSerializer(Vector2::class.java, Vector2Serializer())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,35 +0,0 @@
|
||||
package com.unciv.json
|
||||
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.badlogic.gdx.utils.Json
|
||||
import com.badlogic.gdx.utils.Json.Serializer
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
|
||||
class Vector2Serializer : Serializer<Vector2> {
|
||||
override fun write(json: Json, vector2: Vector2?, knownType: Class<*>?) {
|
||||
|
||||
if (vector2 == null) json.writeValue(null)
|
||||
else {
|
||||
// NEW vector serialization - currently disabled
|
||||
// json.writeValue("${vector2.x.toInt()}/${vector2.y.toInt()}")
|
||||
|
||||
// OLD vector serialization - deprecated 4.12.18
|
||||
json.writeObjectStart()
|
||||
json.writeFields(vector2)
|
||||
json.writeObjectEnd()
|
||||
}
|
||||
}
|
||||
|
||||
override fun read(json: Json, jsonData: JsonValue, knownType: Class<*>?): Vector2? {
|
||||
if (jsonData.isNull) return null // Not entirely sure it's necessary
|
||||
if (jsonData.isString) {
|
||||
val split = jsonData.asString().split("/")
|
||||
return Vector2(split[0].toFloat(), split[1].toFloat())
|
||||
}
|
||||
|
||||
// OLD vector serialization
|
||||
val vector = Vector2()
|
||||
json.readFields(vector, jsonData)
|
||||
return vector
|
||||
}
|
||||
}
|
@ -68,6 +68,8 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
||||
var escorting: Boolean = false
|
||||
|
||||
var automatedRoadConnectionDestination: Vector2? = null
|
||||
// Temp disable, since this data broke saves
|
||||
@Transient
|
||||
var automatedRoadConnectionPath: List<Vector2>? = null
|
||||
|
||||
var attacksThisTurn = 0
|
||||
|
Loading…
Reference in New Issue
Block a user