]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_win.c
if the OS returns a very bogus time (or it wrapped), warn about it and keep ticking
[xonotic/darkplaces.git] / sys_win.c
index f239daf6b0aeb957b4f54f77f1e793c9da276b77..cc3b58be14335697be35ca22bf60a3001a854de9 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -178,6 +178,8 @@ SYSTEM IO
 ===============================================================================
 */
 
+void SleepUntilInput (int time);
+
 void Sys_Error (char *error, ...)
 {
        va_list         argptr;
@@ -324,12 +326,10 @@ double Sys_DoubleTime (void)
        }
 
        if (newtime < oldtime)
-               Con_Printf("Sys_DoubleTime: time running backwards??\n");
+               Con_Printf("Sys_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime);
        else
-       {
                curtime += newtime - oldtime;
-               oldtime = newtime;
-       }
+       oldtime = newtime;
 
        return curtime;
 }
@@ -465,7 +465,7 @@ static char *empty_string = "";
 
 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
-       double                  oldtime, newtime;
+       double                  frameoldtime, framenewtime;
        MEMORYSTATUS    lpBuffer;
        static  char    cwd[1024];
        int                             t;
@@ -568,7 +568,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
 
        Sys_Shared_LateInit();
 
-       oldtime = Sys_DoubleTime ();
+       frameoldtime = Sys_DoubleTime ();
 
        /* main window message loop */
        while (1)
@@ -585,9 +585,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                                SleepUntilInput (NOT_FOCUS_SLEEP);
                }
 
-               newtime = Sys_DoubleTime ();
-               Host_Frame (newtime - oldtime);
-               oldtime = newtime;
+               framenewtime = Sys_DoubleTime ();
+               Host_Frame (framenewtime - frameoldtime);
+               frameoldtime = framenewtime;
        }
 
        /* return success of application */