summaryrefslogtreecommitdiff
path: root/src/sst.c
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-12-26 23:12:11 +0000
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2026-02-16 19:11:24 +0000
commitaf370088fc178996a46ee508aaa1a2c46318bbf2 (patch)
treecf1f6c01ad7c101d3fd4abb44835d9deb600e30d /src/sst.c
parent40f9d989df2c1ff2f567656ccbdbfc0d97e34a77 (diff)
downloadsst-af370088fc178996a46ee508aaa1a2c46318bbf2.tar.gz
sst-af370088fc178996a46ee508aaa1a2c46318bbf2.zip
Move to static trampolines and type-safe hooks
For some reason the DLL got a tiny little bit bigger again but that's fine. This will make orig_ calls more efficient in the inline case, and also make it harder to screw up and hook the wrong thing by mistake. Self-explanatory-ish, apart from the fact it's a fairly large API change of course. And it relies on some more bonkers assembler directive hackery. But it works! The only complaint one might have is that the featsetup functions no longer take an explicit string which occasionally yields slightly less perfect error messages, but I've decided this isn't really a problem and makes the API nicer to use. It's a tradeoff, innit.
Diffstat (limited to 'src/sst.c')
-rw-r--r--src/sst.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/sst.c b/src/sst.c
index 64dd303..070ce12 100644
--- a/src/sst.c
+++ b/src/sst.c
@@ -367,12 +367,12 @@ if (GAMETYPE_MATCHES(x)) { \
}
typedef void (*VCALLCONV VGuiConnect_func)(struct CEngineVGui *this);
-static VGuiConnect_func orig_VGuiConnect;
-static void VCALLCONV hook_VGuiConnect(struct CEngineVGui *this) {
+DEF_VTABLE_HOOK(VGuiConnect_func, VGuiConnect)
+static void VCALLCONV hookdest_VGuiConnect(struct CEngineVGui *this) {
orig_VGuiConnect(this);
do_featureinit();
fixes_apply();
- unhook_vtable(vgui->vtable, vtidx_VGuiConnect, (void *)orig_VGuiConnect);
+ unhook_VGuiConnect(vgui->vtable, vtidx_VGuiConnect);
}
DECL_VFUNC_DYN(struct CEngineVGui, bool, VGuiIsInitialized)
@@ -413,8 +413,7 @@ static bool deferinit() {
"feature setup");
goto e;
}
- orig_VGuiConnect = (VGuiConnect_func)hook_vtable(vgui->vtable,
- vtidx_VGuiConnect, (void *)&hook_VGuiConnect);
+ hook_VGuiConnect(vgui->vtable, vtidx_VGuiConnect, &hookdest_VGuiConnect);
return true;
e: con_warn("!!! SOME FEATURES MAY BE BROKEN !!!\n");