2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 typedef struct server_static_s
27 // number of svs.clients slots (updated by maxplayers command)
30 struct client_s *clients;
31 // episode completion information
33 // cleared when at SV_SpawnServer
34 qboolean changelevel_issued;
36 char serverinfo[MAX_SERVERINFO_STRING];
39 //=============================================================================
41 typedef enum server_state_e {ss_loading, ss_active} server_state_t;
43 #define MAX_CONNECTFLOODADDRESSES 16
44 typedef struct server_connectfloodaddress_s
47 lhnetaddress_t address;
49 server_connectfloodaddress_t;
51 typedef struct server_s
53 // false if only a net client
57 // handle connections specially
60 // one of the PROTOCOL_ values
61 protocolversion_t protocol;
67 // used by PF_checkclient
71 // crc of clientside progs at time of level start
72 int csqc_progcrc; // -1 = no progs
73 int csqc_progsize; // -1 = no progs
74 char csqc_progname[MAX_QPATH]; // copied from csqc_progname at level start
76 // collision culling data
81 // maps/<name>.bsp, for model_precache[0]
83 struct model_s *worldmodel;
85 // LordHavoc: precaches are now MAX_QPATH rather than a pointer
86 // updated by SV_ModelIndex
87 char model_precache[MAX_MODELS][MAX_QPATH];
88 struct model_s *models[MAX_MODELS];
90 // LordHavoc: precaches are now MAX_QPATH rather than a pointer
91 // updated by SV_SoundIndex
92 char sound_precache[MAX_SOUNDS][MAX_QPATH];
93 char lightstyles[MAX_LIGHTSTYLES][64];
94 // some actions are only valid during load
98 unsigned char datagram_buf[NET_MAXMESSAGE];
100 // copied to all clients at end of frame
101 sizebuf_t reliable_datagram;
102 unsigned char reliable_datagram_buf[NET_MAXMESSAGE];
105 // LordHavoc: increased signon message buffer from 8192
106 unsigned char signon_buf[NET_MAXMESSAGE];
108 // connection flood blocking
109 // note this is in server_t rather than server_static_t so that it is
110 // reset on each map command (such as New Game in singleplayer)
111 server_connectfloodaddress_t connectfloodaddresses[MAX_CONNECTFLOODADDRESSES];
113 #define SV_MAX_PARTICLEEFFECTNAME 256
114 qboolean particleeffectnamesloaded;
115 char particleeffectname[SV_MAX_PARTICLEEFFECTNAME][MAX_QPATH];
117 int writeentitiestoclient_stats_culled_pvs;
118 int writeentitiestoclient_stats_culled_trace;
119 int writeentitiestoclient_stats_visibleentities;
120 int writeentitiestoclient_stats_totalentities;
121 int writeentitiestoclient_cliententitynumber;
122 int writeentitiestoclient_clientnumber;
123 sizebuf_t *writeentitiestoclient_msg;
124 vec3_t writeentitiestoclient_testeye;
125 int writeentitiestoclient_pvsbytes;
126 unsigned char writeentitiestoclient_pvs[MAX_MAP_LEAFS/8];
127 entity_state_t writeentitiestoclient_sendstates[MAX_EDICTS];
130 // if defined this does ping smoothing, otherwise it does not
131 //#define NUM_PING_TIMES 16
133 #define NUM_SPAWN_PARMS 16
135 typedef struct client_s
137 // false = empty client slot
139 // false = don't do ClientDisconnect on drop
140 qboolean clientconnectcalled;
141 // false = don't send datagrams
144 // requested rate in bytes per second
147 // realtime this client connected
150 // keepalive messages must be sent periodically during signon
151 double keepalivetime;
153 // communications handle
154 netconn_t *netconnection;
159 // intended motion calced from cmd
162 // PRVM_EDICT_NUM(clientnum+1)
165 #ifdef NUM_PING_TIMES
166 float ping_times[NUM_PING_TIMES];
167 // ping_times[num_pings%NUM_PING_TIMES]
170 // LordHavoc: can be used for prediction or whatever...
173 // this is used by sv_clmovement_minping code
174 double clmovement_disabletimeout;
175 // this is used by sv_clmvoement_waitforinput code
176 int clmovement_skipphysicsframes;
178 // spawn parms are carried from level to level
179 float spawn_parms[NUM_SPAWN_PARMS];
181 // properties that are sent across the network only when changed
182 char name[64], old_name[64];
183 int colors, old_colors;
184 int frags, old_frags;
185 char playermodel[MAX_QPATH], old_model[MAX_QPATH];
186 char playerskin[MAX_QPATH], old_skin[MAX_QPATH];
188 // netaddress support
189 char netaddress[MAX_QPATH];
192 float visibletime[MAX_EDICTS];
194 // version number of csqc-based entity to decide whether to send it
195 unsigned char csqcentityversion[MAX_EDICTS];
197 // prevent animated names
200 // latest received clc_ackframe (used to detect packet loss)
203 // cache weaponmodel name lookups
204 char weaponmodel[MAX_QPATH];
205 int weaponmodelindex;
207 entityframe_database_t *entitydatabase;
208 entityframe4_database_t *entitydatabase4;
209 entityframe5_database_t *entitydatabase5;
211 // delta compression of stats
212 unsigned char statsdeltabits[(MAX_CL_STATS+7)/8];
213 int stats[MAX_CL_STATS];
215 unsigned char unreliablemsg_data[NET_MAXMESSAGE];
216 sizebuf_t unreliablemsg;
217 int unreliablemsg_splitpoints;
218 int unreliablemsg_splitpoint[NET_MAXMESSAGE/16];
220 // information on an active download if any
221 qfile_t *download_file;
222 int download_expectedposition; // next position the client should ack
223 qboolean download_started;
224 char download_name[MAX_QPATH];
227 qboolean fixangle_angles_set;
228 vec3_t fixangle_angles;
232 //=============================================================================
234 // edict->movetype values
235 #define MOVETYPE_NONE 0 // never moves
236 #define MOVETYPE_ANGLENOCLIP 1
237 #define MOVETYPE_ANGLECLIP 2
238 #define MOVETYPE_WALK 3 // gravity
239 #define MOVETYPE_STEP 4 // gravity, special edge handling
240 #define MOVETYPE_FLY 5
241 #define MOVETYPE_TOSS 6 // gravity
242 #define MOVETYPE_PUSH 7 // no clip to world, push and crush
243 #define MOVETYPE_NOCLIP 8
244 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters
245 #define MOVETYPE_BOUNCE 10
246 #define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
247 #define MOVETYPE_FOLLOW 12 // track movement of aiment
248 #define MOVETYPE_FAKEPUSH 13 // tenebrae's push that doesn't push
250 // edict->solid values
251 #define SOLID_NOT 0 // no interaction with other objects
252 #define SOLID_TRIGGER 1 // touch on edge, but not blocking
253 #define SOLID_BBOX 2 // touch on edge, block
254 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
255 #define SOLID_BSP 4 // bsp clip, touch on edge, block
256 // LordHavoc: corpse code
257 #define SOLID_CORPSE 5 // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
259 // edict->deadflag values
271 #define FL_CONVEYOR 4
273 #define FL_INWATER 16
274 #define FL_MONSTER 32
275 #define FL_GODMODE 64
276 #define FL_NOTARGET 128
278 #define FL_ONGROUND 512
279 #define FL_PARTIALGROUND 1024 // not all corners are valid
280 #define FL_WATERJUMP 2048 // player jumping out of water
281 #define FL_JUMPRELEASED 4096 // for jump debouncing
283 #define SPAWNFLAG_NOT_EASY 256
284 #define SPAWNFLAG_NOT_MEDIUM 512
285 #define SPAWNFLAG_NOT_HARD 1024
286 #define SPAWNFLAG_NOT_DEATHMATCH 2048
288 //============================================================================
291 extern cvar_t deathmatch;
292 extern cvar_t fraglimit;
293 extern cvar_t gamecfg;
294 extern cvar_t noexit;
295 extern cvar_t nomonsters;
296 extern cvar_t pausable;
297 extern cvar_t pr_checkextension;
298 extern cvar_t samelevel;
299 extern cvar_t saved1;
300 extern cvar_t saved2;
301 extern cvar_t saved3;
302 extern cvar_t saved4;
303 extern cvar_t savedgamecfg;
304 extern cvar_t scratch1;
305 extern cvar_t scratch2;
306 extern cvar_t scratch3;
307 extern cvar_t scratch4;
309 extern cvar_t slowmo;
310 extern cvar_t sv_accelerate;
311 extern cvar_t sv_aim;
312 extern cvar_t sv_airaccel_qw;
313 extern cvar_t sv_airaccel_sideways_friction;
314 extern cvar_t sv_airaccelerate;
315 extern cvar_t sv_allowdownloads;
316 extern cvar_t sv_allowdownloads_archive;
317 extern cvar_t sv_allowdownloads_config;
318 extern cvar_t sv_allowdownloads_dlcache;
319 extern cvar_t sv_allowdownloads_inarchive;
320 extern cvar_t sv_areagrid_mingridsize;
321 extern cvar_t sv_checkforpacketsduringsleep;
322 extern cvar_t sv_clmovement_enable;
323 extern cvar_t sv_clmovement_minping;
324 extern cvar_t sv_clmovement_minping_disabletime;
325 extern cvar_t sv_clmovement_waitforinput;
326 extern cvar_t sv_cullentities_nevercullbmodels;
327 extern cvar_t sv_cullentities_pvs;
328 extern cvar_t sv_cullentities_stats;
329 extern cvar_t sv_cullentities_trace;
330 extern cvar_t sv_cullentities_trace_delay;
331 extern cvar_t sv_cullentities_trace_enlarge;
332 extern cvar_t sv_cullentities_trace_prediction;
333 extern cvar_t sv_cullentities_trace_samples;
334 extern cvar_t sv_cullentities_trace_samples_extra;
335 extern cvar_t sv_debugmove;
336 extern cvar_t sv_echobprint;
337 extern cvar_t sv_edgefriction;
338 extern cvar_t sv_entpatch;
339 extern cvar_t sv_fixedframeratesingleplayer;
340 extern cvar_t sv_freezenonclients;
341 extern cvar_t sv_friction;
342 extern cvar_t sv_gameplayfix_blowupfallenzombies;
343 extern cvar_t sv_gameplayfix_droptofloorstartsolid;
344 extern cvar_t sv_gameplayfix_findradiusdistancetobox;
345 extern cvar_t sv_gameplayfix_grenadebouncedownslopes;
346 extern cvar_t sv_gameplayfix_noairborncorpse;
347 extern cvar_t sv_gameplayfix_qwplayerphysics;
348 extern cvar_t sv_gameplayfix_setmodelrealbox;
349 extern cvar_t sv_gameplayfix_stepdown;
350 extern cvar_t sv_gameplayfix_stepwhilejumping;
351 extern cvar_t sv_gameplayfix_swiminbmodels;
352 extern cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag;
353 extern cvar_t sv_gravity;
354 extern cvar_t sv_idealpitchscale;
355 extern cvar_t sv_jumpstep;
356 extern cvar_t sv_jumpvelocity;
357 extern cvar_t sv_maxairspeed;
358 extern cvar_t sv_maxrate;
359 extern cvar_t sv_maxspeed;
360 extern cvar_t sv_maxvelocity;
361 extern cvar_t sv_newflymove;
362 extern cvar_t sv_nostep;
363 extern cvar_t sv_playerphysicsqc;
364 extern cvar_t sv_progs;
365 extern cvar_t sv_protocolname;
366 extern cvar_t sv_random_seed;
367 extern cvar_t sv_ratelimitlocalplayer;
368 extern cvar_t sv_sound_land;
369 extern cvar_t sv_sound_watersplash;
370 extern cvar_t sv_stepheight;
371 extern cvar_t sv_stopspeed;
372 extern cvar_t sv_wallfriction;
373 extern cvar_t sv_wateraccelerate;
374 extern cvar_t sv_waterfriction;
375 extern cvar_t sys_ticrate;
376 extern cvar_t teamplay;
378 extern cvar_t timelimit;
380 extern mempool_t *sv_mempool;
382 // persistant server info
383 extern server_static_t svs;
387 extern client_t *host_client;
389 //===========================================================
393 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
394 void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate);
395 void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation);
397 void SV_ConnectClient (int clientnum, netconn_t *netconnection);
398 void SV_DropClient (qboolean crash);
400 void SV_SendClientMessages (void);
402 void SV_ReadClientMessage(void);
404 // precachemode values:
405 // 0 = fail if not precached,
406 // 1 = warn if not found and precache if possible
408 int SV_ModelIndex(const char *s, int precachemode);
409 int SV_SoundIndex(const char *s, int precachemode);
411 int SV_ParticleEffectIndex(const char *name);
413 void SV_SetIdealPitch (void);
415 void SV_AddUpdates (void);
417 void SV_ClientThink (void);
419 void SV_ClientPrint(const char *msg);
420 void SV_ClientPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
421 void SV_BroadcastPrint(const char *msg);
422 void SV_BroadcastPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
424 void SV_Physics (void);
425 void SV_Physics_ClientMove (void);
426 void SV_Physics_ClientEntity (prvm_edict_t *ent);
428 qboolean SV_PlayerCheckGround (prvm_edict_t *ent);
429 qboolean SV_CheckBottom (prvm_edict_t *ent);
430 qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, qboolean settrace);
432 // Needs to be called any time an entity changes origin, mins, maxs, or solid
433 // sets ent->v.absmin and ent->v.absmax
434 // if touchtriggers, calls prog functions for the intersected triggers
435 void SV_LinkEdict (prvm_edict_t *ent, qboolean touch_triggers);
437 // calculates hitsupercontentsmask for a generic qc entity
438 int SV_GenericHitSuperContentsMask(const prvm_edict_t *edict);
439 // traces a box move against worldmodel and all entities in the specified area
440 trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask);
442 #define SV_PointSuperContents(point) (SV_Move((point), vec3_origin, vec3_origin, (point), sv_gameplayfix_swiminbmodels.integer ? MOVE_NOMONSTERS : MOVE_WORLDONLY, NULL, 0).startsupercontents)
444 void SV_FlushBroadcastMessages(void);
445 void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
447 void SV_MoveToGoal (void);
449 void SV_ApplyClientMove (void);
450 void SV_SaveSpawnparms (void);
451 void SV_SpawnServer (const char *server);
453 void SV_CheckVelocity (prvm_edict_t *ent);
455 void SV_SetupVM(void);
457 void SV_VM_Begin(void);
458 void SV_VM_End(void);