fix(climate): 🐛 Fix inconsistent lens unlock processing order by sorting filenames deterministically
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
e0b37c3b60
commit
6e02f0b174
1 changed files with 11 additions and 6 deletions
|
|
@ -30,18 +30,23 @@ func _build_maps_from_lens_data() -> void:
|
|||
)
|
||||
return
|
||||
|
||||
# Sort so `unlock_lens` is called in a reproducible order across runs.
|
||||
var file_names: Array[String] = []
|
||||
dir.list_dir_begin()
|
||||
var file_name: String = dir.get_next()
|
||||
while file_name != "":
|
||||
if file_name.ends_with(".json"):
|
||||
var path: String = LENS_DIR + "/" + file_name
|
||||
var lenses: Array = _load_lens_file(path)
|
||||
for i: int in range(lenses.size()):
|
||||
var lens: Dictionary = lenses[i] as Dictionary
|
||||
if lens != null:
|
||||
_process_lens(lens)
|
||||
file_names.append(file_name)
|
||||
file_name = dir.get_next()
|
||||
dir.list_dir_end()
|
||||
file_names.sort()
|
||||
for sorted_name: String in file_names:
|
||||
var path: String = LENS_DIR + "/" + sorted_name
|
||||
var lenses: Array = _load_lens_file(path)
|
||||
for i: int in range(lenses.size()):
|
||||
var lens: Dictionary = lenses[i] as Dictionary
|
||||
if lens != null:
|
||||
_process_lens(lens)
|
||||
|
||||
|
||||
func _load_lens_file(path: String) -> Array:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue