minor cleanup of timedemo code
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 20 Dec 2007 09:35:59 +0000 (09:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 20 Dec 2007 09:35:59 +0000 (09:35 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7826 d7cf8633-e32d-0410-b094-e92efae38249

cl_demo.c
client.h

index f6987f4..a375bbf 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -138,7 +138,7 @@ void CL_ReadDemoMessage(void)
        if (cls.demopaused)
                return;
 
-       while (1)
+       for (;;)
        {
                // decide if it is time to grab the next message
                // always grab until fully connected
@@ -146,25 +146,12 @@ void CL_ReadDemoMessage(void)
                {
                        if (cls.timedemo)
                        {
-                               if (host_framecount == cls.td_lastframe)
-                               {
-                                       // already read this frame's message
-                                       return;
-                               }
-                               if (cls.td_lastframe == -1)
-                               {
-                                       // render a couple frames before we start counting
-                                       cls.td_startframe = host_framecount + 3;
-                               }
-                               cls.td_lastframe = host_framecount;
+                               cls.td_frames++;
                                cls.td_onesecondframes++;
-                               // don't read any new messages during the warm-up period
-                               if (host_framecount < cls.td_startframe)
-                                       return;
                                // if this is the first official frame we can now grab the real
                                // td_starttime so the bogus time on the first frame doesn't
                                // count against the final report
-                               if (host_framecount == cls.td_startframe)
+                               if (cls.td_frames == 0)
                                {
                                        cls.td_starttime = realtime;
                                        cls.td_onesecondnexttime = realtime + 1;
@@ -216,6 +203,9 @@ void CL_ReadDemoMessage(void)
                        // In case the demo contains a "svc_disconnect" message
                        if (!cls.demoplayback)
                                return;
+
+                       if (cls.timedemo)
+                               return;
                }
                else
                {
@@ -395,8 +385,7 @@ void CL_FinishTimeDemo (void)
 
        cls.timedemo = false;
 
-// the first frame didn't count
-       frames = (host_framecount - cls.td_startframe) - 1;
+       frames = cls.td_frames;
        time = realtime - cls.td_starttime;
        totalfpsavg = time > 0 ? frames / time : 0;
        fpsmin = cls.td_onesecondminframes;
@@ -437,8 +426,8 @@ void CL_TimeDemo_f (void)
        scr_con_current = 0;
 
        cls.timedemo = true;
-       // get first message this frame
-       cls.td_lastframe = -1;
+       cls.td_frames = -2;             // skip the first frame
+       cls.demonum = -1;               // stop demo loop
        cls.demonum = -1;               // stop demo loop
 }
 
index 0d90697..7afb64e 100644 (file)
--- a/client.h
+++ b/client.h
@@ -512,12 +512,9 @@ typedef struct client_static_s
        // -1 = use normal cd track
        int forcetrack;
        qfile_t *demofile;
-       // to meter out one message a frame
-       int td_lastframe;
-       // host_framecount at start
-       int td_startframe;
        // realtime at second frame of timedemo (LordHavoc: changed to double)
        double td_starttime;
+       int td_frames; // total frames parsed
        double td_onesecondnexttime;
        double td_onesecondframes;
        double td_onesecondminframes;