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];
40 float perf_offset_avg;
41 float perf_offset_max;
42 float perf_offset_sdev;
43 // temporary performance data accumulators
44 float perf_acc_realtime;
45 float perf_acc_sleeptime;
47 float perf_acc_offset;
48 float perf_acc_offset_squared;
49 float perf_acc_offset_max;
50 int perf_acc_offset_samples;
53 //=============================================================================
55 typedef enum server_state_e {ss_loading, ss_active} server_state_t;
57 #define MAX_CONNECTFLOODADDRESSES 16
58 typedef struct server_connectfloodaddress_s
61 lhnetaddress_t address;
63 server_connectfloodaddress_t;
65 typedef struct server_s
67 // false if only a net client
72 // handle connections specially
75 // one of the PROTOCOL_ values
76 protocolversion_t protocol;
82 // used by PF_checkclient
86 // crc of clientside progs at time of level start
87 int csqc_progcrc; // -1 = no progs
88 int csqc_progsize; // -1 = no progs
89 char csqc_progname[MAX_QPATH]; // copied from csqc_progname at level start
90 unsigned char *csqc_progdata;
91 size_t csqc_progsize_deflated;
92 unsigned char *csqc_progdata_deflated;
94 // collision culling data
99 // maps/<name>.bsp, for model_precache[0]
101 struct model_s *worldmodel;
103 // LordHavoc: precaches are now MAX_QPATH rather than a pointer
104 // updated by SV_ModelIndex
105 char model_precache[MAX_MODELS][MAX_QPATH];
106 struct model_s *models[MAX_MODELS];
108 // LordHavoc: precaches are now MAX_QPATH rather than a pointer
109 // updated by SV_SoundIndex
110 char sound_precache[MAX_SOUNDS][MAX_QPATH];
111 char lightstyles[MAX_LIGHTSTYLES][64];
112 // some actions are only valid during load
113 server_state_t state;
116 unsigned char datagram_buf[NET_MAXMESSAGE];
118 // copied to all clients at end of frame
119 sizebuf_t reliable_datagram;
120 unsigned char reliable_datagram_buf[NET_MAXMESSAGE];
123 // LordHavoc: increased signon message buffer from 8192
124 unsigned char signon_buf[NET_MAXMESSAGE];
126 // connection flood blocking
127 // note this is in server_t rather than server_static_t so that it is
128 // reset on each map command (such as New Game in singleplayer)
129 server_connectfloodaddress_t connectfloodaddresses[MAX_CONNECTFLOODADDRESSES];
131 #define SV_MAX_PARTICLEEFFECTNAME 256
132 qboolean particleeffectnamesloaded;
133 char particleeffectname[SV_MAX_PARTICLEEFFECTNAME][MAX_QPATH];
135 int writeentitiestoclient_stats_culled_pvs;
136 int writeentitiestoclient_stats_culled_trace;
137 int writeentitiestoclient_stats_visibleentities;
138 int writeentitiestoclient_stats_totalentities;
139 int writeentitiestoclient_cliententitynumber;
140 int writeentitiestoclient_clientnumber;
141 sizebuf_t *writeentitiestoclient_msg;
142 vec3_t writeentitiestoclient_testeye;
143 int writeentitiestoclient_pvsbytes;
144 unsigned char writeentitiestoclient_pvs[MAX_MAP_LEAFS/8];
145 entity_state_t writeentitiestoclient_sendstates[MAX_EDICTS];
148 entity_state_t sendentities[MAX_EDICTS];
149 entity_state_t *sendentitiesindex[MAX_EDICTS];
151 int sententitiesmark;
152 int sententities[MAX_EDICTS];
153 int sententitiesconsideration[MAX_EDICTS];
155 // legacy support for self.Version based csqc entity networking
156 unsigned char csqcentityversion[MAX_EDICTS]; // legacy
159 #define NUM_CSQCENTITIES_PER_FRAME 1024
160 typedef struct csqcentityframedb_s
164 unsigned short entno[NUM_CSQCENTITIES_PER_FRAME];
165 int sendflags[NUM_CSQCENTITIES_PER_FRAME];
166 } csqcentityframedb_t;
168 // if defined this does ping smoothing, otherwise it does not
169 //#define NUM_PING_TIMES 16
171 #define NUM_SPAWN_PARMS 16
173 typedef struct client_s
175 // false = empty client slot
177 // false = don't do ClientDisconnect on drop
178 qboolean clientconnectcalled;
179 // false = don't send datagrams
181 // 1 = send svc_serverinfo and advance to 2, 2 doesn't send, then advances to 0 (allowing unlimited sending) when prespawn is received
184 // requested rate in bytes per second
187 // realtime this client connected
190 // keepalive messages must be sent periodically during signon
191 double keepalivetime;
193 // communications handle
194 netconn_t *netconnection;
199 // intended motion calced from cmd
202 // PRVM_EDICT_NUM(clientnum+1)
205 #ifdef NUM_PING_TIMES
206 float ping_times[NUM_PING_TIMES];
207 // ping_times[num_pings%NUM_PING_TIMES]
210 // LordHavoc: can be used for prediction or whatever...
213 // this is used by sv_clmovement_minping code
214 double clmovement_disabletimeout;
215 // this is used by sv_clmvoement_waitforinput code
216 int clmovement_skipphysicsframes;
218 // spawn parms are carried from level to level
219 float spawn_parms[NUM_SPAWN_PARMS];
221 // properties that are sent across the network only when changed
222 char name[64], old_name[64];
223 int colors, old_colors;
224 int frags, old_frags;
225 char playermodel[MAX_QPATH], old_model[MAX_QPATH];
226 char playerskin[MAX_QPATH], old_skin[MAX_QPATH];
228 // netaddress support
229 char netaddress[MAX_QPATH];
232 float visibletime[MAX_EDICTS];
234 // scope is whether an entity is currently being networked to this client
235 // sendflags is what properties have changed on the entity since the last
236 // update that was sent
238 unsigned char csqcentityscope[MAX_EDICTS];
239 unsigned int csqcentitysendflags[MAX_EDICTS];
241 #define NUM_CSQCENTITYDB_FRAMES 64
242 unsigned char csqcentityglobalhistory[MAX_EDICTS]; // set to 1 if the entity was ever csqc networked to the client, and never reset back to 0
243 csqcentityframedb_t csqcentityframehistory[NUM_CSQCENTITYDB_FRAMES];
244 int csqcentityframehistory_next;
246 // prevent animated names
249 // latest received clc_ackframe (used to detect packet loss)
252 // cache weaponmodel name lookups
253 char weaponmodel[MAX_QPATH];
254 int weaponmodelindex;
256 // clientcamera (entity to use as camera)
259 entityframe_database_t *entitydatabase;
260 entityframe4_database_t *entitydatabase4;
261 entityframe5_database_t *entitydatabase5;
263 // delta compression of stats
264 unsigned char statsdeltabits[(MAX_CL_STATS+7)/8];
265 int stats[MAX_CL_STATS];
267 unsigned char unreliablemsg_data[NET_MAXMESSAGE];
268 sizebuf_t unreliablemsg;
269 int unreliablemsg_splitpoints;
270 int unreliablemsg_splitpoint[NET_MAXMESSAGE/16];
272 // information on an active download if any
273 qfile_t *download_file;
274 int download_expectedposition; // next position the client should ack
275 qboolean download_started;
276 char download_name[MAX_QPATH];
277 qboolean download_deflate;
280 qboolean fixangle_angles_set;
281 vec3_t fixangle_angles;
284 qfile_t *sv_demo_file;
288 //=============================================================================
290 // edict->movetype values
291 #define MOVETYPE_NONE 0 // never moves
292 #define MOVETYPE_ANGLENOCLIP 1
293 #define MOVETYPE_ANGLECLIP 2
294 #define MOVETYPE_WALK 3 // gravity
295 #define MOVETYPE_STEP 4 // gravity, special edge handling
296 #define MOVETYPE_FLY 5
297 #define MOVETYPE_TOSS 6 // gravity
298 #define MOVETYPE_PUSH 7 // no clip to world, push and crush
299 #define MOVETYPE_NOCLIP 8
300 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters
301 #define MOVETYPE_BOUNCE 10
302 #define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
303 #define MOVETYPE_FOLLOW 12 // track movement of aiment
304 #define MOVETYPE_FAKEPUSH 13 // tenebrae's push that doesn't push
306 // edict->solid values
307 #define SOLID_NOT 0 // no interaction with other objects
308 #define SOLID_TRIGGER 1 // touch on edge, but not blocking
309 #define SOLID_BBOX 2 // touch on edge, block
310 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
311 #define SOLID_BSP 4 // bsp clip, touch on edge, block
312 // LordHavoc: corpse code
313 #define SOLID_CORPSE 5 // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
315 // edict->deadflag values
327 #define FL_CONVEYOR 4
329 #define FL_INWATER 16
330 #define FL_MONSTER 32
331 #define FL_GODMODE 64
332 #define FL_NOTARGET 128
334 #define FL_ONGROUND 512
335 #define FL_PARTIALGROUND 1024 // not all corners are valid
336 #define FL_WATERJUMP 2048 // player jumping out of water
337 #define FL_JUMPRELEASED 4096 // for jump debouncing
339 #define SPAWNFLAG_NOT_EASY 256
340 #define SPAWNFLAG_NOT_MEDIUM 512
341 #define SPAWNFLAG_NOT_HARD 1024
342 #define SPAWNFLAG_NOT_DEATHMATCH 2048
344 //============================================================================
347 extern cvar_t deathmatch;
348 extern cvar_t fraglimit;
349 extern cvar_t gamecfg;
350 extern cvar_t noexit;
351 extern cvar_t nomonsters;
352 extern cvar_t pausable;
353 extern cvar_t pr_checkextension;
354 extern cvar_t samelevel;
355 extern cvar_t saved1;
356 extern cvar_t saved2;
357 extern cvar_t saved3;
358 extern cvar_t saved4;
359 extern cvar_t savedgamecfg;
360 extern cvar_t scratch1;
361 extern cvar_t scratch2;
362 extern cvar_t scratch3;
363 extern cvar_t scratch4;
365 extern cvar_t slowmo;
366 extern cvar_t sv_accelerate;
367 extern cvar_t sv_aim;
368 extern cvar_t sv_airaccel_qw;
369 extern cvar_t sv_airaccel_sideways_friction;
370 extern cvar_t sv_airaccelerate;
371 extern cvar_t sv_allowdownloads;
372 extern cvar_t sv_allowdownloads_archive;
373 extern cvar_t sv_allowdownloads_config;
374 extern cvar_t sv_allowdownloads_dlcache;
375 extern cvar_t sv_allowdownloads_inarchive;
376 extern cvar_t sv_areagrid_mingridsize;
377 extern cvar_t sv_checkforpacketsduringsleep;
378 extern cvar_t sv_clmovement_enable;
379 extern cvar_t sv_clmovement_minping;
380 extern cvar_t sv_clmovement_minping_disabletime;
381 extern cvar_t sv_clmovement_waitforinput;
382 extern cvar_t sv_cullentities_nevercullbmodels;
383 extern cvar_t sv_cullentities_pvs;
384 extern cvar_t sv_cullentities_stats;
385 extern cvar_t sv_cullentities_trace;
386 extern cvar_t sv_cullentities_trace_delay;
387 extern cvar_t sv_cullentities_trace_enlarge;
388 extern cvar_t sv_cullentities_trace_prediction;
389 extern cvar_t sv_cullentities_trace_samples;
390 extern cvar_t sv_cullentities_trace_samples_extra;
391 extern cvar_t sv_debugmove;
392 extern cvar_t sv_echobprint;
393 extern cvar_t sv_edgefriction;
394 extern cvar_t sv_entpatch;
395 extern cvar_t sv_fixedframeratesingleplayer;
396 extern cvar_t sv_freezenonclients;
397 extern cvar_t sv_friction;
398 extern cvar_t sv_gameplayfix_blowupfallenzombies;
399 extern cvar_t sv_gameplayfix_delayprojectiles;
400 extern cvar_t sv_gameplayfix_droptofloorstartsolid;
401 extern cvar_t sv_gameplayfix_droptofloorstartsolid_nudgetocorrect;
402 extern cvar_t sv_gameplayfix_easierwaterjump;
403 extern cvar_t sv_gameplayfix_findradiusdistancetobox;
404 extern cvar_t sv_gameplayfix_grenadebouncedownslopes;
405 extern cvar_t sv_gameplayfix_multiplethinksperframe;
406 extern cvar_t sv_gameplayfix_noairborncorpse;
407 extern cvar_t sv_gameplayfix_setmodelrealbox;
408 extern cvar_t sv_gameplayfix_stepdown;
409 extern cvar_t sv_gameplayfix_stepwhilejumping;
410 extern cvar_t sv_gameplayfix_swiminbmodels;
411 extern cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag;
412 extern cvar_t sv_gameplayfix_gravityunaffectedbyticrate;
413 extern cvar_t sv_gravity;
414 extern cvar_t sv_idealpitchscale;
415 extern cvar_t sv_jumpstep;
416 extern cvar_t sv_jumpvelocity;
417 extern cvar_t sv_maxairspeed;
418 extern cvar_t sv_maxrate;
419 extern cvar_t sv_maxspeed;
420 extern cvar_t sv_maxvelocity;
421 extern cvar_t sv_newflymove;
422 extern cvar_t sv_nostep;
423 extern cvar_t sv_playerphysicsqc;
424 extern cvar_t sv_progs;
425 extern cvar_t sv_protocolname;
426 extern cvar_t sv_random_seed;
427 extern cvar_t sv_ratelimitlocalplayer;
428 extern cvar_t sv_sound_land;
429 extern cvar_t sv_sound_watersplash;
430 extern cvar_t sv_stepheight;
431 extern cvar_t sv_stopspeed;
432 extern cvar_t sv_wallfriction;
433 extern cvar_t sv_wateraccelerate;
434 extern cvar_t sv_waterfriction;
435 extern cvar_t sys_ticrate;
436 extern cvar_t teamplay;
438 extern cvar_t timelimit;
440 extern mempool_t *sv_mempool;
442 // persistant server info
443 extern server_static_t svs;
447 extern client_t *host_client;
449 //===========================================================
453 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
454 void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate);
455 void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation);
456 void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation);
458 void SV_ConnectClient (int clientnum, netconn_t *netconnection);
459 void SV_DropClient (qboolean crash);
461 void SV_SendClientMessages (void);
463 void SV_ReadClientMessage(void);
465 // precachemode values:
466 // 0 = fail if not precached,
467 // 1 = warn if not found and precache if possible
469 int SV_ModelIndex(const char *s, int precachemode);
470 int SV_SoundIndex(const char *s, int precachemode);
472 int SV_ParticleEffectIndex(const char *name);
474 void SV_SetIdealPitch (void);
476 void SV_AddUpdates (void);
478 void SV_ClientThink (void);
480 void SV_ClientPrint(const char *msg);
481 void SV_ClientPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
482 void SV_BroadcastPrint(const char *msg);
483 void SV_BroadcastPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
485 void SV_Physics (void);
486 void SV_Physics_ClientMove (void);
487 void SV_Physics_ClientEntity (prvm_edict_t *ent);
489 qboolean SV_PlayerCheckGround (prvm_edict_t *ent);
490 qboolean SV_CheckBottom (prvm_edict_t *ent);
491 qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, qboolean settrace);
493 // Needs to be called any time an entity changes origin, mins, maxs, or solid
494 // sets ent->v.absmin and ent->v.absmax
495 // if touchtriggers, calls prog functions for the intersected triggers
496 void SV_LinkEdict (prvm_edict_t *ent, qboolean touch_triggers);
498 // move an entity that is stuck by small amounts in various directions to try to nudge it back into the collision hull
499 // returns true if it found a better place
500 qboolean SV_UnstickEntity (prvm_edict_t *ent);
502 // calculates hitsupercontentsmask for a generic qc entity
503 int SV_GenericHitSuperContentsMask(const prvm_edict_t *edict);
504 // traces a box move against worldmodel and all entities in the specified area
505 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);
507 int SV_PointSuperContents(const vec3_t point);
509 void SV_FlushBroadcastMessages(void);
510 void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
512 void SV_MoveToGoal (void);
514 void SV_ApplyClientMove (void);
515 void SV_SaveSpawnparms (void);
516 void SV_SpawnServer (const char *server);
518 void SV_CheckVelocity (prvm_edict_t *ent);
520 void SV_SetupVM(void);
522 void SV_VM_Begin(void);
523 void SV_VM_End(void);
525 const char *Host_TimingReport(); // for output in Host_Status_f