summaryrefslogtreecommitdiffhomepage
path: root/src/demorec.h
blob: b53896f7fd4e19721f33bcda629d7ab8f5def8d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * Copyright © 2021 Willian Henrique <wsimanbrazil@yahoo.com.br>
 * 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
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef INC_DEMOREC_H
#define INC_DEMOREC_H

#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). Value will be zero if the recording is stopped
 * before the game has even gotten a chance to create the first demo file.
 */
int demorec_stop(void);

/*
 * Returns the current number in the recording sequence, or -1 if not recording.
 * Value may be 0 if recording was requested but has yet to start (say, because
 * we have yet to join a map).
 */
int demorec_demonum(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(DemoControlAllowed, void)

/*
 * Emitted whenever a recording session is about to be started, as a result of
 * either the record command or a call to the demorec_start() function. A demo
 * file won't actually have been created yet; this merely indicates that a
 * request to record has happened.
 */
DECL_EVENT(DemoRecordStarting, void)

/*
 * Emitted when the current demo or series of demos has finished recording.
 * Receives the number of recorded demo files (which could be 0) as an argument.
 */
DECL_EVENT(DemoRecordStopped, int)

#endif

// vi: sw=4 ts=4 noet tw=80 cc=80