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.
29 struct client_s *clients; // [maxclients]
30 int serverflags; // episode completion information
31 qboolean changelevel_issued; // cleared when at SV_SpawnServer
34 //=============================================================================
36 typedef enum {ss_loading, ss_active} server_state_t;
40 qboolean active; // false if only a net client
43 qboolean loadgame; // handle connections specially
49 int lastcheck; // used by PF_checkclient
52 char name[64]; // map name
53 char modelname[64]; // maps/<name>.bsp, for model_precache[0]
54 struct model_s *worldmodel;
55 char *model_precache[MAX_MODELS]; // NULL terminated
56 struct model_s *models[MAX_MODELS];
57 char *sound_precache[MAX_SOUNDS]; // NULL terminated
58 char *lightstyles[MAX_LIGHTSTYLES];
61 edict_t *edicts; // can NOT be array indexed, because
62 // edict_t is variable sized, but can
63 // be used to reference the world ent
64 server_state_t state; // some actions are only valid during load
67 qbyte datagram_buf[MAX_DATAGRAM];
69 sizebuf_t reliable_datagram; // copied to all clients at end of frame
70 qbyte reliable_datagram_buf[MAX_DATAGRAM];
73 qbyte signon_buf[32768]; // LordHavoc: increased signon message buffer from 8192 to 32768
77 #define NUM_PING_TIMES 16
78 #define NUM_SPAWN_PARMS 16
80 typedef struct client_s
82 qboolean active; // false = client is free
83 qboolean spawned; // false = don't send datagrams
84 qboolean dropasap; // has been told to go to another level
85 qboolean sendsignon; // only valid before spawned
88 // LordHavoc: to make netquake protocol get through NAT routers, have to wait for client to ack
89 qboolean waitingforconnect; // waiting for connect from client (stage 1)
90 qboolean sendserverinfo; // send server info in next datagram (stage 2)
93 double last_message; // reliable messages must be sent
96 struct qsocket_s *netconnection; // communications handle
98 usercmd_t cmd; // movement
99 vec3_t wishdir; // intended motion calced from cmd
101 sizebuf_t message; // can be added to at any time,
102 // copied and clear once per frame
103 qbyte msgbuf[MAX_MSGLEN];
104 edict_t *edict; // EDICT_NUM(clientnum+1)
105 char name[32]; // for printing to other people
108 float ping_times[NUM_PING_TIMES];
109 int num_pings; // ping_times[num_pings%NUM_PING_TIMES]
110 float ping; // LordHavoc: can be used for prediction or whatever...
111 float latency; // LordHavoc: specifically used for prediction, accounts for sys_ticrate too
113 // spawn parms are carried from level to level
114 float spawn_parms[NUM_SPAWN_PARMS];
116 // client known data for deltas
121 // delta compression state
122 float nextfullupdate[MAX_EDICTS];
125 float visibletime[MAX_EDICTS];
127 #ifndef QUAKEENTITIES
128 entity_database_t entitydatabase;
129 int entityframenumber; // incremented each time an entity frame is sent
134 //=============================================================================
136 // edict->movetype values
137 #define MOVETYPE_NONE 0 // never moves
138 #define MOVETYPE_ANGLENOCLIP 1
139 #define MOVETYPE_ANGLECLIP 2
140 #define MOVETYPE_WALK 3 // gravity
141 #define MOVETYPE_STEP 4 // gravity, special edge handling
142 #define MOVETYPE_FLY 5
143 #define MOVETYPE_TOSS 6 // gravity
144 #define MOVETYPE_PUSH 7 // no clip to world, push and crush
145 #define MOVETYPE_NOCLIP 8
146 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters
147 #define MOVETYPE_BOUNCE 10
148 #define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
149 #define MOVETYPE_FOLLOW 12 // track movement of aiment
151 // edict->solid values
152 #define SOLID_NOT 0 // no interaction with other objects
153 #define SOLID_TRIGGER 1 // touch on edge, but not blocking
154 #define SOLID_BBOX 2 // touch on edge, block
155 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
156 #define SOLID_BSP 4 // bsp clip, touch on edge, block
157 // LordHavoc: corpse code
158 #define SOLID_CORPSE 5 // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
160 // edict->deadflag values
172 #define FL_CONVEYOR 4
174 #define FL_INWATER 16
175 #define FL_MONSTER 32
176 #define FL_GODMODE 64
177 #define FL_NOTARGET 128
179 #define FL_ONGROUND 512
180 #define FL_PARTIALGROUND 1024 // not all corners are valid
181 #define FL_WATERJUMP 2048 // player jumping out of water
182 #define FL_JUMPRELEASED 4096 // for jump debouncing
186 #define EF_BRIGHTFIELD 1
187 #define EF_MUZZLEFLASH 2
188 #define EF_BRIGHTLIGHT 4
189 #define EF_DIMLIGHT 8
190 // added EF_ effects:
192 #define EF_ADDITIVE 32 // LordHavoc: Additive Rendering
196 #define SPAWNFLAG_NOT_EASY 256
197 #define SPAWNFLAG_NOT_MEDIUM 512
198 #define SPAWNFLAG_NOT_HARD 1024
199 #define SPAWNFLAG_NOT_DEATHMATCH 2048
201 //============================================================================
203 extern cvar_t teamplay;
205 extern cvar_t deathmatch;
207 extern cvar_t fraglimit;
208 extern cvar_t timelimit;
209 extern cvar_t pausable;
210 extern cvar_t sv_deltacompress;
211 extern cvar_t sv_maxvelocity;
212 extern cvar_t sv_gravity;
213 extern cvar_t sv_nostep;
214 extern cvar_t sv_friction;
215 extern cvar_t sv_edgefriction;
216 extern cvar_t sv_stopspeed;
217 extern cvar_t sv_maxspeed;
218 extern cvar_t sv_accelerate;
219 extern cvar_t sv_idealpitchscale;
220 extern cvar_t sv_aim;
221 extern cvar_t sv_predict;
222 extern cvar_t sv_stepheight;
223 extern cvar_t sv_jumpstep;
225 extern server_static_t svs; // persistant server info
226 extern server_t sv; // local server
228 extern client_t *host_client;
230 extern jmp_buf host_abortserver;
232 extern edict_t *sv_player;
234 //===========================================================
238 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
239 void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate);
240 void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation);
242 void SV_DropClient (qboolean crash);
244 void SV_SendClientMessages (void);
245 void SV_ClearDatagram (void);
247 int SV_ModelIndex (char *name);
249 void SV_SetIdealPitch (void);
251 void SV_AddUpdates (void);
253 void SV_ClientThink (void);
254 void SV_AddClientToServer (struct qsocket_s *ret);
256 void SV_ClientPrintf (char *fmt, ...);
257 void SV_BroadcastPrintf (char *fmt, ...);
259 void SV_Physics (void);
261 qboolean SV_CheckBottom (edict_t *ent);
262 qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink);
264 void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg);
266 void SV_MoveToGoal (void);
268 void SV_CheckForNewClients (void);
269 void SV_RunClients (void);
270 void SV_SaveSpawnparms (void);
271 void SV_SpawnServer (char *server);