Skip to content

Commit ad1f2b1

Browse files
authored
Merge pull request #68 from Qubus0/fix_missing_mod_dir_name
fix validating mod dir name
2 parents 6b931f9 + 2205e52 commit ad1f2b1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

addons/mod_loader/mod_data.gd

+12-11
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

addons/mod_loader/mod_loader.gd

+1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ func _init_mod_data(mod_folder_path):
325325
var local_mod_path = str(UNPACKED_DIR, dir_name)
326326

327327
var mod := ModData.new(local_mod_path)
328+
mod.dir_name = dir_name
328329
mod_data[dir_name] = mod
329330

330331
# Get the mod file paths

0 commit comments

Comments
 (0)