summaryrefslogtreecommitdiffhomepage
path: root/src/nosleep.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-04-30 00:23:31 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-04-30 00:34:47 +0100
commit1a5c55eb89c22e8822ec057a3731a6d753f13859 (patch)
treefa09dd757a1966649119f70717bd11d679c0f179 /src/nosleep.c
parent1aaedffd8c68614936c59d4681e6dc111cb32691 (diff)
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")
Diffstat (limited to 'src/nosleep.c')
-rw-r--r--src/nosleep.c19
1 files changed, 9 insertions, 10 deletions
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 <stdbool.h>
#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