1 /* 2 * hexen2/server.h 3 * $Id: server.h 5787 2017-01-03 22:22:34Z sezero $ 4 * 5 * Copyright (C) 1996-1997 Id Software, Inc. 6 * Copyright (C) 1997-1998 Raven Software Corp. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or (at 11 * your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * See the GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc., 21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 */ 23 24 #ifndef __HX2_SERVER_H 25 #define __HX2_SERVER_H 26 27 typedef struct 28 { 29 int maxclients; 30 int maxclientslimit; 31 struct client_s *clients; // [maxclients] 32 int serverflags; // episode completion information 33 qboolean changelevel_issued; // cleared when at SV_SpawnServer 34 } server_static_t; 35 36 //============================================================================= 37 38 typedef enum 39 { 40 ss_loading, 41 ss_active 42 } server_state_t; 43 44 typedef struct 45 { 46 qboolean active; // false if only a net client 47 48 qboolean paused; 49 qboolean loadgame; // handle connections specially 50 51 double time; 52 53 int lastcheck; // used by PF_checkclient 54 double lastchecktime; 55 56 char name[64]; // map name 57 char midi_name[128]; // midi file name 58 byte cd_track; // cd track number 59 60 char startspot[64]; 61 char modelname[MAX_QPATH]; // maps/<name>.bsp, for model_precache[0] 62 struct qmodel_s *worldmodel; 63 const char *model_precache[MAX_MODELS]; // NULL terminated 64 struct qmodel_s *models[MAX_MODELS]; 65 const char *sound_precache[MAX_SOUNDS]; // NULL terminated 66 const char *lightstyles[MAX_LIGHTSTYLES]; 67 struct EffectT Effects[MAX_EFFECTS]; 68 69 client_state2_t *states; 70 int num_edicts; 71 edict_t *edicts; // can NOT be array indexed, because 72 // edict_t is variable sized, but can 73 // be used to reference the world ent 74 75 server_state_t state; // some actions are only valid during load 76 77 sizebuf_t datagram; 78 byte datagram_buf[NET_MAXMESSAGE]; 79 80 sizebuf_t reliable_datagram; // copied to all clients at end of frame 81 byte reliable_datagram_buf[NET_MAXMESSAGE]; 82 83 sizebuf_t signon; 84 byte signon_buf[NET_MAXMESSAGE]; 85 } server_t; 86 87 88 #define NUM_PING_TIMES 16 89 #define NUM_SPAWN_PARMS 16 90 91 typedef struct client_s 92 { 93 qboolean active; // false = client is free 94 qboolean spawned; // false = don't send datagrams 95 qboolean dropasap; // has been told to go to another level 96 qboolean sendsignon; // only valid before spawned 97 98 double last_message; // reliable messages must be sent 99 // periodically 100 101 struct qsocket_s *netconnection; // communications handle 102 103 usercmd_t cmd; // movement 104 vec3_t wishdir; // intended motion calced from cmd 105 106 sizebuf_t message; // can be added to at any time, 107 // copied and clear once per frame 108 byte msgbuf[MAX_MSGLEN]; 109 110 sizebuf_t datagram; 111 byte datagram_buf[NET_MAXMESSAGE]; 112 113 edict_t *edict; // EDICT_NUM(clientnum+1) 114 char name[32]; // for printing to other people 115 int colors; 116 float playerclass; 117 118 float ping_times[NUM_PING_TIMES]; 119 int num_pings; // ping_times[num_pings%NUM_PING_TIMES] 120 121 // spawn parms are carried from level to level 122 float spawn_parms[NUM_SPAWN_PARMS]; 123 124 // client known data for deltas 125 int old_frags; 126 entvars_t old_v; 127 qboolean send_all_v; 128 129 byte current_frame, last_frame; 130 byte current_sequence, last_sequence; 131 132 // mission pack, objectives strings 133 unsigned int info_mask, info_mask2; 134 } client_t; 135 136 137 //============================================================================= 138 139 // 140 // edict->movetype values 141 // 142 #define MOVETYPE_NONE 0 // never moves 143 #define MOVETYPE_ANGLENOCLIP 1 144 #define MOVETYPE_ANGLECLIP 2 145 #define MOVETYPE_WALK 3 // gravity 146 #define MOVETYPE_STEP 4 // gravity, special edge handling 147 #define MOVETYPE_FLY 5 148 #define MOVETYPE_TOSS 6 // gravity 149 #define MOVETYPE_PUSH 7 // no clip to world, push and crush 150 #define MOVETYPE_NOCLIP 8 151 #define MOVETYPE_FLYMISSILE 9 // extra size to monsters 152 #define MOVETYPE_BOUNCE 10 153 //#ifdef QUAKE2 154 #define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity 155 #define MOVETYPE_FOLLOW 12 // track movement of aiment 156 //#endif 157 #define MOVETYPE_PUSHPULL 13 // pushable/pullable object 158 #define MOVETYPE_SWIM 14 // should keep the object in water 159 160 // 161 // edict->solid values 162 // 163 #define SOLID_NOT 0 // no interaction with other objects 164 #define SOLID_TRIGGER 1 // touch on edge, but not blocking 165 #define SOLID_BBOX 2 // touch on edge, block 166 #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground 167 #define SOLID_BSP 4 // bsp clip, touch on edge, block 168 #define SOLID_PHASE 5 // won't slow down when hitting entities flagged as FL_MONSTER 169 170 // 171 // edict->deadflag values 172 // 173 #define DEAD_NO 0 174 #define DEAD_DYING 1 175 #define DEAD_DEAD 2 176 177 #define DAMAGE_NO 0 // Cannot be damaged 178 #define DAMAGE_YES 1 // Can be damaged 179 #define DAMAGE_NO_GRENADE 2 // Will not set off grenades 180 181 // 182 // edict->flags 183 // 184 #define FL_FLY 1 185 #define FL_SWIM 2 186 #define FL_CONVEYOR 4 187 #define FL_CLIENT 8 188 #define FL_INWATER 16 189 #define FL_MONSTER 32 190 #define FL_GODMODE 64 191 #define FL_NOTARGET 128 192 #define FL_ITEM 256 193 #define FL_ONGROUND 512 194 #define FL_PARTIALGROUND 1024 // not all corners are valid 195 #define FL_WATERJUMP 2048 // player jumping out of water 196 #define FL_JUMPRELEASED 4096 // for jump debouncing 197 #define FL_FLASHLIGHT 8192 198 #define FL_ARCHIVE_OVERRIDE 1048576 199 #define FL_ARTIFACTUSED 16384 200 #define FL_MOVECHAIN_ANGLE 32768 // when in a move chain, will update the angle 201 /* the following three are for monster_pentacles of the mission pack */ 202 #define FL_HUNTFACE 65536 // Makes monster go for enemy view_ofs thwn moving 203 #define FL_NOZ 131072 // Monster will not automove on Z if flying or swimming 204 #define FL_SET_TRACE 262144 // Trace will always be set for this monster (pentacles) 205 206 #define FL_CLASS_DEPENDENT 2097152 // model will appear different to each player 207 #define FL_SPECIAL_ABILITY1 4194304 // has 1st special ability 208 #define FL_SPECIAL_ABILITY2 8388608 // has 2nd special ability 209 210 #define FL2_CROUCHED 4096 211 212 // 213 // Built-in Spawn Flags 214 // 215 #define SPAWNFLAG_NOT_PALADIN 0x00000100 216 #define SPAWNFLAG_NOT_CLERIC 0x00000200 217 #define SPAWNFLAG_NOT_NECROMANCER 0x00000400 218 #define SPAWNFLAG_NOT_THEIF 0x00000800 219 #define SPAWNFLAG_NOT_EASY 0x00001000 220 #define SPAWNFLAG_NOT_MEDIUM 0x00002000 221 #define SPAWNFLAG_NOT_HARD 0x00004000 222 #define SPAWNFLAG_NOT_DEATHMATCH 0x00008000 223 #define SPAWNFLAG_NOT_COOP 0x00010000 224 #define SPAWNFLAG_NOT_SINGLE 0x00020000 225 /* SPAWNFLAG_NOT_DEMON is NOT used: ED_LoadFromFile 226 * checks SPAWNFLAG_NOT_NECROMANCER for CLASS_DEMON !! */ 227 #define SPAWNFLAG_NOT_DEMON 0x00040000 228 229 // 230 // server flags 231 // 232 #define SFL_EPISODE_1 1 233 #define SFL_EPISODE_2 2 234 #define SFL_EPISODE_3 4 235 #define SFL_EPISODE_4 8 236 #define SFL_NEW_UNIT 16 237 #define SFL_NEW_EPISODE 32 238 #define SFL_CROSS_TRIGGERS 65280 239 240 //============================================================================ 241 242 extern cvar_t teamplay; 243 extern cvar_t skill; 244 extern cvar_t deathmatch; 245 extern cvar_t coop; 246 extern cvar_t randomclass; 247 extern cvar_t fraglimit; 248 extern cvar_t timelimit; 249 250 extern server_static_t svs; // persistant server info 251 extern server_t sv; // local server 252 253 extern int sv_protocol; // protocol version to use 254 255 extern client_t *host_client; 256 257 extern edict_t *sv_player; 258 259 //=========================================================== 260 261 void SV_Init (void); 262 void SV_UserInit (void); 263 264 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count); 265 void SV_StartParticle2 (vec3_t org, vec3_t dmin, vec3_t dmax, int color, int effect, int count); 266 void SV_StartParticle3 (vec3_t org, vec3_t box, int color, int effect, int count); 267 void SV_StartParticle4 (vec3_t org, float radius, int color, int effect, int count); 268 void SV_StartSound (edict_t *entity, int channel, const char *sample, int volume, float attenuation); 269 void SV_StopSound (edict_t *entity, int channel); 270 void SV_UpdateSoundPos (edict_t *entity, int channel); 271 272 void SV_DropClient (qboolean crash); 273 274 void SV_Edicts (const char *Name); 275 276 void SV_SendClientMessages (void); 277 void SV_ClearDatagram (void); 278 279 int SV_ModelIndex (const char *name); 280 281 void SV_SetIdealPitch (void); 282 283 void SV_AddUpdates (void); 284 285 void SV_ClientThink (void); 286 void SV_AddClientToServer (struct qsocket_s *ret); 287 288 void SV_ClientPrintf (unsigned int unused, const char *fmt, ...) FUNC_PRINTF(2,3); 289 void SV_BroadcastPrintf (const char *fmt, ...) FUNC_PRINTF(1,2); 290 291 void SV_Physics (void); 292 293 qboolean SV_CheckBottom (edict_t *ent); 294 qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, 295 qboolean set_trace); 296 297 void SV_WriteClientdataToMessage (client_t *client, edict_t *ent, sizebuf_t *msg); 298 299 void SV_MoveToGoal (void); 300 301 void SV_CheckForNewClients (void); 302 void SV_RunClients (void); 303 void SV_SaveSpawnparms (void); 304 void SV_SpawnServer (const char *server, const char *startspot); 305 306 const char *SV_GetLevelname (void); 307 308 void SV_ParseEffect (sizebuf_t *sb); 309 void SV_UpdateEffects (sizebuf_t *sb); 310 void SV_SaveEffects (FILE *FH); 311 void SV_LoadEffects (FILE *FH); 312 313 #endif /* __HX2_SERVER_H */ 314 315