]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - progs.h
replaced Mod_LoadSkinFrame functions with R_SkinFrame system, this
[xonotic/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 #define ENTITYGRIDAREAS 16
26 #define MAX_ENTITYCLUSTERS 16
27
28 typedef struct edict_engineprivate_s
29 {
30         // true if this edict is unused
31         qboolean free;
32         // sv.time when the object was freed (to prevent early reuse which could
33         // mess up client interpolation or obscure severe QuakeC bugs)
34         float freetime;
35         // initially false to prevent projectiles from moving on their first frame
36         // (even if they were spawned by an synchronous client think)
37         qboolean move;
38
39         // cached cluster links for quick stationary object visibility checking
40         vec3_t cullmins, cullmaxs;
41         int pvs_numclusters;
42         int pvs_clusterlist[MAX_ENTITYCLUSTERS];
43
44         // physics grid areas this edict is linked into
45         link_t areagrid[ENTITYGRIDAREAS];
46         // since the areagrid can have multiple references to one entity,
47         // we should avoid extensive checking on entities already encountered
48         int areagridmarknumber;
49         // mins/maxs passed to World_LinkEdict
50         vec3_t areamins, areamaxs;
51
52         // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKEWORLD
53         // baseline values
54         entity_state_t baseline;
55
56         // LordHavoc: gross hack to make floating items still work
57         int suspendedinairflag;
58         // used by PushMove to keep track of where objects were before they were
59         // moved, in case they need to be moved back
60         vec3_t moved_from;
61         vec3_t moved_fromangles;
62 }
63 edict_engineprivate_t;
64
65 #endif
66
67
68
69
70
71
72 //////////////////////////////////
73 #if 0
74
75 #include "pr_comp.h"                    // defs shared with qcc
76 #include "progdefs.h"                   // generated by program cdefs
77
78 typedef union eval_s
79 {
80         string_t                string;
81         float                   _float;
82         float                   vector[3];
83         func_t                  function;
84         int                             ivector[3];
85         int                             _int;
86         int                             edict;
87 } prvm_eval_t;
88
89 typedef struct link_s
90 {
91         int entitynumber;
92         struct link_s   *prev, *next;
93 } link_t;
94
95 #define ENTITYGRIDAREAS 16
96
97 typedef struct edict_engineprivate_s
98 {
99         // true if this edict is unused
100         qboolean free;
101         // sv.time when the object was freed (to prevent early reuse which could
102         // mess up client interpolation or obscure severe QuakeC bugs)
103         float freetime;
104
105         // cached cluster links for quick stationary object visibility checking
106         vec3_t cullmins, cullmaxs;
107         int pvs_numclusters;
108         int pvs_clusterlist[MAX_ENTITYCLUSTERS];
109
110         // physics grid areas this edict is linked into
111         link_t areagrid[ENTITYGRIDAREAS];
112         // since the areagrid can have multiple references to one entity,
113         // we should avoid extensive checking on entities already encountered
114         int areagridmarknumber;
115
116         // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKEWORLD
117         // baseline values
118         entity_state_t baseline;
119
120         // LordHavoc: gross hack to make floating items still work
121         int suspendedinairflag;
122         // used by PushMove to keep track of where objects were before they were
123         // moved, in case they need to be moved back
124         vec3_t moved_from;
125         vec3_t moved_fromangles;
126 }
127 edict_engineprivate_t;
128
129 // the entire server entity structure
130 // NOTE: keep this small!  priv and v are dynamic but this struct is not!
131 typedef struct edict_s
132 {
133         // engine-private fields (stored in dynamically resized array)
134         edict_engineprivate_t *e;
135         // QuakeC fields (stored in dynamically resized array)
136         entvars_t *v;
137 }
138 prvm_edict_t;
139
140 #define PRVM_EDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (prvm_eval_t *)((int *)ed->v + fieldoffset) : NULL)
141
142 //============================================================================
143
144 extern  dprograms_t             *progs;
145 extern  mfunction_t             *pr_functions;
146 extern  char                    *pr_strings;
147 extern  int                             pr_stringssize;
148 extern  ddef_t                  *pr_globaldefs;
149 extern  ddef_t                  *pr_fielddefs;
150 extern  dstatement_t    *pr_statements;
151 extern  globalvars_t    *pr_global_struct;
152 extern  float                   *pr_globals;                    // same as pr_global_struct
153
154 extern  int                             prog->edict_size;       // in bytes
155 extern  int                             pr_edictareasize; // LordHavoc: for bounds checking
156
157 extern  int                             pr_maxknownstrings;
158 extern  int                             pr_numknownstrings;
159 extern  const char              **pr_knownstrings;
160
161 //============================================================================
162
163 void PR_Init (void);
164 void PR_Shutdown (void);
165
166 void PRVM_ExecuteProgram (func_t fnum, const char *errormessage);
167 void PR_LoadProgs (const char *progsname);
168
169 #define PR_Alloc(buffersize) _PR_Alloc(buffersize, __FILE__, __LINE__)
170 #define PR_Free(buffer) _PR_Free(buffer, __FILE__, __LINE__)
171 #define PR_FreeAll() _PR_FreeAll(__FILE__, __LINE__)
172 void *_PR_Alloc (size_t buffersize, const char *filename, int fileline);
173 void _PR_Free (void *buffer, const char *filename, int fileline);
174 void _PR_FreeAll (const char *filename, int fileline);
175
176 void PR_Profile_f (void);
177
178 void PR_PrintState(void);
179 void PR_Crash (void);
180
181 void SV_IncreaseEdicts(void);
182
183 prvm_edict_t *ED_Alloc (void);
184 void ED_Free (prvm_edict_t *ed);
185 void ED_ClearEdict (prvm_edict_t *e);
186
187 void ED_Print(prvm_edict_t *ed);
188 void ED_Write (qfile_t *f, prvm_edict_t *ed);
189 const char *ED_ParseEdict (const char *data, prvm_edict_t *ent);
190
191 void ED_WriteGlobals (qfile_t *f);
192 void ED_ParseGlobals (const char *data);
193
194 void ED_LoadFromFile (const char *data);
195
196 prvm_edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline);
197 #define PRVM_EDICT_NUM(n) (((n) >= 0 && (n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
198 #define EDICT_NUM_UNSIGNED(n) (((n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
199
200 //int NUM_FOR_EDICT_ERROR(prvm_edict_t *e);
201 #define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts))
202 //int PRVM_NUM_FOR_EDICT(prvm_edict_t *e);
203
204 #define PRVM_NEXT_EDICT(e) ((e) + 1)
205
206 #define PRVM_EDICT_TO_PROG(e) (PRVM_NUM_FOR_EDICT(e))
207 //int PRVM_EDICT_TO_PROG(prvm_edict_t *e);
208 #define PRVM_PROG_TO_EDICT(n) (PRVM_EDICT_NUM(n))
209 //prvm_edict_t *PRVM_PROG_TO_EDICT(int n);
210
211 //============================================================================
212
213 #define PRVM_G_FLOAT(o) (pr_globals[o])
214 #define PRVM_G_INT(o) (*(int *)&pr_globals[o])
215 #define PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(*(int *)&pr_globals[o]))
216 #define PRVM_G_EDICTNUM(o) PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(o))
217 #define PRVM_G_VECTOR(o) (&pr_globals[o])
218 #define PRVM_G_STRING(o) (PRVM_GetString(*(string_t *)&pr_globals[o]))
219 //#define       G_FUNCTION(o) (*(func_t *)&pr_globals[o])
220
221 // FIXME: make these go away?
222 #define E_FLOAT(e,o) (((float*)e->v)[o])
223 //#define       E_INT(e,o) (((int*)e->v)[o])
224 //#define       E_VECTOR(e,o) (&((float*)e->v)[o])
225 #define E_STRING(e,o) (PRVM_GetString(*(string_t *)&((float*)e->v)[o]))
226
227 extern  int             type_size[8];
228
229 typedef void (*builtin_t) (void);
230 extern  builtin_t *pr_builtins;
231 extern int pr_numbuiltins;
232
233 extern int              pr_argc;
234
235 extern  int                     pr_trace;
236 extern  mfunction_t     *pr_xfunction;
237 extern  int                     pr_xstatement;
238
239 extern  unsigned short          pr_crc;
240
241 void PR_Execute_ProgsLoaded(void);
242
243 void ED_PrintEdicts (void);
244 void ED_PrintNum (int ent);
245
246 const char *PRVM_GetString(int num);
247 int PR_SetQCString(const char *s);
248 int PRVM_SetEngineString(const char *s);
249 int PRVM_SetTempString(const char *s);
250 char *PR_AllocString(int bufferlength);
251 void PR_FreeString(char *s);
252
253 #endif
254