main sched

This commit is contained in:
ineed bots 2023-08-29 14:14:44 -06:00
parent 8a6f707e4e
commit fe55a14edc
2 changed files with 13 additions and 4 deletions

View File

@ -93,6 +93,11 @@ namespace scheduler
execute(pipeline::server); execute(pipeline::server);
} }
void execute_main()
{
execute(pipeline::main);
}
utils::hook::detour com_init_hook; utils::hook::detour com_init_hook;
utils::hook::detour gscr_postloadscripts_hook; utils::hook::detour gscr_postloadscripts_hook;
@ -110,6 +115,8 @@ namespace scheduler
{ {
func(); func();
} }
post_init_funcs.clear();
} }
void com_init_stub() void com_init_stub()
@ -156,7 +163,7 @@ namespace scheduler
{ {
if (com_inited) if (com_inited)
{ {
callback(); once(callback, pipeline::main);
} }
else else
{ {
@ -180,6 +187,7 @@ namespace scheduler
com_init_hook.create(SELECT(0x0, 0x59D710), com_init_stub); com_init_hook.create(SELECT(0x0, 0x59D710), com_init_stub);
utils::hook::call(SELECT(0x0, 0x503B5D), execute_server); utils::hook::call(SELECT(0x0, 0x503B5D), execute_server);
utils::hook::call(SELECT(0x0, 0x59DCFD), execute_main);
} }
}; };
} }

View File

@ -6,17 +6,18 @@ namespace scheduler
{ {
server, server,
async, async,
main,
count, count,
}; };
static const bool cond_continue = false; static const bool cond_continue = false;
static const bool cond_end = true; static const bool cond_end = true;
void schedule(const std::function<bool()>& callback, pipeline type = pipeline::server, void schedule(const std::function<bool()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms); std::chrono::milliseconds delay = 0ms);
void loop(const std::function<void()>& callback, pipeline type = pipeline::server, void loop(const std::function<void()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms); std::chrono::milliseconds delay = 0ms);
void once(const std::function<void()>& callback, pipeline type = pipeline::server, void once(const std::function<void()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms); std::chrono::milliseconds delay = 0ms);
void on_init(const std::function<void()>& callback); void on_init(const std::function<void()>& callback);