1 /* 2 Copyright (C) 1996-1997 Id Software, Inc. 3 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. 8 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. 12 13 See the GNU General Public License for more details. 14 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. 18 19 */ 20 // server.h 21 22 typedef struct 23 { 24 int maxclients; 25 int maxclientslimit; 26 struct client_s *clients; // [maxclients] 27 int serverflags; // episode completion information 28 qboolean changelevel_issued; // cleared when at SV_SpawnServer 29 } server_static_t; 30 31 //============================================================================= 32 33 typedef enum {ss_loading, ss_active} server_state_t; 34 35 typedef struct 36 { 37 qboolean active; // false if only a net client 38 39 qboolean paused; 40 qboolean loadgame; // handle connections specially 41 42 double time; 43 44 int lastcheck; // used by PF_checkclient 45 double lastchecktime; 46 47 char name[64]; // map name 48 #ifdef QUAKE2 49 char startspot[64]; 50 #endif 51 char modelname[64]; // maps/<name>.bsp, for model_precache[0] 52 struct model_s *worldmodel; 53 char *model_precache[MAX_MODELS]; // NULL terminated 54 struct model_s *models[MAX_MODELS]; 55 char *sound_precache[MAX_SOUNDS]; // NULL terminated 56 char *lightstyles[MAX_LIGHTSTYLES]; 57 int num_edicts; 58 int active_edicts; 59 int max_edicts; 60 edict_t *edicts; // can NOT be array indexed, because 61 // edict_t is variable sized, but can 62 // be used to reference the world ent 63 server_state_t state; // some actions are only valid during load 64 65 sizebuf_t datagram; 66 byte datagram_buf[MAX_DATAGRAM]; 67 68 sizebuf_t reliable_datagram; // copied to all clients at end of frame 69 byte reliable_datagram_buf[MAX_DATAGRAM]; 70 71 sizebuf_t signon; 72 byte signon_buf[MAX_MSGLEN-2]; //8192 73 int signondiff; // Track extra bytes due to >256 model support, kludge 74 } server_t; 75 76 77 #define NUM_PING_TIMES 16 78 #define NUM_SPAWN_PARMS 16 79 80 typedef struct client_s 81 { 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 privileged; // can execute any host command 86 qboolean sendsignon; // only valid before spawned 87 88 double last_message; // reliable messages must be sent 89 // periodically 90 91 struct qsocket_s *netconnection; // communications handle 92 93 usercmd_t cmd; // movement 94 vec3_t wishdir; // intended motion calced from cmd 95 96 sizebuf_t message; // can be added to at any time, 97 // copied and clear once per frame 98 byte msgbuf[MAX_MSGLEN]; 99 edict_t *edict; // EDICT_NUM(clientnum+1) 100 char name[32]; // for printing to other people 101 int colors; 102 103 float ping_times[NUM_PING_TIMES]; 104 int num_pings; // ping_times[num_pings%NUM_PING_TIMES] 105 106 // spawn parms are carried from level to level 107 float spawn_parms[NUM_SPAWN_PARMS]; 108 109 // client known data for deltas 110 int old_frags; 111 } client_t; 112 113 114 //============================================================================= 115 116 // edict->movetype values 117 #define MOVETYPE_NONE 0 // never moves 118 #define MOVETYPE_ANGLENOCLIP 1 119 #define MOVETYPE_ANGLECLIP 2 120 #define MOVETYPE_WALK 3 // gravity 121 #define MOVETYPE_STEP 4 // gravity, special edge handling 122 #define MOVETYPE_FLY 5 123 #define MOVETYPE_TOSS 6 // gravity 124 #define MOVETYPE_PUSH 7 // no clip to world, push and crush 125 #define MOVETYPE_NOCLIP 8 126 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters 127 #define MOVETYPE_BOUNCE 10 128 #define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity 129 #define MOVETYPE_FOLLOW 12 // track movement of aiment 130 131 // edict->solid values 132 #define SOLID_NOT 0 // no interaction with other objects 133 #define SOLID_TRIGGER 1 // touch on edge, but not blocking 134 #define SOLID_BBOX 2 // touch on edge, block 135 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground 136 #define SOLID_BSP 4 // bsp clip, touch on edge, block 137 138 // edict->deadflag values 139 #define DEAD_NO 0 140 #define DEAD_DYING 1 141 #define DEAD_DEAD 2 142 143 #define DAMAGE_NO 0 144 #define DAMAGE_YES 1 145 #define DAMAGE_AIM 2 146 147 // edict->flags 148 #define FL_FLY 1 149 #define FL_SWIM 2 150 //#define FL_GLIMPSE 4 151 #define FL_CONVEYOR 4 152 #define FL_CLIENT 8 153 #define FL_INWATER 16 154 #define FL_MONSTER 32 155 #define FL_GODMODE 64 156 #define FL_NOTARGET 128 157 #define FL_ITEM 256 158 #define FL_ONGROUND 512 159 #define FL_PARTIALGROUND 1024 // not all corners are valid 160 #define FL_WATERJUMP 2048 // player jumping out of water 161 #define FL_JUMPRELEASED 4096 // for jump debouncing 162 #ifdef QUAKE2 163 #define FL_FLASHLIGHT 8192 164 #define FL_ARCHIVE_OVERRIDE 1048576 165 #endif 166 167 // entity effects 168 169 // tQER<1>: START 170 #define PAR_SMOKE 1 171 #define PAR_SMOKE_SMOKE 2 172 #define PAR_TRACER 3 173 #define PAR_BLOOD 4 174 #define PAR_LIGHT_BLOOD 5 175 #define PAR_TRAIL 6 176 #define PAR_FIRE 7 177 #define PAR_BUBBLE 8 178 #define PAR_GLOW 9 179 #define PAR_CORONA 10 180 // tQER<1>: END 181 182 183 184 #define EF_BRIGHTFIELD 1 185 #define EF_MUZZLEFLASH 2 186 #define EF_BRIGHTLIGHT 4 187 #define EF_DIMLIGHT 8 188 #ifdef QUAKE2 189 #define EF_DARKLIGHT 16 190 #define EF_DARKFIELD 32 191 #define EF_NODRAW 128 192 #endif 193 194 #define SPAWNFLAG_NOT_EASY 256 195 #define SPAWNFLAG_NOT_MEDIUM 512 196 #define SPAWNFLAG_NOT_HARD 1024 197 #define SPAWNFLAG_NOT_DEATHMATCH 2048 198 199 #ifdef QUAKE2 200 // server flags 201 #define SFL_EPISODE_1 1 202 #define SFL_EPISODE_2 2 203 #define SFL_EPISODE_3 4 204 #define SFL_EPISODE_4 8 205 #define SFL_NEW_UNIT 16 206 #define SFL_NEW_EPISODE 32 207 #define SFL_CROSS_TRIGGERS 65280 208 #endif 209 210 //============================================================================ 211 212 extern cvar_t teamplay; 213 extern cvar_t skill; 214 extern cvar_t deathmatch; 215 extern cvar_t coop; 216 extern cvar_t fraglimit; 217 extern cvar_t timelimit; 218 219 extern server_static_t svs; // persistant server info 220 extern server_t sv; // local server 221 222 extern client_t *host_client; 223 224 extern jmp_buf host_abortserver; 225 226 extern double host_time; 227 228 extern edict_t *sv_player; 229 230 //=========================================================== 231 232 void SV_Init (void); 233 qboolean SV_IsPaused (void); 234 235 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count); 236 void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, 237 float attenuation); 238 239 void SV_WriteByteShort (sizebuf_t *sb, int c); 240 void SV_DropClient (qboolean crash); 241 242 void SV_SendClientMessages (void); 243 void SV_ClearDatagram (void); 244 245 int SV_ModelIndex (char *name); 246 247 void SV_SetIdealPitch (void); 248 249 void SV_AddUpdates (void); 250 251 void SV_ClientThink (void); 252 void SV_AddClientToServer (struct qsocket_s *ret); 253 254 void SV_ClientPrintf (char *fmt, ...); 255 void SV_BroadcastPrintf (char *fmt, ...); 256 257 void SV_Physics (void); 258 259 qboolean SV_CheckBottom (edict_t *ent); 260 qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink); 261 262 void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg); 263 264 void SV_MoveToGoal (void); 265 266 void SV_CheckForNewClients (void); 267 void SV_RunClients (void); 268 void SV_SaveSpawnparms (); 269 #ifdef QUAKE2 270 void SV_SpawnServer (char *server, char *startspot); 271 #else 272 void SV_SpawnServer (char *server); 273 #endif 274