Browse Source

fix: Config is utterly broken

master
Dominique Merle 2 years ago
parent
commit
57b9bac4a2
  1. 9
      core/Config.gd

9
core/Config.gd

@ -13,11 +13,11 @@ var __config : Dictionary
func get_parameter(parameter_key:String, default=null):
hydrate_lazily()
if parameter_key in self.__config:
if self.__config.has(parameter_key):
# print("[Config] Reading parameter `%s' from Config." % parameter_key)
return self.__config[parameter_key]
else:
# printerr("[Config] Unknown parameter `%s'." % parameter_key)
# assert(false)
# print("[Config] Using default value for parameter `%s'." % parameter_key)
return default
@ -27,7 +27,7 @@ func set_parameter(parameter_key:String, parameter_value) -> void:
func hydrate_lazily() -> void:
if null == self.__config:
if null == self.__config or self.__config.empty():
self.__config = load_from_file()
@ -48,5 +48,6 @@ func load_from_file() -> Dictionary:
printerr("[Config] Cannot read from file `%s'." % self.file_path)
return {} # null
var data = file.get_var()
assert(data is Dictionary)
file.close()
return data
Loading…
Cancel
Save