Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 35 additions & 19 deletions addons/mod_loader/classes/mod_manifest.gd
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,19 @@ func _init(manifest: Dictionary) -> void:
var mod_id = get_mod_id()
if (not is_mod_id_array_valid(mod_id, dependencies, "dependency") or
not is_mod_id_array_valid(mod_id, incompatibilities, "incompatibility") or
not is_mod_id_array_valid(mod_id, optional_dependencies, "optional_dependency")):
not is_mod_id_array_valid(mod_id, optional_dependencies, "optional_dependency") or
not validate_distinct_mod_ids_in_arrays(
mod_id,
dependencies,
incompatibilities,
["dependencies", "incompatibilities"]
) or
not validate_distinct_mod_ids_in_arrays(
mod_id,
optional_dependencies,
incompatibilities,
["optional_dependencies", "incompatibilities"]
)):
return


Expand Down Expand Up @@ -249,34 +261,38 @@ static func is_semver_valid(check_version_number: String, is_silent := false) ->
return true


# Validates a mod's dependencies and incompatibilities to ensure they don't conflict.
static func validate_dependencies_and_incompatibilities_conflicts(
static func validate_distinct_mod_ids_in_arrays(
mod_id: String,
dependencies: PoolStringArray,
incompatibilities: PoolStringArray,
array_one: PoolStringArray,
array_two: PoolStringArray,
array_description: PoolStringArray,
additional_info := "",
is_silent := false
) -> bool:
# Initialize an empty array to hold any overlaps.
var overlaps: PoolStringArray = []

# Loop through each incompatibility and check if it is also listed as a dependency.
for incompatibility in incompatibilities:
if dependencies.has(incompatibility):
overlaps.push_back(incompatibility)
for mod_id in array_one:
if array_two.has(mod_id):
overlaps.push_back(mod_id)

# If any overlaps were found, log a fatal error message and return true.
if overlaps.size() > 0:
if not is_silent:
ModLoaderUtils.log_fatal(
(
"The mod -> %s lists the same mod(s) -> %s - in incompatibilities and dependencies"
% [mod_id, overlaps]
),
LOG_NAME
)
# If no overlaps were found
if overlaps.size() == 0:
return true

# If no overlaps were found, return false.
# If any overlaps were found
if not is_silent:
ModLoaderUtils.log_fatal(
(
"The mod -> %s lists the same mod(s) -> %s - in \"%s\" and \"%s\". %s"
% [mod_id, overlaps, array_description[0], array_description[1], additional_info]
),
LOG_NAME
)
return false

# If silent just return false
return false


Expand Down