]> icculus.org git repositories - divverent/darkplaces.git/blob - progs.h
new zymotic hud
[divverent/darkplaces.git] / progs.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
21 #ifndef PROGS_H
22 #define PROGS_H
23 #include "pr_comp.h"                    // defs shared with qcc
24
25 typedef struct link_s
26 {
27         int entitynumber;
28         struct link_s   *prev, *next;
29 } link_t;
30
31 #define ENTITYGRIDAREAS 16
32 #define MAX_ENTITYCLUSTERS 16
33
34 typedef struct edict_engineprivate_s
35 {
36         // true if this edict is unused
37         qboolean free;
38         // sv.time when the object was freed (to prevent early reuse which could
39         // mess up client interpolation or obscure severe QuakeC bugs)
40         float freetime;
41
42         // cached cluster links for quick stationary object visibility checking
43         vec3_t cullmins, cullmaxs;
44         int pvs_numclusters;
45         int pvs_clusterlist[MAX_ENTITYCLUSTERS];
46
47         // physics grid areas this edict is linked into
48         link_t areagrid[ENTITYGRIDAREAS];
49         // since the areagrid can have multiple references to one entity,
50         // we should avoid extensive checking on entities already encountered
51         int areagridmarknumber;
52
53         // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE
54         // baseline values
55         entity_state_t baseline;
56
57         // LordHavoc: gross hack to make floating items still work
58         int suspendedinairflag;
59         // used by PushMove to keep track of where objects were before they were
60         // moved, in case they need to be moved back
61         vec3_t moved_from;
62         vec3_t moved_fromangles;
63 }
64 edict_engineprivate_t;
65
66 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
67 extern int eval_gravity;
68 extern int eval_button3;
69 extern int eval_button4;
70 extern int eval_button5;
71 extern int eval_button6;
72 extern int eval_button7;
73 extern int eval_button8;
74 extern int eval_buttonuse;
75 extern int eval_buttonchat;
76 extern int eval_glow_size;
77 extern int eval_glow_trail;
78 extern int eval_glow_color;
79 extern int eval_items2;
80 extern int eval_scale;
81 extern int eval_alpha;
82 extern int eval_renderamt; // HalfLife support
83 extern int eval_rendermode; // HalfLife support
84 extern int eval_fullbright;
85 extern int eval_ammo_shells1;
86 extern int eval_ammo_nails1;
87 extern int eval_ammo_lava_nails;
88 extern int eval_ammo_rockets1;
89 extern int eval_ammo_multi_rockets;
90 extern int eval_ammo_cells1;
91 extern int eval_ammo_plasma;
92 extern int eval_idealpitch;
93 extern int eval_pitch_speed;
94 extern int eval_viewmodelforclient;
95 extern int eval_nodrawtoclient;
96 extern int eval_exteriormodeltoclient;
97 extern int eval_drawonlytoclient;
98 extern int eval_ping;
99 extern int eval_movement;
100 extern int eval_pmodel;
101 extern int eval_punchvector;
102 extern int eval_viewzoom;
103 extern int eval_clientcolors;
104 extern int eval_tag_entity;
105 extern int eval_tag_index;
106 extern int eval_light_lev;
107 extern int eval_color;
108 extern int eval_style;
109 extern int eval_pflags;
110 extern int eval_cursor_active;
111 extern int eval_cursor_screen;
112 extern int eval_cursor_trace_start;
113 extern int eval_cursor_trace_endpos;
114 extern int eval_cursor_trace_ent;
115 extern int eval_colormod;
116 extern int eval_playermodel;
117 extern int eval_playerskin;
118
119 extern mfunction_t *SV_PlayerPhysicsQC;
120 extern mfunction_t *EndFrameQC;
121 //KrimZon - SERVER COMMANDS IN QUAKEC
122 extern mfunction_t *SV_ParseClientCommandQC;
123
124 #endif
125
126
127
128
129
130
131 //////////////////////////////////
132 #if 0
133
134 #include "pr_comp.h"                    // defs shared with qcc
135 #include "progdefs.h"                   // generated by program cdefs
136
137 typedef union eval_s
138 {
139         string_t                string;
140         float                   _float;
141         float                   vector[3];
142         func_t                  function;
143         int                             ivector[3];
144         int                             _int;
145         int                             edict;
146 } prvm_eval_t;
147
148 typedef struct link_s
149 {
150         int entitynumber;
151         struct link_s   *prev, *next;
152 } link_t;
153
154 #define ENTITYGRIDAREAS 16
155
156 typedef struct edict_engineprivate_s
157 {
158         // true if this edict is unused
159         qboolean free;
160         // sv.time when the object was freed (to prevent early reuse which could
161         // mess up client interpolation or obscure severe QuakeC bugs)
162         float freetime;
163
164         // cached cluster links for quick stationary object visibility checking
165         vec3_t cullmins, cullmaxs;
166         int pvs_numclusters;
167         int pvs_clusterlist[MAX_ENTITYCLUSTERS];
168
169         // physics grid areas this edict is linked into
170         link_t areagrid[ENTITYGRIDAREAS];
171         // since the areagrid can have multiple references to one entity,
172         // we should avoid extensive checking on entities already encountered
173         int areagridmarknumber;
174
175         // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE
176         // baseline values
177         entity_state_t baseline;
178
179         // LordHavoc: gross hack to make floating items still work
180         int suspendedinairflag;
181         // used by PushMove to keep track of where objects were before they were
182         // moved, in case they need to be moved back
183         vec3_t moved_from;
184         vec3_t moved_fromangles;
185 }
186 edict_engineprivate_t;
187
188 // the entire server entity structure
189 // NOTE: keep this small!  priv and v are dynamic but this struct is not!
190 typedef struct edict_s
191 {
192         // engine-private fields (stored in dynamically resized array)
193         edict_engineprivate_t *e;
194         // QuakeC fields (stored in dynamically resized array)
195         entvars_t *v;
196 }
197 prvm_edict_t;
198
199 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
200 extern int eval_gravity;
201 extern int eval_button3;
202 extern int eval_button4;
203 extern int eval_button5;
204 extern int eval_button6;
205 extern int eval_button7;
206 extern int eval_button8;
207 extern int eval_buttonuse;
208 extern int eval_buttonchat;
209 extern int eval_glow_size;
210 extern int eval_glow_trail;
211 extern int eval_glow_color;
212 extern int eval_items2;
213 extern int eval_scale;
214 extern int eval_alpha;
215 extern int eval_renderamt; // HalfLife support
216 extern int eval_rendermode; // HalfLife support
217 extern int eval_fullbright;
218 extern int eval_ammo_shells1;
219 extern int eval_ammo_nails1;
220 extern int eval_ammo_lava_nails;
221 extern int eval_ammo_rockets1;
222 extern int eval_ammo_multi_rockets;
223 extern int eval_ammo_cells1;
224 extern int eval_ammo_plasma;
225 extern int eval_idealpitch;
226 extern int eval_pitch_speed;
227 extern int eval_viewmodelforclient;
228 extern int eval_nodrawtoclient;
229 extern int eval_exteriormodeltoclient;
230 extern int eval_drawonlytoclient;
231 extern int eval_ping;
232 extern int eval_movement;
233 extern int eval_pmodel;
234 extern int eval_punchvector;
235 extern int eval_viewzoom;
236 extern int eval_clientcolors;
237 extern int eval_tag_entity;
238 extern int eval_tag_index;
239 extern int eval_light_lev;
240 extern int eval_color;
241 extern int eval_style;
242 extern int eval_pflags;
243 extern int eval_cursor_active;
244 extern int eval_cursor_screen;
245 extern int eval_cursor_trace_start;
246 extern int eval_cursor_trace_endpos;
247 extern int eval_cursor_trace_ent;
248 extern int eval_colormod;
249 extern int eval_playermodel;
250 extern int eval_playerskin;
251
252 #define PRVM_GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (prvm_eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
253
254
255 extern mfunction_t *SV_PlayerPhysicsQC;
256 extern mfunction_t *EndFrameQC;
257 //KrimZon - SERVER COMMANDS IN QUAKEC
258 extern mfunction_t *SV_ParseClientCommandQC;
259
260 //============================================================================
261
262 extern  dprograms_t             *progs;
263 extern  mfunction_t             *prog->functions;
264 extern  char                    *pr_strings;
265 extern  int                             pr_stringssize;
266 extern  ddef_t                  *pr_globaldefs;
267 extern  ddef_t                  *pr_fielddefs;
268 extern  dstatement_t    *pr_statements;
269 extern  globalvars_t    *pr_global_struct;
270 extern  float                   *pr_globals;                    // same as pr_global_struct
271
272 extern  int                             prog->edict_size;       // in bytes
273 extern  int                             pr_edictareasize; // LordHavoc: for bounds checking
274
275 extern  int                             pr_maxknownstrings;
276 extern  int                             pr_numknownstrings;
277 extern  const char              **pr_knownstrings;
278
279 //============================================================================
280
281 void PR_Init (void);
282 void PR_Shutdown (void);
283
284 void PRVM_ExecuteProgram (func_t fnum, const char *errormessage);
285 void PR_LoadProgs (const char *progsname);
286
287 #define PR_Alloc(buffersize) _PR_Alloc(buffersize, __FILE__, __LINE__)
288 #define PR_Free(buffer) _PR_Free(buffer, __FILE__, __LINE__)
289 #define PR_FreeAll() _PR_FreeAll(__FILE__, __LINE__)
290 void *_PR_Alloc (size_t buffersize, const char *filename, int fileline);
291 void _PR_Free (void *buffer, const char *filename, int fileline);
292 void _PR_FreeAll (const char *filename, int fileline);
293
294 void PR_Profile_f (void);
295
296 void PR_PrintState(void);
297 void PR_Crash (void);
298
299 void SV_IncreaseEdicts(void);
300
301 prvm_edict_t *ED_Alloc (void);
302 void ED_Free (prvm_edict_t *ed);
303 void ED_ClearEdict (prvm_edict_t *e);
304
305 void ED_Print(prvm_edict_t *ed);
306 void ED_Write (qfile_t *f, prvm_edict_t *ed);
307 const char *ED_ParseEdict (const char *data, prvm_edict_t *ent);
308
309 void ED_WriteGlobals (qfile_t *f);
310 void ED_ParseGlobals (const char *data);
311
312 void ED_LoadFromFile (const char *data);
313
314 prvm_edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline);
315 #define PRVM_EDICT_NUM(n) (((n) >= 0 && (n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
316 #define EDICT_NUM_UNSIGNED(n) (((n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
317
318 //int NUM_FOR_EDICT_ERROR(prvm_edict_t *e);
319 #define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts))
320 //int PRVM_NUM_FOR_EDICT(prvm_edict_t *e);
321
322 #define PRVM_NEXT_EDICT(e) ((e) + 1)
323
324 #define PRVM_EDICT_TO_PROG(e) (PRVM_NUM_FOR_EDICT(e))
325 //int PRVM_EDICT_TO_PROG(prvm_edict_t *e);
326 #define PRVM_PROG_TO_EDICT(n) (PRVM_EDICT_NUM(n))
327 //prvm_edict_t *PRVM_PROG_TO_EDICT(int n);
328
329 //============================================================================
330
331 #define PRVM_G_FLOAT(o) (pr_globals[o])
332 #define PRVM_G_INT(o) (*(int *)&pr_globals[o])
333 #define PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(*(int *)&pr_globals[o]))
334 #define PRVM_G_EDICTNUM(o) PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(o))
335 #define PRVM_G_VECTOR(o) (&pr_globals[o])
336 #define PRVM_G_STRING(o) (PRVM_GetString(*(string_t *)&pr_globals[o]))
337 //#define       G_FUNCTION(o) (*(func_t *)&pr_globals[o])
338
339 // FIXME: make these go away?
340 #define E_FLOAT(e,o) (((float*)e->v)[o])
341 //#define       E_INT(e,o) (((int*)e->v)[o])
342 //#define       E_VECTOR(e,o) (&((float*)e->v)[o])
343 #define E_STRING(e,o) (PRVM_GetString(*(string_t *)&((float*)e->v)[o]))
344
345 extern  int             type_size[8];
346
347 typedef void (*builtin_t) (void);
348 extern  builtin_t *pr_builtins;
349 extern int pr_numbuiltins;
350
351 extern int              pr_argc;
352
353 extern  int                     pr_trace;
354 extern  mfunction_t     *pr_xfunction;
355 extern  int                     pr_xstatement;
356
357 extern  unsigned short          pr_crc;
358
359 void PR_Execute_ProgsLoaded(void);
360
361 void ED_PrintEdicts (void);
362 void ED_PrintNum (int ent);
363
364 const char *PRVM_GetString(int num);
365 int PR_SetQCString(const char *s);
366 int PRVM_SetEngineString(const char *s);
367 char *PR_AllocString(int bufferlength);
368 void PR_FreeString(char *s);
369
370 #endif
371