diff --git a/src/component/scheduler.cpp b/src/component/scheduler.cpp index 8c25a50..0f9b370 100644 --- a/src/component/scheduler.cpp +++ b/src/component/scheduler.cpp @@ -93,6 +93,11 @@ namespace scheduler execute(pipeline::server); } + void execute_main() + { + execute(pipeline::main); + } + utils::hook::detour com_init_hook; utils::hook::detour gscr_postloadscripts_hook; @@ -110,6 +115,8 @@ namespace scheduler { func(); } + + post_init_funcs.clear(); } void com_init_stub() @@ -156,7 +163,7 @@ namespace scheduler { if (com_inited) { - callback(); + once(callback, pipeline::main); } else { @@ -180,6 +187,7 @@ namespace scheduler com_init_hook.create(SELECT(0x0, 0x59D710), com_init_stub); utils::hook::call(SELECT(0x0, 0x503B5D), execute_server); + utils::hook::call(SELECT(0x0, 0x59DCFD), execute_main); } }; } diff --git a/src/component/scheduler.hpp b/src/component/scheduler.hpp index baf6454..8e18997 100644 --- a/src/component/scheduler.hpp +++ b/src/component/scheduler.hpp @@ -6,17 +6,18 @@ namespace scheduler { server, async, + main, count, }; static const bool cond_continue = false; static const bool cond_end = true; - void schedule(const std::function& callback, pipeline type = pipeline::server, + void schedule(const std::function& callback, pipeline type = pipeline::main, std::chrono::milliseconds delay = 0ms); - void loop(const std::function& callback, pipeline type = pipeline::server, + void loop(const std::function& callback, pipeline type = pipeline::main, std::chrono::milliseconds delay = 0ms); - void once(const std::function& callback, pipeline type = pipeline::server, + void once(const std::function& callback, pipeline type = pipeline::main, std::chrono::milliseconds delay = 0ms); void on_init(const std::function& callback);