X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fgps.cxx;h=2d448f575a94e833c409ce80247ef0c409c470bd;hb=73fbc05a6b6af52825c792902d7738f9cad7ec2f;hp=913aba769ad969de3ac368b9a1fa9f9f0316f7c3;hpb=69b2c0b6973d8f60620e7ea232deaaf98c558c82;p=flightgear.git diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 913aba769..2d448f575 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -11,9 +11,9 @@ #include #include -#include "Main/fg_props.hxx" -#include "Main/util.hxx" // for fgLowPass -#include "Navaids/positioned.hxx" +#include
+#include
// for fgLowPass +#include #include #include @@ -479,20 +479,14 @@ GPS::updateTTWNode(UpdateContext& ctx, double distance_m, SGPropertyNode_ptr nod if (ctx.speed_kt > 0.0 && distance_m > 0.0) { TTW = (distance_m * SG_METER_TO_NM) / (ctx.speed_kt / 3600); } - - unsigned int TTW_seconds = (int) (TTW + 0.5); - if (TTW_seconds < 356400) { // That's 99 hours + if (TTW < 356400.5) { // That's 99 hours + unsigned int TTW_seconds = (int) (TTW + 0.5); unsigned int TTW_minutes = 0; unsigned int TTW_hours = 0; char TTW_str[9]; - while (TTW_seconds >= 3600) { - TTW_seconds -= 3600; - TTW_hours++; - } - while (TTW_seconds >= 60) { - TTW_seconds -= 60; - TTW_minutes++; - } + TTW_hours = TTW_seconds / 3600; + TTW_minutes = (TTW_seconds / 60) % 60; + TTW_seconds = TTW_seconds % 60; snprintf(TTW_str, 9, "%02d:%02d:%02d", TTW_hours, TTW_minutes, TTW_seconds); node->setStringValue(TTW_str);