]> git.mxchange.org Git - flightgear.git/blobdiff - src/Aircraft/replay.cxx
Minor renaming issue.
[flightgear.git] / src / Aircraft / replay.cxx
index 7ef44c20205f8fb3b486693cdc04a14856d03297..f44d38b88234f743dcf5c45040d7b0fd7c74e22e 100644 (file)
@@ -173,19 +173,26 @@ printTimeStr(char* pStrBuffer,double _Time, bool ShowDecimal=true)
 {
     if (_Time<0)
         _Time = 0;
-    unsigned int Time = (unsigned int) (_Time*10);
-    int h = Time/36000;
-    int m = (Time % 36000)/600;
-    int s = (Time % 600)/10;
-    int d = Time % 10;
+    unsigned int Time = _Time*10;
+    unsigned int h = Time/36000;
+    unsigned int m = (Time % 36000)/600;
+    unsigned int s = (Time % 600)/10;
+    unsigned int d = Time % 10;
+
+    int len;
     if (h>0)
-        sprintf(pStrBuffer,"%u:%02u",h,m);
+        len = sprintf(pStrBuffer,"%u:%02u:%02u",h,m,s);
     else
-        sprintf(pStrBuffer,"%u",m);
+        len = sprintf(pStrBuffer,"%u:%02u",m,s);
+
+    if (len < 0)
+    {
+        *pStrBuffer = 0;
+        return;
+    }
+
     if (ShowDecimal)
-        sprintf(pStrBuffer,"%s:%02u.%u",pStrBuffer,s,d);
-    else
-        sprintf(pStrBuffer,"%s:%02u",pStrBuffer,s);
+        sprintf(&pStrBuffer[len],".%u",d);
 }
 
 /** Start replay session
@@ -295,7 +302,8 @@ FGReplay::update( double dt )
         {
             // replay active
             double current_time = replay_time->getDoubleValue();
-            if (current_time<=0.0)
+            bool ResetTime = (current_time<=0.0);
+            if (ResetTime)
             {
                 // initialize start time
                 double startTime = get_start_time();
@@ -318,6 +326,11 @@ FGReplay::update( double dt )
             char StrBuffer[30];
             printTimeStr(StrBuffer,current_time);
             replay_time_str->setStringValue((const char*)StrBuffer);
+
+            // when time skipped (looped replay), trigger listeners to reset views etc
+            if (ResetTime)
+                replay_master->setIntValue(replay_state);
+
             return; // don't record the replay session 
         }
         case 2: // normal replay operation