X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=prvm_exec.c;h=47ab908973b5058bde5b1b3f8e0e25963a05d6d0;hp=7ba8a1b2d1446e651b449e8b3d1eb5f3908a48a5;hb=701925453d9a40b422e3f29fd13e30fe59a9b572;hpb=f7942c3a41dbea29b68274312abf47c2755a7606 diff --git a/prvm_exec.c b/prvm_exec.c index 7ba8a1b2..47ab9089 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "quakedef.h" +#include "progsvm.h" char *prvm_opnames[] = { @@ -126,33 +127,33 @@ void PRVM_PrintStatement (dstatement_t *s) if ( (unsigned)s->op < sizeof(prvm_opnames)/sizeof(prvm_opnames[0])) { - Con_Printf ("%s ", prvm_opnames[s->op]); + Con_Printf("%s ", prvm_opnames[s->op]); i = strlen(prvm_opnames[s->op]); for ( ; i<10 ; i++) - Con_Printf (" "); + Con_Print(" "); } if (s->op == OP_IF || s->op == OP_IFNOT) - Con_Printf ("%sbranch %i",PRVM_GlobalString((unsigned short) s->a),s->b); + Con_Printf("%sbranch %i",PRVM_GlobalString((unsigned short) s->a),s->b); else if (s->op == OP_GOTO) { - Con_Printf ("branch %i",s->a); + Con_Printf("branch %i",s->a); } else if ( (unsigned)(s->op - OP_STORE_F) < 6) { - Con_Printf ("%s", PRVM_GlobalString((unsigned short) s->a)); - Con_Printf ("%s", PRVM_GlobalStringNoContents((unsigned short) s->b)); + Con_Print(PRVM_GlobalString((unsigned short) s->a)); + Con_Print(PRVM_GlobalStringNoContents((unsigned short) s->b)); } else { if (s->a) - Con_Printf ("%s", PRVM_GlobalString((unsigned short) s->a)); + Con_Print(PRVM_GlobalString((unsigned short) s->a)); if (s->b) - Con_Printf ("%s", PRVM_GlobalString((unsigned short) s->b)); + Con_Print(PRVM_GlobalString((unsigned short) s->b)); if (s->c) - Con_Printf ("%s", PRVM_GlobalStringNoContents((unsigned short) s->c)); + Con_Print(PRVM_GlobalStringNoContents((unsigned short) s->c)); } - Con_Printf ("\n"); + Con_Print("\n"); } /* @@ -172,9 +173,9 @@ void PRVM_StackTrace (void) f = prog->stack[i].f; if (!f) - Con_Printf ("\n"); + Con_Print("\n"); else - Con_Printf ("%12s : %s : statement %i\n", PRVM_GetString(f->s_file), PRVM_GetString(f->s_name), prog->stack[i].s - f->first_statement); + Con_Printf("%12s : %s : statement %i\n", PRVM_GetString(f->s_file), PRVM_GetString(f->s_name), prog->stack[i].s - f->first_statement); } } @@ -220,7 +221,7 @@ void PRVM_Profile_f (void) if (best) { //if (num < howmany) - Con_Printf ("%s: %7i %7i %s\n", PRVM_NAME, best->profile, best->builtinsprofile, PRVM_GetString(best->s_name)); + Con_Printf("%s: %7i %7i %s\n", PRVM_NAME, best->profile, best->builtinsprofile, PRVM_GetString(best->s_name)); num++; best->profile = 0; best->builtinsprofile = 0; @@ -246,10 +247,22 @@ void PRVM_CrashAll() prog = oldprog; } -void PRVM_Crash() +void PRVM_PrintState(void) { int i; - + if (prog->xfunction) + { + for (i = -7; i <= 0;i++) + if (prog->xstatement + i >= prog->xfunction->first_statement) + PRVM_PrintStatement (prog->statements + prog->xstatement + i); + } + else + Con_Print("null function executing??\n"); + PRVM_StackTrace (); +} + +void PRVM_Crash() +{ if (prog->depth < 1) { // kill the stack just to be sure @@ -259,15 +272,7 @@ void PRVM_Crash() } Con_Printf("QuakeC crash report for %s:\n", PRVM_NAME); - if (prog->xfunction) - { - for (i = -4;i <= 0;i++) - if (prog->xstatement + i >= prog->xfunction->first_statement) - PRVM_PrintStatement (prog->statements + prog->xstatement + i); - } - else - Con_Printf("null function executing??\n"); - PRVM_StackTrace (); + PRVM_PrintState(); // dump the stack so host_error can shutdown functions prog->depth = 0; @@ -386,10 +391,10 @@ void PRVM_ExecuteProgram (func_t fnum, const char *errormessage) prvm_eval_t *ptr; int profile, startprofile, cachedpr_trace, exitdepth; - if (!fnum || fnum >= prog->progs->numfunctions) + if (!fnum || fnum >= (unsigned int)prog->progs->numfunctions) { if (prog->self && PRVM_G_INT(prog->self->ofs)) - PRVM_ED_Print (PRVM_PROG_TO_EDICT(PRVM_G_INT(prog->self->ofs))); + PRVM_ED_Print(PRVM_PROG_TO_EDICT(PRVM_G_INT(prog->self->ofs))); PRVM_ERROR ("PR_ExecuteProgram: %s", errormessage); }