From 3ff6d47277fc0e39053584d8889240cab446a72a Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 5 May 2023 00:04:43 +0100 Subject: Implement APIs to control demo recording This is a surprise tool that will help us later! --- src/demorec.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'src/demorec.h') 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 - * Copyright © 2021 Michael Smith + * Copyright © 2023 Michael Smith * * 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 -- cgit v1.2.3