reset stack position when new progs loaded, or error occurs
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 14 Aug 2002 23:48:14 +0000 (23:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 14 Aug 2002 23:48:14 +0000 (23:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2243 d7cf8633-e32d-0410-b094-e92efae38249

pr_edict.c
pr_exec.c
progs.h

index bf35130..f0b3524 100644 (file)
@@ -1378,6 +1378,7 @@ void PR_LoadProgs (void)
        }
 
        FindEdictFieldOffsets(); // LordHavoc: update field offset list
+       PR_Execute_ProgsLoaded();
 }
 
 
index 113941a..eda7404 100644 (file)
--- a/pr_exec.c
+++ b/pr_exec.c
@@ -268,7 +268,9 @@ void PR_RunError (char *error, ...)
        PR_StackTrace ();
        Con_Printf ("%s\n", string);
 
-       pr_depth = 0;           // dump the stack so host_error can shutdown functions
+       // dump the stack so host_error can shutdown functions
+       pr_depth = 0;
+       localstack_used = 0;
 
        Host_Error ("Program error");
 }
@@ -354,6 +356,13 @@ int PR_LeaveFunction (void)
        return pr_stack[pr_depth].s;
 }
 
+void PR_Execute_ProgsLoaded(void)
+{
+       // dump the stack
+       pr_depth = 0;
+       localstack_used = 0;
+}
+
 /*
 ====================
 PR_ExecuteProgram
diff --git a/progs.h b/progs.h
index f8e1513..c456c89 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -177,6 +177,7 @@ extern      int                     pr_xstatement;
 extern unsigned short          pr_crc;
 
 void PR_RunError (char *error, ...);
+void PR_Execute_ProgsLoaded(void);
 
 void ED_PrintEdicts (void);
 void ED_PrintNum (int ent);