]> git.xonotic.org Git - xonotic/darkplaces.git/blob - host.h
d4beddfd7db806cb35783519730b787e0fa63ac5
[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 typedef enum host_state_e
10 {
11         host_shutdown,
12         host_init,
13         host_loading,
14         host_active
15 } host_state_t;
16
17 typedef struct host_s
18 {
19         jmp_buf abortframe;
20         int state;
21         int framecount; // incremented every frame, never reset (checked by Host_Error and Host_SaveConfig_f)
22         double realtime; // the accumulated mainloop time since application started (with filtering), without any slowmo or clamping
23         double dirtytime; // the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame
24         double sleeptime; // time spent sleeping overall
25         qbool restless; // don't sleep
26         qbool paused; // global paused state, pauses both client and server
27         cmd_buf_t *cbuf;
28
29         struct
30         {
31                 void (*ConnectLocal)(void);
32                 void (*Disconnect)(void);
33                 void (*ToggleMenu)(void);
34                 qbool (*CL_Intermission)(void); // Quake compatibility
35                 qbool (*SV_CanSave)(void); // Quake compatibility
36         } hook;
37 } host_t;
38
39 extern host_t host;
40
41 void Host_InitCommands(void);
42 void Host_Main(void);
43 double Host_Frame(double time);
44 void Host_Shutdown(void);
45 void Host_StartVideo(void);
46 void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
47 void Host_LockSession(void);
48 void Host_UnlockSession(void);
49 void Host_AbortCurrentFrame(void);
50 void Host_SaveConfig(void);
51 void Host_LoadConfig_f(cmd_state_t *cmd);
52 void Host_NoOperation_f(cmd_state_t *cmd);
53
54 #endif