UFO: Alien Invasion
Loading...
Searching...
No Matches
server.h
Go to the documentation of this file.
1
5
6/*
7All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9Original file from Quake 2 v3.21: quake2-2.31/server/server.h
10Copyright (C) 1997-2001 Id Software, Inc.
11
12This program is free software; you can redistribute it and/or
13modify it under the terms of the GNU General Public License
14as published by the Free Software Foundation; either version 2
15of the License, or (at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
21See the GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with this program; if not, write to the Free Software
25Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27*/
28
29#pragma once
30
31#include "../common/common.h"
32#include "../common/http.h"
34#include "../game/game.h"
35#include <SDL_thread.h>
36
38
39typedef struct sv_edict_s {
40 struct worldSector_s* worldSector;
41 struct sv_edict_s* nextEntityInWorldSector;
42 bool linked;
45
47typedef struct sv_model_s {
49 int frame;
50 char* name;
52
57typedef struct worldSector_s {
58 int axis;
59 float dist;
60 struct worldSector_s* children[2];
63
64#define AREA_NODES 32
65
66typedef struct pending_event_s {
68 bool pending;
71 int type;
72 int entnum;
75
76typedef struct serverInstanceStatic_s {
80 struct client_s* clients;
84 bool abandon;
86 SDL_mutex* serverMutex;
87 SDL_cond* gameFrameCond;
88 SDL_Thread* gameThread;
89#ifndef HARD_LINKED_GAME
91#endif
94
102
136
137#define PLAYER_NUM(n) ((player_t*)((byte*)svs.ge->players + svs.ge->player_size * (n)))
138
147
165
167extern serverInstanceGame_t* sv;
168
169extern cvar_t* sv_mapname;
170extern cvar_t* sv_rma;
173extern cvar_t* sv_public;
175extern cvar_t* sv_threads;
176
177/* sv_main.c */
178void SV_DropClient(client_t* drop, const char* message);
179int SV_CountPlayers(void);
180void SV_InitOperatorCommands(void);
182void SV_ReadPacket(struct net_stream* s);
183char* SV_GetConfigString(int index);
186char* SV_SetConfigString(int index, ...);
187/* ensure that always two parameters are used */
188#define SV_SetConfigString(index, value) SV_SetConfigString(index, value)
191
192/* sv_mapcycle.c */
193void SV_MapcycleInit(void);
194void SV_NextMapcycle(void);
195void SV_MapcycleClear(void);
196
197/* sv_init.c */
198void SV_Map(bool day, const char* levelstring, const char* assembly, bool verbose = true);
199
200void SV_Multicast(int mask, const dbuffer& msg);
201void SV_ClientCommand(client_t* client, const char* fmt, ...) __attribute__((format(__printf__,2,3)));
202void SV_ClientPrintf(client_t* cl, int level, const char* fmt, ...) __attribute__((format(__printf__,3,4)));
203void SV_BroadcastPrintf(int level, const char* fmt, ...) __attribute__((format(__printf__,2,3)));
204
205/* sv_user.c */
206void SV_ExecuteClientMessage(client_t* cl, int cmd, dbuffer* msg);
207void SV_SetClientState(client_t* client, client_state_t state);
208
209/* sv_ccmds.c */
210void SV_SetMaster_f(void);
211void SV_Heartbeat_f(void);
212bool SV_CheckMap(const char* map, const char* assembly);
213
214/* sv_game.c */
215int SV_RunGameFrameThread(void* data);
216void SV_RunGameFrame(void);
217void SV_InitGameProgs(void);
218void SV_ShutdownGameProgs(void);
219
220/*============================================================ */
221
222void SV_ClearWorld(void);
223
224void SV_UnlinkEdict(edict_t* ent);
225void SV_LinkEdict(edict_t* ent);
226
227/*=================================================================== */
228
229/* returns the CONTENTS_* value from the world at the given point. */
230int SV_PointContents(const vec3_t p);
231const char* SV_GetFootstepSound(const char* texture);
232float SV_GetBounceFraction(const char* texture);
233bool SV_LoadModelAABB(const char* model, int frame, AABB& aabb);
234trace_t SV_Trace(const Line& traceLine, const AABB& box, const edict_t* passedict, int contentmask);
clientBattleScape_t cl
Definition aabb.h:42
Definition line.h:31
definitions common between client and server, but not game lib
#define __attribute__(x)
Definition cxx.h:37
#define MAX_EDICTS
Definition defines.h:99
#define MAX_TOKEN_CHARS
Definition defines.h:372
#define MAX_MOD_KNOWN
Definition defines.h:160
#define MAX_MODELS
Definition defines.h:100
#define MAX_QPATH
Definition filesys.h:40
level_locals_t level
Definition g_main.cpp:38
Interface to game library.
SrvEdict edict_t
Definition game.h:164
SrvPlayer player_t
Definition game.h:72
Info string handling.
#define MAX_INFO_STRING
Definition infostring.h:36
#define MAX_CONFIGSTRINGS
Definition q_shared.h:330
void format(__printf__, 1, 2)))
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89
QGL_EXTERN GLuint index
Definition r_gl.h:110
cvar_t * sv_mapname
Definition sv_main.cpp:53
memPool_t * sv_genericPool
Definition sv_main.cpp:55
void SV_MapcycleClear(void)
Empty the mapcycle list.
char * SV_GetConfigString(int index)
Definition sv_main.cpp:77
cvar_t * sv_rmadisplaythemap
display a character graphic of the tiles placed when RMA2 reaches a dead end.
Definition sv_main.cpp:50
const char * SV_GetFootstepSound(const char *texture)
Query the footstep sound for the given surface texture.
Definition sv_world.cpp:451
trace_t SV_Trace(const Line &traceLine, const AABB &box, const edict_t *passedict, int contentmask)
Moves the given mins/maxs volume through the world from start to end.
Definition sv_world.cpp:417
void SV_ClearWorld(void)
Clear physics interaction links.
Definition sv_world.cpp:81
void SV_SetServerState(server_state_t)
Definition sv_user.cpp:317
client_t * SV_GetClient(int index)
Definition sv_main.cpp:174
void SV_Map(bool day, const char *levelstring, const char *assembly, bool verbose=true)
Change the server to a new map, taking all connected clients along with it.
Definition sv_init.cpp:113
void SV_Heartbeat_f(void)
Definition sv_ccmds.cpp:35
bool SV_CheckMap(const char *map, const char *assembly)
Checks whether a map exists.
Definition sv_ccmds.cpp:101
void SV_LinkEdict(edict_t *ent)
Needs to be called any time an entity changes origin, mins, maxs, or solid. Automatically unlinks if ...
Definition sv_world.cpp:131
void SV_MapcycleInit(void)
server_state_t SV_GetServerState(void)
Definition sv_user.cpp:312
void SV_ShutdownGameProgs(void)
Called when either the entire server is being killed, or it is changing to a different game directory...
Definition sv_game.cpp:681
client_state_t
Definition server.h:139
@ cs_spawned
Definition server.h:145
@ cs_connected
Definition server.h:141
@ cs_free
Definition server.h:140
@ cs_spawning
Definition server.h:142
@ cs_began
Definition server.h:143
void SV_ReadPacket(struct net_stream *s)
Definition sv_main.cpp:669
#define AREA_NODES
Definition server.h:64
void SV_InitOperatorCommands(void)
Definition sv_ccmds.cpp:542
void SV_InitGameProgs(void)
Init the game subsystem for a new map.
Definition sv_game.cpp:747
void SV_Multicast(int mask, const dbuffer &msg)
Sends the contents of msg to a subset of the clients, then frees msg.
Definition sv_send.cpp:126
int SV_GetConfigStringLength(int index)
Definition sv_main.cpp:85
void void SV_ClientPrintf(client_t *cl, int level, const char *fmt,...) __attribute__((format(__printf__
cvar_t * sv_threads
Definition sv_main.cpp:48
float SV_GetBounceFraction(const char *texture)
Different terrain types might have different bounce fraction.
Definition sv_world.cpp:462
int SV_GetConfigStringInteger(int index)
Definition sv_main.cpp:108
void SV_NextMapcycle(void)
Start the next map in the cycle.
server_state_t
Definition server.h:95
@ ss_game_shutdown
Definition server.h:100
@ ss_loading
Definition server.h:98
@ ss_game
Definition server.h:99
@ ss_restart
Definition server.h:97
@ ss_dead
Definition server.h:96
void SV_SetMaster_f(void)
Add the server to the master server list so that others can see the server in the server list.
Definition sv_ccmds.cpp:45
void SV_RunGameFrame(void)
Calls the G_RunFrame function from game api let everything in the world think and move.
Definition sv_game.cpp:736
bool SV_LoadModelAABB(const char *model, int frame, AABB &aabb)
Load the bounding box for the model on the serverside for pathfinding and clipping.
Definition sv_world.cpp:543
serverInstanceGame_t * sv
Definition sv_init.cpp:36
void SV_SetClientState(client_t *client, client_state_t state)
Set the client state.
Definition sv_user.cpp:36
void void void SV_BroadcastPrintf(int level, const char *fmt,...) __attribute__((format(__printf__
#define SV_SetConfigString(index, value)
Definition server.h:188
int SV_CountPlayers(void)
Returns the number of spawned players.
Definition sv_main.cpp:1096
void SV_UnlinkEdict(edict_t *ent)
call before removing an entity, and before trying to move one, so it doesn't clip against itself
Definition sv_world.cpp:97
client_t * SV_GetNextClient(client_t *lastClient)
Iterates through clients.
Definition sv_main.cpp:152
serverInstanceStatic_t svs
Definition sv_init.cpp:35
cvar_t * sv_public
Definition sv_main.cpp:52
void SV_ClientCommand(client_t *client, const char *fmt,...) __attribute__((format(__printf__
cvar_t * sv_rma
Definition sv_main.cpp:49
void SV_DropClient(client_t *drop, const char *message)
Called when the player is totally leaving the server, either willingly or unwillingly....
Definition sv_main.cpp:184
void void void void SV_ExecuteClientMessage(client_t *cl, int cmd, dbuffer *msg)
The current net_message is parsed for the given client.
Definition sv_user.cpp:235
int SV_RunGameFrameThread(void *data)
Thread for the game frame function.
Definition sv_game.cpp:719
int SV_PointContents(const vec3_t p)
Returns the content flags for a given point.
Definition sv_world.cpp:395
void SV_UserinfoChanged(client_t *cl)
Pull specific info from a newly changed userinfo string into a more C friendly form.
Definition sv_main.cpp:921
cvar_t * sv_dumpmapassembly
Definition sv_main.cpp:47
player_t * player
Definition server.h:158
char name[32]
Definition server.h:159
char peername[256]
Definition server.h:162
char userinfo[MAX_INFO_STRING]
Definition server.h:157
client_state_t state
Definition server.h:156
int lastmessage
Definition server.h:161
int messagelevel
Definition server.h:160
struct net_stream * stream
Definition server.h:163
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition cvar.h:71
functions exported by the game subsystem
Definition game.h:317
dbuffer * buf
Definition server.h:73
Struct that is only valid for one map. It's deleted on every map load.
Definition server.h:106
worldSector_t worldSectors[AREA_NODES]
Definition server.h:131
mapData_t mapData
Definition server.h:124
unsigned int numSVModels
Definition server.h:129
sv_model_t svModels[MAX_MOD_KNOWN]
Definition server.h:128
dbuffer * messageBuffer
Definition server.h:119
server_state_t state
Definition server.h:107
char assembly[MAX_QPATH]
Definition server.h:110
pending_event_t pendingEvent
Definition server.h:120
struct cBspModel_s * models[MAX_MODELS]
Definition server.h:111
char name[MAX_QPATH]
Definition server.h:109
memPool_t * gameSysPool
Definition server.h:134
char configstrings[MAX_CONFIGSTRINGS][MAX_TOKEN_CHARS]
Definition server.h:117
mapTiles_t mapTiles
Definition server.h:126
sv_edict_t edicts[MAX_EDICTS]
Definition server.h:130
pending_event_t eventQueue[64]
Definition server.h:121
unsigned int numWorldSectors
Definition server.h:132
struct client_s * clients
Definition server.h:80
SDL_Thread * gameThread
Definition server.h:88
SDL_mutex * serverMutex
Definition server.h:86
SDL_cond * gameFrameCond
Definition server.h:87
game_export_t * ge
Definition server.h:92
struct datagram_socket * netDatagramSocket
Definition server.h:79
struct worldSector_s * worldSector
Definition server.h:40
edict_t * ent
Definition server.h:43
struct sv_edict_s * nextEntityInWorldSector
Definition server.h:41
bool linked
Definition server.h:42
static mesh models (none-animated) can have a server side flag set to be clipped for pathfinding
Definition server.h:47
AABB aabb
Definition server.h:48
char * name
Definition server.h:50
int frame
Definition server.h:49
To avoid linearly searching through lists of entities during environment testing, the world is carved...
Definition server.h:57
float dist
Definition server.h:59
struct worldSector_s * children[2]
Definition server.h:60
sv_edict_t * entities
Definition server.h:61
vec_t vec3_t[3]
Definition ufotypes.h:39