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
71 // handle connections specially
74 // one of the PROTOCOL_ values
75 protocolversion_t protocol;
81 // used by PF_checkclient
85 // crc of clientside progs at time of level start
86 int csqc_progcrc; // -1 = no progs
87 int csqc_progsize; // -1 = no progs
88 char csqc_progname[MAX_QPATH]; // copied from csqc_progname at level start
90 // collision culling data
95 // maps/<name>.bsp, for model_precache[0]
97 struct model_s *worldmodel;
99 // LordHavoc: precaches are now MAX_QPATH rather than a pointer
100 // updated by SV_ModelIndex
101 char model_precache[MAX_MODELS][MAX_QPATH];
102 struct model_s *models[MAX_MODELS];
104 // LordHavoc: precaches are now MAX_QPATH rather than a pointer
105 // updated by SV_SoundIndex
106 char sound_precache[MAX_SOUNDS][MAX_QPATH];
107 char lightstyles[MAX_LIGHTSTYLES][64];
108 // some actions are only valid during load
109 server_state_t state;
112 unsigned char datagram_buf[NET_MAXMESSAGE];
114 // copied to all clients at end of frame
115 sizebuf_t reliable_datagram;
116 unsigned char reliable_datagram_buf[NET_MAXMESSAGE];
119 // LordHavoc: increased signon message buffer from 8192
120 unsigned char signon_buf[NET_MAXMESSAGE];
122 // connection flood blocking
123 // note this is in server_t rather than server_static_t so that it is
124 // reset on each map command (such as New Game in singleplayer)
125 server_connectfloodaddress_t connectfloodaddresses[MAX_CONNECTFLOODADDRESSES];
127 #define SV_MAX_PARTICLEEFFECTNAME 256
128 qboolean particleeffectnamesloaded;
129 char particleeffectname[SV_MAX_PARTICLEEFFECTNAME][MAX_QPATH];
131 int writeentitiestoclient_stats_culled_pvs;
132 int writeentitiestoclient_stats_culled_trace;
133 int writeentitiestoclient_stats_visibleentities;
134 int writeentitiestoclient_stats_totalentities;
135 int writeentitiestoclient_cliententitynumber;
136 int writeentitiestoclient_clientnumber;
137 sizebuf_t *writeentitiestoclient_msg;
138 vec3_t writeentitiestoclient_testeye;
139 int writeentitiestoclient_pvsbytes;
140 unsigned char writeentitiestoclient_pvs[MAX_MAP_LEAFS/8];
141 entity_state_t writeentitiestoclient_sendstates[MAX_EDICTS];
144 entity_state_t sendentities[MAX_EDICTS];
145 entity_state_t *sendentitiesindex[MAX_EDICTS];
147 int sententitiesmark;
148 int sententities[MAX_EDICTS];
149 int sententitiesconsideration[MAX_EDICTS];
152 // if defined this does ping smoothing, otherwise it does not
153 //#define NUM_PING_TIMES 16
155 #define NUM_SPAWN_PARMS 16
157 typedef struct client_s
159 // false = empty client slot
161 // false = don't do ClientDisconnect on drop
162 qboolean clientconnectcalled;
163 // false = don't send datagrams
165 // 1 = send svc_serverinfo and advance to 2, 2 doesn't send, then advances to 0 (allowing unlimited sending) when prespawn is received
168 // requested rate in bytes per second
171 // realtime this client connected
174 // keepalive messages must be sent periodically during signon
175 double keepalivetime;
177 // communications handle
178 netconn_t *netconnection;
183 // intended motion calced from cmd
186 // PRVM_EDICT_NUM(clientnum+1)
189 #ifdef NUM_PING_TIMES
190 float ping_times[NUM_PING_TIMES];
191 // ping_times[num_pings%NUM_PING_TIMES]
194 // LordHavoc: can be used for prediction or whatever...
197 // this is used by sv_clmovement_minping code
198 double clmovement_disabletimeout;
199 // this is used by sv_clmvoement_waitforinput code
200 int clmovement_skipphysicsframes;
202 // spawn parms are carried from level to level
203 float spawn_parms[NUM_SPAWN_PARMS];
205 // properties that are sent across the network only when changed
206 char name[64], old_name[64];
207 int colors, old_colors;
208 int frags, old_frags;
209 char playermodel[MAX_QPATH], old_model[MAX_QPATH];
210 char playerskin[MAX_QPATH], old_skin[MAX_QPATH];
212 // netaddress support
213 char netaddress[MAX_QPATH];
216 float visibletime[MAX_EDICTS];
218 // version number of csqc-based entity to decide whether to send it
219 unsigned char csqcentityversion[MAX_EDICTS];
221 // prevent animated names
224 // latest received clc_ackframe (used to detect packet loss)
227 // cache weaponmodel name lookups
228 char weaponmodel[MAX_QPATH];
229 int weaponmodelindex;
231 entityframe_database_t *entitydatabase;
232 entityframe4_database_t *entitydatabase4;
233 entityframe5_database_t *entitydatabase5;
235 // delta compression of stats
236 unsigned char statsdeltabits[(MAX_CL_STATS+7)/8];
237 int stats[MAX_CL_STATS];
239 unsigned char unreliablemsg_data[NET_MAXMESSAGE];
240 sizebuf_t unreliablemsg;
241 int unreliablemsg_splitpoints;
242 int unreliablemsg_splitpoint[NET_MAXMESSAGE/16];
244 // information on an active download if any
245 qfile_t *download_file;
246 int download_expectedposition; // next position the client should ack
247 qboolean download_started;
248 char download_name[MAX_QPATH];
251 qboolean fixangle_angles_set;
252 vec3_t fixangle_angles;
255 qfile_t *sv_demo_file;
259 //=============================================================================
261 // edict->movetype values
262 #define MOVETYPE_NONE 0 // never moves
263 #define MOVETYPE_ANGLENOCLIP 1
264 #define MOVETYPE_ANGLECLIP 2
265 #define MOVETYPE_WALK 3 // gravity
266 #define MOVETYPE_STEP 4 // gravity, special edge handling
267 #define MOVETYPE_FLY 5
268 #define MOVETYPE_TOSS 6 // gravity
269 #define MOVETYPE_PUSH 7 // no clip to world, push and crush
270 #define MOVETYPE_NOCLIP 8
271 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters
272 #define MOVETYPE_BOUNCE 10
273 #define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
274 #define MOVETYPE_FOLLOW 12 // track movement of aiment
275 #define MOVETYPE_FAKEPUSH 13 // tenebrae's push that doesn't push
277 // edict->solid values
278 #define SOLID_NOT 0 // no interaction with other objects
279 #define SOLID_TRIGGER 1 // touch on edge, but not blocking
280 #define SOLID_BBOX 2 // touch on edge, block
281 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
282 #define SOLID_BSP 4 // bsp clip, touch on edge, block
283 // LordHavoc: corpse code
284 #define SOLID_CORPSE 5 // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
286 // edict->deadflag values
298 #define FL_CONVEYOR 4
300 #define FL_INWATER 16
301 #define FL_MONSTER 32
302 #define FL_GODMODE 64
303 #define FL_NOTARGET 128
305 #define FL_ONGROUND 512
306 #define FL_PARTIALGROUND 1024 // not all corners are valid
307 #define FL_WATERJUMP 2048 // player jumping out of water
308 #define FL_JUMPRELEASED 4096 // for jump debouncing
310 #define SPAWNFLAG_NOT_EASY 256
311 #define SPAWNFLAG_NOT_MEDIUM 512
312 #define SPAWNFLAG_NOT_HARD 1024
313 #define SPAWNFLAG_NOT_DEATHMATCH 2048
315 //============================================================================
318 extern cvar_t deathmatch;
319 extern cvar_t fraglimit;
320 extern cvar_t gamecfg;
321 extern cvar_t noexit;
322 extern cvar_t nomonsters;
323 extern cvar_t pausable;
324 extern cvar_t pr_checkextension;
325 extern cvar_t samelevel;
326 extern cvar_t saved1;
327 extern cvar_t saved2;
328 extern cvar_t saved3;
329 extern cvar_t saved4;
330 extern cvar_t savedgamecfg;
331 extern cvar_t scratch1;
332 extern cvar_t scratch2;
333 extern cvar_t scratch3;
334 extern cvar_t scratch4;
336 extern cvar_t slowmo;
337 extern cvar_t sv_accelerate;
338 extern cvar_t sv_aim;
339 extern cvar_t sv_airaccel_qw;
340 extern cvar_t sv_airaccel_sideways_friction;
341 extern cvar_t sv_airaccelerate;
342 extern cvar_t sv_allowdownloads;
343 extern cvar_t sv_allowdownloads_archive;
344 extern cvar_t sv_allowdownloads_config;
345 extern cvar_t sv_allowdownloads_dlcache;
346 extern cvar_t sv_allowdownloads_inarchive;
347 extern cvar_t sv_areagrid_mingridsize;
348 extern cvar_t sv_checkforpacketsduringsleep;
349 extern cvar_t sv_clmovement_enable;
350 extern cvar_t sv_clmovement_minping;
351 extern cvar_t sv_clmovement_minping_disabletime;
352 extern cvar_t sv_clmovement_waitforinput;
353 extern cvar_t sv_cullentities_nevercullbmodels;
354 extern cvar_t sv_cullentities_pvs;
355 extern cvar_t sv_cullentities_stats;
356 extern cvar_t sv_cullentities_trace;
357 extern cvar_t sv_cullentities_trace_delay;
358 extern cvar_t sv_cullentities_trace_enlarge;
359 extern cvar_t sv_cullentities_trace_prediction;
360 extern cvar_t sv_cullentities_trace_samples;
361 extern cvar_t sv_cullentities_trace_samples_extra;
362 extern cvar_t sv_debugmove;
363 extern cvar_t sv_echobprint;
364 extern cvar_t sv_edgefriction;
365 extern cvar_t sv_entpatch;
366 extern cvar_t sv_fixedframeratesingleplayer;
367 extern cvar_t sv_freezenonclients;
368 extern cvar_t sv_friction;
369 extern cvar_t sv_gameplayfix_blowupfallenzombies;
370 extern cvar_t sv_gameplayfix_delayprojectiles;
371 extern cvar_t sv_gameplayfix_droptofloorstartsolid;
372 extern cvar_t sv_gameplayfix_easierwaterjump;
373 extern cvar_t sv_gameplayfix_findradiusdistancetobox;
374 extern cvar_t sv_gameplayfix_grenadebouncedownslopes;
375 extern cvar_t sv_gameplayfix_multiplethinksperframe;
376 extern cvar_t sv_gameplayfix_noairborncorpse;
377 extern cvar_t sv_gameplayfix_setmodelrealbox;
378 extern cvar_t sv_gameplayfix_stepdown;
379 extern cvar_t sv_gameplayfix_stepwhilejumping;
380 extern cvar_t sv_gameplayfix_swiminbmodels;
381 extern cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag;
382 extern cvar_t sv_gravity;
383 extern cvar_t sv_idealpitchscale;
384 extern cvar_t sv_jumpstep;
385 extern cvar_t sv_jumpvelocity;
386 extern cvar_t sv_maxairspeed;
387 extern cvar_t sv_maxrate;
388 extern cvar_t sv_maxspeed;
389 extern cvar_t sv_maxvelocity;
390 extern cvar_t sv_newflymove;
391 extern cvar_t sv_nostep;
392 extern cvar_t sv_playerphysicsqc;
393 extern cvar_t sv_progs;
394 extern cvar_t sv_protocolname;
395 extern cvar_t sv_random_seed;
396 extern cvar_t sv_ratelimitlocalplayer;
397 extern cvar_t sv_sound_land;
398 extern cvar_t sv_sound_watersplash;
399 extern cvar_t sv_stepheight;
400 extern cvar_t sv_stopspeed;
401 extern cvar_t sv_wallfriction;
402 extern cvar_t sv_wateraccelerate;
403 extern cvar_t sv_waterfriction;
404 extern cvar_t sys_ticrate;
405 extern cvar_t teamplay;
407 extern cvar_t timelimit;
409 extern mempool_t *sv_mempool;
411 // persistant server info
412 extern server_static_t svs;
416 extern client_t *host_client;
418 //===========================================================
422 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
423 void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate);
424 void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation);
425 void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation);
427 void SV_ConnectClient (int clientnum, netconn_t *netconnection);
428 void SV_DropClient (qboolean crash);
430 void SV_SendClientMessages (void);
432 void SV_ReadClientMessage(void);
434 // precachemode values:
435 // 0 = fail if not precached,
436 // 1 = warn if not found and precache if possible
438 int SV_ModelIndex(const char *s, int precachemode);
439 int SV_SoundIndex(const char *s, int precachemode);
441 int SV_ParticleEffectIndex(const char *name);
443 void SV_SetIdealPitch (void);
445 void SV_AddUpdates (void);
447 void SV_ClientThink (void);
449 void SV_ClientPrint(const char *msg);
450 void SV_ClientPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
451 void SV_BroadcastPrint(const char *msg);
452 void SV_BroadcastPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
454 void SV_Physics (void);
455 void SV_Physics_ClientMove (void);
456 void SV_Physics_ClientEntity (prvm_edict_t *ent);
458 qboolean SV_PlayerCheckGround (prvm_edict_t *ent);
459 qboolean SV_CheckBottom (prvm_edict_t *ent);
460 qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, qboolean settrace);
462 // Needs to be called any time an entity changes origin, mins, maxs, or solid
463 // sets ent->v.absmin and ent->v.absmax
464 // if touchtriggers, calls prog functions for the intersected triggers
465 void SV_LinkEdict (prvm_edict_t *ent, qboolean touch_triggers);
467 // calculates hitsupercontentsmask for a generic qc entity
468 int SV_GenericHitSuperContentsMask(const prvm_edict_t *edict);
469 // traces a box move against worldmodel and all entities in the specified area
470 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);
472 #define SV_PointSuperContents(point) (SV_Move((point), vec3_origin, vec3_origin, (point), sv_gameplayfix_swiminbmodels.integer ? MOVE_NOMONSTERS : MOVE_WORLDONLY, NULL, 0).startsupercontents)
474 void SV_FlushBroadcastMessages(void);
475 void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
477 void SV_MoveToGoal (void);
479 void SV_ApplyClientMove (void);
480 void SV_SaveSpawnparms (void);
481 void SV_SpawnServer (const char *server);
483 void SV_CheckVelocity (prvm_edict_t *ent);
485 void SV_SetupVM(void);
487 void SV_VM_Begin(void);
488 void SV_VM_End(void);
490 const char *Host_TimingReport(); // for output in Host_Status_f