FTEQW
Documentation of the FTE engine source tree.
progslib.h
Go to the documentation of this file.
1
2#ifndef PROGSLIB_H
3#define PROGSLIB_H
4
5#include "progtype.h"
6#include <stdlib.h>
7#ifdef _MSC_VER
8 #define VARGS __cdecl
9#endif
10#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
11 #if defined(_WIN32)
12 #include <stdio.h>
13 #ifdef __MINGW_PRINTF_FORMAT
14 #define LIKEPRINTF(x) __attribute__((format(__MINGW_PRINTF_FORMAT,x,x+1)))
15 #else
16 #define LIKEPRINTF(x) __attribute__((format(ms_printf,x,x+1)))
17 #endif
18 #else
19 #define LIKEPRINTF(x) __attribute__((format(printf,x,x+1)))
20 #endif
21#endif
22#ifndef LIKEPRINTF
23 #define LIKEPRINTF(x)
24#endif
25#ifndef VARGS
26 #define VARGS
27#endif
28
29#if defined(_M_IX86) || defined(__i386__) //supported arch
30 #if defined(__GNUC__) || defined(_MSC_VER) //supported compilers (yay for inline asm)
31 //#define QCJIT
32 #endif
33#endif
34
35#define QCBUILTIN ASMCALL
36
37#ifdef _WIN32
38#define PDECL __cdecl
39#else
40#define PDECL
41#endif
42
43#ifdef QCJIT
44#define ASMCALL VARGS
45#else
46#define ASMCALL PDECL
47#endif
48
49
50#define QCGC
51
52struct edict_s;
53struct entvars_s;
54struct globalvars_s;
55struct qcthread_s;
57typedef void (ASMCALL *builtin_t) (pubprogfuncs_t *prinst, struct globalvars_s *gvars);
58
60{
63 ER_OBJECT //custom sized, no vm/engine fields.
64};
65#define ED_ISFREE(e) ((e)->ereftype != ER_ENTITY)
66
67//used by progs engine. All nulls is reset.
68typedef struct {
69 const char *varname;
70 struct fdef_s *ofs32;
71
72 int spare[2];
73} evalc_t;
74#define sizeofevalc sizeof(evalc_t)
75typedef enum {
76//vanilla types
78ev_string, //offset into the string table - but if the high bit is set then its probably some special thing.
79ev_float, //can hold up to 24 bits... sucks, but this is our basic numeric type.
80ev_vector, //3 floats.
81ev_entity, //index into the edicts array (vanilla used byte offsets from world).
82ev_field, //index into the per-entity field table.
83ev_function,//all functions are called via reference.
84ev_pointer, //exists in vanilla - *(&ent.fld) opcodes are valid there - how else would you store to a field?
85//extended types
86ev_integer, //our first extended type... probably won't help performance much but at least it doesn't have the imprecision issue of floats.
87ev_uint, //mostly just reuses int opcodes.
88ev_int64, //large int type, because we can. might be useful for system handles perhaps? dunno, probably not that useful.
89ev_uint64, //mostly just reuses int64 opcodes.
90ev_double, //useful for timers, for the extra precision.
91//qc-only types
92ev_variant, //used primarily for builtin args, or for type punning casts without using pointers. should never be used for a global.
93ev_struct, //big complex type
94ev_union, //not really sure why this is separate from struct
95ev_accessor,//some weird type to provide class-like functions over a basic type.
96ev_enum, //just a numeric type
97ev_typedef, //so typedefs can refer to their original type (primarily for structs).
98ev_boolean, //exists to optimise if(-0) workarounds. engine just sees int/float.
99} etype_t;
100enum {
101 DEBUG_TRACE_OFF, //debugging should be off.
102 DEBUG_TRACE_INTO, //debug into functions
103 DEBUG_TRACE_OVER, //switch debugging off while executing child functions (and back on afterwards)
104 DEBUG_TRACE_OUT, //keep running until the end of the current function (trigger single-stepping again at that point)
105 DEBUG_TRACE_ABORTERROR, //give up with an endgame.
106// DEBUG_TRACE_ABORTSTACK, //stop executing, without any errors.
107 DEBUG_TRACE_NORESUME //line number or something changed, but we should still be sitting at the debugger.
109
110typedef struct fdef_s
111{
112 unsigned int type; //if DEF_SAVEGLOBAL bit is set then the variable needs to be saved in savegames
113 int ofs; //runtime offset. add fieldadj to get the real array index.
114 unsigned int progsofs; //used at loading time, so maching field offsets (unions/members) are positioned at the same runtime offset.
115 const char * name; //proper name for the field.
117
118//the number of pointers to variables (as opposed to functions - those are fine) in these structures is excessive.
119//Many of the functions are also obsolete.
121{
122 int progsversion; //PROGSTRUCT_VERSION
123
124 void (PDECL *Shutdown) (pubprogfuncs_t *inst);
125
126 void (PDECL *Configure) (pubprogfuncs_t *prinst, size_t addressablesize, int max_progs, pbool enableprofiling); //configure buffers and memory. Used to reset and must be called first. Flushes a running VM.
127 progsnum_t (PDECL *LoadProgs) (pubprogfuncs_t *prinst, const char *s); //load a progs
128 int (PDECL *InitEnts) (pubprogfuncs_t *prinst, int max_ents); //returns size of edicts for use with nextedict macro
129 void (PDECL *ExecuteProgram) (pubprogfuncs_t *prinst, func_t fnum); //start execution
130 struct globalvars_s *(PDECL *globals) (pubprogfuncs_t *prinst, progsnum_t num); //get the globals of a progs
131 struct entvars_s *(PDECL *entvars) (pubprogfuncs_t *prinst, struct edict_s *ent); //return a pointer to the entvars of an ent. can be achieved via the edict_t structure instead, so obsolete.
132
133 void (VARGS *RunError) (pubprogfuncs_t *prinst, const char *msg, ...) LIKEPRINTF(2); //builtins call this to say there was a problem
134 void (PDECL *PrintEdict) (pubprogfuncs_t *prinst, struct edict_s *ed); //get a listing of all vars on an edict (sent back via 'print')
135
136 struct edict_s *(PDECL *EntAlloc) (pubprogfuncs_t *prinst, pbool object, size_t extrasize); //allocate a random index.
137 struct edict_s *(PDECL *EntAllocIndex) (pubprogfuncs_t *prinst, unsigned int idx, pbool object, size_t extrasize); //allocate a specific index.
138 void (PDECL *EntFree) (pubprogfuncs_t *prinst, struct edict_s *ed, pbool instant);
139
140 struct edict_s *(PDECL *EdictNum) (pubprogfuncs_t *prinst, unsigned int n); //get the nth edict
141 unsigned int (PDECL *NumForEdict) (pubprogfuncs_t *prinst, struct edict_s *e); //so you can find out what that 'n' will be
142
143 char *(PDECL *VarString) (pubprogfuncs_t *prinst, int first); //returns a string made up of multiple arguments
144
145 struct progstate_s **progstate; //internal to the library.
147
148 func_t (PDECL *FindFunction) (pubprogfuncs_t *prinst, const char *funcname, progsnum_t num);
149
150 int (PDECL *StartCompile) (pubprogfuncs_t *prinst, int argv, const char **argc); //1 if can compile, 0 if failed to compile
151 int (PDECL *ContinueCompile) (pubprogfuncs_t *prinst); //2 if finished, 1 if more to go, 0 if failed
152
153 char *(PDECL *filefromprogs) (pubprogfuncs_t *prinst, progsnum_t prnum, const char *fname, size_t *size, char *buffer); //reveals encoded/added files from already loaded progs
154 char *(PDECL *filefromnewprogs) (pubprogfuncs_t *prinst, const char *prname, const char *fname, size_t *size, char *buffer); //reveals encoded/added files from a progs on the disk somewhere
155
156 void (PDECL *ED_Print) (pubprogfuncs_t *prinst, struct edict_s *ed);
157 char *(PDECL *save_ents) (pubprogfuncs_t *prinst, char *buf, size_t *size, size_t maxsize, int mode); //dump the entire progs info into one big self allocated string
158 int (PDECL *load_ents) (pubprogfuncs_t *prinst, const char *s, void *ctx,
159 void (PDECL *memoryreset) (pubprogfuncs_t *progfuncs, void *ctx),
160 void (PDECL *entspawned) (pubprogfuncs_t *progfuncs, struct edict_s *ed, void *ctx, const char *entstart, const char *entend),
161 pbool(PDECL *extendedterm)(pubprogfuncs_t *progfuncs, void *ctx, const char **extline)
162 ); //restore the entire progs state (or just add some more ents) (returns edicts ize)
163
164 char *(PDECL *saveent) (pubprogfuncs_t *prinst, char *buf, size_t *size, size_t maxsize, struct edict_s *ed); //will save just one entities vars
165 struct edict_s *(PDECL *restoreent) (pubprogfuncs_t *prinst, const char *buf, size_t *size, struct edict_s *ed); //will restore the entity that had it's values saved (can use NULL for ed)
166
167 union eval_s *(PDECL *FindGlobal) (pubprogfuncs_t *prinst, const char *name, progsnum_t num, etype_t *type); //find a pointer to the globals value
168
169 union eval_s *(PDECL *GetEdictFieldValue)(pubprogfuncs_t *prinst, struct edict_s *ent, const char *name, etype_t type, evalc_t *s); //get an entityvar (cache it) and return the possible values
170 struct edict_s *(PDECL *ProgsToEdict) (pubprogfuncs_t *prinst, int progs); //edicts are stored as ints and need to be adjusted
171 int (PDECL *EdictToProgs) (pubprogfuncs_t *prinst, struct edict_s *ed); //edicts are stored as ints and need to be adjusted
172
173 char *(PDECL *EvaluateDebugString) (pubprogfuncs_t *prinst, const char *key); //evaluate a string and return it's value (according to current progs) (expands edict vars)
174 int debug_trace; //start calling the editor for each line executed
175 void (PDECL *StackTrace) (pubprogfuncs_t *prinst, int showlocals);
176 int (PDECL *ToggleBreak) (pubprogfuncs_t *prinst, const char *filename, int linenum, int mode);
177
178 struct progexterns_s *parms; //these are the initial parms, they may be changed
179
180 pbool (PDECL *Decompile) (pubprogfuncs_t *prinst, const char *fname);
181
182 int callargc; //number of args of built-in call
183
184 char *stringtable; //qc strings are all relative. add to a qc string. this is required for support of frikqcc progs that strip string immediates.
185 unsigned int stringtablesize;
186 unsigned int stringtablemaxsize;
187 int fieldadjust; //FrikQCC style arrays can cause problems due to field remapping. This causes us to leave gaps but offsets identical. except for system fields, qc-addressable variables use their old offsets, this is the bias so that the offset pokes the correct memory.
188 unsigned int activefieldslots; //f+=fieldadjust; invalidfield = (f<0)||(f+fldsize>=activefieldslots); note that this does NOT apply to 'object' entities which are variable sized, use ed->fieldsize for those.
189
190
191 struct qcthread_s *(PDECL *Fork) (pubprogfuncs_t *prinst); //returns a pointer to a thread which can be resumed via RunThread.
192 void (PDECL *RunThread) (pubprogfuncs_t *prinst, struct qcthread_s *thread);
193 void (PDECL *AbortStack) (pubprogfuncs_t *prinst); //annigilates the current stack, positioning on a return statement. It is expected that this is only used via a builtin!
194
195 pbool (PDECL *GetBuiltinCallInfo) (pubprogfuncs_t *prinst, int *builtinnum, char *function, size_t sizeoffunction); //call to query the qc's name+index for the builtin
196 pbool (PDECL *FindBuiltins) (pubprogfuncs_t *progfuncs, progsnum_t prnum, int binum, pbool (PDECL *found) (pubprogfuncs_t *progfuncs, const char *name, void *ctx), void *ctx); //calls the callback for each function reference that's mapped to the specified builtin number.
197
198 int (PDECL *RegisterFieldVar) (pubprogfuncs_t *prinst, unsigned int type, const char *name, signed long requestedpos, signed long originalofs);
199
200 char *(PDECL *AddString) (pubprogfuncs_t *prinst, const char *val, int minlength, pbool demarkup); //dump a string into the progs memory (for setting globals and whatnot)
201 void *(PDECL *Tempmem) (pubprogfuncs_t *prinst, int ammount, char *whatfor); //grab some mem for as long as the progs stays loaded
202 void *(PDECL *AddressableAlloc) (pubprogfuncs_t *progfuncs, unsigned int ammount); /*returns memory within the qc block, use stringtoprogs to get a usable qc pointer/string*/
203 void (PDECL *AddressableFree) (pubprogfuncs_t *progfuncs, void *mem); /*frees a block of addressable memory*/
204 string_t (PDECL *TempString) (pubprogfuncs_t *prinst, const char *str);
205 string_t (PDECL *AllocTempString) (pubprogfuncs_t *prinst, char **str, unsigned int len);
206 string_t (PDECL *StringToProgs) (pubprogfuncs_t *prinst, const char *str); //commonly makes a semi-permanent mapping from some table to the string value. mapping can be removed via RemoveProgsString
207 const char *(ASMCALL *StringToNative) (pubprogfuncs_t *prinst, string_t str);
208
209 int (PDECL *QueryField) (pubprogfuncs_t *prinst, unsigned int fieldoffset, etype_t *type, char const**name, evalc_t *fieldcache); //find info on a field definition at an offset
210
211 void (PDECL *EntClear) (pubprogfuncs_t *progfuncs, struct edict_s *e);
212 void (PDECL *FindPrefixGlobals) (pubprogfuncs_t *progfuncs, int prnum, char *prefix, void (PDECL *found) (pubprogfuncs_t *progfuncs, char *name, union eval_s *val, etype_t type, void *ctx), void *ctx); //calls the callback for each named global found
213
214 pbool (PDECL *SetWatchPoint) (pubprogfuncs_t *prinst, const char *key);
215
216 void (PDECL *AddSharedVar) (pubprogfuncs_t *progfuncs, int start, int size);
217 void (PDECL *AddSharedFieldVar) (pubprogfuncs_t *progfuncs, int num, char *relstringtable);
219 pbool (PDECL *GetFunctionInfo) (pubprogfuncs_t *progfuncs, func_t func, int *argcount, unsigned char **argsizes, int *builtinnum, char *funcname, size_t funcnamesize); //queries the interesting info from a function def
220 void (PDECL *GenerateStatementString) (pubprogfuncs_t *progfuncs, int statementnum, char *out, int outlen); //disassembles a specific statement. for debugging reports.
221 fdef_t *(PDECL *FieldInfo) (pubprogfuncs_t *progfuncs, unsigned int *count);
223 pbool (PDECL *ParseEval) (pubprogfuncs_t *progfuncs, union eval_s *eval, int type, const char *s);
224 void (PDECL *SetStringField) (pubprogfuncs_t *progfuncs, struct edict_s *ed, string_t *fld, const char *str, pbool str_is_static); //if ed is null, fld points to a global. if str_is_static, then s doesn't need its own memory allocated.
226
227 unsigned int edicttable_length;
229
230 //stuff not used by the qclib at all, but provided for lazy user storage.
231 struct
232 {
233 char *tempstringbase; //for engine's use. Store your base tempstring pointer here.
234 int tempstringnum; //for engine's use.
236};
237
238typedef struct progexterns_s {
239 int progsversion; //PROGSTRUCT_VERSION
240
241 void *(PDECL *ReadFile) (const char *fname, unsigned char *(PDECL *buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size, pbool issourcefile);
242 int (PDECL *FileSize) (const char *fname); //-1 if file does not exist
243 pbool (PDECL *WriteFile) (const char *name, void *data, int len);
244 int (VARGS *Printf) (const char *, ...) LIKEPRINTF(1);
245 int (VARGS *DPrintf) (const char *, ...) LIKEPRINTF(1);
246 void (VARGS *Sys_Error) (const char *, ...) LIKEPRINTF(1);
247 void (VARGS *Abort) (char *, ...) LIKEPRINTF(1);
248 pbool (PDECL *CheckHeaderCrc) (pubprogfuncs_t *inst, progsnum_t idx, int crc, const char *filename);
249
250 void (PDECL *entspawn) (struct edict_s *ent, int loading); //ent has been spawned, but may not have all the extra variables (that may need to be set) set
251 pbool (PDECL *entcanfree) (struct edict_s *ent); //return true to stop ent from being freed
252 void (ASMCALL *stateop) (pubprogfuncs_t *prinst, float var, func_t func); //what to do on qc's state opcode.
253 void (ASMCALL *cstateop) (pubprogfuncs_t *prinst, float vara, float varb, func_t currentfunc); //a hexen2 opcode.
254 void (ASMCALL *cwstateop) (pubprogfuncs_t *prinst, float vara, float varb, func_t currentfunc); //a hexen2 opcode.
255 void (ASMCALL *thinktimeop) (pubprogfuncs_t *prinst, struct edict_s *ent, float varb); //a hexen2 opcode.
256
257
258 //used when loading a game
259 int (PDECL *MapNamedBuiltin) (pubprogfuncs_t *prinst, int headercrc, const char *builtinname); //return 0 for not found.
260 void (PDECL *loadcompleate) (int edictsize); //notification to reset any pointers.
261 pbool (PDECL *badfield) (pubprogfuncs_t *prinst, struct edict_s *ent, const char *keyname, const char *value); //called for any fields that are not registered
262
263 void *(VARGS *memalloc) (int size); //small string allocation malloced and freed randomly by the executor. (use malloc if you want)
264 void (VARGS *memfree) (void * mem);
265
266 int (PDECL *useeditor) (pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, int funcstart, char *reason, pbool fatal); //called on syntax errors or step-by-step debugging. line and statement(if line was set to 0) can be used to change the next line. return value is the new debug state to use/step.
267 void (PDECL *addressablerelocated) (pubprogfuncs_t *progfuncs, char *oldb, char *newb, int oldlen); //called when the progs memory was resized. you must fix up all pointers to globals, strings, fields, addressable blocks.
268
269 builtin_t *globalbuiltins; //these are available to all progs
271
273
274 double *gametime; //used to prevent the vm from reusing an entity faster than 2 secs.
275
277
278 struct edict_s **edicts; //pointer to the engine's reference to world.
279 unsigned int *num_edicts; //pointer to the engine's edict count.
280 int edictsize; //size of edict_t
281
282 void *user; /*contains the owner's world reference in FTE*/
284
285#if defined(QCLIBDLL_EXPORTS)
286 #ifdef _WIN32
287 __declspec(dllexport)
288 #else
289 __attribute__((visibility("default")))
290 #endif
291#endif
292pubprogfuncs_t * PDECL InitProgs(progparms_t *ext);
293
294typedef union eval_s
295{ //FIXME: we should not be using a leading underscore here. that is reserved for libc.
299 func_t function; //module=0xff000000, func=0x00ffffff
302 pint64_t i64;
303 puint64_t u64;
304 pdouble_t _double;
306 pvec_t prog; //so it can easily be changed
308
309#define PR_CURRENT -1
310#define PR_ANY -2 //not always valid. Use for finding funcs
311#define PR_ANYBACK -3
312#define PROGSTRUCT_VERSION 4
313
314
315#ifndef DLL_PROG
316#define PR_Configure(pf, memsize, max_progs, profiling) (*pf->Configure) (pf, memsize, max_progs, profiling)
317#define PR_LoadProgs(pf, s) (*pf->LoadProgs) (pf, s)
318#define PR_InitEnts(pf, maxents) (*pf->InitEnts) (pf, maxents)
319#define PR_ExecuteProgram(pf, fnum) (*pf->ExecuteProgram) (pf, fnum)
320#define PR_globals(pf, num) (*pf->globals) (pf, num)
321#define PR_entvars(pf, ent) (*pf->entvars) (pf, ent)
322
323#define PR_RegisterFieldVar(pf,type,name,reqofs,qcofs) (*pf->RegisterFieldVar) (pf,type,name,reqofs,qcofs)
324
325#define ED_Alloc(pf,isobj,extsize) (*pf->EntAlloc) (pf, isobj, extsize)
326#define ED_Free(pf, ed) (*pf->EntFree) (pf, ed, false)
327#define ED_Clear(pf, ed) (*pf->EntClear) (pf, ed)
328
329#define PR_LoadEnts(pf, s, ctx, memreset, entcb, extcb) (*pf->load_ents) (pf, s, ctx, memreset, entcb, extcb)
330#define PR_SaveEnts(pf, buf, size, maxsize, mode) (*pf->save_ents) (pf, buf, size, maxsize, mode)
331
332#if 0//def _DEBUG
333#define EDICT_NUM(pf, num) (*pf->EDICT_NUM) (pf, num)
334#else
335#define EDICT_NUM_PB(pf, num) (pf->edicttable[num])
336#define EDICT_NUM_UB(pf, num) EDICT_NUM_PB(pf,(((unsigned int)(num))>=pf->edicttable_length)?0:num)
337#endif
338#define NUM_FOR_EDICT(pf, e) (*pf->NumForEdict) (pf, (struct edict_s*)(e))
339#define SetGlobalEdict(pf, ed, ofs) (*pf->SetGlobalEdict) (pf, ed, ofs)
340#define PR_VarString(pf,first) (*pf->VarString) (pf,first)
341
342#define PR_StartCompile(pf,argc,argv) (*pf->StartCompile) (pf,argc,argv)
343#define PR_ContinueCompile(pf) (*pf->ContinueCompile) (pf)
344
345#define PR_StackTrace(pf,locals) (*pf->StackTrace) (pf,locals)
346#define PR_AbortStack(pf) (*pf->AbortStack) (pf)
347
348#define PR_RunError(pf,str) (*pf->RunError) (pf,str)
349
350#define PR_PrintEdict(pf,ed) (*pf->PrintEdict) (pf, ed)
351
352#define PR_FindFunction(pf, name, num) (*pf->FindFunction) (pf, name, num)
353#define PR_FindGlobal(pf, name, progs, type) (*pf->FindGlobal) (pf, name, progs, type)
354#define PR_AddString(pf, ed, len, demarkup) (*pf->AddString) (pf, ed, len, demarkup)
355#define PR_Alloc(pf,size,whatfor) (*pf->Tempmem) (pf, size, whatfor)
356#define PR_AddressableAlloc(pf,size) (*pf->AddressableAlloc) (pf, size)
357#define PR_AddressableFree(pf,mem) (*pf->AddressableFree) (pf, mem)
358
359#define PROG_TO_EDICTINDEX(pf, ed) ed
360#define PROG_TO_EDICT(pf, ed) (*pf->ProgsToEdict) (pf, ed)
361#define EDICT_TO_PROG(pf, ed) (*pf->EdictToProgs) (pf, (struct edict_s*)ed)
362
363#define PR_GetString(pf,s) (*pf->StringToNative) (pf, s)
364#define PR_GetStringOfs(pf,o) (*pf->StringToNative) (pf, G_INT(o))
365#define PR_SetString(pf, s) (*pf->StringToProgs) (pf, s)
366
367#define NEXT_EDICT(pf,o) EDICT_NUM(pf, NUM_FOR_EDICT(pf, o)+1)
368#define RETURN_EDICT(pf, e) (((pint_t *)pr_globals)[OFS_RETURN] = EDICT_TO_PROG(pf, e))
369
370
371//builtin funcs (which operate on globals)
372//To use these outside of builtins, you will likly have to use the 'globals' method.
373#define G_FLOAT(o) (((pvec_t *)pr_globals)[o])
374#define G_FLOAT2(o) (((pvec_t *)pr_globals)[OFS_PARM0 + o*3])
375#define G_DOUBLE(o) (*(pdouble_t *)(((pvec_t *)pr_globals+(o))))
376#define G_INT(o) (((pint_t *)pr_globals)[o])
377#define G_UINT(o) (((puint_t *)pr_globals)[o])
378#define G_INT64(o) (*(pint64_t *)((pint_t *)pr_globals+(o)))
379#define G_UINT64(o) (*(puint64_t *)((puint_t *)pr_globals+(o)))
380#define G_EDICT(pf, o) PROG_TO_EDICT(pf, G_INT(o)) //((edict_t *)((char *) sv.edicts+ *(int *)&((float *)pr_globals)[o]))
381#define G_EDICTNUM(pf, o) NUM_FOR_EDICT(pf, G_EDICT(pf, o))
382#define G_VECTOR(o) (&((pvec_t *)pr_globals)[o])
383#define G_FUNCTION(o) (*(func_t *)&((pvec_t *)pr_globals)[o])
384
385/*
386#define PR_GetString(p,s) (s?s + p->stringtable:"")
387#define PR_GetStringOfs(p,o) (G_INT(o)?G_INT(o) + p->stringtable:"")
388#define PR_SetStringOfs(p,o,s) (G_INT(o) = s - p->stringtable)
389*/
390//#define PR_SetString(p, s) ((s&&*s)?(s - p->stringtable):0)
391
392
393#ifdef QCGC
394#define PR_NewString(p, s) (p)->TempString(p, s)
395#else
396#define PR_NewString(p, s) PR_SetString(p, PR_AddString(p, s, 0, false))
397#endif
398
399#define ev_prog ev_integer
400
401#define E_STRING(o) (char *)(((pint_t *)((char *)ed) + progparms.edictsize)[o])
402
403//#define pr_global_struct pr_globals
404
405#endif
406
407
408#define OFS_NULL 0
409#define OFS_RETURN 1
410#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
411#define OFS_PARM1 7
412#define OFS_PARM2 10
413#define OFS_PARM3 13
414#define OFS_PARM4 16
415#define OFS_PARM5 19
416#define OFS_PARM6 22
417#define OFS_PARM7 25
418#define RESERVED_OFS 28
419
420
421#undef edict_t
422#undef globalvars_t
423
424#endif //PROGSLIB_H
struct @13::@38 ext
void(QDECL *vgui_frame)(void)
entity_t * ent
Definition: com_mesh.c:717
static EGLSurface EGLSurface EGLContext ctx
Definition: gl_videgl.c:47
GLsizei count
Definition: glquake.h:149
GLint GLenum type
Definition: glquake.h:157
GLuint GLcharARB * name
Definition: glquake.h:155
GLint size
Definition: glquake.h:157
char fname[MAX_QPATH]
Definition: m_mp3.c:160
void PDECL ED_Print(pubprogfuncs_t *ppf, struct edict_s *ed)
Definition: pr_edict.c:1046
pubprogfuncs_t progfuncs
Definition: pr_lua.c:198
int idx
Definition: pr_lua.c:221
ereftype_e
Definition: progslib.h:60
@ ER_FREE
Definition: progslib.h:62
@ ER_ENTITY
Definition: progslib.h:61
@ ER_OBJECT
Definition: progslib.h:63
void(ASMCALL * builtin_t)(pubprogfuncs_t *prinst, struct globalvars_s *gvars)
Definition: progslib.h:57
struct fdef_s fdef_t
__declspec(dllexport) __attribute__((visibility("default"))) pubprogfuncs_t *PDECL InitProgs(progparms_t *ext)
Definition: sys_win.c:46
union eval_s eval_t
struct progexterns_s progparms_t
struct progexterns_s progexterns_t
etype_t
Definition: progslib.h:75
@ ev_boolean
Definition: progslib.h:98
@ ev_uint64
Definition: progslib.h:89
@ ev_accessor
Definition: progslib.h:95
@ ev_enum
Definition: progslib.h:96
@ ev_function
Definition: progslib.h:83
@ ev_typedef
Definition: progslib.h:97
@ ev_void
Definition: progslib.h:77
@ ev_vector
Definition: progslib.h:80
@ ev_entity
Definition: progslib.h:81
@ ev_int64
Definition: progslib.h:88
@ ev_field
Definition: progslib.h:82
@ ev_double
Definition: progslib.h:90
@ ev_variant
Definition: progslib.h:92
@ ev_string
Definition: progslib.h:78
@ ev_union
Definition: progslib.h:94
@ ev_uint
Definition: progslib.h:87
@ ev_float
Definition: progslib.h:79
@ ev_integer
Definition: progslib.h:86
@ ev_pointer
Definition: progslib.h:84
@ ev_struct
Definition: progslib.h:93
@ DEBUG_TRACE_NORESUME
Definition: progslib.h:107
@ DEBUG_TRACE_ABORTERROR
Definition: progslib.h:105
@ DEBUG_TRACE_OVER
Definition: progslib.h:103
@ DEBUG_TRACE_INTO
Definition: progslib.h:102
@ DEBUG_TRACE_OUT
Definition: progslib.h:104
@ DEBUG_TRACE_OFF
Definition: progslib.h:101
unsigned int pbool
Definition: progtype.h:62
uint64_t puint_t
Definition: progtype.h:21
pint_t progsnum_t
Definition: progtype.h:64
int64_t pint_t
Definition: progtype.h:20
puint_t string_t
Definition: progtype.h:66
puint_t func_t
Definition: progtype.h:65
double pvec_t
Definition: progtype.h:19
static ALC_API ALCvoid * buffer
Definition: snd_al.c:259
static AL_API ALsizei n
Definition: snd_al.c:161
Definition: progs.h:65
Definition: progslib.h:68
struct fdef_s * ofs32
Definition: progslib.h:70
const char * varname
Definition: progslib.h:69
Definition: progslib.h:111
const char * name
Definition: progslib.h:115
unsigned int progsofs
Definition: progslib.h:114
unsigned int type
Definition: progslib.h:112
int ofs
Definition: progslib.h:113
Definition: progdefs.h:24
Definition: progslib.h:238
float vara
Definition: progslib.h:253
void *VARGS * memalloc(int size)
progsnum_t idx
Definition: progslib.h:248
char * oldb
Definition: progslib.h:267
void(VARGS *memfree)(void *mem)
progsnum_t int const char * filename
Definition: progslib.h:248
int headercrc
Definition: progslib.h:259
float var
Definition: progslib.h:252
void(PDECL *loadcompleate)(int edictsize)
const char int int * statement
Definition: progslib.h:266
int edictsize
Definition: progslib.h:280
struct edict_s ** edicts
Definition: progslib.h:278
int(VARGS *DPrintf)(const char *
void(VARGS *Sys_Error)(const char *
void int len
Definition: progslib.h:243
void(ASMCALL *cwstateop)(pubprogfuncs_t *prinst
char char * newb
Definition: progslib.h:267
float float varb
Definition: progslib.h:253
pbool(PDECL *entcanfree)(struct edict_s *ent)
const char int * line
Definition: progslib.h:266
int(PDECL *FileSize)(const char *fname)
progsnum_t int crc
Definition: progslib.h:248
@ PR_COMPILEEXISTANDCHANGED
Definition: progslib.h:272
@ PR_COMPILEALWAYS
Definition: progslib.h:272
@ PR_COMPILEIGNORE
Definition: progslib.h:272
@ PR_COMPILECHANGED
Definition: progslib.h:272
@ PR_COMPILENEXIST
Definition: progslib.h:272
@ PR_NOCOMPILE
Definition: progslib.h:272
const char int int int char * reason
Definition: progslib.h:266
void * user
Definition: progslib.h:282
int progsversion
Definition: progslib.h:239
char char int oldlen
Definition: progslib.h:267
float func_t func
Definition: progslib.h:252
struct edict_s const char const char * value
Definition: progslib.h:261
int loading
Definition: progslib.h:250
enum progexterns_s::@371 autocompile
int numglobalbuiltins
Definition: progslib.h:270
pbool usethreadedgc
Definition: progslib.h:276
struct edict_s const char * keyname
Definition: progslib.h:261
const char int int int char pbool fatal
Definition: progslib.h:266
const char int int int funcstart
Definition: progslib.h:266
struct edict_s * ent
Definition: progslib.h:255
unsigned int * num_edicts
Definition: progslib.h:279
int(VARGS *Printf)(const char *
double * gametime
Definition: progslib.h:274
void *PDECL * ReadFile(const char *fname, unsigned char *(PDECL *buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size, pbool issourcefile)
int const char * builtinname
Definition: progslib.h:259
builtin_t * globalbuiltins
Definition: progslib.h:269
void * data
Definition: progslib.h:243
pbool(PDECL *WriteFile)(const char *name
float float func_t currentfunc
Definition: progslib.h:253
Definition: progsint.h:355
Definition: progslib.h:121
progsnum_t int const char * name
Definition: progslib.h:196
string_t(PDECL *StringToProgs)(pubprogfuncs_t *prinst
unsigned struct edict_s * e
Definition: progslib.h:141
struct edict_s *PDECL * EntAlloc(pubprogfuncs_t *prinst, pbool object, size_t extrasize)
func_t int unsigned char int char size_t funcnamesize
Definition: progslib.h:219
unsigned int activefieldslots
Definition: progslib.h:188
int char int outlen
Definition: progslib.h:220
void(PDECL *Shutdown)(pubprogfuncs_t *inst)
const char void void struct edict_s void const char * entstart
Definition: progslib.h:160
int const char ** argc
Definition: progslib.h:150
func_t func
Definition: progslib.h:219
struct edict_s string_t * fld
Definition: progslib.h:224
const char void void struct edict_s void const char const char * entend
Definition: progslib.h:160
void(PDECL *AbortStack)(pubprogfuncs_t *prinst)
int num
Definition: progslib.h:217
struct edict_s string_t const char pbool str_is_static
Definition: progslib.h:224
const char int linenum
Definition: progslib.h:176
const char void void struct edict_s void const char const char void const char ** extline
Definition: progslib.h:162
char *PDECL * VarString(pubprogfuncs_t *prinst, int first)
char * tempstringbase
Definition: progslib.h:233
char unsigned int len
Definition: progslib.h:205
void *PDECL * AddressableAlloc(pubprogfuncs_t *progfuncs, unsigned int ammount)
const char * s
Definition: progslib.h:127
int argv
Definition: progslib.h:150
const char void void struct edict_s void const char const char pbool(PDECL *extendedterm)(pubprogfuncs_t *progfuncs
fdef_t *PDECL * FieldInfo(pubprogfuncs_t *progfuncs, unsigned int *count)
int showlocals
Definition: progslib.h:175
const char void * ctx
Definition: progslib.h:158
int tempstringnum
Definition: progslib.h:234
string_t(PDECL *TempString)(pubprogfuncs_t *prinst
int statementnum
Definition: progslib.h:220
unsigned int type
Definition: progslib.h:198
const char *ASMCALL * StringToNative(pubprogfuncs_t *prinst, string_t str)
struct edict_s * ed
Definition: progslib.h:134
int(PDECL *EdictToProgs)(pubprogfuncs_t *prinst
func_t(PDECL *FindFunction)(pubprogfuncs_t *prinst
const char void void struct edict_s void * ctx
Definition: progslib.h:160
char *PDECL * UglyValueString(pubprogfuncs_t *progfuncs, etype_t type, union eval_s *val)
struct edict_s *PDECL * ProgsToEdict(pubprogfuncs_t *prinst, int progs)
int char * function
Definition: progslib.h:195
int debug_trace
Definition: progslib.h:174
char *PDECL * RemoveProgsString(pubprogfuncs_t *progfuncs, string_t str)
struct qcthread_s * thread
Definition: progslib.h:192
struct edict_s ** edicttable
Definition: progslib.h:228
union eval_s *PDECL * GetEdictFieldValue(pubprogfuncs_t *prinst, struct edict_s *ent, const char *name, etype_t type, evalc_t *s)
progsnum_t prnum
Definition: progslib.h:196
int char size_t sizeoffunction
Definition: progslib.h:195
const char void void struct edict_s void const char const char void * ctx
Definition: progslib.h:161
int * builtinnum
Definition: progslib.h:195
struct edict_s pbool instant
Definition: progslib.h:138
int int size
Definition: progslib.h:216
struct edict_s * e
Definition: progslib.h:211
struct edict_s *PDECL * EntAllocIndex(pubprogfuncs_t *prinst, unsigned int idx, pbool object, size_t extrasize)
unsigned int const char signed long signed long originalofs
Definition: progslib.h:198
struct progstate_s ** progstate
Definition: progslib.h:145
int progsversion
Definition: progslib.h:122
size_t int max_progs
Definition: progslib.h:126
const char LIKEPRINTF(2)
const char void void * ctx
Definition: progslib.h:159
progsnum_t(PDECL *LoadProgs)(pubprogfuncs_t *prinst
unsigned int stringtablesize
Definition: progslib.h:185
char *PDECL * save_ents(pubprogfuncs_t *prinst, char *buf, size_t *size, size_t maxsize, int mode)
const char * key
Definition: progslib.h:214
int char * relstringtable
Definition: progslib.h:217
int callargc
Definition: progslib.h:182
int(PDECL *InitEnts)(pubprogfuncs_t *prinst
size_t addressablesize
Definition: progslib.h:126
struct progexterns_s * parms
Definition: progslib.h:178
struct edict_s *PDECL * restoreent(pubprogfuncs_t *prinst, const char *buf, size_t *size, struct edict_s *ed)
const char progsnum_t num
Definition: progslib.h:148
const char int int mode
Definition: progslib.h:176
pbool resetprofiles
Definition: progslib.h:225
struct pubprogfuncs_s::@370 user
func_t fnum
Definition: progslib.h:129
char *PDECL * EvaluateDebugString(pubprogfuncs_t *prinst, const char *key)
unsigned int stringtablemaxsize
Definition: progslib.h:186
char *PDECL * filefromprogs(pubprogfuncs_t *prinst, progsnum_t prnum, const char *fname, size_t *size, char *buffer)
char *PDECL * saveent(pubprogfuncs_t *prinst, char *buf, size_t *size, size_t maxsize, struct edict_s *ed)
char * stringtable
Definition: progslib.h:184
int char * prefix
Definition: progslib.h:212
union eval_s * eval
Definition: progslib.h:223
const char * msg
Definition: progslib.h:133
int numprogs
Definition: progslib.h:146
const char * str
Definition: progslib.h:204
union eval_s *PDECL * FindGlobal(pubprogfuncs_t *prinst, const char *name, progsnum_t num, etype_t *type)
unsigned int const char signed long requestedpos
Definition: progslib.h:198
const char * filename
Definition: progslib.h:176
int char char union eval_s etype_t void * ctx
Definition: progslib.h:212
const char * funcname
Definition: progslib.h:148
unsigned int etype_t char const evalc_t * fieldcache
Definition: progslib.h:209
struct entvars_s *PDECL * entvars(pubprogfuncs_t *prinst, struct edict_s *ent)
char *PDECL * filefromnewprogs(pubprogfuncs_t *prinst, const char *prname, const char *fname, size_t *size, char *buffer)
char *PDECL * AddString(pubprogfuncs_t *prinst, const char *val, int minlength, pbool demarkup)
size_t int pbool enableprofiling
Definition: progslib.h:126
int char * out
Definition: progslib.h:220
pbool(PDECL *DumpProfile)(pubprogfuncs_t *progfuncs
int fieldadjust
Definition: progslib.h:187
void * mem
Definition: progslib.h:203
int(PDECL *RegisterFieldVar)(pubprogfuncs_t *prinst
func_t int * argcount
Definition: progslib.h:219
int(PDECL *ContinueCompile)(pubprogfuncs_t *prinst)
unsigned int fieldoffset
Definition: progslib.h:209
const char * fname
Definition: progslib.h:180
int start
Definition: progslib.h:216
func_t int unsigned char ** argsizes
Definition: progslib.h:219
progsnum_t int binum
Definition: progslib.h:196
struct globalvars_s *PDECL * globals(pubprogfuncs_t *prinst, progsnum_t num)
int max_ents
Definition: progslib.h:128
struct qcthread_s *PDECL * Fork(pubprogfuncs_t *prinst)
void(PDECL *ED_Print)(pubprogfuncs_t *prinst
void *PDECL * Tempmem(pubprogfuncs_t *prinst, int ammount, char *whatfor)
struct edict_s *PDECL * EdictNum(pubprogfuncs_t *prinst, unsigned int n)
int char char union eval_s * val
Definition: progslib.h:212
unsigned int edicttable_length
Definition: progslib.h:227
unsigned char buf[KBRINGSIZE]
Definition: sys_dos.c:27
void Sys_Error(const char *error,...)
Definition: sys_droid.c:878
__attribute__((visibility("default")))
Definition: sys_win.c:3997
Definition: progslib.h:295
pvec_t _float
Definition: progslib.h:297
pvec_t prog
Definition: progslib.h:306
pint64_t i64
Definition: progslib.h:302
puint64_t u64
Definition: progslib.h:303
pvec_t _vector[3]
Definition: progslib.h:298
pint_t _int
Definition: progslib.h:300
pdouble_t _double
Definition: progslib.h:304
pint_t edict
Definition: progslib.h:305
func_t function
Definition: progslib.h:299
string_t string
Definition: progslib.h:296
puint_t _uint
Definition: progslib.h:301
ctx first
Definition: zone.c:587