]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_exec.c
clarify in_pitch_* cvar descriptions about upward/downward values
[xonotic/darkplaces.git] / prvm_exec.c
index f2ad83edf459fed77e436b8972c065e9a5195fdf..fee9d82995d7d67edb94313bf2176e50cb2521a5 100644 (file)
@@ -480,21 +480,26 @@ void PRVM_ChildProfile_f (void)
        PRVM_Profile(prog, howmany, 0, 1);
 }
 
-void PRVM_PrintState(prvm_prog_t *prog)
+void PRVM_PrintState(prvm_prog_t *prog, int stack_index)
 {
        int i;
+       mfunction_t *func = prog->xfunction;
+       int st = prog->xstatement;
+       if (stack_index > 0 && stack_index <= prog->depth)
+       {
+               func = prog->stack[prog->depth - stack_index].f;
+               st = prog->stack[prog->depth - stack_index].s;
+       }
        if (prog->statestring)
        {
                Con_Printf("Caller-provided information: %s\n", prog->statestring);
        }
-       if (prog->xfunction)
+       if (func)
        {
                for (i = -7; i <= 0;i++)
-                       if (prog->xstatement + i >= prog->xfunction->first_statement)
-                               PRVM_PrintStatement(prog, prog->statements + prog->xstatement + i);
+                       if (st + i >= func->first_statement)
+                               PRVM_PrintStatement(prog, prog->statements + st + i);
        }
-       else
-               Con_Print("null function executing??\n");
        PRVM_StackTrace(prog);
 }
 
@@ -512,7 +517,7 @@ void PRVM_Crash(prvm_prog_t *prog)
        if( prog->depth > 0 )
        {
                Con_Printf("QuakeC crash report for %s:\n", prog->name);
-               PRVM_PrintState(prog);
+               PRVM_PrintState(prog, 0);
        }
 
        if(prvm_errordump.integer)
@@ -657,6 +662,7 @@ extern cvar_t prvm_statementprofiling;
 extern qboolean prvm_runawaycheck;
 
 #ifdef PROFILING
+#ifdef CONFIG_MENU
 /*
 ====================
 MVM_ExecuteProgram
@@ -672,6 +678,20 @@ void MVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessag
        int             restorevm_tempstringsbuf_cursize;
        double  calltime;
        double tm, starttm;
+       prvm_vec_t tempfloat;
+       // these may become out of date when a builtin is called, and are updated accordingly
+       prvm_vec_t *cached_edictsfields = prog->edictsfields;
+       unsigned int cached_entityfields = prog->entityfields;
+       unsigned int cached_entityfields_3 = prog->entityfields - 3;
+       unsigned int cached_entityfieldsarea = prog->entityfieldsarea;
+       unsigned int cached_entityfieldsarea_entityfields = prog->entityfieldsarea - prog->entityfields;
+       unsigned int cached_entityfieldsarea_3 = prog->entityfieldsarea - 3;
+       unsigned int cached_entityfieldsarea_entityfields_3 = prog->entityfieldsarea - prog->entityfields - 3;
+       unsigned int cached_max_edicts = prog->max_edicts;
+       // these do not change
+       mstatement_t *cached_statements = prog->statements;
+       qboolean cached_allowworldwrites = prog->allowworldwrites;
+       unsigned int cached_flag = prog->flag;
 
        calltime = Sys_DirtyTime();
 
@@ -706,7 +726,7 @@ void MVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessag
 
 chooseexecprogram:
        cachedpr_trace = prog->trace;
-       if (prvm_statementprofiling.integer || prog->trace)
+       if (prvm_statementprofiling.integer || prog->trace || prog->watch_global >= 0 || prog->watch_edict >= 0 || prog->break_statement >= 0)
        {
 #define PRVMSLOWINTERPRETER 1
                if (prvm_timeprofiling.integer)
@@ -747,6 +767,7 @@ cleanup:
        if (prog == SVVM_prog)
                SV_FlushBroadcastMessages();
 }
+#endif
 
 /*
 ====================
@@ -763,6 +784,20 @@ void CLVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessa
        int             restorevm_tempstringsbuf_cursize;
        double  calltime;
        double tm, starttm;
+       prvm_vec_t tempfloat;
+       // these may become out of date when a builtin is called, and are updated accordingly
+       prvm_vec_t *cached_edictsfields = prog->edictsfields;
+       unsigned int cached_entityfields = prog->entityfields;
+       unsigned int cached_entityfields_3 = prog->entityfields - 3;
+       unsigned int cached_entityfieldsarea = prog->entityfieldsarea;
+       unsigned int cached_entityfieldsarea_entityfields = prog->entityfieldsarea - prog->entityfields;
+       unsigned int cached_entityfieldsarea_3 = prog->entityfieldsarea - 3;
+       unsigned int cached_entityfieldsarea_entityfields_3 = prog->entityfieldsarea - prog->entityfields - 3;
+       unsigned int cached_max_edicts = prog->max_edicts;
+       // these do not change
+       mstatement_t *cached_statements = prog->statements;
+       qboolean cached_allowworldwrites = prog->allowworldwrites;
+       unsigned int cached_flag = prog->flag;
 
        calltime = Sys_DirtyTime();
 
@@ -797,7 +832,7 @@ void CLVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessa
 
 chooseexecprogram:
        cachedpr_trace = prog->trace;
-       if (prvm_statementprofiling.integer || prog->trace)
+       if (prvm_statementprofiling.integer || prog->trace || prog->watch_global >= 0 || prog->watch_edict >= 0 || prog->break_statement >= 0)
        {
 #define PRVMSLOWINTERPRETER 1
                if (prvm_timeprofiling.integer)
@@ -859,6 +894,20 @@ void PRVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessa
        int             restorevm_tempstringsbuf_cursize;
        double  calltime;
        double tm, starttm;
+       prvm_vec_t tempfloat;
+       // these may become out of date when a builtin is called, and are updated accordingly
+       prvm_vec_t *cached_edictsfields = prog->edictsfields;
+       unsigned int cached_entityfields = prog->entityfields;
+       unsigned int cached_entityfields_3 = prog->entityfields - 3;
+       unsigned int cached_entityfieldsarea = prog->entityfieldsarea;
+       unsigned int cached_entityfieldsarea_entityfields = prog->entityfieldsarea - prog->entityfields;
+       unsigned int cached_entityfieldsarea_3 = prog->entityfieldsarea - 3;
+       unsigned int cached_entityfieldsarea_entityfields_3 = prog->entityfieldsarea - prog->entityfields - 3;
+       unsigned int cached_max_edicts = prog->max_edicts;
+       // these do not change
+       mstatement_t *cached_statements = prog->statements;
+       qboolean cached_allowworldwrites = prog->allowworldwrites;
+       unsigned int cached_flag = prog->flag;
 
        calltime = Sys_DirtyTime();
 
@@ -893,7 +942,7 @@ void PRVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessa
 
 chooseexecprogram:
        cachedpr_trace = prog->trace;
-       if (prvm_statementprofiling.integer || prog->trace)
+       if (prvm_statementprofiling.integer || prog->trace || prog->watch_global >= 0 || prog->watch_edict >= 0 || prog->break_statement >= 0)
        {
 #define PRVMSLOWINTERPRETER 1
                if (prvm_timeprofiling.integer)