Skip to content

Commit e36724b

Browse files
authored
Merge pull request #71 from Qubus0/no_leading_zero_semver
2 parents ad1f2b1 + cdc0962 commit e36724b

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

addons/mod_loader/mod_loader_utils.gd

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ static func log_debug_json_print(message: String, json_printable, mod_name: Stri
5656

5757

5858
static func _loader_log(message: String, mod_name: String, log_type: String = "info") -> void:
59-
var ignored_arg := get_cmd_line_arg_value("--log-ignore")
60-
var ignored_names: Array = str2var(ignored_arg)
61-
if ignored_names and mod_name in ignored_names:
59+
if is_mod_name_ignored(mod_name):
6260
return
6361

6462
var date := "%s " % get_date_time_string()
@@ -89,6 +87,16 @@ static func _loader_log(message: String, mod_name: String, log_type: String = "i
8987
_write_to_log_file(log_message)
9088

9189

90+
static func is_mod_name_ignored(mod_name: String) -> bool:
91+
var ignored_arg := get_cmd_line_arg_value("--log-ignore")
92+
93+
if not ignored_arg == "":
94+
var ignored_names: Array = ignored_arg.split(",")
95+
if mod_name in ignored_names:
96+
return true
97+
return false
98+
99+
92100
static func _write_to_log_file(log_entry: String) -> void:
93101
var log_file := File.new()
94102

addons/mod_loader/mod_manifest.gd

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ extends Resource
22
# Stores and validates contents of the manifest set by the user
33
class_name ModManifest
44

5+
const LOG_NAME := "ModLoader:ModManifest"
56

67
# Mod name.
78
# Validated by [method is_name_or_namespace_valid]
@@ -95,7 +96,7 @@ func get_package_id() -> String:
9596

9697
# A valid namespace may only use letters (any case), numbers and underscores
9798
# and has to be longer than 3 characters
98-
# /^[a-zA-Z0-9_]{3,}$/
99+
# a-z A-Z 0-9 _ (longer than 3 characters)
99100
static func is_name_or_namespace_valid(name: String) -> bool:
100101
var re := RegEx.new()
101102
re.compile("^[a-zA-Z0-9_]*$") # alphanumeric and _
@@ -114,14 +115,22 @@ static func is_name_or_namespace_valid(name: String) -> bool:
114115

115116
# A valid semantic version should follow this format: {mayor}.{minor}.{patch}
116117
# reference https://semver.org/ for details
117-
# /^[0-9]+\\.[0-9]+\\.[0-9]+$/
118+
# {0-9}.{0-9}.{0-9} (no leading 0, shorter than 16 characters total)
118119
static func is_semver_valid(version_number: String) -> bool:
119120
var re := RegEx.new()
120-
re.compile("^[0-9]+\\.[0-9]+\\.[0-9]+$")
121+
re.compile("^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$")
121122

122123
if re.search(version_number) == null:
123-
printerr('Invalid semantic version: "%s". ' +
124-
'You may only use numbers and periods in this format {mayor}.{minor}.{patch}' % version_number)
124+
ModLoaderUtils.log_fatal('Invalid semantic version: "%s". ' +
125+
'You may only use numbers without leading zero and periods following this format {mayor}.{minor}.{patch}' % version_number,
126+
LOG_NAME
127+
)
128+
return false
129+
130+
if version_number.length() > 16:
131+
ModLoaderUtils.log_fatal('Invalid semantic version: "%s". ' +
132+
'Version number must be shorter than 16 characters.', LOG_NAME
133+
)
125134
return false
126135

127136
return true

0 commit comments

Comments
 (0)