Skip to content

Commit 2205e52

Browse files
committed
fix validation of folder name and mod id from manifest json
1 parent 8616e1f commit 2205e52

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

addons/mod_loader/mod_data.gd

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,22 @@ func load_manifest() -> void:
4545
# Load meta data file
4646
var manifest_path := get_required_mod_file_path(required_mod_files.MANIFEST)
4747
var manifest_dict := ModLoaderUtils.get_json_as_dict(manifest_path)
48-
4948
ModLoaderUtils.log_debug_json_print("%s loaded manifest data -> " % dir_name, manifest_dict, LOG_NAME)
5049

5150
var mod_manifest := ModManifest.new(manifest_dict)
5251

53-
if not mod_manifest:
54-
is_loadable = false
55-
return
56-
52+
is_loadable = has_manifest(mod_manifest)
53+
if not is_loadable: return
54+
is_loadable = is_mod_dir_name_same_as_id(mod_manifest)
55+
if not is_loadable: return
5756
manifest = mod_manifest
5857

5958

6059
# Validates if [member dir_name] matches [method ModManifest.get_mod_id]
61-
func is_mod_dir_name_same_as_id() -> bool:
62-
var manifest_id := manifest.get_mod_id()
60+
func is_mod_dir_name_same_as_id(mod_manifest: ModManifest) -> bool:
61+
var manifest_id := mod_manifest.get_mod_id()
6362
if not dir_name == manifest_id:
64-
ModLoaderUtils.log_fatal('Mod directory name "%s" does not match the data in manifest.json. Expected "%s"' % [ dir_name, manifest_id ], LOG_NAME)
65-
is_loadable = false
63+
ModLoaderUtils.log_fatal('Mod directory name "%s" does not match the data in manifest.json. Expected "%s" (Format: {namespace}-{name})' % [ dir_name, manifest_id ], LOG_NAME)
6664
return false
6765
return true
6866

@@ -81,8 +79,11 @@ func has_required_files() -> bool:
8179

8280

8381
# Validates if manifest is set
84-
func has_manifest() -> bool:
85-
return not manifest == null
82+
func has_manifest(mod_manifest: ModManifest) -> bool:
83+
if mod_manifest == null:
84+
ModLoaderUtils.log_fatal("Mod manifest could not be created correctly due to errors.", LOG_NAME)
85+
return false
86+
return true
8687

8788

8889
# Converts enum indices [member required_mod_files] into their respective file paths

0 commit comments

Comments
 (0)