]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
add cvar prvm_backtraceforwarning
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 1 Jan 2008 14:19:44 +0000 (14:19 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 1 Jan 2008 14:19:44 +0000 (14:19 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7887 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c
prvm_edict.c

index 7f099c469e64a7866c4837440a2e4b72cdaf5ca1..b7cae0d24e345234b08789055f888fcaed3820e4 100644 (file)
@@ -9,19 +9,28 @@
 #include "prvm_cmds.h"
 #include <time.h>
 
+extern cvar_t prvm_backtraceforwarnings;
+
 // LordHavoc: changed this to NOT use a return statement, so that it can be used in functions that must return a value
 void VM_Warning(const char *fmt, ...)
 {
        va_list argptr;
        char msg[MAX_INPUTLINE];
+       static double recursive = -1;
 
        va_start(argptr,fmt);
        dpvsnprintf(msg,sizeof(msg),fmt,argptr);
        va_end(argptr);
 
-       Con_Print(msg);
+       Con_Printf(msg);
+
        // TODO: either add a cvar/cmd to control the state dumping or replace some of the calls with Con_Printf [9/13/2006 Black]
-       //PRVM_PrintState();
+       if(prvm_backtraceforwarnings.integer && recursive != realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set
+       {
+               recursive = realtime;
+               PRVM_PrintState();
+               recursive = -1;
+       }
 }
 
 
index 64fae58b56e94fa49b7d2ad711f231d0745bc25f..f752f9e743f3d7116e1d022088719bca0569ccce 100644 (file)
@@ -37,6 +37,7 @@ cvar_t prvm_boundscheck = {0, "prvm_boundscheck", "1", "enables detection of out
 cvar_t prvm_traceqc = {0, "prvm_traceqc", "0", "prints every QuakeC statement as it is executed (only for really thorough debugging!)"};
 // LordHavoc: counts usage of each QuakeC statement
 cvar_t prvm_statementprofiling = {0, "prvm_statementprofiling", "0", "counts how many times each QuakeC statement has been executed, these counts are displayed in prvm_printfunction output (if enabled)"};
+cvar_t prvm_backtraceforwarnings = {0, "prvm_backtraceforwarnings", "0", "print a backtrace for warnings too"};
 
 extern sizebuf_t vm_tempstringsbuf;
 
@@ -2042,6 +2043,7 @@ void PRVM_Init (void)
        Cvar_RegisterVariable (&prvm_boundscheck);
        Cvar_RegisterVariable (&prvm_traceqc);
        Cvar_RegisterVariable (&prvm_statementprofiling);
+       Cvar_RegisterVariable (&prvm_backtraceforwarnings);
 
        //VM_Cmd_Init();
 }
@@ -2156,14 +2158,14 @@ const char *PRVM_GetString(int num)
                                return (char *)vm_tempstringsbuf.data + num;
                        else
                        {
-                               VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)", num, vm_tempstringsbuf.cursize);
+                               VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)\n", num, vm_tempstringsbuf.cursize);
                                return "";
                        }
                }
                else
 #endif
                {
-                       VM_Warning("PRVM_GetString: Invalid constant-string offset (%i >= %i prog->stringssize)", num, prog->stringssize);
+                       VM_Warning("PRVM_GetString: Invalid constant-string offset (%i >= %i prog->stringssize)\n", num, prog->stringssize);
                        return "";
                }
        }
@@ -2179,7 +2181,7 @@ const char *PRVM_GetString(int num)
                                return (char *)vm_tempstringsbuf.data + num;
                        else
                        {
-                               VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)", num, vm_tempstringsbuf.cursize);
+                               VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)\n", num, vm_tempstringsbuf.cursize);
                                return "";
                        }
                }
@@ -2188,12 +2190,12 @@ const char *PRVM_GetString(int num)
                if (num < prog->numknownstrings)
                {
                        if (!prog->knownstrings[num])
-                               VM_Warning("PRVM_GetString: Invalid zone-string offset (%i has been freed)", num);
+                               VM_Warning("PRVM_GetString: Invalid zone-string offset (%i has been freed)\n", num);
                        return prog->knownstrings[num];
                }
                else
                {
-                       VM_Warning("PRVM_GetString: Invalid zone-string offset (%i >= %i)", num, prog->numknownstrings);
+                       VM_Warning("PRVM_GetString: Invalid zone-string offset (%i >= %i)\n", num, prog->numknownstrings);
                        return "";
                }
        }