]> git.xonotic.org Git - xonotic/darkplaces.git/blob - host.h
csqc: Implement builtin #177 "localsound"
[xonotic/darkplaces.git] / host.h
1 #ifndef HOST_H
2 #define HOST_H
3
4 #include <setjmp.h>
5 #include "qtypes.h"
6 #include "qdefs.h"
7 #include "cmd.h"
8
9 struct cmd_state_s;
10
11 typedef enum host_state_e
12 {
13         host_shutdown,
14         host_init,
15         host_loading,
16         host_active
17 } host_state_t;
18
19 typedef struct host_static_s
20 {
21         jmp_buf abortframe;
22         int state;
23         int framecount; // incremented every frame, never reset (checked by Host_Error and Host_SaveConfig_f)
24         double realtime; // the accumulated mainloop time since application started (with filtering), without any slowmo or clamping
25         double dirtytime; // the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame
26         double sleeptime; // time spent sleeping overall
27         qbool restless; // don't sleep
28         qbool paused; // global paused state, pauses both client and server
29         cmd_buf_t *cbuf;
30
31         struct
32         {
33                 void (*ConnectLocal)(void);
34                 void (*Disconnect)(qbool, const char *, ... );
35                 void (*ToggleMenu)(void);
36                 qbool (*CL_Intermission)(void); // Quake compatibility
37                 void (*CL_SendCvar)(struct cmd_state_s *);
38                 void (*SV_SendCvar)(struct cmd_state_s *);
39                 void (*SV_Shutdown)(void);
40         } hook;
41 } host_static_t;
42
43 extern host_static_t host;
44
45 void Host_Main(void);
46 void Host_Shutdown(void);
47 void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
48 void Host_LockSession(void);
49 void Host_UnlockSession(void);
50 void Host_AbortCurrentFrame(void) DP_FUNC_NORETURN;
51 void Host_SaveConfig(const char *file);
52
53 #endif