Skip to content

feat: split off verbose hook preprocessing #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion addons/mod_loader/_export_plugin/export_plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ func _export_file(path: String, type: String, features: PackedStringArray) -> vo
skip()
add_file(
path,
hook_pre_processor.process_script(path, true).to_utf8_buffer(),
hook_pre_processor.process_script_verbose(path, true).to_utf8_buffer(),
false
)
2 changes: 1 addition & 1 deletion addons/mod_loader/internal/mod_hook_packer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static func start() -> void:
if path in script_paths_with_hook:
continue

var processed_source_code := hook_pre_processor.process_script(path)
var processed_source_code := hook_pre_processor.process_script_verbose(path)

zip_writer.start_file(path.trim_prefix("res://"))
zip_writer.write_file(processed_source_code.to_utf8_buffer())
Expand Down
10 changes: 7 additions & 3 deletions addons/mod_loader/internal/mod_hook_preprocessor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ func process_begin() -> void:
hashmap.clear()


func process_script(path: String, enable_hook_check := false) -> String:
func process_script_verbose(path: String, enable_hook_check := false) -> String:
var start_time := Time.get_ticks_msec()
ModLoaderLog.debug("Start processing script at path: %s" % path, LOG_NAME)
var processed := process_script(path, enable_hook_check)
ModLoaderLog.debug("Finished processing script at path: %s in %s ms" % [path, Time.get_ticks_msec() - start_time], LOG_NAME)
return processed


func process_script(path: String, enable_hook_check := false) -> String:
var current_script := load(path) as GDScript

var source_code := current_script.source_code
Expand Down Expand Up @@ -110,8 +116,6 @@ func process_script(path: String, enable_hook_check := false) -> String:
if source_code_additions != "":
source_code = "%s\n%s\n%s" % [source_code, MOD_LOADER_HOOKS_START_STRING, source_code_additions]

ModLoaderLog.debug("Finished processing script at path: %s in %s ms" % [path, Time.get_ticks_msec() - start_time], LOG_NAME)

return source_code


Expand Down