QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
progs.h File Reference
This graph shows which files directly or indirectly include this file:

Data Structures

struct  bfunction_t
 Duplicate the dfunction_t descriptor with the addition of a pointer to the builtin function. More...
 
struct  builtin_t
 Create a static array of these and pass the array to PR_RegisterBuiltins() to register the module's QC builtin functions. More...
 
struct  edict_s
 
struct  progs_s
 
struct  prstack_t
 

Macros

#define E_DSTRING(p, e, o)
 Access a dstring entity field. More...
 
#define E_FLOAT(e, o)
 Access a float entity field. More...
 
#define E_FUNCTION(e, o)
 Access a function entity field. More...
 
#define E_GSTRING(p, e, o)
 Access a string entity field, converting it to a C string. More...
 
#define E_INT(e, o)
 Access an integer entity field. More...
 
#define E_POINTER(e, o)
 Access a pointer entity field. More...
 
#define E_QUAT(e, o)
 Access a quaternion entity field. More...
 
#define E_STRING(e, o)
 Access a string index entity field. More...
 
#define E_UINT(e, o)
 Access an unsigned integer entity field. More...
 
#define E_var(e, o, t)   ((e)->v[o].t##_var)
 
#define E_VECTOR(e, o)
 Access a vector entity field. More...
 
#define EDICT_NUM(p, n)   (PROG_TO_EDICT (p, (n) * (p)->pr_edict_size))
 
#define EDICT_TO_PROG(p, e)   ((pr_int_t)(intptr_t)((byte *)(e) - PR_edicts (p)))
 
#define G_DSTRING(p, o)
 Access a dstring global. More...
 
#define G_EDICT(p, o)
 Access an entity global. More...
 
#define G_EDICTNUM(p, o)
 Access an entity global. More...
 
#define G_FLOAT(p, o)
 Access a float global. More...
 
#define G_FUNCTION(p, o)
 Access a function global. More...
 
#define G_GPOINTER(p, o)
 Access a pointer parameter. More...
 
#define G_GSTRING(p, o)
 Access a string global, converting it to a C string. More...
 
#define G_INT(p, o)
 Access an integer global. More...
 
#define G_POINTER(p, o)   G_var (p, o, pointer)
 Access a pointer global. More...
 
#define G_QUAT(p, o)
 Access a quaternion global. More...
 
#define G_STRING(p, o)
 Access a string index global. More...
 
#define G_STRUCT(p, t, o)   (*(t *)G_GPOINTER (p, o))
 Access a structure global. More...
 
#define G_UINT(p, o)
 Access an unsigned integer global. More...
 
#define G_var(p, o, t)   ((p)->pr_globals[o].t##_var)
 
#define G_VECTOR(p, o)
 Access a vector global. More...
 
#define LOCALSTACK_SIZE   4096
 
#define MAX_STACK_DEPTH   64
 
#define NEXT_EDICT(p, e)   ((edict_t *) ((byte *) e + (p)->pr_edict_size))
 
#define NUM_FOR_BAD_EDICT(p, e)   ((e)->entnum)
 
#define NUM_FOR_EDICT(p, e)   NUM_FOR_BAD_EDICT (p, e)
 
#define P_DSTRING(p, n)
 Access a dstring parameter. More...
 
#define P_EDICT(p, n)
 Access an entity parameter. More...
 
#define P_EDICTNUM(p, n)
 Access an entity parameter. More...
 
#define P_FLOAT(p, n)
 Access a float parameter. More...
 
#define P_FUNCTION(p, n)
 Access a function parameter. More...
 
#define P_GPOINTER(p, n)
 Access a pointer parameter. More...
 
#define P_GSTRING(p, n)
 Access a string parameter, converting it to a C string. More...
 
#define P_INT(p, n)
 Access an integer parameter. More...
 
#define P_POINTER(p, n)
 Access a pointer parameter. More...
 
#define P_QUAT(p, n)
 Access a quaterion parameter. More...
 
#define P_STRING(p, n)
 Access a string index parameter. More...
 
#define P_STRUCT(p, t, n)
 Access a structure pointer parameter. More...
 
#define P_UINT(p, n)
 Access an unsigned integer parameter. More...
 
#define P_var(p, n, t)   ((p)->pr_params[n]->t##_var)
 
#define P_VECTOR(p, n)
 Access a vector parameter. More...
 
#define PR_AUTOBUILTIN   (PR_RANGE_AUTO << PR_RANGE_SHIFT)
 
#define PR_edicts(p)   ((byte *) *(p)->edicts)
 
#define PR_RANGE_AUTO   0x1000
 
#define PR_RANGE_MASK   0xffff0000
 
#define PR_RANGE_MAX   0x7fff
 
#define PR_RANGE_NONE   0xffff
 
#define PR_RANGE_QF   0x000f
 
#define PR_RANGE_SHIFT   16
 
#define PR_RESET_PARAMS(pr)
 Ensure P_* macros point to the right place for passing parameters to progs functions. More...
 
#define PR_RS_SLOTS   16
 
#define PROG_TO_EDICT(p, e)   ((edict_t *) (PR_edicts (p) + (e)))
 
#define R_FLOAT(p)
 Access the VM function return value as a float. More...
 
#define R_FUNCTION(p)
 Access the VM function return value as a func_t (a VM function reference) More...
 
#define R_INT(p)
 Access the VM function return value as a pr_int_t (AKA int32_t) More...
 
#define R_POINTER(p)
 Access the VM function return value as a pointer_t (a VM "pointer") More...
 
#define R_QUAT(p)
 Access the VM function return value as a quat_t quaternion. More...
 
#define R_STRING(p)
 Access the VM function return value as a string_t (a VM string reference). More...
 
#define R_UINT(p)
 Access the VM function return value as a pr_uint_t (AKA uint32_t) More...
 
#define R_var(p, t)   ((p)->pr_return->t##_var)
 
#define R_VECTOR(p)
 Access the VM function return value as a vec3_t vector. More...
 
#define RETURN_EDICT(p, e)
 Set the return value to the given C entity pointer. More...
 
#define RETURN_POINTER(p, ptr)
 Set the return value to the given C pointer. More...
 
#define RETURN_QUAT(p, q)
 Set the return value to the given quaterion. More...
 
#define RETURN_STRING(p, s)
 Set the return value to the given C string. More...
 
#define RETURN_VECTOR(p, v)
 Set the return value to the given vector. More...
 
Resource Map support

These macros can be used to create functions for mapping C resources to QuakeC integer handles.

Valid handles are always negative.

Note
map is the resource map itself, not a pointer to the resource map.
#define PR_RESMAP(type)   struct { type *_free; type **_map; unsigned _size; }
 Type delcaration for the resource map. More...
 
#define PR_RESNEW(type, map)
 Allocate a new resource from the resource map. More...
 
#define PR_RESFREE(type, map, t)
 Free a resource returning it to the resource map. More...
 
#define PR_RESRESET(type, map)
 Free all resources in the resource map. More...
 
#define PR_RESGET(map, col)
 Retrieve a resource from the resource map using a handle. More...
 
#define PR_RESINDEX(map, ptr)
 Convert a resource pointer to a handle. More...
 

Typedefs

typedef void(* builtin_proc )(progs_t *pr)
 
typedef struct edict_s edict_t
 
typedef int pr_load_func_t (progs_t *pr)
 Type of functions that are called at progs load. More...
 
typedef struct pr_resource_s pr_resource_t
 
typedef struct progs_s progs_t
 
typedef struct strref_s strref_t
 

Functions

edict_tED_Alloc (progs_t *pr)
 
void ED_ClearEdict (progs_t *pr, edict_t *e, int val)
 
struct plitem_s * ED_ConvertToPlist (struct script_s *script, int nohack)
 
void ED_Count (progs_t *pr)
 
edict_tED_EdictNum (progs_t *pr, pr_int_t n)
 
struct plitem_s * ED_EntityDict (progs_t *pr, edict_t *ed)
 
void ED_EntityParseFunction (progs_t *pr)
 
void ED_Free (progs_t *pr, edict_t *ed)
 
struct plitem_s * ED_GlobalsDict (progs_t *pr)
 
void ED_InitEntity (progs_t *pr, struct plitem_s *entity, edict_t *ent)
 
void ED_InitGlobals (progs_t *pr, struct plitem_s *globals)
 
void ED_LoadFromFile (progs_t *pr, const char *data)
 
pr_int_t ED_NumForEdict (progs_t *pr, edict_t *e)
 
struct plitem_s * ED_Parse (progs_t *pr, const char *data)
 
qboolean ED_ParseEpair (progs_t *pr, pr_type_t *base, ddef_t *key, const char *s)
 
void ED_Print (progs_t *pr, edict_t *ed)
 
void ED_PrintEdicts (progs_t *pr, const char *fieldval)
 
void ED_PrintNum (progs_t *pr, pr_int_t ent)
 
char * PF_VarString (progs_t *pr, int first)
 
int PR_AccessField (progs_t *pr, const char *name, etype_t type, const char *file, int line)
 
void PR_AddLoadFinishFunc (progs_t *pr, pr_load_func_t *func)
 Register a secondary function to be called after the progs code has been loaded. More...
 
void PR_AddLoadFunc (progs_t *pr, pr_load_func_t *func)
 Register a primary function to be called after the progs code has been loaded. More...
 
void PR_BoundsCheck (progs_t *pr, int addr, etype_t type)
 
void PR_BoundsCheckSize (progs_t *pr, pointer_t addr, unsigned size)
 
int PR_CallFunction (progs_t *pr, func_t fnum)
 Setup to call a function. More...
 
string_t PR_CatStrings (progs_t *pr, const char *a, const char *b)
 Make a temporary progs string that is the concatenation of two C strings. More...
 
int PR_Check_Opcodes (progs_t *pr)
 Validate the opcodes and statement addresses in the progs. More...
 
void PR_ClearReturnStrings (progs_t *pr)
 Clear all of the return string slots. More...
 
void PR_Cmds_Init (progs_t *pr)
 
void PR_Debug_Init (void)
 
void PR_Debug_Init_Cvars (void)
 
void PR_Debug_Print (progs_t *pr, const char *expr)
 
void PR_Debug_Watch (progs_t *pr, const char *expr)
 
void PR_DumpState (progs_t *pr)
 
qboolean PR_EdictValid (progs_t *pr, pr_int_t e)
 
void PR_Error (progs_t *pr, const char *error,...)
 
void PR_ExecuteProgram (progs_t *pr, func_t fnum)
 Run a progs function. More...
 
ddef_tPR_FieldAtOfs (progs_t *pr, pr_int_t ofs)
 
pr_lineno_tPR_Find_Lineno (progs_t *pr, pr_uint_t addr)
 
builtin_tPR_FindBuiltin (progs_t *pr, const char *name)
 Lookup a builtin function referred by name. More...
 
builtin_tPR_FindBuiltinNum (progs_t *pr, pr_int_t num)
 Lookup a builtin function by builtin number. More...
 
ddef_tPR_FindField (progs_t *pr, const char *name)
 
dfunction_tPR_FindFunction (progs_t *pr, const char *name)
 
ddef_tPR_FindGlobal (progs_t *pr, const char *name)
 
void PR_FreeString (progs_t *pr, string_t str)
 Destroy a mutable, dynamic or temporary string. More...
 
void PR_FreeTempStrings (progs_t *pr)
 Free all the temporary strings allocated in the current stack frame. More...
 
pr_uint_t PR_Get_Lineno_Addr (progs_t *pr, pr_lineno_t *lineno)
 
pr_auxfunction_tPR_Get_Lineno_Func (progs_t *pr, pr_lineno_t *lineno)
 
pr_uint_t PR_Get_Lineno_Line (progs_t *pr, pr_lineno_t *lineno)
 
ddef_tPR_Get_Local_Def (progs_t *pr, pr_int_t offs)
 
ddef_tPR_Get_Param_Def (progs_t *pr, dfunction_t *func, unsigned parm)
 
const char * PR_Get_Source_File (progs_t *pr, pr_lineno_t *lineno)
 
const char * PR_Get_Source_Line (progs_t *pr, pr_uint_t addr)
 
struct dstring_sPR_GetMutableString (progs_t *pr, string_t num)
 Retrieve the dstring_t associated with a mutable string. More...
 
const char * PR_GetString (progs_t *pr, string_t num)
 Convert a string index to a C string. More...
 
ddef_tPR_GlobalAtOfs (progs_t *pr, pr_int_t ofs)
 
void PR_Init (void)
 Initialize the progs engine. More...
 
void PR_Init_Cvars (void)
 Initialize the Cvars for the progs engine. More...
 
int PR_LoadDebug (progs_t *pr)
 
void PR_LoadProgs (progs_t *pr, const char *progsname, int max_edicts, int zone)
 Convenience wrapper for PR_LoadProgsFile() and PR_RunLoadFuncs(). More...
 
void PR_LoadProgsFile (progs_t *pr, struct QFile_s *file, int size, int max_edicts, int zone)
 Initialize a progs_t VM struct from an already open file. More...
 
int PR_LoadStrings (progs_t *pr)
 Initialize the string tables using the strings supplied by the progs. More...
 
void PR_MakeTempString (progs_t *pr, string_t str)
 Convert a mutable string to a temporary string. More...
 
string_t PR_NewMutableString (progs_t *pr)
 Create a new mutable string. More...
 
void PR_PopFrame (progs_t *pr)
 Pop an execution frame from the VM stack. More...
 
void PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
 
void PR_Profile (progs_t *pr)
 
void PR_PushFrame (progs_t *pr)
 Push an execution frame onto the VM stack. More...
 
void PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins)
 Register a set of builtin functions with the VM. More...
 
int PR_RelocateBuiltins (progs_t *pr)
 Fixup all automatically resolved builtin functions (func = #0 in QC). More...
 
int PR_ResolveGlobals (progs_t *pr)
 
void PR_Resources_Clear (progs_t *pr)
 Clear all resources before loading a new progs. More...
 
void * PR_Resources_Find (progs_t *pr, const char *name)
 Retrieve a resource registered with the VM. More...
 
void PR_Resources_Init (progs_t *pr)
 Initialize the resource management fields. More...
 
void PR_Resources_Register (progs_t *pr, const char *name, void *data, void(*clear)(progs_t *, void *))
 Register a resource with a VM. More...
 
void PR_RestoreParams (progs_t *pr)
 Restore the parameters saved by PR_SaveParams(). More...
 
void PR_RunError (progs_t *pr, const char *error,...)
 
int PR_RunLoadFuncs (progs_t *pr)
 Run all load functions. More...
 
void PR_SaveParams (progs_t *pr)
 Save the current parameters. More...
 
string_t PR_SetDynamicString (progs_t *pr, const char *s)
 Make a dynamic progs string from the given C string. More...
 
string_t PR_SetReturnString (progs_t *pr, const char *s)
 Make a temporary progs string that will survive across function returns. More...
 
string_t PR_SetString (progs_t *pr, const char *s)
 Make a permanent progs string from the given C string. More...
 
string_t PR_SetTempString (progs_t *pr, const char *s)
 Make a temporary progs string that will be freed when the current progs stack frame is exited. More...
 
void PR_Sprintf (progs_t *pr, struct dstring_s *result, const char *name, const char *format, int count, pr_type_t **args)
 Formatted printing similar to C's vsprintf, but using QC types. More...
 
void PR_StackTrace (progs_t *pr)
 
qboolean PR_StringValid (progs_t *pr, string_t num)
 Check the validity of a string index. More...
 
void PR_Undefined (progs_t *pr, const char *type, const char *name)
 
void PR_Zone_Free (progs_t *pr, void *ptr)
 
void PR_Zone_Init (progs_t *pr)
 
void * PR_Zone_Malloc (progs_t *pr, pr_int_t size)
 
void * PR_Zone_Realloc (progs_t *pr, void *ptr, pr_int_t size)
 

Variables

struct cvar_spr_boundscheck
 
struct cvar_spr_deadbeef_ents
 
struct cvar_spr_deadbeef_locals
 
struct cvar_spr_debug
 
struct cvar_spr_faultchecks
 
const char * pr_gametype
 

Macro Definition Documentation

#define LOCALSTACK_SIZE   4096
#define MAX_STACK_DEPTH   64
#define PR_RS_SLOTS   16

Typedef Documentation

typedef struct strref_s strref_t