aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/global.gd12
1 files changed, 12 insertions, 0 deletions
diff --git a/client/global.gd b/client/global.gd
index 5e016178..0648d80a 100644
--- a/client/global.gd
+++ b/client/global.gd
@@ -114,6 +114,10 @@ func load_dict(path: String, default: Dictionary) -> Dictionary:
return default
var f = FileAccess.open(path, FileAccess.READ)
var saved_dict = f.get_var(true)
+
+ if saved_dict != null and saved_dict is Dictionary:
+ add_missing_keys(saved_dict, default)
+
return saved_dict
func load_settings(path: String):
@@ -219,3 +223,11 @@ func language_list():
func array_eq(a, b):
return a.all(func(e): return a.count(e) == b.count(e))
+
+func add_missing_keys(dict: Dictionary, reference: Dictionary):
+ for k in reference.keys():
+ if !dict.has(k):
+ dict[k] = reference[k]
+ else:
+ if dict[k] is Dictionary:
+ add_missing_keys(dict[k], reference[k])