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.
21 #include "pr_comp.h" // defs shared with qcc
22 #include "progdefs.h" // generated by program cdefs
36 struct link_s *prev, *next;
39 // LordHavoc: increased number of leafs per entity limit from 16 to 256
40 #define MAX_ENT_LEAFS 256
41 typedef struct edict_s
47 entity_state_t baseline;
48 entity_state_t deltabaseline; // LordHavoc: previous frame
51 float freetime; // sv.time when the object was freed
52 entvars_t v; // C exported fields from progs
53 // other fields from progs come immediately after
55 //#define EDICT_FROM_AREA(l) ((edict_t *)((qbyte *)l - (int)&(((edict_t *)0)->area)))
56 //#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
58 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these.
59 extern int eval_gravity;
60 extern int eval_button3;
61 extern int eval_button4;
62 extern int eval_button5;
63 extern int eval_button6;
64 extern int eval_button7;
65 extern int eval_button8;
66 extern int eval_glow_size;
67 extern int eval_glow_trail;
68 extern int eval_glow_color;
69 extern int eval_items2;
70 extern int eval_scale;
71 extern int eval_alpha;
72 extern int eval_renderamt; // HalfLife support
73 extern int eval_rendermode; // HalfLife support
74 extern int eval_fullbright;
75 extern int eval_ammo_shells1;
76 extern int eval_ammo_nails1;
77 extern int eval_ammo_lava_nails;
78 extern int eval_ammo_rockets1;
79 extern int eval_ammo_multi_rockets;
80 extern int eval_ammo_cells1;
81 extern int eval_ammo_plasma;
82 extern int eval_idealpitch;
83 extern int eval_pitch_speed;
84 extern int eval_viewmodelforclient;
85 extern int eval_nodrawtoclient;
86 extern int eval_exteriormodeltoclient;
87 extern int eval_drawonlytoclient;
89 extern int eval_movement;
90 extern int eval_pmodel;
91 extern int eval_punchvector;
92 extern int eval_viewzoom;
94 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t*)((char*)&ed->v + fieldoffset) : NULL)
97 extern dfunction_t *SV_PlayerPhysicsQC;
98 extern dfunction_t *EndFrameQC;
100 //============================================================================
102 extern dprograms_t *progs;
103 extern dfunction_t *pr_functions;
104 extern char *pr_strings;
105 extern ddef_t *pr_globaldefs;
106 extern ddef_t *pr_fielddefs;
107 extern dstatement_t *pr_statements;
108 extern globalvars_t *pr_global_struct;
109 extern float *pr_globals; // same as pr_global_struct
111 extern int pr_edict_size; // in bytes
112 extern int pr_edictareasize; // LordHavoc: for bounds checking
114 //============================================================================
118 void PR_ExecuteProgram (func_t fnum, char *errormessage);
119 void PR_LoadProgs (void);
121 void PR_Profile_f (void);
123 edict_t *ED_Alloc (void);
124 void ED_Free (edict_t *ed);
126 char *ED_NewString (char *string);
127 // returns a copy of the string allocated from the server's string heap
129 void ED_Print (edict_t *ed);
130 void ED_Write (QFile *f, edict_t *ed);
131 char *ED_ParseEdict (char *data, edict_t *ent);
133 void ED_WriteGlobals (QFile *f);
134 void ED_ParseGlobals (char *data);
136 void ED_LoadFromFile (char *data);
138 edict_t *EDICT_NUM_ERROR(int n);
139 #define EDICT_NUM(n) (n >= 0 ? (n < sv.max_edicts ? (edict_t *)((qbyte *)sv.edicts + (n) * pr_edict_size) : EDICT_NUM_ERROR(n)) : EDICT_NUM_ERROR(n))
140 //define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size))
141 //define NUM_FOR_EDICT(e) (((qbyte *)(e) - sv.edicts)/pr_edict_size)
143 //edict_t *EDICT_NUM(int n);
144 int NUM_FOR_EDICT(edict_t *e);
146 #define NEXT_EDICT(e) ((edict_t *)( (qbyte *)e + pr_edict_size))
148 #define EDICT_TO_PROG(e) ((qbyte *)e - (qbyte *)sv.edicts)
149 #define PROG_TO_EDICT(e) ((edict_t *)((qbyte *)sv.edicts + e))
151 //============================================================================
153 #define G_FLOAT(o) (pr_globals[o])
154 #define G_INT(o) (*(int *)&pr_globals[o])
155 #define G_EDICT(o) ((edict_t *)((qbyte *)sv.edicts+ *(int *)&pr_globals[o]))
156 #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
157 #define G_VECTOR(o) (&pr_globals[o])
158 #define G_STRING(o) (pr_strings + *(string_t *)&pr_globals[o])
159 #define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
161 #define E_FLOAT(e,o) (((float*)&e->v)[o])
162 #define E_INT(e,o) (*(int *)&((float*)&e->v)[o])
163 #define E_VECTOR(e,o) (&((float*)&e->v)[o])
164 #define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)&e->v)[o])
166 extern int type_size[8];
168 typedef void (*builtin_t) (void);
169 extern builtin_t *pr_builtins;
170 extern int pr_numbuiltins;
174 extern qboolean pr_trace;
175 extern dfunction_t *pr_xfunction;
176 extern int pr_xstatement;
178 extern unsigned short pr_crc;
180 void PR_RunError (char *error, ...);
182 void ED_PrintEdicts (void);
183 void ED_PrintNum (int ent);
185 //eval_t *GetEdictFieldValue(edict_t *ed, char *field);