#include <simgear/compiler.h>
#include <Aircraft/aircraft.hxx>
-#include "Main/fg_props.hxx"
-#include "Main/util.hxx" // for fgLowPass
-#include "Navaids/positioned.hxx"
+#include <Main/fg_props.hxx>
+#include <Main/util.hxx> // for fgLowPass
+#include <Navaids/positioned.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/sg_inlines.h>
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);