X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAircraft%2Freplay.cxx;h=f44d38b88234f743dcf5c45040d7b0fd7c74e22e;hb=f6207d5cb8eeb2ed83e1873dd2f621785832a3f3;hp=7ef44c20205f8fb3b486693cdc04a14856d03297;hpb=c6062ad93cf3bfbffb6dec63cd6844167bb56980;p=flightgear.git diff --git a/src/Aircraft/replay.cxx b/src/Aircraft/replay.cxx index 7ef44c202..f44d38b88 100644 --- a/src/Aircraft/replay.cxx +++ b/src/Aircraft/replay.cxx @@ -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