]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
graceful handling of stack underflows, or host_abortframe, during loading
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 5 Apr 2009 10:53:43 +0000 (10:53 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 5 Apr 2009 10:53:43 +0000 (10:53 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8871 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
host.c
screen.h

index 790887330f41d4d72d1f532caa10c480a8d863f2..3d75c0b828a22e42103922d161ff4eb5e33deedf 100644 (file)
@@ -1707,6 +1707,13 @@ void SCR_PushLoadingScreen (qboolean redraw, const char *msg, float len_in_paren
 void SCR_PopLoadingScreen (qboolean redraw)
 {
        loadingscreenstack_t *s = loadingscreenstack;
+
+       if(!s)
+       {
+               Con_DPrintf("Popping a loading screen item from an empty stack!\n");
+               return;
+       }
+
        loadingscreenstack = s->prev;
        if(s->prev)
                s->prev->relative_completion = (s->absolute_loading_amount_min + s->absolute_loading_amount_len - s->prev->absolute_loading_amount_min) / s->prev->absolute_loading_amount_len;
@@ -1716,6 +1723,12 @@ void SCR_PopLoadingScreen (qboolean redraw)
                SCR_UpdateLoadingScreenIfShown();
 }
 
+void SCR_ClearLoadingScreen (qboolean redraw)
+{
+       while(loadingscreenstack)
+               SCR_PopLoadingScreen(redraw && !loadingscreenstack->prev);
+}
+
 static float SCR_DrawLoadingStack_r(loadingscreenstack_t *s, float y)
 {
        float size = 8;
diff --git a/host.c b/host.c
index c8521f2753dd8300bb9e44c05d0aca2f44612d95..0dea16e6331cb012c86798ebca635b3631639d15 100644 (file)
--- a/host.c
+++ b/host.c
@@ -619,7 +619,10 @@ void Host_Main(void)
        for (;;)
        {
                if (setjmp(host_abortframe))
+               {
+                       SCR_ClearLoadingScreen(false);
                        continue;                       // something bad happened, or the server disconnected
+               }
 
                oldrealtime = realtime;
                realtime = Sys_DoubleTime();
index 3efbd7a98029cbd707eecd7d741d83879c5434d2..4a3330190d9394110d0072c835749b242c681eb0 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -35,6 +35,7 @@ void SCR_UpdateLoadingScreenIfShown();
 // pushes an item on the loading screen
 void SCR_PushLoadingScreen (qboolean redraw, const char *msg, float len_in_parent);
 void SCR_PopLoadingScreen (qboolean redraw);
+void SCR_ClearLoadingScreen (qboolean redraw);
 
 extern float scr_con_current; // current height of displayed console