aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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__)