mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
Fixed "Endless Production" bug for Hanse
This commit is contained in:
parent
8f0c3f1c02
commit
e921833580
@ -69,11 +69,11 @@ class GameSaver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun autoSave(gameInfo: GameInfo, postRunnable: () -> Unit = {}) {
|
fun autoSave(gameInfo: GameInfo, postRunnable: () -> Unit = {}) {
|
||||||
|
// The save takes a long time (up to a few seconds on large games!) and we can do it while the player continues his game.
|
||||||
|
// On the other hand if we alter the game data while it's being serialized we could get a concurrent modification exception.
|
||||||
|
// So what we do is we clone all the game data and serialize the clone.
|
||||||
val gameInfoClone = gameInfo.clone()
|
val gameInfoClone = gameInfo.clone()
|
||||||
kotlin.concurrent.thread {
|
kotlin.concurrent.thread {
|
||||||
// the save takes a long time (up to a second!) and we can do it while the player continues his game.
|
|
||||||
// On the other hand if we alter the game data while it's being serialized we could get a concurrent modification exception.
|
|
||||||
// So what we do is we clone all the game data and serialize the clone.
|
|
||||||
saveGame(gameInfoClone, "Autosave")
|
saveGame(gameInfoClone, "Autosave")
|
||||||
|
|
||||||
// keep auto-saves for the last 10 turns for debugging purposes
|
// keep auto-saves for the last 10 turns for debugging purposes
|
||||||
|
@ -163,8 +163,7 @@ class Building : NamedStats(), IConstruction{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getStatPercentageBonuses(civInfo: CivilizationInfo?): Stats {
|
fun getStatPercentageBonuses(civInfo: CivilizationInfo?): Stats {
|
||||||
val stats = percentStatBonus
|
val stats = if(percentStatBonus==null) Stats() else percentStatBonus!!.clone()
|
||||||
if(stats==null) return Stats() // empty
|
|
||||||
if(civInfo==null) return stats // initial stats
|
if(civInfo==null) return stats // initial stats
|
||||||
|
|
||||||
val adoptedPolicies = civInfo.policies.adoptedPolicies
|
val adoptedPolicies = civInfo.policies.adoptedPolicies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user