From 4fddfa831d2a33ab3eee7ceb5f181c82d5aa78d2 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 16 Apr 2025 02:13:01 +0100 Subject: 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. --- src/l4dreset.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/l4dreset.c') diff --git a/src/l4dreset.c b/src/l4dreset.c index 2de75cd..84daa65 100644 --- a/src/l4dreset.c +++ b/src/l4dreset.c @@ -549,8 +549,11 @@ INIT { errmsg_errorx("couldn't find UnfreezeTeam function"); return FEAT_INCOMPAT; } - orig_UnfreezeTeam = (UnfreezeTeam_func)hook_inline( - (void *)orig_UnfreezeTeam, (void *)&hook_UnfreezeTeam); + struct hook_inline_featsetup_ret h = hook_inline_featsetup( + (void *)orig_UnfreezeTeam, (void **)&orig_UnfreezeTeam, + "UnfreezeTeam"); + if_cold (h.err) return h.err; + hook_inline_commit(h.prologue, (void *)&hook_UnfreezeTeam); } #endif // Only try cooldown stuff for L4D2, since L4D1 always had unlimited votes. -- cgit v1.2.3-54-g00ecf