]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/hud.cxx
Detect and recover from a math overflow that can possibly prevent panel text
[flightgear.git] / src / Cockpit / hud.cxx
index 88608312ca46d45ad0ea931c4496f667de9db13f..9d5f5272b64a44ba18be81017bf4208771119248 100644 (file)
 
 #include <GL/glut.h>
 #include <stdlib.h>
-#include <stdio.h>     //char related functions
+#include <stdio.h>             // char related functions
+#include <string.h>            // strcmp()
 #include STL_STRING
 #include STL_FSTREAM
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/props.hxx>
+#include <simgear/misc/sg_path.hxx>
 //#include <simgear/math/fg_random.h>
 //#include <simgear/math/polar3d.hxx>
 
@@ -391,6 +393,8 @@ readCard(const SGPropertyNode * node)
         load_fn = get_aileronval;
     } else if (loadfn=="elevatorval") {
         load_fn = get_elevatorval;
+    } else if (loadfn=="elevatortrimval") {
+        load_fn = get_elev_trimval;
     } else if (loadfn=="rudderval") {
         load_fn = get_rudderval;
     } else if (loadfn=="throttleval") {
@@ -644,10 +648,12 @@ readTBI(const SGPropertyNode * node)
 
 int readInstrument(const SGPropertyNode * node)
 {
+    static const SGPropertyNode *startup_units_node
+        = fgGetNode("/sim/startup/units");
 
     instr_item *HIptr;
     
-    if ( fgGetString("/sim/startup/units") == "feet" ) {
+    if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
         strcpy(units, " ft");
     } else {
         strcpy(units, " m");
@@ -1181,31 +1187,31 @@ void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
     // char scratch[128];
     // HUD_TextList.add( fgText( "AUTOPILOT", 20, apY) );
     // apY -= 15;
-    if( current_autopilot->get_HeadingEnabled() ) {
+    if( globals->get_autopilot()->get_HeadingEnabled() ) {
         HUD_TextList.add( fgText( 40, apY, 
-                                  current_autopilot->get_TargetHeadingStr()) );
+                                  globals->get_autopilot()->get_TargetHeadingStr()) );
         apY -= 15;
     }
-    if( current_autopilot->get_AltitudeEnabled() ) {
+    if( globals->get_autopilot()->get_AltitudeEnabled() ) {
         HUD_TextList.add( fgText( 40, apY, 
-                                  current_autopilot->get_TargetAltitudeStr()) );
+                                  globals->get_autopilot()->get_TargetAltitudeStr()) );
         apY -= 15;
     }
-    if( current_autopilot->get_HeadingMode() == 
+    if( globals->get_autopilot()->get_HeadingMode() == 
         FGAutopilot::FG_HEADING_WAYPOINT )
     {
         char *wpstr;
-        wpstr = current_autopilot->get_TargetWP1Str();
+        wpstr = globals->get_autopilot()->get_TargetWP1Str();
         if ( strlen( wpstr ) ) {
             HUD_TextList.add( fgText( 40, apY, wpstr ) );
             apY -= 15;
         }
-        wpstr = current_autopilot->get_TargetWP2Str();
+        wpstr = globals->get_autopilot()->get_TargetWP2Str();
         if ( strlen( wpstr ) ) {
             HUD_TextList.add( fgText( 40, apY, wpstr ) );
             apY -= 15;
         }
-        wpstr = current_autopilot->get_TargetWP3Str();
+        wpstr = globals->get_autopilot()->get_TargetWP3Str();
         if ( strlen( wpstr ) ) {
             HUD_TextList.add( fgText( 40, apY, wpstr ) );
                 apY -= 15;