diff options
author | nokoe <nokoe@mailbox.org> | 2024-06-26 14:29:22 +0200 |
---|---|---|
committer | nokoe <nokoe@mailbox.org> | 2024-06-26 14:30:12 +0200 |
commit | 974d5151b28faf94dfa73e33a484eecaa2f69e40 (patch) | |
tree | c66dc3046368c4eb9694e09247992d736c985f3a | |
parent | fe0bda76240d4794afde9d3dd796213d32a2b22a (diff) | |
download | hurrycurry-974d5151b28faf94dfa73e33a484eecaa2f69e40.tar hurrycurry-974d5151b28faf94dfa73e33a484eecaa2f69e40.tar.bz2 hurrycurry-974d5151b28faf94dfa73e33a484eecaa2f69e40.tar.zst |
handle broken profile files
-rw-r--r-- | client/global.gd | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/client/global.gd b/client/global.gd index a09f8696..095deec8 100644 --- a/client/global.gd +++ b/client/global.gd @@ -1,3 +1,20 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# Copyright 2024 tpart +# Copyright 2024 nokoe +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# extends Node const DEFAULT_SETTINGS := { @@ -17,7 +34,7 @@ func _ready(): func save_profile(): var f = FileAccess.open("user://profile", FileAccess.WRITE) f.store_var(settings.duplicate(true)) - + print("Saved settings: ", settings) func load_profile(): @@ -26,11 +43,10 @@ func load_profile(): print("Skip profile load") return var f = FileAccess.open("user://profile", FileAccess.READ) - settings = f.get_var() - - # Add missing keys - for k in DEFAULT_SETTINGS.keys(): - if !settings.has(k): - settings[k] = DEFAULT_SETTINGS[k] - + var saved_settings = f.get_var() + if saved_settings != null and saved_settings is Dictionary: + for i in DEFAULT_SETTINGS.keys(): + if saved_settings.has(i): + settings[i] = saved_settings[i] + print("Loaded settings: ", settings) |