From 1a5c55eb89c22e8822ec057a3731a6d753f13859 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 30 Apr 2022 00:23:31 +0100 Subject: Centralise engine access, add Portal FOV changer - A bunch of stuff is now defined in one header, engineapi.h - engineapi.c is responsible for setting up any interfaces/stuff that's used in more than one place - mkgamedata is pretty much rewritten and now supports nested conditionals - gamedata variables no longer have the gamedata_ prefix because it was just annoyingly long all the time - vcall macros are somewhat revamped and support dynamic (gamedata) indices - Portal 1 FOV can be set anywhere from 75-120 using fov_desired - tested in both the main versions currently used by runners - A few typos were also fixed ("intput," "writeable," "indexes") --- src/nosleep.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/nosleep.c') diff --git a/src/nosleep.c b/src/nosleep.c index db206e0..4ad02df 100644 --- a/src/nosleep.c +++ b/src/nosleep.c @@ -17,9 +17,9 @@ #include #include "con_.h" -#include "hook.h" -#include "factory.h" +#include "engineapi.h" #include "gamedata.h" +#include "hook.h" #include "os.h" #include "vcall.h" @@ -44,30 +44,29 @@ bool nosleep_init(void) { con_warn("nosleep: missing required factories\n"); return false; } - if (!gamedata_has_vtidx_SleepUntilInput) { + if (!has_vtidx_SleepUntilInput) { con_warn("nosleep: missing gamedata entries for this engine\n"); return false; } void *insys = factory_inputsystem("InputSystemVersion001", 0); if (!insys) { - con_warn("nosleep: couldn't get intput system interface\n"); + con_warn("nosleep: couldn't get input system interface\n"); return false; } vtable = *(void ***)insys; - if (!os_mprot(vtable + gamedata_vtidx_SleepUntilInput, - sizeof(void *), PAGE_EXECUTE_READWRITE)) { - con_warn("nosleep: couldn't make memory writeable\n"); + if (!os_mprot(vtable + vtidx_SleepUntilInput, sizeof(void *), + PAGE_EXECUTE_READWRITE)) { + con_warn("nosleep: couldn't make memory writable\n"); return false; } orig_SleepUntilInput = (SleepUntilInput_func)hook_vtable(vtable, - gamedata_vtidx_SleepUntilInput, (void *)&hook_SleepUntilInput); + vtidx_SleepUntilInput, (void *)&hook_SleepUntilInput); engine_no_focus_sleep->base.flags &= ~CON_HIDDEN; return true; } void nosleep_end(void) { - unhook_vtable(vtable, gamedata_vtidx_SleepUntilInput, - (void *)orig_SleepUntilInput); + unhook_vtable(vtable, vtidx_SleepUntilInput, (void *)orig_SleepUntilInput); } // vi: sw=4 ts=4 noet tw=80 cc=80 -- cgit v1.2.3