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