foxygit / doom Log in
commit 7510c7488be938826fc93630560ccd985c69545b
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Mon Sep 7 11:25:46 2015 +0200
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Mon Sep 7 11:25:46 2015 +0200

    condense checks for drawing disk icon and redrawing HUD into one variable
---
 src/doom/d_main.c   | 14 +-------------
 src/i_video.c       | 10 +++++++---
 src/strife/d_main.c |  9 +--------
 src/w_wad.c         |  4 ++--
 src/w_wad.h         |  9 ++++++++-
 5 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index 48241d3c..b5ce5bc3 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -182,17 +182,10 @@ void D_Display (void)
     boolean			done;
     boolean			wipe;
     boolean			redrawsbar;
-    static boolean force_redrawsbar = false;

     if (nodrawers)
 	return;                    // for comparative timing / profiling

-    if (force_redrawsbar)
-    {
-	redrawsbar = true;
-	force_redrawsbar = false;
-    }
-    else
     redrawsbar = false;

     // change the view size if needed
@@ -223,7 +216,7 @@ void D_Display (void)
 	    break;
 	if (automapactive)
 	    AM_Drawer ();
-	if (wipe || (viewheight != 200 && fullscreen) )
+	if (wipe || (viewheight != 200 && fullscreen) || disk_indicator == disk_dirty )
 	    redrawsbar = true;
 	if (inhelpscreensstate && !inhelpscreens)
 	    redrawsbar = true;              // just put away the help screen
@@ -310,11 +303,6 @@ void D_Display (void)
     // normal update
     if (!wipe)
     {
-	if (disk_indicator)
-	{
-	    force_redrawsbar = true;
-	}
-
 	I_FinishUpdate ();              // page flip or blit buffer
 	return;
     }
diff --git a/src/i_video.c b/src/i_video.c
index 48a0594b..e1224eb3 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -986,13 +986,17 @@ void I_FinishUpdate (void)
 	    I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
     }

-    if (disk_indicator)
+    if (disk_indicator == disk_on)
     {
 	I_BeginRead();
-	disk_indicator = false;
+	disk_indicator = disk_dirty;
+    }
+    else if (disk_indicator == disk_dirty)
+    {
+	disk_indicator = disk_off;
     }

-    // draw to screen
+   // draw to screen

     BlitArea(0, 0, SCREENWIDTH, SCREENHEIGHT);

diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index 4353b640..0018e8ce 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -217,7 +217,6 @@ void D_Display (void)
     boolean                     done;
     boolean                     wipe;
     boolean                     redrawsbar;
-    static boolean force_borderdraw = false;

     if (nodrawers)
         return;                    // for comparative timing / profiling
@@ -301,11 +300,10 @@ void D_Display (void)
     // see if the border needs to be updated to the screen
     if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320)
     {
-        if (menuactive || menuactivestate || !viewactivestate || force_borderdraw)
+        if (menuactive || menuactivestate || !viewactivestate || disk_indicator == disk_dirty)
         {
             borderdrawcount = 3;
             popupactivestate = false;
-            force_borderdraw = false;
         }
         if (borderdrawcount)
         {
@@ -360,11 +358,6 @@ void D_Display (void)
     // normal update
     if (!wipe)
     {
-        if (disk_indicator)
-        {
-            force_borderdraw = true;
-        }
-
         I_FinishUpdate ();              // page flip or blit buffer
         return;
     }
diff --git a/src/w_wad.c b/src/w_wad.c
index 21c9c0bd..8831f0f1 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -335,7 +335,7 @@ int W_LumpLength(lumpindex_t lump)
 // Loads the lump into the given buffer,
 //  which must be >= W_LumpLength().
 //
-boolean disk_indicator = false;
+disk_indicator_e disk_indicator = false;

 void W_ReadLump(lumpindex_t lump, void *dest)
 {
@@ -349,7 +349,7 @@ void W_ReadLump(lumpindex_t lump, void *dest)

     l = lumpinfo[lump];

-    disk_indicator = true;
+    disk_indicator = disk_on;

     c = W_Read(l->wad_file, l->position, dest, l->size);

diff --git a/src/w_wad.h b/src/w_wad.h
index 03bae344..6a07c78f 100644
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -49,10 +49,17 @@ struct lumpinfo_s
     lumpindex_t next;
 };

+typedef enum
+{
+    disk_off,
+    disk_on,
+    disk_dirty
+} disk_indicator_e;
+
+extern disk_indicator_e disk_indicator;

 extern lumpinfo_t **lumpinfo;
 extern unsigned int numlumps;
-extern boolean disk_indicator;

 wad_file_t *W_AddFile(char *filename);
 void W_Reload(void);