2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
server.h
|
|
|
|
|
|
|
|
@description@
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __server_h
|
|
|
|
#define __server_h
|
|
|
|
|
|
|
|
#include <setjmp.h>
|
|
|
|
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/info.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakeio.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sizebuf.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
|
2022-06-03 06:43:53 +00:00
|
|
|
#include "game.h"
|
2003-02-11 22:48:57 +00:00
|
|
|
#include "netmain.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "protocol.h"
|
|
|
|
#include "sv_progs.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
extern progs_t sv_pr_state;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
unsigned maxclients;
|
|
|
|
unsigned maxclientslimit;
|
2001-02-19 21:15:25 +00:00
|
|
|
struct client_s *clients; // [maxclients]
|
2011-12-22 04:42:39 +00:00
|
|
|
void (*phys_client) (struct edict_s *ent, int num);
|
2001-02-19 21:15:25 +00:00
|
|
|
int serverflags; // episode completion information
|
2023-06-13 09:06:11 +00:00
|
|
|
bool changelevel_issued; // cleared when at SV_SpawnServer
|
2001-02-19 21:15:25 +00:00
|
|
|
} server_static_t;
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
typedef enum {ss_loading, ss_active} server_state_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2023-06-13 09:06:11 +00:00
|
|
|
bool active; // false if only a net client
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
bool paused;
|
|
|
|
bool loadgame; // handle connections specially
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
double time;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
int lastcheck; // used by PF_checkclient
|
|
|
|
double lastchecktime;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
char name[64]; // map name
|
|
|
|
char modelname[64]; // maps/<name>.bsp, for model_precache[0]
|
|
|
|
struct model_s *worldmodel;
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *model_precache[MAX_MODELS]; // NULL terminated
|
2001-02-19 21:15:25 +00:00
|
|
|
struct model_s *models[MAX_MODELS];
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *sound_precache[MAX_SOUNDS]; // NULL terminated
|
2003-05-29 04:49:34 +00:00
|
|
|
const char *lightstyles[MAX_LIGHTSTYLES];
|
2022-01-16 13:15:18 +00:00
|
|
|
unsigned num_edicts;
|
2001-02-19 21:15:25 +00:00
|
|
|
int max_edicts;
|
|
|
|
edict_t *edicts; // can NOT be array indexed, because
|
|
|
|
// edict_t is variable sized, but can
|
|
|
|
// be used to reference the world ent
|
2010-01-13 06:42:26 +00:00
|
|
|
server_state_t state; // some actions are valid only during load
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
sizebuf_t datagram;
|
|
|
|
byte datagram_buf[MAX_DATAGRAM];
|
|
|
|
|
|
|
|
sizebuf_t reliable_datagram; // copied to all clients at end of frame
|
|
|
|
byte reliable_datagram_buf[MAX_DATAGRAM];
|
|
|
|
|
|
|
|
sizebuf_t signon;
|
2010-08-24 00:53:54 +00:00
|
|
|
byte signon_buf[MAX_MSGLEN-2];
|
|
|
|
|
|
|
|
unsigned protocol;
|
2001-02-19 21:15:25 +00:00
|
|
|
} server_t;
|
|
|
|
|
|
|
|
|
|
|
|
#define NUM_PING_TIMES 16
|
|
|
|
#define NUM_SPAWN_PARMS 16
|
|
|
|
|
|
|
|
typedef struct client_s
|
|
|
|
{
|
2023-06-13 09:06:11 +00:00
|
|
|
bool active; // false = client is free
|
|
|
|
bool spawned; // false = don't send datagrams
|
|
|
|
bool dropasap; // has been told to go to another level
|
|
|
|
bool privileged; // can execute any host command
|
|
|
|
bool sendsignon; // valid only before spawned
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
double last_message; // reliable messages must be sent
|
|
|
|
// periodically
|
|
|
|
|
|
|
|
struct qsocket_s *netconnection; // communications handle
|
|
|
|
|
|
|
|
usercmd_t cmd; // movement
|
|
|
|
vec3_t wishdir; // intended motion calced from cmd
|
|
|
|
|
|
|
|
sizebuf_t message; // can be added to at any time,
|
|
|
|
// copied and clear once per frame
|
|
|
|
byte msgbuf[MAX_MSGLEN];
|
|
|
|
edict_t *edict; // EDICT_NUM(clientnum+1)
|
|
|
|
char name[32]; // for printing to other people
|
|
|
|
int colors;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
float ping_times[NUM_PING_TIMES];
|
|
|
|
int num_pings; // ping_times[num_pings%NUM_PING_TIMES]
|
|
|
|
|
|
|
|
// spawn parms are carried from level to level
|
|
|
|
float spawn_parms[NUM_SPAWN_PARMS];
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
// client known data for deltas
|
2001-02-19 21:15:25 +00:00
|
|
|
int old_frags;
|
|
|
|
} client_t;
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
// edict->movetype values
|
|
|
|
#define MOVETYPE_NONE 0 // never moves
|
|
|
|
#define MOVETYPE_ANGLENOCLIP 1
|
|
|
|
#define MOVETYPE_ANGLECLIP 2
|
|
|
|
#define MOVETYPE_WALK 3 // gravity
|
|
|
|
#define MOVETYPE_STEP 4 // gravity, special edge handling
|
|
|
|
#define MOVETYPE_FLY 5
|
|
|
|
#define MOVETYPE_TOSS 6 // gravity
|
|
|
|
#define MOVETYPE_PUSH 7 // no clip to world, push and crush
|
|
|
|
#define MOVETYPE_NOCLIP 8
|
|
|
|
#define MOVETYPE_FLYMISSILE 9 // extra size to monsters
|
|
|
|
#define MOVETYPE_BOUNCE 10
|
|
|
|
|
|
|
|
// edict->solid values
|
|
|
|
#define SOLID_NOT 0 // no interaction with other objects
|
|
|
|
#define SOLID_TRIGGER 1 // touch on edge, but not blocking
|
|
|
|
#define SOLID_BBOX 2 // touch on edge, block
|
|
|
|
#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
|
|
|
|
#define SOLID_BSP 4 // bsp clip, touch on edge, block
|
|
|
|
|
|
|
|
// edict->deadflag values
|
|
|
|
#define DEAD_NO 0
|
|
|
|
#define DEAD_DYING 1
|
|
|
|
#define DEAD_DEAD 2
|
|
|
|
|
|
|
|
#define DAMAGE_NO 0
|
|
|
|
#define DAMAGE_YES 1
|
|
|
|
#define DAMAGE_AIM 2
|
|
|
|
|
|
|
|
// edict->flags
|
|
|
|
#define FL_FLY 1
|
|
|
|
#define FL_SWIM 2
|
|
|
|
//#define FL_GLIMPSE 4
|
|
|
|
#define FL_CONVEYOR 4
|
|
|
|
#define FL_CLIENT 8
|
|
|
|
#define FL_INWATER 16
|
|
|
|
#define FL_MONSTER 32
|
|
|
|
#define FL_GODMODE 64
|
|
|
|
#define FL_NOTARGET 128
|
|
|
|
#define FL_ITEM 256
|
|
|
|
#define FL_ONGROUND 512
|
|
|
|
#define FL_PARTIALGROUND 1024 // not all corners are valid
|
|
|
|
#define FL_WATERJUMP 2048 // player jumping out of water
|
|
|
|
#define FL_JUMPRELEASED 4096 // for jump debouncing
|
2010-12-08 03:55:07 +00:00
|
|
|
#define FL_FINALIZED 8192
|
|
|
|
#define FL_FINDABLE_NONSOLID 16384
|
|
|
|
|
|
|
|
#define TL_ANY_SOLID 0
|
|
|
|
#define TL_BSP_ONLY 1
|
|
|
|
// 2 used internally (MOVE_MISSILE)
|
|
|
|
#define TL_TRIGGERS 3 // scan for triggers
|
|
|
|
#define TL_EVERYTHING 4 // scan for anything
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// entity effects
|
|
|
|
|
|
|
|
#define EF_BRIGHTFIELD 1
|
|
|
|
#define EF_MUZZLEFLASH 2
|
|
|
|
#define EF_BRIGHTLIGHT 4
|
|
|
|
#define EF_DIMLIGHT 8
|
|
|
|
|
|
|
|
#define SPAWNFLAG_NOT_EASY 256
|
|
|
|
#define SPAWNFLAG_NOT_MEDIUM 512
|
|
|
|
#define SPAWNFLAG_NOT_HARD 1024
|
|
|
|
#define SPAWNFLAG_NOT_DEATHMATCH 2048
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
extern int teamplay;
|
|
|
|
extern int skill;
|
|
|
|
extern int deathmatch;
|
|
|
|
extern int coop;
|
|
|
|
extern int timelimit;
|
|
|
|
|
|
|
|
extern float sv_rollangle;
|
|
|
|
extern float sv_rollspeed;
|
|
|
|
|
|
|
|
extern float sv_maxvelocity;
|
|
|
|
extern float sv_gravity;
|
|
|
|
extern int sv_jump_any;
|
|
|
|
extern int sv_nostep;
|
|
|
|
extern float sv_friction;
|
|
|
|
extern float sv_edgefriction;
|
|
|
|
extern float sv_stopspeed;
|
|
|
|
extern float sv_maxspeed;
|
|
|
|
extern float sv_accelerate;
|
|
|
|
extern float sv_idealpitchscale;
|
|
|
|
extern float sv_aim;
|
|
|
|
extern float sv_friction;
|
|
|
|
extern float sv_stopspeed;
|
|
|
|
|
|
|
|
extern int max_edicts;
|
2010-08-24 00:53:54 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
extern server_static_t svs; // persistant server info
|
|
|
|
extern server_t sv; // local server
|
|
|
|
|
|
|
|
extern client_t *host_client;
|
|
|
|
|
|
|
|
extern jmp_buf host_abortserver;
|
|
|
|
|
|
|
|
extern double host_time;
|
2011-12-22 04:42:39 +00:00
|
|
|
extern double sv_frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern edict_t *sv_player;
|
|
|
|
|
|
|
|
//===========================================================
|
|
|
|
|
|
|
|
void SV_Init (void);
|
2001-08-03 06:40:28 +00:00
|
|
|
void SV_PR_Cmds_Init (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-01-03 05:29:38 +00:00
|
|
|
void SV_StartParticle (const vec3_t org, const vec3_t dir, int color,
|
|
|
|
int count);
|
|
|
|
void SV_StartSound (edict_t *entity, int channel, const char *sample,
|
|
|
|
int volume, float attenuation);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
void SV_DropClient (bool crash);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void SV_SendClientMessages (void);
|
|
|
|
void SV_ClearDatagram (void);
|
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
int SV_ModelIndex (const char *name) __attribute__((pure));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void SV_SetIdealPitch (void);
|
|
|
|
|
|
|
|
void SV_AddUpdates (void);
|
|
|
|
|
|
|
|
void SV_ClientThink (void);
|
|
|
|
void SV_AddClientToServer (struct qsocket_s *ret);
|
|
|
|
|
2021-03-27 10:52:59 +00:00
|
|
|
void SV_ClientPrintf (const char *fmt, ...) __attribute__((format(PRINTF,1,2)));
|
|
|
|
void SV_BroadcastPrintf (const char *fmt, ...) __attribute__((format(PRINTF,1,2)));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-02-22 05:28:17 +00:00
|
|
|
struct trace_s SV_PushEntity (edict_t *ent, vec3_t push);
|
2018-10-09 03:35:01 +00:00
|
|
|
int SV_EntCanSupportJump (edict_t *ent) __attribute__((pure));
|
2002-02-22 05:28:17 +00:00
|
|
|
int SV_FlyMove (edict_t *ent, float time, struct trace_s *steptrace);
|
|
|
|
void SV_CheckVelocity (edict_t *ent);
|
2023-06-13 09:06:11 +00:00
|
|
|
bool SV_RunThink (edict_t *ent);
|
2002-02-22 05:28:17 +00:00
|
|
|
void SV_AddGravity (edict_t *ent);
|
2012-04-28 05:53:15 +00:00
|
|
|
void SV_FinishGravity (edict_t *ent, vec3_t move);
|
2002-02-22 05:28:17 +00:00
|
|
|
void SV_Physics_Toss (edict_t *ent);
|
|
|
|
void SV_Physics_Client (edict_t *ent, int num);
|
2001-02-19 21:15:25 +00:00
|
|
|
void SV_Physics (void);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
void SV_Physics_Init_Cvars (void);
|
2010-12-08 23:52:40 +00:00
|
|
|
void SV_ProgStartFrame (void);
|
|
|
|
void SV_RunNewmis (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
bool SV_CheckBottom (edict_t *ent);
|
|
|
|
bool SV_movestep (edict_t *ent, const vec3_t move, bool relink);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
void SV_MoveToGoal (progs_t *pr, void *data);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void SV_CheckForNewClients (void);
|
|
|
|
void SV_RunClients (void);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
void SV_User_Init_Cvars (void);
|
2003-01-06 18:28:13 +00:00
|
|
|
void SV_SaveSpawnparms (void);
|
2001-07-15 07:04:17 +00:00
|
|
|
void SV_SpawnServer (const char *server);
|
2022-05-26 08:10:23 +00:00
|
|
|
void SV_Frame (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
void SV_LoadProgs (void);
|
|
|
|
void SV_Progs_Init (void);
|
|
|
|
void SV_Progs_Init_Cvars (void);
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
struct cvar_s;
|
|
|
|
void Cvar_Info (void *data, const struct cvar_s *cvar);
|
2001-03-31 01:02:52 +00:00
|
|
|
|
2011-12-22 04:42:39 +00:00
|
|
|
//FIXME location
|
2002-02-25 22:57:17 +00:00
|
|
|
#define STOP_EPSILON 0.1
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
extern struct clip_hull_s *pf_hull_list[];
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif // __server_h
|