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
143 // 1 = send svc_serverinfo and advance to 2, 2 doesn't send, then advances to 0 (allowing unlimited sending) when prespawn is received
146 // requested rate in bytes per second
149 // realtime this client connected
152 // keepalive messages must be sent periodically during signon
153 double keepalivetime;
155 // communications handle
156 netconn_t *netconnection;
161 // intended motion calced from cmd
164 // PRVM_EDICT_NUM(clientnum+1)
167 #ifdef NUM_PING_TIMES
168 float ping_times[NUM_PING_TIMES];
169 // ping_times[num_pings%NUM_PING_TIMES]
172 // LordHavoc: can be used for prediction or whatever...
175 // this is used by sv_clmovement_minping code
176 double clmovement_disabletimeout;
177 // this is used by sv_clmvoement_waitforinput code
178 int clmovement_skipphysicsframes;
180 // spawn parms are carried from level to level
181 float spawn_parms[NUM_SPAWN_PARMS];
183 // properties that are sent across the network only when changed
184 char name[64], old_name[64];
185 int colors, old_colors;
186 int frags, old_frags;
187 char playermodel[MAX_QPATH], old_model[MAX_QPATH];
188 char playerskin[MAX_QPATH], old_skin[MAX_QPATH];
190 // netaddress support
191 char netaddress[MAX_QPATH];
194 float visibletime[MAX_EDICTS];
196 // version number of csqc-based entity to decide whether to send it
197 unsigned char csqcentityversion[MAX_EDICTS];
199 // prevent animated names
202 // latest received clc_ackframe (used to detect packet loss)
205 // cache weaponmodel name lookups
206 char weaponmodel[MAX_QPATH];
207 int weaponmodelindex;
209 entityframe_database_t *entitydatabase;
210 entityframe4_database_t *entitydatabase4;
211 entityframe5_database_t *entitydatabase5;
213 // delta compression of stats
214 unsigned char statsdeltabits[(MAX_CL_STATS+7)/8];
215 int stats[MAX_CL_STATS];
217 unsigned char unreliablemsg_data[NET_MAXMESSAGE];
218 sizebuf_t unreliablemsg;
219 int unreliablemsg_splitpoints;
220 int unreliablemsg_splitpoint[NET_MAXMESSAGE/16];
222 // information on an active download if any
223 qfile_t *download_file;
224 int download_expectedposition; // next position the client should ack
225 qboolean download_started;
226 char download_name[MAX_QPATH];
229 qboolean fixangle_angles_set;
230 vec3_t fixangle_angles;
234 //=============================================================================
236 // edict->movetype values
237 #define MOVETYPE_NONE 0 // never moves
238 #define MOVETYPE_ANGLENOCLIP 1
239 #define MOVETYPE_ANGLECLIP 2
240 #define MOVETYPE_WALK 3 // gravity
241 #define MOVETYPE_STEP 4 // gravity, special edge handling
242 #define MOVETYPE_FLY 5
243 #define MOVETYPE_TOSS 6 // gravity
244 #define MOVETYPE_PUSH 7 // no clip to world, push and crush
245 #define MOVETYPE_NOCLIP 8
246 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters
247 #define MOVETYPE_BOUNCE 10
248 #define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
249 #define MOVETYPE_FOLLOW 12 // track movement of aiment
250 #define MOVETYPE_FAKEPUSH 13 // tenebrae's push that doesn't push
252 // edict->solid values
253 #define SOLID_NOT 0 // no interaction with other objects
254 #define SOLID_TRIGGER 1 // touch on edge, but not blocking
255 #define SOLID_BBOX 2 // touch on edge, block
256 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
257 #define SOLID_BSP 4 // bsp clip, touch on edge, block
258 // LordHavoc: corpse code
259 #define SOLID_CORPSE 5 // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
261 // edict->deadflag values
273 #define FL_CONVEYOR 4
275 #define FL_INWATER 16
276 #define FL_MONSTER 32
277 #define FL_GODMODE 64
278 #define FL_NOTARGET 128
280 #define FL_ONGROUND 512
281 #define FL_PARTIALGROUND 1024 // not all corners are valid
282 #define FL_WATERJUMP 2048 // player jumping out of water
283 #define FL_JUMPRELEASED 4096 // for jump debouncing
285 #define SPAWNFLAG_NOT_EASY 256
286 #define SPAWNFLAG_NOT_MEDIUM 512
287 #define SPAWNFLAG_NOT_HARD 1024
288 #define SPAWNFLAG_NOT_DEATHMATCH 2048
290 //============================================================================
293 extern cvar_t deathmatch;
294 extern cvar_t fraglimit;
295 extern cvar_t gamecfg;
296 extern cvar_t noexit;
297 extern cvar_t nomonsters;
298 extern cvar_t pausable;
299 extern cvar_t pr_checkextension;
300 extern cvar_t samelevel;
301 extern cvar_t saved1;
302 extern cvar_t saved2;
303 extern cvar_t saved3;
304 extern cvar_t saved4;
305 extern cvar_t savedgamecfg;
306 extern cvar_t scratch1;
307 extern cvar_t scratch2;
308 extern cvar_t scratch3;
309 extern cvar_t scratch4;
311 extern cvar_t slowmo;
312 extern cvar_t sv_accelerate;
313 extern cvar_t sv_aim;
314 extern cvar_t sv_airaccel_qw;
315 extern cvar_t sv_airaccel_sideways_friction;
316 extern cvar_t sv_airaccelerate;
317 extern cvar_t sv_allowdownloads;
318 extern cvar_t sv_allowdownloads_archive;
319 extern cvar_t sv_allowdownloads_config;
320 extern cvar_t sv_allowdownloads_dlcache;
321 extern cvar_t sv_allowdownloads_inarchive;
322 extern cvar_t sv_areagrid_mingridsize;
323 extern cvar_t sv_checkforpacketsduringsleep;
324 extern cvar_t sv_clmovement_enable;
325 extern cvar_t sv_clmovement_minping;
326 extern cvar_t sv_clmovement_minping_disabletime;
327 extern cvar_t sv_clmovement_waitforinput;
328 extern cvar_t sv_cullentities_nevercullbmodels;
329 extern cvar_t sv_cullentities_pvs;
330 extern cvar_t sv_cullentities_stats;
331 extern cvar_t sv_cullentities_trace;
332 extern cvar_t sv_cullentities_trace_delay;
333 extern cvar_t sv_cullentities_trace_enlarge;
334 extern cvar_t sv_cullentities_trace_prediction;
335 extern cvar_t sv_cullentities_trace_samples;
336 extern cvar_t sv_cullentities_trace_samples_extra;
337 extern cvar_t sv_debugmove;
338 extern cvar_t sv_echobprint;
339 extern cvar_t sv_edgefriction;
340 extern cvar_t sv_entpatch;
341 extern cvar_t sv_fixedframeratesingleplayer;
342 extern cvar_t sv_freezenonclients;
343 extern cvar_t sv_friction;
344 extern cvar_t sv_gameplayfix_blowupfallenzombies;
345 extern cvar_t sv_gameplayfix_droptofloorstartsolid;
346 extern cvar_t sv_gameplayfix_findradiusdistancetobox;
347 extern cvar_t sv_gameplayfix_grenadebouncedownslopes;
348 extern cvar_t sv_gameplayfix_noairborncorpse;
349 extern cvar_t sv_gameplayfix_qwplayerphysics;
350 extern cvar_t sv_gameplayfix_setmodelrealbox;
351 extern cvar_t sv_gameplayfix_stepdown;
352 extern cvar_t sv_gameplayfix_stepwhilejumping;
353 extern cvar_t sv_gameplayfix_swiminbmodels;
354 extern cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag;
355 extern cvar_t sv_gravity;
356 extern cvar_t sv_idealpitchscale;
357 extern cvar_t sv_jumpstep;
358 extern cvar_t sv_jumpvelocity;
359 extern cvar_t sv_maxairspeed;
360 extern cvar_t sv_maxrate;
361 extern cvar_t sv_maxspeed;
362 extern cvar_t sv_maxvelocity;
363 extern cvar_t sv_newflymove;
364 extern cvar_t sv_nostep;
365 extern cvar_t sv_playerphysicsqc;
366 extern cvar_t sv_progs;
367 extern cvar_t sv_protocolname;
368 extern cvar_t sv_random_seed;
369 extern cvar_t sv_ratelimitlocalplayer;
370 extern cvar_t sv_sound_land;
371 extern cvar_t sv_sound_watersplash;
372 extern cvar_t sv_stepheight;
373 extern cvar_t sv_stopspeed;
374 extern cvar_t sv_wallfriction;
375 extern cvar_t sv_wateraccelerate;
376 extern cvar_t sv_waterfriction;
377 extern cvar_t sys_ticrate;
378 extern cvar_t teamplay;
380 extern cvar_t timelimit;
382 extern mempool_t *sv_mempool;
384 // persistant server info
385 extern server_static_t svs;
389 extern client_t *host_client;
391 //===========================================================
395 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
396 void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate);
397 void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation);
399 void SV_ConnectClient (int clientnum, netconn_t *netconnection);
400 void SV_DropClient (qboolean crash);
402 void SV_SendClientMessages (void);
404 void SV_ReadClientMessage(void);
406 // precachemode values:
407 // 0 = fail if not precached,
408 // 1 = warn if not found and precache if possible
410 int SV_ModelIndex(const char *s, int precachemode);
411 int SV_SoundIndex(const char *s, int precachemode);
413 int SV_ParticleEffectIndex(const char *name);
415 void SV_SetIdealPitch (void);
417 void SV_AddUpdates (void);
419 void SV_ClientThink (void);
421 void SV_ClientPrint(const char *msg);
422 void SV_ClientPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
423 void SV_BroadcastPrint(const char *msg);
424 void SV_BroadcastPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
426 void SV_Physics (void);
427 void SV_Physics_ClientMove (void);
428 void SV_Physics_ClientEntity (prvm_edict_t *ent);
430 qboolean SV_PlayerCheckGround (prvm_edict_t *ent);
431 qboolean SV_CheckBottom (prvm_edict_t *ent);
432 qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, qboolean settrace);
434 // Needs to be called any time an entity changes origin, mins, maxs, or solid
435 // sets ent->v.absmin and ent->v.absmax
436 // if touchtriggers, calls prog functions for the intersected triggers
437 void SV_LinkEdict (prvm_edict_t *ent, qboolean touch_triggers);
439 // calculates hitsupercontentsmask for a generic qc entity
440 int SV_GenericHitSuperContentsMask(const prvm_edict_t *edict);
441 // traces a box move against worldmodel and all entities in the specified area
442 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);
444 #define SV_PointSuperContents(point) (SV_Move((point), vec3_origin, vec3_origin, (point), sv_gameplayfix_swiminbmodels.integer ? MOVE_NOMONSTERS : MOVE_WORLDONLY, NULL, 0).startsupercontents)
446 void SV_FlushBroadcastMessages(void);
447 void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
449 void SV_MoveToGoal (void);
451 void SV_ApplyClientMove (void);
452 void SV_SaveSpawnparms (void);
453 void SV_SpawnServer (const char *server);
455 void SV_CheckVelocity (prvm_edict_t *ent);
457 void SV_SetupVM(void);
459 void SV_VM_Begin(void);
460 void SV_VM_End(void);