Fixed relatively rare crash where the settings were being read but ended up null, not sure how that happened to start with...

This commit is contained in:
Yair Morgenstern 2019-12-22 18:35:41 +02:00
parent 31b4680b5f
commit 314b620405

View File

@ -48,7 +48,10 @@ class GameSaver {
fun getGeneralSettings(): GameSettings {
val settingsFile = getGeneralSettingsFile()
if(!settingsFile.exists()) return GameSettings()
val settings = json().fromJson(GameSettings::class.java, settingsFile)
var settings = json().fromJson(GameSettings::class.java, settingsFile)
// I'm not sure of the circumstances,
// but some people were getting null settings, even though the file existed??? Very odd.
if(settings==null) settings = GameSettings()
val currentTileSets = ImageGetter.atlas.regions.asSequence()
.filter { it.name.startsWith("TileSets") }