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 This is a try to make the vm more generic, it is mainly based on the progs.h file.
22 For the license refer to progs.h.
24 Generic means, less as possible hard-coded links with the other parts of the engine.
25 This means no edict_engineprivate struct usage, etc.
26 The code uses void pointers instead.
32 #include "pr_comp.h" // defs shared with qcc
33 #include "progdefs.h" // generated by program cdefs
34 #include "clprogdefs.h" // generated by program cdefs
36 // forward declaration of clgecko_t
39 typedef struct prvm_stack_s
44 double builtinsprofile_acc;
48 typedef union prvm_eval_s
59 typedef struct prvm_required_field_s
63 } prvm_required_field_t;
66 // AK: I dont call it engine private cause it doesnt really belongs to the engine
67 // it belongs to prvm.
68 typedef struct prvm_edict_private_s
73 const char *allocation_origin;
74 } prvm_edict_private_t;
76 typedef struct prvm_edict_s
78 // engine-private fields (stored in dynamically resized array)
79 //edict_engineprivate_t *e;
82 prvm_edict_private_t *required;
84 // FIXME: this server pointer really means world, not server
85 // (it is used by both server qc and client qc, but not menu qc)
86 edict_engineprivate_t *server;
87 // add other private structs as you desire
88 // new structs have to start with the elements of prvm_edit_private_t
89 // e.g. a new struct has to either look like this:
90 // typedef struct server_edict_private_s {
91 // prvm_edict_private_t base;
93 // vec3_t moved_fromangles;
94 // ... } server_edict_private_t;
96 // typedef struct server_edict_private_s {
100 // vec3_t moved_fromangles;
101 // ... } server_edict_private_t;
102 // However, the first one should be preferred.
104 // QuakeC fields (stored in dynamically resized array)
109 cl_entvars_t *client;
113 #define PRVM_EDICTFIELDVALUE(ed, fieldoffset) (fieldoffset >= 0 ? (prvm_eval_t *)((int *)ed->fields.vp + fieldoffset) : NULL)
114 #define PRVM_GLOBALFIELDVALUE(fieldoffset) (fieldoffset >= 0 ? (prvm_eval_t *)((int *)prog->globals.generic + fieldoffset) : NULL)
116 //============================================================================
117 #define PRVM_OP_STATE 1
119 #ifdef DP_SMALLMEMORY
120 #define PRVM_MAX_STACK_DEPTH 128
121 #define PRVM_LOCALSTACK_SIZE 2048
123 #define PRVM_MAX_OPENFILES 16
124 #define PRVM_MAX_OPENSEARCHES 8
125 #define PRVM_MAX_GECKOINSTANCES 1
127 #define PRVM_MAX_STACK_DEPTH 1024
128 #define PRVM_LOCALSTACK_SIZE 16384
130 #define PRVM_MAX_OPENFILES 256
131 #define PRVM_MAX_OPENSEARCHES 128
132 #define PRVM_MAX_GECKOINSTANCES 32
135 typedef void (*prvm_builtin_t) (void);
137 // NOTE: field offsets use -1 for NULL
138 typedef struct prvm_prog_fieldoffsets_s
140 // server and client use a lot of similar fields, so this is combined
141 int SendEntity; // ssqc
142 int SendFlags; // ssqc
143 int Version; // ssqc (legacy)
144 int alpha; // ssqc / csqc
145 int ammo_cells1; // ssqc - Dissolution of Eternity mission pack
146 int ammo_lava_nails; // ssqc - Dissolution of Eternity mission pack
147 int ammo_multi_rockets; // ssqc - Dissolution of Eternity mission pack
148 int ammo_nails1; // ssqc - Dissolution of Eternity mission pack
149 int ammo_plasma; // ssqc - Dissolution of Eternity mission pack
150 int ammo_rockets1; // ssqc - Dissolution of Eternity mission pack
151 int ammo_shells1; // ssqc - Dissolution of Eternity mission pack
152 int angles; // common - used by changeyaw/changepitch
160 int button10; // ssqc
161 int button11; // ssqc
162 int button12; // ssqc
163 int button13; // ssqc
164 int button14; // ssqc
165 int button15; // ssqc
166 int button16; // ssqc
167 int buttonchat; // ssqc
168 int buttonuse; // ssqc
169 int chain; // common - used by find builtins
170 int classname; // common
171 int clientcamera; // ssqc
172 int clientcolors; // ssqc
173 int clientstatus; // ssqc
175 int colormod; // ssqc / csqc
176 int contentstransition; // ssqc
177 int cursor_active; // ssqc
178 int cursor_screen; // ssqc
179 int cursor_trace_endpos; // ssqc
180 int cursor_trace_ent; // ssqc
181 int cursor_trace_start; // ssqc
182 int customizeentityforclient; // ssqc
183 int dimension_hit; // ssqc / csqc
184 int dimension_solid; // ssqc / csqc
185 int disableclientprediction; // ssqc
186 int dphitcontentsmask; // ssqc / csqc
187 int drawonlytoclient; // ssqc
188 int effects; // ssqc / csqc
189 int exteriormodeltoclient; // ssqc
190 int fatness; // ssqc / csqc
191 int forceshader; // csqc
192 int frame1time; // csqc
194 int frame2time; // csqc
196 int frame3time; // csqc
198 int frame4time; // csqc
199 int frame; // common - used by OP_STATE
200 int fullbright; // ssqc - Nehahra support
201 int glow_color; // ssqc
202 int glow_size; // ssqc
203 int glow_trail; // ssqc
204 int glowmod; // ssqc / csqc
206 int groundentity; // ssqc / csqc
207 int hull; // ssqc / csqc
208 int ideal_yaw; // ssqc / csqc
209 int idealpitch; // ssqc / csqc
211 int lerpfrac3; // csqc
212 int lerpfrac4; // csqc
213 int lerpfrac; // csqc
214 int light_lev; // ssqc
216 int modelflags; // ssqc
217 int movement; // ssqc
218 int movetypesteplandevent; // ssqc
219 int netaddress; // ssqc
220 int nextthink; // common - used by OP_STATE
221 int nodrawtoclient; // ssqc
224 int packetloss; // ssqc
225 int movementloss; // ssqc
226 int pitch_speed; // ssqc / csqc
227 int playermodel; // ssqc
228 int playerskin; // ssqc
230 int punchvector; // ssqc
231 int renderamt; // ssqc - HalfLife support
232 int renderflags; // csqc
233 int rendermode; // ssqc - HalfLife support
234 int scale; // ssqc / csqc
235 int shadertime; // csqc
236 int skeletonindex; // csqc / ssqc FTE_CSQC_SKELETONOBJECTS / DP_SKELETONOBJECTS
238 int tag_entity; // ssqc / csqc
239 int tag_index; // ssqc / csqc
240 int think; // common - used by OP_STATE
241 int viewmodelforclient; // ssqc
242 int viewzoom; // ssqc
243 int yaw_speed; // ssqc / csqc
244 int bouncefactor; // ssqc
245 int bouncestop; // ssqc
247 int solid; // ssqc / csqc (physics)
248 int movetype; // ssqc / csqc (physics)
249 int modelindex; // ssqc / csqc (physics)
250 int mins; // ssqc / csqc (physics)
251 int maxs; // ssqc / csqc (physics)
252 int mass; // ssqc / csqc (physics)
253 int origin; // ssqc / csqc (physics)
254 int velocity; // ssqc / csqc (physics)
255 //int axis_forward; // ssqc / csqc (physics)
256 //int axis_left; // ssqc / csqc (physics)
257 //int axis_up; // ssqc / csqc (physics)
258 //int spinvelocity; // ssqc / csqc (physics)
259 //int angles; // ssqc / csqc (physics)
260 int avelocity; // ssqc / csqc (physics)
261 int jointtype; // ssqc / csqc (physics)
262 int enemy; // ssqc / csqc (physics)
263 int aiment; // ssqc / csqc (physics)
264 int movedir; // ssqc / csqc (physics)
266 prvm_prog_fieldoffsets_t;
268 // NOTE: global offsets use -1 for NULL
269 typedef struct prvm_prog_globaloffsets_s
271 // server and client use a lot of similar globals, so this is combined
272 int SV_InitCmd; // ssqc
274 int time; // ssqc / csqc
275 int v_forward; // ssqc / csqc
276 int v_right; // ssqc / csqc
277 int v_up; // ssqc / csqc
278 int view_angles; // csqc
279 int trace_allsolid; // ssqc / csqc
280 int trace_startsolid; // ssqc / csqc
281 int trace_fraction; // ssqc / csqc
282 int trace_inwater; // ssqc / csqc
283 int trace_inopen; // ssqc / csqc
284 int trace_endpos; // ssqc / csqc
285 int trace_plane_normal; // ssqc / csqc
286 int trace_plane_dist; // ssqc / csqc
287 int trace_ent; // ssqc / csqc
288 int trace_networkentity; // csqc
289 int trace_dphitcontents; // ssqc / csqc
290 int trace_dphitq3surfaceflags; // ssqc / csqc
291 int trace_dphittexturename; // ssqc / csqc
292 int trace_dpstartcontents; // ssqc / csqc
293 int intermission; // csqc
295 int deathmatch; // csqc
296 int dmg_take; // csqc
297 int dmg_save; // csqc
298 int dmg_origin; // csqc
299 int sb_showscores; // csqc
300 int drawfont; // csqc / menu
301 int drawfontscale; // csqc / menu
302 int require_spawnfunc_prefix; // ssqc
303 int worldstatus; // ssqc
304 int servertime; // csqc
305 int serverprevtime; // csqc
306 int serverdeltatime; // csqc
307 int gettaginfo_name; // ssqc / csqc
308 int gettaginfo_parent; // ssqc / csqc
309 int gettaginfo_offset; // ssqc / csqc
310 int gettaginfo_forward; // ssqc / csqc
311 int gettaginfo_right; // ssqc / csqc
312 int gettaginfo_up; // ssqc / csqc
313 int transparent_offset; // csqc
315 prvm_prog_globaloffsets_t;
317 // these are initialized using PRVM_ED_FindFunction
318 // NOTE: function offsets use 0 for NULL
319 typedef struct prvm_prog_funcoffsets_s
321 func_t CSQC_ConsoleCommand; // csqc
322 func_t CSQC_Ent_Remove; // csqc
323 func_t CSQC_Ent_Spawn; // csqc DP_CSQC_ENT_SPAWN extension (BlackHC - TODO: needs to be added to dpextensions.qc)
324 func_t CSQC_Ent_Update; // csqc
325 func_t CSQC_Event; // csqc [515]: engine call this for its own needs so csqc can do some things according to what engine it's running on. example: to say about edicts increase, whatever...
326 func_t CSQC_Event_Sound; // csqc : called by engine when an incoming sound packet arrives so CSQC can act on it
327 func_t CSQC_Init; // csqc
328 func_t CSQC_InputEvent; // csqc
329 func_t CSQC_Parse_CenterPrint; // csqc
330 func_t CSQC_Parse_Print; // csqc
331 func_t CSQC_Parse_StuffCmd; // csqc
332 func_t CSQC_Parse_TempEntity; // csqc [515]: very helpfull when you want to create your own particles/decals/etc for effects that already exist
333 func_t CSQC_Shutdown; // csqc
334 func_t CSQC_UpdateView; // csqc
335 func_t Gecko_Query; // csqc, mqc
336 func_t EndFrame; // ssqc
337 func_t RestoreGame; // ssqc
338 func_t SV_ChangeTeam; // ssqc
339 func_t SV_ParseClientCommand; // ssqc
340 func_t SV_PlayerPhysics; // ssqc
341 func_t SV_OnEntityPreSpawnFunction; // ssqc
342 func_t SV_OnEntityNoSpawnFunction; // ssqc
343 func_t SV_OnEntityPostSpawnFunction; // ssqc
344 func_t GameCommand; // any
345 func_t SV_Shutdown; // ssqc
346 func_t URI_Get_Callback; // any
347 func_t SV_PausedTic; //ssqc
349 // menu qc only uses some functions, nothing else
350 func_t m_draw; // mqc
351 func_t m_init; // mqc
352 func_t m_keydown; // mqc
353 func_t m_keyup; // mqc
354 func_t m_shutdown; // mqc
355 func_t m_toggle; // mqc
357 prvm_prog_funcoffsets_t;
359 typedef struct prvm_stringbuffer_s
368 // [INIT] variables flagged with this token can be initialized by 'you'
369 // NOTE: external code has to create and free the mempools but everything else is done by prvm !
370 typedef struct prvm_prog_s
373 unsigned int id; // increasing unique id of progs instance
375 mfunction_t *functions;
380 dstatement_t *statements;
381 int entityfields; // number of vec_t fields in progs (some variables are 3)
382 int entityfieldsarea; // LordHavoc: equal to max_edicts * entityfields (for bounds checking)
384 int *statement_linenums; // NULL if not available
386 double *statement_profile; // only incremented if prvm_statementprofiling is on
390 globalvars_t *server;
391 cl_globalvars_t *client;
396 // this is updated whenever a string is removed or added
397 // (simple optimization of the free string search)
398 int firstfreeknownstring;
399 const char **knownstrings;
400 unsigned char *knownstrings_freeable;
401 const char **knownstrings_origin;
402 const char ***stringshash;
404 memexpandablearray_t stringbuffersarray;
406 // all memory allocations related to this vm_prog (code, edicts, strings)
407 mempool_t *progs_mempool; // [INIT]
409 prvm_builtin_t *builtins; // [INIT]
410 int numbuiltins; // [INIT]
415 mfunction_t *xfunction;
418 // stacktrace writes into stack[MAX_STACK_DEPTH]
419 // thus increase the array, so depth wont be overwritten
420 prvm_stack_t stack[PRVM_MAX_STACK_DEPTH+1];
423 int localstack[PRVM_LOCALSTACK_SIZE];
426 unsigned short headercrc; // [INIT]
427 unsigned short headercrc2; // [INIT] alternate CRC for tenebrae progs.dat
429 unsigned short filecrc;
431 //============================================================================
432 // until this point everything also exists (with the pr_ prefix) in the old vm
434 qfile_t *openfiles[PRVM_MAX_OPENFILES];
435 const char * openfiles_origin[PRVM_MAX_OPENFILES];
436 fssearch_t *opensearches[PRVM_MAX_OPENSEARCHES];
437 const char * opensearches_origin[PRVM_MAX_OPENSEARCHES];
438 struct clgecko_s *opengeckoinstances[PRVM_MAX_GECKOINSTANCES];
439 skeleton_t *skeletons[MAX_EDICTS];
441 // copies of some vars that were former read from sv
443 // number of edicts for which space has been (should be) allocated
444 int max_edicts; // [INIT]
445 // used instead of the constant MAX_EDICTS
446 int limit_edicts; // [INIT]
448 // number of reserved edicts (allocated from 1)
449 int reserved_edicts; // [INIT]
451 prvm_edict_t *edicts;
455 // size of the engine private struct
456 int edictprivate_size; // [INIT]
458 prvm_prog_fieldoffsets_t fieldoffsets;
459 prvm_prog_globaloffsets_t globaloffsets;
460 prvm_prog_funcoffsets_t funcoffsets;
462 // allow writing to world entity fields, this is set by server init and
463 // cleared before first server frame
464 qboolean allowworldwrites;
466 // name of the prog, e.g. "Server", "Client" or "Menu" (used for text output)
467 char *name; // [INIT]
469 // flag - used to store general flags like PRVM_GE_SELF, etc.
472 char *extensionstring; // [INIT]
474 qboolean loadintoworld; // [INIT]
476 // used to indicate whether a prog is loaded
478 qboolean leaktest_active;
480 // translation buffer (only needs to be freed on unloading progs, type is private to prvm_edict.c)
483 // printed together with backtraces
484 const char *statestring;
486 // prvm_builtin_mem_t *mem_list;
488 // now passed as parameter of PRVM_LoadProgs
489 // char **required_func;
490 // int numrequiredfunc;
492 //============================================================================
494 ddef_t *self; // if self != 0 then there is a global self
496 //============================================================================
499 void (*begin_increase_edicts)(void); // [INIT] used by PRVM_MEM_Increase_Edicts
500 void (*end_increase_edicts)(void); // [INIT]
502 void (*init_edict)(prvm_edict_t *edict); // [INIT] used by PRVM_ED_ClearEdict
503 void (*free_edict)(prvm_edict_t *ed); // [INIT] used by PRVM_ED_Free
505 void (*count_edicts)(void); // [INIT] used by PRVM_ED_Count_f
507 qboolean (*load_edict)(prvm_edict_t *ent); // [INIT] used by PRVM_ED_LoadFromFile
509 void (*init_cmd)(void); // [INIT] used by PRVM_InitProg
510 void (*reset_cmd)(void); // [INIT] used by PRVM_ResetProg
512 void (*error_cmd)(const char *format, ...) DP_FUNC_PRINTF(1); // [INIT]
514 void (*ExecuteProgram)(func_t fnum, const char *errormessage); // pointer to one of the *VM_ExecuteProgram functions
517 extern prvm_prog_t * prog;
519 #define PRVM_MAXPROGS 3
520 #define PRVM_SERVERPROG 0 // actually not used at the moment
521 #define PRVM_CLIENTPROG 1
522 #define PRVM_MENUPROG 2
524 extern prvm_prog_t prvm_prog_list[PRVM_MAXPROGS];
526 //============================================================================
529 extern prvm_builtin_t vm_sv_builtins[];
530 extern prvm_builtin_t vm_cl_builtins[];
531 extern prvm_builtin_t vm_m_builtins[];
533 extern const int vm_sv_numbuiltins;
534 extern const int vm_cl_numbuiltins;
535 extern const int vm_m_numbuiltins;
537 extern char * vm_sv_extensions; // client also uses this
538 extern char * vm_m_extensions;
540 void VM_SV_Cmd_Init(void);
541 void VM_SV_Cmd_Reset(void);
543 void VM_CL_Cmd_Init(void);
544 void VM_CL_Cmd_Reset(void);
546 void VM_M_Cmd_Init(void);
547 void VM_M_Cmd_Reset(void);
549 void VM_Cmd_Init(void);
550 void VM_Cmd_Reset(void);
551 //============================================================================
553 void PRVM_Init (void);
556 void MVM_ExecuteProgram (func_t fnum, const char *errormessage);
557 void CLVM_ExecuteProgram (func_t fnum, const char *errormessage);
558 void SVVM_ExecuteProgram (func_t fnum, const char *errormessage);
560 #define MVM_ExecuteProgram SVVM_ExecuteProgram
561 #define CLVM_ExecuteProgram SVVM_ExecuteProgram
562 void SVVM_ExecuteProgram (func_t fnum, const char *errormessage);
564 #define PRVM_ExecuteProgram prog->ExecuteProgram
566 #define PRVM_Alloc(buffersize) _PRVM_Alloc(buffersize, __FILE__, __LINE__)
567 #define PRVM_Free(buffer) _PRVM_Free(buffer, __FILE__, __LINE__)
568 #define PRVM_FreeAll() _PRVM_FreeAll(__FILE__, __LINE__)
569 void *_PRVM_Alloc (size_t buffersize, const char *filename, int fileline);
570 void _PRVM_Free (void *buffer, const char *filename, int fileline);
571 void _PRVM_FreeAll (const char *filename, int fileline);
573 void PRVM_Profile (int maxfunctions, int mininstructions, int sortby);
574 void PRVM_Profile_f (void);
575 void PRVM_ChildProfile_f (void);
576 void PRVM_CallProfile_f (void);
577 void PRVM_PrintFunction_f (void);
579 void PRVM_PrintState(void);
580 void PRVM_CrashAll (void);
581 void PRVM_Crash (void);
582 void PRVM_ShortStackTrace(char *buf, size_t bufsize);
583 const char *PRVM_AllocationOrigin(void);
585 ddef_t *PRVM_ED_FindField(const char *name);
586 ddef_t *PRVM_ED_FindGlobal(const char *name);
587 mfunction_t *PRVM_ED_FindFunction(const char *name);
589 int PRVM_ED_FindFieldOffset(const char *name);
590 int PRVM_ED_FindGlobalOffset(const char *name);
591 func_t PRVM_ED_FindFunctionOffset(const char *name);
592 #define PRVM_ED_FindFieldOffset_FromStruct(st, field) prog->fieldoffsets . field = ((int *)(&((st *)NULL)-> field ) - ((int *)NULL))
593 #define PRVM_ED_FindGlobalOffset_FromStruct(st, field) prog->globaloffsets . field = ((int *)(&((st *)NULL)-> field ) - ((int *)NULL))
595 void PRVM_MEM_IncreaseEdicts(void);
597 qboolean PRVM_ED_CanAlloc(prvm_edict_t *e);
598 prvm_edict_t *PRVM_ED_Alloc (void);
599 void PRVM_ED_Free (prvm_edict_t *ed);
600 void PRVM_ED_ClearEdict (prvm_edict_t *e);
602 void PRVM_PrintFunctionStatements (const char *name);
603 void PRVM_ED_Print(prvm_edict_t *ed, const char *wildcard_fieldname);
604 void PRVM_ED_Write (qfile_t *f, prvm_edict_t *ed);
605 const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent);
607 void PRVM_ED_WriteGlobals (qfile_t *f);
608 void PRVM_ED_ParseGlobals (const char *data);
610 void PRVM_ED_LoadFromFile (const char *data);
612 unsigned int PRVM_EDICT_NUM_ERROR(unsigned int n, char *filename, int fileline);
613 #define PRVM_EDICT(n) (((unsigned)(n) < (unsigned int)prog->max_edicts) ? (unsigned int)(n) : PRVM_EDICT_NUM_ERROR((unsigned int)(n), __FILE__, __LINE__))
614 #define PRVM_EDICT_NUM(n) (prog->edicts + PRVM_EDICT(n))
616 //int NUM_FOR_EDICT_ERROR(prvm_edict_t *e);
617 #define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts))
618 //int PRVM_NUM_FOR_EDICT(prvm_edict_t *e);
620 #define PRVM_NEXT_EDICT(e) ((e) + 1)
622 #define PRVM_EDICT_TO_PROG(e) (PRVM_NUM_FOR_EDICT(e))
623 //int PRVM_EDICT_TO_PROG(prvm_edict_t *e);
624 #define PRVM_PROG_TO_EDICT(n) (PRVM_EDICT_NUM(n))
625 //prvm_edict_t *PRVM_PROG_TO_EDICT(int n);
627 //============================================================================
629 #define PRVM_G_FLOAT(o) (prog->globals.generic[o])
630 #define PRVM_G_INT(o) (*(int *)&prog->globals.generic[o])
631 #define PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(*(int *)&prog->globals.generic[o]))
632 #define PRVM_G_EDICTNUM(o) PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(o))
633 #define PRVM_G_VECTOR(o) (&prog->globals.generic[o])
634 #define PRVM_G_STRING(o) (PRVM_GetString(*(string_t *)&prog->globals.generic[o]))
635 //#define PRVM_G_FUNCTION(o) (*(func_t *)&prog->globals.generic[o])
637 // FIXME: make these go away?
638 #define PRVM_E_FLOAT(e,o) (((float*)e->fields.vp)[o])
639 #define PRVM_E_INT(e,o) (((int*)e->fields.vp)[o])
640 //#define PRVM_E_VECTOR(e,o) (&((float*)e->fields.vp)[o])
641 #define PRVM_E_STRING(e,o) (PRVM_GetString(*(string_t *)&((float*)e->fields.vp)[o]))
643 extern int prvm_type_size[8]; // for consistency : I think a goal of this sub-project is to
644 // make the new vm mostly independent from the old one, thus if it's necessary, I copy everything
646 void PRVM_Init_Exec(void);
648 void PRVM_ED_PrintEdicts_f (void);
649 void PRVM_ED_PrintNum (int ent, const char *wildcard_fieldname);
651 const char *PRVM_GetString(int num);
652 int PRVM_SetEngineString(const char *s);
653 const char *PRVM_ChangeEngineString(int i, const char *s);
654 int PRVM_SetTempString(const char *s);
655 int PRVM_AllocString(size_t bufferlength, char **pointer);
656 void PRVM_FreeString(int num);
658 //============================================================================
660 // used as replacement for a prog stack
661 //#define PRVM_DEBUGPRSTACK
663 #ifdef PRVM_DEBUGPRSTACK
664 #define PRVM_Begin if(prog != 0) Con_Printf("prog not 0(prog = %i) in file: %s line: %i!\n", PRVM_GetProgNr(), __FILE__, __LINE__)
665 #define PRVM_End prog = 0
668 #define PRVM_End prog = 0
671 //#define PRVM_SAFENAME
672 #ifndef PRVM_SAFENAME
673 # define PRVM_NAME (prog->name)
675 # define PRVM_NAME (prog->name ? prog->name : "Unknown prog name")
678 // helper macro to make function pointer calls easier
679 #define PRVM_GCALL(func) if(prog->func) prog->func
681 #define PRVM_ERROR prog->error_cmd
683 // other prog handling functions
684 qboolean PRVM_SetProgFromString(const char *str);
685 void PRVM_SetProg(int prognr);
689 Call InitProg with the num
690 Set up the fields marked with [INIT] in the prog struct
691 Load a program with LoadProgs
693 void PRVM_InitProg(int prognr);
694 // LoadProgs expects to be called right after InitProg
695 void PRVM_LoadProgs (const char *filename, int numrequiredfunc, char **required_func, int numrequiredfields, prvm_required_field_t *required_field, int numrequiredglobals, char **required_global);
696 void PRVM_ResetProg(void);
698 qboolean PRVM_ProgLoaded(int prognr);
700 int PRVM_GetProgNr(void);
702 void VM_Warning(const char *fmt, ...) DP_FUNC_PRINTF(1);
704 // TODO: fill in the params
705 //void PRVM_Create();
707 void VM_GenerateFrameGroupBlend(framegroupblend_t *framegroupblend, const prvm_edict_t *ed);
708 void VM_FrameBlendFromFrameGroupBlend(frameblend_t *frameblend, const framegroupblend_t *framegroupblend, const dp_model_t *model);
709 void VM_UpdateEdictSkeleton(prvm_edict_t *ed, const dp_model_t *edmodel, const frameblend_t *frameblend);
710 void VM_RemoveEdictSkeleton(prvm_edict_t *ed);