aboutsummaryrefslogtreecommitdiff
path: root/src/fov.c
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-16 02:13:01 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-16 21:31:20 +0100
commit4fddfa831d2a33ab3eee7ceb5f181c82d5aa78d2 (patch)
treef62a0fc1a0b3d7ffcd7967b98885453636309686 /src/fov.c
parent5c805aac744df43dd96f70bc7e39337d9c3a966a (diff)
downloadsst-4fddfa831d2a33ab3eee7ceb5f181c82d5aa78d2.tar.gz
sst-4fddfa831d2a33ab3eee7ceb5f181c82d5aa78d2.zip
Rework API for inline hooking
This both simplifies and complicates things, but probably hopefully maybe simplifies things overall. Certainly in cases like the L4D1 demo thing where there's 3 inline hooks at once, it seems simpler to be able to batch the fallible stuff to avoid rollbacks. In cases where you only need one hook, it's a bit more verbose, but what can you do. Thanks bill for discussing this with me pretty exhaustively and giving a lot of good input. I think both of us still kind of hate it actually.
Diffstat (limited to 'src/fov.c')
-rw-r--r--src/fov.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/fov.c b/src/fov.c
index 967d783..bfef858 100644
--- a/src/fov.c
+++ b/src/fov.c
@@ -100,12 +100,12 @@ INIT {
errmsg_errorx("couldn't find SetDefaultFOV function");
return FEAT_INCOMPAT;
}
- orig_SetDefaultFOV = (SetDefaultFOV_func)hook_inline(
- (void *)orig_SetDefaultFOV, (void *)&hook_SetDefaultFOV);
- if_cold (!orig_SetDefaultFOV) {
- errmsg_errorsys("couldn't hook SetDefaultFOV function");
- return FEAT_FAIL;
- }
+
+ struct hook_inline_featsetup_ret h = hook_inline_featsetup(
+ (void *)orig_SetDefaultFOV, (void **)&orig_SetDefaultFOV,
+ "SetDefaultFov");
+ if_cold (h.err) return h.err;
+ hook_inline_commit(h.prologue, (void *)&hook_SetDefaultFOV);
// we might not be using our cvar but simpler to do this unconditionally
fov_desired->cb = &fovcb;