Try to add a detour to whatever is called by RegisterSpawnFunction

This commit is contained in:
Nikita Tomashevich 2024-09-11 13:46:21 +03:00
parent c6524b07bb
commit fbdbb30d60
2 changed files with 20 additions and 19 deletions

View file

@ -1,5 +1,23 @@
local orig_RegisterSpawnFunction = RegisterSpawnFunction
function RegisterSpawnFunction(color, fn_name)
local orig_do_mod_appends = do_mod_appends
-- The root file that imported everything else.
-- TODO: maybe dofile should be patched?
EwImportRoot = "???"
orig_do_mod_appends = do_mod_appends
do_mod_appends = function(filename, ...)
--do_mod_appends = orig_do_mod_appends
orig_do_mod_appends(filename, ...)
EwImportRoot = filename
end
function RegisterSpawnFunction(color, fn_name)
local root_id = "???" -- TODO, this should be id (path) of a file that actually calls RegisterSpawnFunction, that we can dofile to call related functions manually.
detour_fn_name = "ew_detour_"..fn_name
_G[detour_fn_name] = function(...)
_G[fn_name](...)
end
RegisterSpawnFunction(color, detour_fn_name)
end

View file

@ -2,21 +2,4 @@ ModLuaFileAppend("data/scripts/director_helpers.lua", "mods/quant.ew/files/syste
local module = {}
local module.files_with_spawnhooks = {}
for line in string.gmatch(ModTextFileGetContent("mods/quant.ew/files/system/wang_hooks/files_with_spawnhooks.txt"), "(.-)\n") do
-- print("Interned", line)
table.insert(module.files_with_spawnhooks, line)
end
local function patch_file(filename)
end
function module.on_late_init()
for _, filename in ipairs(module.files_with_spawnhooks) do
patch_file(filename)
end
end
return module