Descent3/lib/dedicated_server.h

67 lines
1.8 KiB
C
Raw Normal View History

2024-04-16 03:43:29 +00:00
#ifndef DEDICATED_SERVER_H
#define DEDICATED_SERVER_H
2024-04-16 18:56:40 +00:00
#define CVAR_GAMEINIT 0x0001 // this variable can be set/changed during server init
#define CVAR_GAMEPLAY 0x0002 // this variable can be set/changed during game play
typedef enum {
CVAR_TYPE_INT,
CVAR_TYPE_FLOAT,
CVAR_TYPE_STRING,
CVAR_TYPE_NONE,
2024-04-16 03:43:29 +00:00
} cvar_type;
2024-04-16 18:56:40 +00:00
typedef struct {
char *varname;
cvar_type type;
void *dest_variable;
int var_min, var_max;
short permissions;
2024-04-16 03:43:29 +00:00
} cvar_entry;
extern bool Dedicated_server;
// Sets the value for a cvar INT type
2024-04-16 18:56:40 +00:00
void SetCVarInt(int index, int val);
2024-04-16 03:43:29 +00:00
// Sets the value for a cvar FLOAT type
2024-04-16 18:56:40 +00:00
void SetCVarFloat(int index, float val);
2024-04-16 03:43:29 +00:00
// Sets the value for a cvar string type
2024-04-16 18:56:40 +00:00
void SetCVarString(int index, char *val);
2024-04-16 03:43:29 +00:00
// The accessor function that sets the value of a cvar
2024-04-16 18:56:40 +00:00
void SetCVar(char *cvar_string, char *cvar_argument, bool in_game_init);
2024-04-16 03:43:29 +00:00
// The accessor function that sets the value of a cvar...INT only
2024-04-16 18:56:40 +00:00
void SetCVar(char *cvar_string, int cvar_argument);
2024-04-16 03:43:29 +00:00
// The accessor function that sets the value of a cvar...FLOAT only
2024-04-16 18:56:40 +00:00
void SetCVar(char *cvar_string, float cvar_argument);
2024-04-16 03:43:29 +00:00
// Starts a dedicated server and loads the server config file
2024-04-16 18:56:40 +00:00
void StartDedicatedServer();
2024-04-16 03:43:29 +00:00
// Reads in the server config file for a dedicated server
// Returns true if everything is ok
2024-04-16 18:56:40 +00:00
int LoadServerConfigFile();
2024-04-16 03:43:29 +00:00
// Called once per frame for the dedicated server
2024-04-16 18:56:40 +00:00
void DoDedicatedServerFrame();
2024-04-16 03:43:29 +00:00
// Prints a message to the console if the dedicated server is active
void PrintDedicatedMessage(const char *fmt, ...);
2024-04-16 18:56:40 +00:00
// Reads incoming data from the telnet connection to the server
2024-04-16 03:43:29 +00:00
void DedicatedReadTelnet(void);
2024-04-16 18:56:40 +00:00
// Sends a string to all connected and logged in clients
2024-04-16 03:43:29 +00:00
void DedicatedSocketputs(char *str);
2024-04-16 18:56:40 +00:00
// Look for incoming connections
void ListenDedicatedSocket(void);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Init the socket and start listening
2024-04-16 03:43:29 +00:00
void InitDedicatedSocket(ushort port);
#endif