Rehooking will only happen when allow_rehooking is set to true
This commit is contained in:
parent
4cbdba8951
commit
9f05b8a326
1 changed files with 7 additions and 1 deletions
|
@ -107,6 +107,12 @@ local function get_return_values(...)
|
||||||
return num, { ... }
|
return num, { ... }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function can_rehook(mod, hook_data, obj, hook_type)
|
||||||
|
if mod:get_internal_data("allow_rehooking") and hook_data.obj == obj and hook_data.hook_type == hook_type then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
-- ##### Hook Creation ################################################################################################
|
-- ##### Hook Creation ################################################################################################
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
@ -233,7 +239,7 @@ local function create_hook(mod, orig, obj, method, handler, func_name, hook_type
|
||||||
-- If hook_data already exists and it's the same hook_type, we can safely change the hook handler.
|
-- If hook_data already exists and it's the same hook_type, we can safely change the hook handler.
|
||||||
-- This should (in practice) only be used for debugging by modders who uses DoFile.
|
-- This should (in practice) only be used for debugging by modders who uses DoFile.
|
||||||
-- Revisit purpose when lua files are in plain text.
|
-- Revisit purpose when lua files are in plain text.
|
||||||
if hook_data.obj == obj and hook_data.hook_type == hook_type then
|
if can_rehook(mod, hook_data, obj, hook_type) then
|
||||||
hook_data.handler = handler
|
hook_data.handler = handler
|
||||||
else
|
else
|
||||||
-- This should be a warning log, but currently there are no differences between warning and error.
|
-- This should be a warning log, but currently there are no differences between warning and error.
|
||||||
|
|
Loading…
Add table
Reference in a new issue