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.
23 #include "pr_comp.h" // defs shared with qcc
28 struct link_s *prev, *next;
31 #define ENTITYGRIDAREAS 16
33 typedef struct edict_engineprivate_s
35 // true if this edict is unused
37 // sv.time when the object was freed (to prevent early reuse which could
38 // mess up client interpolation or obscure severe QuakeC bugs)
41 // physics grid areas this edict is linked into
42 link_t areagrid[ENTITYGRIDAREAS];
43 // since the areagrid can have multiple references to one entity,
44 // we should avoid extensive checking on entities already encountered
45 int areagridmarknumber;
47 // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE
49 entity_state_t baseline;
51 // LordHavoc: gross hack to make floating items still work
52 int suspendedinairflag;
53 // used by PushMove to keep track of where objects were before they were
54 // moved, in case they need to be moved back
56 vec3_t moved_fromangles;
58 edict_engineprivate_t;
60 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these.
61 extern int eval_gravity;
62 extern int eval_button3;
63 extern int eval_button4;
64 extern int eval_button5;
65 extern int eval_button6;
66 extern int eval_button7;
67 extern int eval_button8;
68 extern int eval_buttonuse;
69 extern int eval_buttonchat;
70 extern int eval_glow_size;
71 extern int eval_glow_trail;
72 extern int eval_glow_color;
73 extern int eval_items2;
74 extern int eval_scale;
75 extern int eval_alpha;
76 extern int eval_renderamt; // HalfLife support
77 extern int eval_rendermode; // HalfLife support
78 extern int eval_fullbright;
79 extern int eval_ammo_shells1;
80 extern int eval_ammo_nails1;
81 extern int eval_ammo_lava_nails;
82 extern int eval_ammo_rockets1;
83 extern int eval_ammo_multi_rockets;
84 extern int eval_ammo_cells1;
85 extern int eval_ammo_plasma;
86 extern int eval_idealpitch;
87 extern int eval_pitch_speed;
88 extern int eval_viewmodelforclient;
89 extern int eval_nodrawtoclient;
90 extern int eval_exteriormodeltoclient;
91 extern int eval_drawonlytoclient;
93 extern int eval_movement;
94 extern int eval_pmodel;
95 extern int eval_punchvector;
96 extern int eval_viewzoom;
97 extern int eval_clientcolors;
98 extern int eval_tag_entity;
99 extern int eval_tag_index;
100 extern int eval_light_lev;
101 extern int eval_color;
102 extern int eval_style;
103 extern int eval_pflags;
104 extern int eval_cursor_active;
105 extern int eval_cursor_screen;
106 extern int eval_cursor_trace_start;
107 extern int eval_cursor_trace_endpos;
108 extern int eval_cursor_trace_ent;
109 extern int eval_colormod;
110 extern int eval_playermodel;
111 extern int eval_playerskin;
113 extern mfunction_t *SV_PlayerPhysicsQC;
114 extern mfunction_t *EndFrameQC;
115 //KrimZon - SERVER COMMANDS IN QUAKEC
116 extern mfunction_t *SV_ParseClientCommandQC;
125 //////////////////////////////////
128 #include "pr_comp.h" // defs shared with qcc
129 #include "progdefs.h" // generated by program cdefs
142 typedef struct link_s
145 struct link_s *prev, *next;
148 #define ENTITYGRIDAREAS 16
150 typedef struct edict_engineprivate_s
152 // true if this edict is unused
154 // sv.time when the object was freed (to prevent early reuse which could
155 // mess up client interpolation or obscure severe QuakeC bugs)
158 // physics grid areas this edict is linked into
159 link_t areagrid[ENTITYGRIDAREAS];
160 // since the areagrid can have multiple references to one entity,
161 // we should avoid extensive checking on entities already encountered
162 int areagridmarknumber;
164 // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE
166 entity_state_t baseline;
168 // LordHavoc: gross hack to make floating items still work
169 int suspendedinairflag;
170 // used by PushMove to keep track of where objects were before they were
171 // moved, in case they need to be moved back
173 vec3_t moved_fromangles;
175 edict_engineprivate_t;
177 // the entire server entity structure
178 // NOTE: keep this small! priv and v are dynamic but this struct is not!
179 typedef struct edict_s
181 // engine-private fields (stored in dynamically resized array)
182 edict_engineprivate_t *e;
183 // QuakeC fields (stored in dynamically resized array)
188 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these.
189 extern int eval_gravity;
190 extern int eval_button3;
191 extern int eval_button4;
192 extern int eval_button5;
193 extern int eval_button6;
194 extern int eval_button7;
195 extern int eval_button8;
196 extern int eval_buttonuse;
197 extern int eval_buttonchat;
198 extern int eval_glow_size;
199 extern int eval_glow_trail;
200 extern int eval_glow_color;
201 extern int eval_items2;
202 extern int eval_scale;
203 extern int eval_alpha;
204 extern int eval_renderamt; // HalfLife support
205 extern int eval_rendermode; // HalfLife support
206 extern int eval_fullbright;
207 extern int eval_ammo_shells1;
208 extern int eval_ammo_nails1;
209 extern int eval_ammo_lava_nails;
210 extern int eval_ammo_rockets1;
211 extern int eval_ammo_multi_rockets;
212 extern int eval_ammo_cells1;
213 extern int eval_ammo_plasma;
214 extern int eval_idealpitch;
215 extern int eval_pitch_speed;
216 extern int eval_viewmodelforclient;
217 extern int eval_nodrawtoclient;
218 extern int eval_exteriormodeltoclient;
219 extern int eval_drawonlytoclient;
220 extern int eval_ping;
221 extern int eval_movement;
222 extern int eval_pmodel;
223 extern int eval_punchvector;
224 extern int eval_viewzoom;
225 extern int eval_clientcolors;
226 extern int eval_tag_entity;
227 extern int eval_tag_index;
228 extern int eval_light_lev;
229 extern int eval_color;
230 extern int eval_style;
231 extern int eval_pflags;
232 extern int eval_cursor_active;
233 extern int eval_cursor_screen;
234 extern int eval_cursor_trace_start;
235 extern int eval_cursor_trace_endpos;
236 extern int eval_cursor_trace_ent;
237 extern int eval_colormod;
238 extern int eval_playermodel;
239 extern int eval_playerskin;
241 #define PRVM_GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (prvm_eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
244 extern mfunction_t *SV_PlayerPhysicsQC;
245 extern mfunction_t *EndFrameQC;
246 //KrimZon - SERVER COMMANDS IN QUAKEC
247 extern mfunction_t *SV_ParseClientCommandQC;
249 //============================================================================
251 extern dprograms_t *progs;
252 extern mfunction_t *prog->functions;
253 extern char *pr_strings;
254 extern int pr_stringssize;
255 extern ddef_t *pr_globaldefs;
256 extern ddef_t *pr_fielddefs;
257 extern dstatement_t *pr_statements;
258 extern globalvars_t *pr_global_struct;
259 extern float *pr_globals; // same as pr_global_struct
261 extern int prog->edict_size; // in bytes
262 extern int pr_edictareasize; // LordHavoc: for bounds checking
264 extern int pr_maxknownstrings;
265 extern int pr_numknownstrings;
266 extern const char **pr_knownstrings;
268 //============================================================================
271 void PR_Shutdown (void);
273 void PRVM_ExecuteProgram (func_t fnum, const char *errormessage);
274 void PR_LoadProgs (const char *progsname);
276 #define PR_Alloc(buffersize) _PR_Alloc(buffersize, __FILE__, __LINE__)
277 #define PR_Free(buffer) _PR_Free(buffer, __FILE__, __LINE__)
278 #define PR_FreeAll() _PR_FreeAll(__FILE__, __LINE__)
279 void *_PR_Alloc (size_t buffersize, const char *filename, int fileline);
280 void _PR_Free (void *buffer, const char *filename, int fileline);
281 void _PR_FreeAll (const char *filename, int fileline);
283 void PR_Profile_f (void);
285 void PR_PrintState(void);
286 void PR_Crash (void);
288 void SV_IncreaseEdicts(void);
290 prvm_edict_t *ED_Alloc (void);
291 void ED_Free (prvm_edict_t *ed);
292 void ED_ClearEdict (prvm_edict_t *e);
294 void ED_Print(prvm_edict_t *ed);
295 void ED_Write (qfile_t *f, prvm_edict_t *ed);
296 const char *ED_ParseEdict (const char *data, prvm_edict_t *ent);
298 void ED_WriteGlobals (qfile_t *f);
299 void ED_ParseGlobals (const char *data);
301 void ED_LoadFromFile (const char *data);
303 prvm_edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline);
304 #define PRVM_EDICT_NUM(n) (((n) >= 0 && (n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
305 #define EDICT_NUM_UNSIGNED(n) (((n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
307 //int NUM_FOR_EDICT_ERROR(prvm_edict_t *e);
308 #define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts))
309 //int PRVM_NUM_FOR_EDICT(prvm_edict_t *e);
311 #define PRVM_NEXT_EDICT(e) ((e) + 1)
313 #define PRVM_EDICT_TO_PROG(e) (PRVM_NUM_FOR_EDICT(e))
314 //int PRVM_EDICT_TO_PROG(prvm_edict_t *e);
315 #define PRVM_PROG_TO_EDICT(n) (PRVM_EDICT_NUM(n))
316 //prvm_edict_t *PRVM_PROG_TO_EDICT(int n);
318 //============================================================================
320 #define PRVM_G_FLOAT(o) (pr_globals[o])
321 #define PRVM_G_INT(o) (*(int *)&pr_globals[o])
322 #define PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(*(int *)&pr_globals[o]))
323 #define PRVM_G_EDICTNUM(o) PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(o))
324 #define PRVM_G_VECTOR(o) (&pr_globals[o])
325 #define PRVM_G_STRING(o) (PRVM_GetString(*(string_t *)&pr_globals[o]))
326 //#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
328 // FIXME: make these go away?
329 #define E_FLOAT(e,o) (((float*)e->v)[o])
330 //#define E_INT(e,o) (((int*)e->v)[o])
331 //#define E_VECTOR(e,o) (&((float*)e->v)[o])
332 #define E_STRING(e,o) (PRVM_GetString(*(string_t *)&((float*)e->v)[o]))
334 extern int type_size[8];
336 typedef void (*builtin_t) (void);
337 extern builtin_t *pr_builtins;
338 extern int pr_numbuiltins;
343 extern mfunction_t *pr_xfunction;
344 extern int pr_xstatement;
346 extern unsigned short pr_crc;
348 void PR_Execute_ProgsLoaded(void);
350 void ED_PrintEdicts (void);
351 void ED_PrintNum (int ent);
353 const char *PRVM_GetString(int num);
354 int PR_SetQCString(const char *s);
355 int PRVM_SetEngineString(const char *s);
356 char *PR_AllocString(int bufferlength);
357 void PR_FreeString(char *s);