]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - server.h
minor tweak to the forcing of color 255 to black
[xonotic/darkplaces.git] / server.h
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         char            modelname[64];          // maps/<name>.bsp, for model_precache[0]
49         struct model_s  *worldmodel;
50         char            *model_precache[MAX_MODELS];    // NULL terminated
51         struct model_s  *models[MAX_MODELS];
52         char            *sound_precache[MAX_SOUNDS];    // NULL terminated
53         char            *lightstyles[MAX_LIGHTSTYLES];
54         int                     num_edicts;
55         int                     max_edicts;
56         edict_t         *edicts;                        // can NOT be array indexed, because
57                                                                         // edict_t is variable sized, but can
58                                                                         // be used to reference the world ent
59         server_state_t  state;                  // some actions are only valid during load
60
61         sizebuf_t       datagram;
62         byte            datagram_buf[MAX_DATAGRAM];
63
64         sizebuf_t       reliable_datagram;      // copied to all clients at end of frame
65         byte            reliable_datagram_buf[MAX_DATAGRAM];
66
67         sizebuf_t       signon;
68         byte            signon_buf[32768]; // LordHavoc: increased signon message buffer from 8192 to 32768
69 } server_t;
70
71
72 #define NUM_PING_TIMES          16
73 #define NUM_SPAWN_PARMS         16
74
75 typedef struct client_s
76 {
77         qboolean                active;                         // false = client is free
78         qboolean                spawned;                        // false = don't send datagrams
79         qboolean                dropasap;                       // has been told to go to another level
80         qboolean                sendsignon;                     // only valid before spawned
81
82         double                  last_message;           // reliable messages must be sent
83                                                                                 // periodically
84
85         struct qsocket_s *netconnection;        // communications handle
86
87         usercmd_t               cmd;                            // movement
88         vec3_t                  wishdir;                        // intended motion calced from cmd
89
90         sizebuf_t               message;                        // can be added to at any time,
91                                                                                 // copied and clear once per frame
92         byte                    msgbuf[MAX_MSGLEN];
93         edict_t                 *edict;                         // EDICT_NUM(clientnum+1)
94         char                    name[32];                       // for printing to other people
95         int                             colors;
96                 
97         float                   ping_times[NUM_PING_TIMES];
98         int                             num_pings;                      // ping_times[num_pings%NUM_PING_TIMES]
99
100 // spawn parms are carried from level to level
101         float                   spawn_parms[NUM_SPAWN_PARMS];
102
103 // client known data for deltas 
104         int                             old_frags;
105         int                             pmodel;
106 } client_t;
107
108
109 //=============================================================================
110
111 // edict->movetype values
112 #define MOVETYPE_NONE                   0               // never moves
113 #define MOVETYPE_ANGLENOCLIP    1
114 #define MOVETYPE_ANGLECLIP              2
115 #define MOVETYPE_WALK                   3               // gravity
116 #define MOVETYPE_STEP                   4               // gravity, special edge handling
117 #define MOVETYPE_FLY                    5
118 #define MOVETYPE_TOSS                   6               // gravity
119 #define MOVETYPE_PUSH                   7               // no clip to world, push and crush
120 #define MOVETYPE_NOCLIP                 8
121 #define MOVETYPE_FLYMISSILE             9               // extra size to monsters
122 #define MOVETYPE_BOUNCE                 10
123 #define MOVETYPE_BOUNCEMISSILE  11              // bounce w/o gravity
124 #define MOVETYPE_FOLLOW                 12              // track movement of aiment
125
126 // edict->solid values
127 #define SOLID_NOT                               0               // no interaction with other objects
128 #define SOLID_TRIGGER                   1               // touch on edge, but not blocking
129 #define SOLID_BBOX                              2               // touch on edge, block
130 #define SOLID_SLIDEBOX                  3               // touch on edge, but not an onground
131 #define SOLID_BSP                               4               // bsp clip, touch on edge, block
132 // LordHavoc: corpse code
133 #define SOLID_CORPSE                    5               // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
134
135 // edict->deadflag values
136 #define DEAD_NO                                 0
137 #define DEAD_DYING                              1
138 #define DEAD_DEAD                               2
139
140 #define DAMAGE_NO                               0
141 #define DAMAGE_YES                              1
142 #define DAMAGE_AIM                              2
143
144 // edict->flags
145 #define FL_FLY                                  1
146 #define FL_SWIM                                 2
147 //#define       FL_GLIMPSE                              4
148 #define FL_CONVEYOR                             4
149 #define FL_CLIENT                               8
150 #define FL_INWATER                              16
151 #define FL_MONSTER                              32
152 #define FL_GODMODE                              64
153 #define FL_NOTARGET                             128
154 #define FL_ITEM                                 256
155 #define FL_ONGROUND                             512
156 #define FL_PARTIALGROUND                1024    // not all corners are valid
157 #define FL_WATERJUMP                    2048    // player jumping out of water
158 #define FL_JUMPRELEASED                 4096    // for jump debouncing
159
160 // entity effects
161
162 #define EF_BRIGHTFIELD                  1
163 #define EF_MUZZLEFLASH                  2
164 #define EF_BRIGHTLIGHT                  4
165 #define EF_DIMLIGHT                     8
166 // added EF_ effects:
167 #define EF_NODRAW                               16
168 #define EF_ADDITIVE                             32  // LordHavoc: Additive Rendering
169 #define EF_BLUE                                 64
170 #define EF_RED                                  128
171
172 #define SPAWNFLAG_NOT_EASY                      256
173 #define SPAWNFLAG_NOT_MEDIUM            512
174 #define SPAWNFLAG_NOT_HARD                      1024
175 #define SPAWNFLAG_NOT_DEATHMATCH        2048
176
177 //============================================================================
178
179 extern  cvar_t  teamplay;
180 extern  cvar_t  skill;
181 extern  cvar_t  deathmatch;
182 extern  cvar_t  coop;
183 extern  cvar_t  fraglimit;
184 extern  cvar_t  timelimit;
185
186 extern  server_static_t svs;                            // persistant server info
187 extern  server_t                sv;                                     // local server
188
189 extern  client_t        *host_client;
190
191 extern  jmp_buf         host_abortserver;
192
193 extern  double          host_time;
194
195 extern  edict_t         *sv_player;
196
197 //===========================================================
198
199 void SV_Init (void);
200
201 void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
202 void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
203     float attenuation);
204
205 void SV_DropClient (qboolean crash);
206
207 void SV_SendClientMessages (void);
208 void SV_ClearDatagram (void);
209
210 int SV_ModelIndex (char *name);
211
212 void SV_SetIdealPitch (void);
213
214 void SV_AddUpdates (void);
215
216 void SV_ClientThink (void);
217 void SV_AddClientToServer (struct qsocket_s     *ret);
218
219 void SV_ClientPrintf (char *fmt, ...);
220 void SV_BroadcastPrintf (char *fmt, ...);
221
222 void SV_Physics (void);
223
224 qboolean SV_CheckBottom (edict_t *ent);
225 qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink);
226
227 void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg);
228
229 void SV_MoveToGoal (void);
230
231 void SV_CheckForNewClients (void);
232 void SV_RunClients (void);
233 void SV_SaveSpawnparms ();
234 void SV_SpawnServer (char *server);