DEADSOFTWARE

gfx: cleaned up and fixed progress update code (it was broken; oops)
[d2df-sdl.git] / src / game / g_window.pas
index b8d0921b589b98eb4190e598cd1f8ea32766a41f..b0c06786a82ac434609231d0d69d835d60e04256 100644 (file)
@@ -2,8 +2,7 @@
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -65,7 +64,7 @@ uses
 
 
 const
-  ProgressUpdateMSecs = 1;//100;
+  ProgressUpdateMSecs = 35; //1;//100;
 
 var
   h_Wnd: PSDL_Window = nil;
@@ -783,8 +782,10 @@ begin
 end;
 
 
+{$IFNDEF HEADLESS}
 var
   prevLoadingUpdateTime: UInt64 = 0;
+{$ENDIF}
 
 procedure ProcessLoading (forceUpdate: Boolean=false);
 var
@@ -807,23 +808,15 @@ begin
     exit;
   end;
 
+{$IFNDEF HEADLESS}
   if not wMinimized then
   begin
-    if forceUpdate then
-    begin
-      prevLoadingUpdateTime := getTimeMilli();
-    end
-    else
+    if not forceUpdate then
     begin
       stt := getTimeMilli();
-      if (stt < prevLoadingUpdateTime) or (stt-prevLoadingUpdateTime >= ProgressUpdateMSecs) then
-      begin
-        prevLoadingUpdateTime := stt;
-        forceUpdate := true;
-      end;
+      forceUpdate := (stt < prevLoadingUpdateTime) or (stt-prevLoadingUpdateTime >= ProgressUpdateMSecs);
     end;
 
-{$IFNDEF HEADLESS}
     if forceUpdate then
     begin
       DrawMenuBackground('INTER');
@@ -832,9 +825,10 @@ begin
       DrawLoadingStat();
       g_Console_Draw(True);
       SwapBuffers();
+      prevLoadingUpdateTime := getTimeMilli();
     end;
-{$ENDIF}
   end;
+{$ENDIF}
 
   e_SoundUpdate();