shithub: choc

Download patch

ref: bba2a845a5ce3b6aabbe6f801636910819302289
parent: 5803fe84945d0e1fb353df63b7f522e80d499561
author: Fabian Greffrath <fabian@greffrath.com>
date: Mon Nov 2 06:25:54 EST 2015

disk icon: Add a threshold for showing the disk icon

Only display the disk icon if more then the threshold of bytes
have been read during the previous tic.

--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -26,6 +26,7 @@
 
 #include "doomtype.h"
 
+#include "d_loop.h" // gametic
 #include "i_swap.h"
 #include "i_system.h"
 #include "i_video.h"
@@ -340,15 +341,32 @@
 {
     int c;
     lumpinfo_t *l;
+    static int lasttic, readbytes;
 
+    // Only display the disk icon if more then this much bytes have been read
+    // during the previous tic.
+
+    const int threshold = 20*1024;
+
     if (lump >= numlumps)
     {
         I_Error ("W_ReadLump: %i >= numlumps", lump);
     }
 
+    if (gametic > lasttic)
+    {
+        lasttic = gametic;
+        readbytes = 0;
+    }
+
     l = lumpinfo[lump];
 
-    disk_indicator = disk_on;
+    readbytes += l->size;
+
+    if (readbytes >= threshold)
+    {
+        disk_indicator = disk_on;
+    }
 
     c = W_Read(l->wad_file, l->position, dest, l->size);