On Friday 02 January 2009 18:32:58 Csaba Halász wrote:
> 0x00000000007e1c50 in GPS::updateTTWNode (this=0xce164c0,
> c...@0x7fff664fdee0, distance_m=12822604.584446406,
> no...@0x7fff664fddd0) at src/Instrumentation/gps.cxx:483
> 483         unsigned int TTW_seconds = (int) (TTW + 0.5);
> (gdb) p TTW
> $10 = 62278235905.950584
>
> Not sure what it is calculating anyway.  This happened with the
> hurricane just at startup.
> And all the "while" loops look silly too.

Please apply this patch to extract the hours minutes and seconds without using 
silly while loops.


-- 
Roy Vegard Ovesen
diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx
index 913aba7..424ed3e 100644
--- a/src/Instrumentation/gps.cxx
+++ b/src/Instrumentation/gps.cxx
@@ -485,14 +485,9 @@ GPS::updateTTWNode(UpdateContext& ctx, double distance_m, SGPropertyNode_ptr nod
       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);
------------------------------------------------------------------------------
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to