summaryrefslogtreecommitdiffhomepage
path: root/src/demorec.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-07-31 16:02:10 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-08-10 22:40:52 +0100
commit5e921bf59373d79d27c322ff86e8b5a37b151e45 (patch)
tree4d40e39543b085ce4c8cb9b1a7b3c0108de680c0 /src/demorec.c
parentc8d7588251fd4fe63ac6afe2a90ca7066c786609 (diff)
Add magical feature codegen system, at long last
Diffstat (limited to 'src/demorec.c')
-rw-r--r--src/demorec.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/demorec.c b/src/demorec.c
index 1fb5e8e..50128f0 100644
--- a/src/demorec.c
+++ b/src/demorec.c
@@ -21,6 +21,7 @@
#include "con_.h"
#include "engineapi.h"
#include "errmsg.h"
+#include "feature.h"
#include "gamedata.h"
#include "gameinfo.h"
#include "hook.h"
@@ -32,6 +33,9 @@
#include "x86.h"
#include "x86util.h"
+FEATURE("improved demo recording")
+REQUIRE_GAMEDATA(vtidx_StopRecording)
+
DEF_CVAR(sst_autorecord, "Continuously record demos even after reconnecting", 1,
CON_ARCHIVE | CON_HIDDEN)
@@ -187,7 +191,7 @@ static inline bool find_recmembers(void *stoprecording) {
recording = mem_offset(demorecorder, mem_load32(p + 2));
}
if (recording && demonum) return true; // blegh
- NEXT_INSN(p, "state variables");
+ NEXT_INSN(p, "recording state variables");
}
#else // linux is probably different here idk
#warning TODO(linux): implement linux equivalent (???)
@@ -195,11 +199,7 @@ static inline bool find_recmembers(void *stoprecording) {
return false;
}
-bool demorec_init(void) {
- if (!has_vtidx_StopRecording) {
- errmsg_errorx("missing gamedata entries for this engine");
- return false;
- }
+INIT {
cmd_record = con_findcmd("record");
if (!cmd_record) { // can *this* even happen? I hope not!
errmsg_errorx("couldn't find \"record\" command");
@@ -240,7 +240,7 @@ bool demorec_init(void) {
return true;
}
-void demorec_end(void) {
+END {
// avoid dumb edge case if someone somehow records and immediately unloads
if (*recording && *demonum == 0) *demonum = 1;
void **vtable = *(void ***)demorecorder;