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
27 changes: 15 additions & 12 deletions addons/mod_loader/internal/mod_hook_preprocessor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,7 @@ func process_script(path: String) -> String:
var getters_setters := collect_getters_and_setters(source_code, regex_getter_setter)

var moddable_methods := current_script.get_script_method_list().filter(
func is_func_moddable(method: Dictionary):
if getters_setters.has(method.name):
return false

var method_first_line_start := _ModLoaderModHookPreProcessor.get_index_at_method_start(method.name, source_code)
if method_first_line_start == -1:
return false

if not _ModLoaderModHookPreProcessor.is_func_marked_moddable(method_first_line_start, source_code):
return false

return true
is_func_moddable.bind(source_code, getters_setters)
)

for method in moddable_methods:
Expand Down Expand Up @@ -125,6 +114,20 @@ func process_script(path: String) -> String:
return source_code


static func is_func_moddable(method: Dictionary, source_code: String, getters_setters := {}) -> bool:
if getters_setters.has(method.name):
return false

var method_first_line_start := _ModLoaderModHookPreProcessor.get_index_at_method_start(method.name, source_code)
if method_first_line_start == -1:
return false

if not _ModLoaderModHookPreProcessor.is_func_marked_moddable(method_first_line_start, source_code):
return false

return true


static func get_function_arg_name_string(args: Array) -> String:
var arg_string := ""
for x in args.size():
Expand Down