Debian Codegraph @

lib/dedicated_server.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef DEDICATED_SERVER_H
20 #define DEDICATED_SERVER_H
21
22 #define CVAR_GAMEINIT 0x0001 // this variable can be set/changed during server init
23 #define CVAR_GAMEPLAY 0x0002 // this variable can be set/changed during game play
24
25 enum cvar_type {
26 CVAR_TYPE_INT,
27 CVAR_TYPE_FLOAT,
28 CVAR_TYPE_STRING,
29 CVAR_TYPE_NONE,
30 };
31
32 struct cvar_entry {
33 const char *varname;
34 cvar_type type;
35 void *dest_variable;
36 int var_min, var_max;
37 int16_t permissions;
38 };
39
40 extern bool Dedicated_server;
41
42 // Sets the value for a cvar INT type
43 void SetCVarInt(int index, int val);
44
45 // Sets the value for a cvar FLOAT type
46 void SetCVarFloat(int index, float val);
47
48 // Sets the value for a cvar string type
49 void SetCVarString(int index, const char *val);
50
51 // The accessor function that sets the value of a cvar
52 void SetCVar(const char *cvar_string, const char *cvar_argument, bool in_game_init);
53
54 // The accessor function that sets the value of a cvar...INT only
55 void SetCVar(const char *cvar_string, int cvar_argument);
56
57 // The accessor function that sets the value of a cvar...FLOAT only
58 void SetCVar(const char *cvar_string, float cvar_argument);
59
60 // Starts a dedicated server and loads the server config file
61 void StartDedicatedServer();
62
63 // Reads in the server config file for a dedicated server
64 // Returns true if everything is ok
65 int LoadServerConfigFile();
66
67 // Called once per frame for the dedicated server
68 void DoDedicatedServerFrame();
69
70 // Prints a message to the console if the dedicated server is active
71 void PrintDedicatedMessage(const char *fmt, ...);
72
73 // Reads incoming data from the telnet connection to the server
74 void DedicatedReadTelnet(void);
75
76 // Sends a string to all connected and logged in clients
77 void DedicatedSocketputs(char *str);
78
79 // Look for incoming connections
80 void ListenDedicatedSocket(void);
81
82 // Init the socket and start listening
83 void InitDedicatedSocket(uint16_t port);
84
85 #endif