summaryrefslogtreecommitdiffhomepage
path: root/src/demorec.h
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2023-05-05 00:04:43 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2023-05-05 00:06:17 +0100
commit3ff6d47277fc0e39053584d8889240cab446a72a (patch)
tree03c26795061fc472d2224efefa283af6b42fe3e0 /src/demorec.h
parentea752466846c129a0910e47d34d725af1aea5d84 (diff)
Implement APIs to control demo recording
This is a surprise tool that will help us later!
Diffstat (limited to 'src/demorec.h')
-rw-r--r--src/demorec.h51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/demorec.h b/src/demorec.h
index 40f8c38..2de4f24 100644
--- a/src/demorec.h
+++ b/src/demorec.h
@@ -1,6 +1,6 @@
/*
* Copyright © 2021 Willian Henrique <wsimanbrazil@yahoo.com.br>
- * Copyright © 2021 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -18,9 +18,56 @@
#ifndef INC_DEMOREC_H
#define INC_DEMOREC_H
-/* For internal use by democustom */
+#include "event.h"
+
+// For internal use by democustom
extern void *demorecorder;
+/*
+ * Whether to ignore the value of the sst_autorecord cvar and just keep
+ * recording anyway. Will be used to further automate demo recording later.
+ */
+extern bool demorec_forceauto;
+
+/*
+ * The current/last basename for recorded demos - to which _2, _3, etc. is
+ * appended by the engine. May contain garbage or null bytes if recording hasn't
+ * been started.
+ *
+ * This is currently implemented as a pointer directly inside the engine demo
+ * recorder instance.
+ */
+extern const char *demorec_basename;
+
+/*
+ * Starts recording a demo with the provided name (or relative path). If a demo
+ * is already being recorded, or the path was deemed invalid by the game, does
+ * nothing and returns false. Otherwise returns true.
+ *
+ * Assumes any subdirectories already exist - recording may silently fail
+ * otherwise.
+ */
+bool demorec_start(const char *name);
+
+/*
+ * Stops recording the current demo and returns the number of demos recorded
+ * (the first will have the original basename + .dem extension; the rest will
+ * have the _N.dem suffixes).
+ */
+int demorec_stop(void);
+
+/*
+ * Queries whether a demo is currently being recorded.
+ */
+bool demorec_recording(void);
+
+/*
+ * Used to determine whether to allow usage of the normal record and stop
+ * commands. Code which takes over control of demo recording can use this to
+ * block the user from interfering.
+ */
+DECL_PREDICATE(AllowDemoControl)
+
#endif
// vi: sw=4 ts=4 noet tw=80 cc=80