aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-16 21:28:45 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-16 21:31:20 +0100
commit0b40d4d9ea1cbfbb92795e0d6f26cf108f2dec5f (patch)
tree3caf7789a3141a369575c0749124089dbc08e916 /src
parent7dcdcd0f62c7c103148b17aed8376a457aad6d8a (diff)
downloadsst-0b40d4d9ea1cbfbb92795e0d6f26cf108f2dec5f.tar.gz
sst-0b40d4d9ea1cbfbb92795e0d6f26cf108f2dec5f.zip
Add missing REQUIRE_GAMEDATA things to demorec
These gamedata entries are always available, but there's no reason not to check for them in case that changes in future. As-is now, the checks will be trivial for the compiler to optimise out.
Diffstat (limited to 'src')
-rw-r--r--src/demorec.c9
-rw-r--r--src/vcall.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/demorec.c b/src/demorec.c
index a14798a..5aacf06 100644
--- a/src/demorec.c
+++ b/src/demorec.c
@@ -36,7 +36,10 @@
#include "x86util.h"
FEATURE("improved demo recording")
+REQUIRE_GAMEDATA(vtidx_SetSignonState)
+REQUIRE_GAMEDATA(vtidx_StartRecording)
REQUIRE_GAMEDATA(vtidx_StopRecording)
+REQUIRE_GAMEDATA(vtidx_RecordPacket)
DEF_FEAT_CVAR(sst_autorecord,
"Continuously record demos even after reconnecting", 1, CON_ARCHIVE)
@@ -56,7 +59,9 @@ DEF_PREDICATE(DemoControlAllowed)
DEF_EVENT(DemoRecordStarting)
DEF_EVENT(DemoRecordStopped, int)
-typedef void (*VCALLCONV SetSignonState_func)(void *, int);
+DECL_VCALL_DYN(SetSignonState, int)
+
+//typedef void (*VCALLCONV SetSignonState_func)(void *, int);
static SetSignonState_func orig_SetSignonState;
static void VCALLCONV hook_SetSignonState(void *this_, int state) {
struct CDemoRecorder *this = this_;
@@ -293,7 +298,7 @@ END {
if_hot (!sst_userunloaded) return;
// avoid dumb edge case if someone somehow records and immediately unloads
if (*recording && *demonum == 0) *demonum = 1;
- void **vtable = *(void ***)demorecorder;
+ void **vtable = mem_loadptr(demorecorder);
unhook_vtable(vtable, vtidx_SetSignonState, (void *)orig_SetSignonState);
unhook_vtable(vtable, vtidx_StopRecording, (void *)orig_StopRecording);
cmd_record->cb = orig_record_cb;
diff --git a/src/vcall.h b/src/vcall.h
index 285bc79..55fcfe6 100644
--- a/src/vcall.h
+++ b/src/vcall.h
@@ -128,7 +128,7 @@
#define DECL_VFUNC_CDECL(ret, name, idx, ...) \
_DECL_VFUNC(ret, , name, idx __VA_OPT__(,) __VA_ARGS__)
-/* Define a virtual function with an index defined elsewhere */
+/* Define a virtual function with an index defined elsewhere (e.g. gamedata) */
#define DECL_VFUNC_DYN(ret, name, ...) \
_DECL_VFUNC_DYN(ret, VCALLCONV, name __VA_OPT__(,) __VA_ARGS__)