char sv_spawnmap[MAX_QPATH];
char sv_loadgame[MAX_OSPATH];
-dfunction_t *ED_FindFunction (char *name);
+mfunction_t *ED_FindFunction (char *name);
/*
==================
{
int top, bottom;
int playercolor;
- dfunction_t *f;
+ mfunction_t *f;
func_t SV_ChangeTeam;
if (Cmd_Argc() == 1)
client_t *client;
edict_t *ent;
func_t RestoreGame;
- dfunction_t *f;
+ mfunction_t *f;
if (cmd_source == src_command)
{
}
client = &svs.clients[entnum-1];
-
+
MSG_WriteChar (&client->message,svc_centerprint);
MSG_WriteString (&client->message, s );
}
void PF_random (void)
{
float num;
-
+
num = (rand ()&0x7fff) / ((float)0x7fff);
G_FLOAT(OFS_RETURN) = num;
int nomonsters;
edict_t *ent;
+ pr_xfunction->builtinsprofile += 30;
+
v1 = G_VECTOR(OFS_PARM0);
v2 = G_VECTOR(OFS_PARM1);
nomonsters = G_FLOAT(OFS_PARM2);
int nomonsters;
edict_t *ent;
+ pr_xfunction->builtinsprofile += 30;
+
v1 = G_VECTOR(OFS_PARM0);
m1 = G_VECTOR(OFS_PARM1);
m2 = G_VECTOR(OFS_PARM2);
pr_global_struct->trace_inopen = trace.inopen;
VectorCopy (trace.endpos, pr_global_struct->trace_endpos);
VectorCopy (trace.plane.normal, pr_global_struct->trace_plane_normal);
- pr_global_struct->trace_plane_dist = trace.plane.dist;
+ pr_global_struct->trace_plane_dist = trace.plane.dist;
if (trace.ent)
pr_global_struct->trace_ent = EDICT_TO_PROG(trace.ent);
else
edict_t *ent;
edict_t *ignore;
+ pr_xfunction->builtinsprofile += 600;
+
ent = G_EDICT(OFS_PARM0);
ignore = G_EDICT(OFS_PARM1);
pr_global_struct->trace_inopen = trace.inopen;
VectorCopy (trace.endpos, pr_global_struct->trace_endpos);
VectorCopy (trace.plane.normal, pr_global_struct->trace_plane_normal);
- pr_global_struct->trace_plane_dist = trace.plane.dist;
+ pr_global_struct->trace_plane_dist = trace.plane.dist;
if (trace.ent)
pr_global_struct->trace_ent = EDICT_TO_PROG(trace.ent);
else
for ( ; ; i++)
{
+ pr_xfunction->builtinsprofile++;
if (i == svs.maxclients+1)
i = 1;
int entnum;
char *str;
client_t *old;
-
+
entnum = G_EDICTNUM(OFS_PARM0);
if (entnum < 1 || entnum > svs.maxclients)
Host_Error ("Parm 0 not a client");
- str = G_STRING(OFS_PARM1);
+ str = G_STRING(OFS_PARM1);
old = host_client;
host_client = &svs.clients[entnum-1];
{
char *str;
- str = G_STRING(OFS_PARM0);
+ str = G_STRING(OFS_PARM0);
Cbuf_AddText (str);
}
void PF_cvar (void)
{
char *str;
-
+
str = G_STRING(OFS_PARM0);
G_FLOAT(OFS_RETURN) = Cvar_VariableValue (str);
void PF_cvar_set (void)
{
char *var, *val;
-
+
var = G_STRING(OFS_PARM0);
val = G_STRING(OFS_PARM1);
-
+
Cvar_Set (var, val);
}
ent = NEXT_EDICT(sv.edicts);
for (i=1 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
{
+ pr_xfunction->builtinsprofile++;
if (ent->free)
continue;
if (ent->v->solid == SOLID_NOT)
void PF_Spawn (void)
{
edict_t *ed;
+ pr_xfunction->builtinsprofile += 20;
ed = ED_Alloc();
RETURN_EDICT(ed);
}
void PF_Remove (void)
{
edict_t *ed;
+ pr_xfunction->builtinsprofile += 20;
ed = G_EDICT(OFS_PARM0);
if (ed == sv.edicts)
for (e++ ; e < sv.num_edicts ; e++)
{
+ pr_xfunction->builtinsprofile++;
ed = EDICT_NUM(e);
if (ed->free)
continue;
for (e++ ; e < sv.num_edicts ; e++)
{
+ pr_xfunction->builtinsprofile++;
ed = EDICT_NUM(e);
if (ed->free)
continue;
ent = NEXT_EDICT(sv.edicts);
for (i = 1;i < sv.num_edicts;i++, ent = NEXT_EDICT(ent))
{
+ pr_xfunction->builtinsprofile++;
if (ent->free)
continue;
t = E_STRING(ent,f);
ent = NEXT_EDICT(sv.edicts);
for (i = 1;i < sv.num_edicts;i++, ent = NEXT_EDICT(ent))
{
+ pr_xfunction->builtinsprofile++;
if (ent->free)
continue;
if (E_FLOAT(ent,f) != s)
edict_t *ent;
float yaw, dist;
vec3_t move;
- dfunction_t *oldf;
+ mfunction_t *oldf;
int oldself;
ent = PROG_TO_EDICT(pr_global_struct->self);
i = G_EDICTNUM(OFS_PARM0);
while (1)
{
+ pr_xfunction->builtinsprofile++;
i++;
if (i == sv.num_edicts)
{
check = NEXT_EDICT(sv.edicts);
for (i=1 ; i<sv.num_edicts ; i++, check = NEXT_EDICT(check) )
{
+ pr_xfunction->builtinsprofile++;
if (check->v->takedamage != DAMAGE_AIM)
continue;
if (check == ent)
/*
=================
-PF_setcolor
+PF_setcolors
sets the color of a client and broadcasts the update to all connected clients
-setcolor(clientent, value)
+setcolors(clientent, value)
=================
*/
-void PF_setcolor (void)
+void PF_setcolors (void)
{
client_t *client;
int entnum, i;
aa // #300
aa // #400
PF_copyentity, // #400 LordHavoc: builtin range (4xx)
-PF_setcolor, // #401
+PF_setcolors, // #401
PF_findchain, // #402
PF_findchainfloat, // #403
PF_effect, // #404
int first_statement; // negative numbers are builtins
int parm_start;
int locals; // total ints of parms + locals
-
+
int profile; // runtime
-
+
int s_name;
int s_file; // source file defined in
-
+
int numparms;
qbyte parm_size[MAX_PARMS];
} dfunction_t;
+typedef struct
+{
+ int first_statement; // negative numbers are builtins
+ int parm_start;
+ int locals; // total ints of parms + locals
+
+ int profile; // runtime
+ int builtinsprofile; // cost of builtin functions called by this function
+
+ int s_name;
+ int s_file; // source file defined in
+
+ int numparms;
+ qbyte parm_size[MAX_PARMS];
+} mfunction_t;
+
#define PROG_VERSION 6
typedef struct
{
int version;
int crc; // check of header file
-
+
int ofs_statements;
int numstatements; // statement 0 is an error
int ofs_globaldefs;
int numglobaldefs;
-
+
int ofs_fielddefs;
int numfielddefs;
-
+
int ofs_functions;
int numfunctions; // function 0 is an empty
-
+
int ofs_strings;
int numstrings; // first string is a null string
int ofs_globals;
int numglobals;
-
+
int entityfields;
} dprograms_t;
#include "quakedef.h"
dprograms_t *progs;
-dfunction_t *pr_functions;
+mfunction_t *pr_functions;
char *pr_strings;
ddef_t *pr_fielddefs;
ddef_t *pr_globaldefs;
static gefv_cache gefvCache[GEFV_CACHESIZE] = {{NULL, ""}, {NULL, ""}};
ddef_t *ED_FindField (const char *name);
-dfunction_t *ED_FindFunction (const char *name);
+mfunction_t *ED_FindFunction (const char *name);
// LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... these are defined as externs in progs.h
int eval_gravity;
int eval_punchvector;
int eval_viewzoom;
-dfunction_t *SV_PlayerPhysicsQC;
-dfunction_t *EndFrameQC;
+mfunction_t *SV_PlayerPhysicsQC;
+mfunction_t *EndFrameQC;
int FindFieldOffset(const char *field)
{
ED_FindFunction
============
*/
-dfunction_t *ED_FindFunction (const char *name)
+mfunction_t *ED_FindFunction (const char *name)
{
- dfunction_t *func;
+ mfunction_t *func;
int i;
for (i=0 ; i<progs->numfunctions ; i++)
{
static char line[1024]; // LordHavoc: enlarged a bit (was 256)
ddef_t *def;
- dfunction_t *f;
+ mfunction_t *f;
int n;
type &= ~DEF_SAVEGLOBAL;
int i;
char *s;
ddef_t *def;
- dfunction_t *f;
+ mfunction_t *f;
type &= ~DEF_SAVEGLOBAL;
ddef_t *def;
char *v, *w;
void *d;
- dfunction_t *func;
+ mfunction_t *func;
d = (void *)((int *)base + key->ofs);
{
edict_t *ent;
int inhibit;
- dfunction_t *func;
+ mfunction_t *func;
ent = NULL;
inhibit = 0;
dstatement_t *st;
ddef_t *infielddefs;
void *temp;
+ dfunction_t *dfunctions;
// flush the non-C variable lookup cache
for (i=0 ; i<GEFV_CACHESIZE ; i++)
if (progs->crc != PROGHEADER_CRC)
Host_Error ("progs.dat system vars have been modified, progdefs.h is out of date");
- pr_functions = (dfunction_t *)((qbyte *)progs + progs->ofs_functions);
+ //pr_functions = (dfunction_t *)((qbyte *)progs + progs->ofs_functions);
+ dfunctions = (dfunction_t *)((qbyte *)progs + progs->ofs_functions);
pr_strings = (char *)progs + progs->ofs_strings;
pr_globaldefs = (ddef_t *)((qbyte *)progs + progs->ofs_globaldefs);
pr_statements[i].c = LittleShort(pr_statements[i].c);
}
- for (i=0 ; i<progs->numfunctions; i++)
+ pr_functions = Mem_Alloc(progs_mempool, sizeof(mfunction_t) * progs->numfunctions);
+ for (i = 0;i < progs->numfunctions;i++)
{
- pr_functions[i].first_statement = LittleLong (pr_functions[i].first_statement);
- pr_functions[i].parm_start = LittleLong (pr_functions[i].parm_start);
- pr_functions[i].s_name = LittleLong (pr_functions[i].s_name);
- pr_functions[i].s_file = LittleLong (pr_functions[i].s_file);
- pr_functions[i].numparms = LittleLong (pr_functions[i].numparms);
- pr_functions[i].locals = LittleLong (pr_functions[i].locals);
+ pr_functions[i].first_statement = LittleLong (dfunctions[i].first_statement);
+ pr_functions[i].parm_start = LittleLong (dfunctions[i].parm_start);
+ pr_functions[i].s_name = LittleLong (dfunctions[i].s_name);
+ pr_functions[i].s_file = LittleLong (dfunctions[i].s_file);
+ pr_functions[i].numparms = LittleLong (dfunctions[i].numparms);
+ pr_functions[i].locals = LittleLong (dfunctions[i].locals);
+ memcpy(pr_functions[i].parm_size, dfunctions[i].parm_size, sizeof(dfunctions[i].parm_size));
}
for (i=0 ; i<progs->numglobaldefs ; i++)
typedef struct
{
int s;
- dfunction_t *f;
+ mfunction_t *f;
} prstack_t;
#define MAX_STACK_DEPTH 256
int pr_trace;
-dfunction_t *pr_xfunction;
+mfunction_t *pr_xfunction;
int pr_xstatement;
*/
void PR_StackTrace (void)
{
- dfunction_t *f;
+ mfunction_t *f;
int i;
pr_stack[pr_depth].s = pr_xstatement;
*/
void PR_Profile_f (void)
{
- dfunction_t *f, *best;
- int max;
- int num;
- int i;
+ mfunction_t *f, *best;
+ int i, num, max/*, howmany*/;
+ //howmany = 10;
+ //if (Cmd_Argc() == 2)
+ // howmany = atoi(Cmd_Argv(1));
num = 0;
do
{
}
if (best)
{
- if (num < 10)
- Con_Printf ("%7i %s\n", best->profile, PR_GetString(best->s_name));
+ //if (num < howmany)
+ Con_Printf ("%7i %7i %s\n", best->profile, best->builtinsprofile, PR_GetString(best->s_name));
num++;
best->profile = 0;
+ best->builtinsprofile = 0;
}
} while (best);
}
Returns the new program statement counter
====================
*/
-int PR_EnterFunction (dfunction_t *f)
+int PR_EnterFunction (mfunction_t *f)
{
int i, j, c, o;
void PR_ExecuteProgram (func_t fnum, const char *errormessage)
{
dstatement_t *st;
- dfunction_t *f, *newf;
+ mfunction_t *f, *newf;
edict_t *ed;
eval_t *ptr;
int profile, startprofile, cachedpr_trace, exitdepth;
// negative statements are built in functions
if ((-newf->first_statement) >= pr_numbuiltins)
Host_Error ("Bad builtin call number");
+ pr_xfunction->builtinsprofile++;
pr_builtins[-newf->first_statement] ();
}
else
#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
-extern dfunction_t *SV_PlayerPhysicsQC;
-extern dfunction_t *EndFrameQC;
+extern mfunction_t *SV_PlayerPhysicsQC;
+extern mfunction_t *EndFrameQC;
//============================================================================
extern dprograms_t *progs;
-extern dfunction_t *pr_functions;
+extern mfunction_t *pr_functions;
extern char *pr_strings;
extern ddef_t *pr_globaldefs;
extern ddef_t *pr_fielddefs;
extern int pr_argc;
extern int pr_trace;
-extern dfunction_t *pr_xfunction;
+extern mfunction_t *pr_xfunction;
extern int pr_xstatement;
extern unsigned short pr_crc;