]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/hud_ladr.cxx
Fix two bugs in the new autopilot code
[flightgear.git] / src / Cockpit / hud_ladr.cxx
index 4b3a881727b5eff0a4c9f6da0f94acfe0f8a9915..d56315b069e440e81976848f2878b98ef35676c8 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "hud.hxx"
 #include "panel.hxx"
-
+#include <Main/viewer.hxx>
 
 // FIXME
 extern float get_roll(void);
@@ -21,7 +21,7 @@ HudLadder::HudLadder(const SGPropertyNode *node) :
             node->getIntValue("height"),
             get_roll,
             get_pitch,                         // FIXME getter functions from cockpit.cxx
-            node->getBoolValue("working"),
+            node->getBoolValue("working", true),
             HUDS_RIGHT),
     width_units(int(node->getFloatValue("span_units"))),
     div_units(int(fabs(node->getFloatValue("division_units")))),
@@ -49,9 +49,10 @@ HudLadder::HudLadder(const SGPropertyNode *node) :
     // Invert to convert the "compression" factor to a
     // pixels-per-degree number.
     if (fgGetBool("/sim/hud/enable3d", true) && HUD_style == 1)
-        factor = (640./55.);
+        factor = 640.0 / 55.0;
 
-    SG_LOG(SG_INPUT, SG_INFO, "Done reading HudLadder instrument");    // TODO add name
+    SG_LOG(SG_INPUT, SG_BULK, "Done reading HudLadder instrument"
+            << node->getStringValue("name", "[unnamed]"));
 
     if (!width_units)
         width_units = 45;
@@ -61,11 +62,6 @@ HudLadder::HudLadder(const SGPropertyNode *node) :
 }
 
 
-HudLadder::~HudLadder()
-{
-}
-
-
 //
 //  Draws a climb ladder in the center of the HUD
 //
@@ -98,13 +94,13 @@ void HudLadder::draw(void)
     alpha = get_aoa();
     pla = get_throttleval();
 
-#ifdef ENABLE_SP_FMDS
+#ifdef ENABLE_SP_FDM
     int lgear, wown, wowm, ilcanclaw, ihook;
-    ilcanclaw = get_iaux2();
-    lgear = get_iaux3();
-    wown = get_iaux4();
-    wowm = get_iaux5();
-    ihook = get_iaux6();
+    ilcanclaw = fgGetInt("/fdm-ada/iaux2", 0);
+    lgear = fgGetInt("/fdm-ada/iaux3", 0);
+    wown = fgGetInt("/fdm-ada/iaux4", 0);
+    wowm = fgGetInt("/fdm-ada/iaux5", 0);;
+    ihook = fgGetInt("/fdm-ada/iaux6", 0);
 #endif
     float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES;
 
@@ -163,12 +159,12 @@ void HudLadder::draw(void)
     //****************************************************************
     //velocity vector reticle - computations
     if (velocity_vector) {
-        Vxx = get_Vx();
-        Vyy = get_Vy();
-        Vzz = get_Vz();
-        Axx = get_Ax();
-        Ayy = get_Ay();
-        Azz = get_Az();
+        Vxx = fgGetDouble("/velocities/north-relground-fps", 0.0);
+        Vyy = fgGetDouble("/velocities/east-relground-fps", 0.0);
+        Vzz = fgGetDouble("/velocities/down-relground-fps", 0.0);
+        Axx = fgGetDouble("/accelerations/ned/north-accel-fps_sec", 0.0);
+        Ayy = fgGetDouble("/accelerations/ned/east-accel-fps_sec", 0.0);
+        Azz = fgGetDouble("/accelerations/ned/down-accel-fps_sec", 0.0);
         psi = get_heading();
 
         if (psi > 180.0)
@@ -251,7 +247,7 @@ void HudLadder::draw(void)
         glVertex2f(vel_x, vel_y + 6);
         glEnd();
 
-#ifdef ENABLE_SP_FMDS
+#ifdef ENABLE_SP_FDM
         // OBJECT MOVING RETICLE
         // TYPE LINE
         // ATTRIB - ON CONDITION
@@ -299,7 +295,7 @@ void HudLadder::draw(void)
     // TYPE - SQUARE_BRACKET
     // ATTRIB - ON CONDITION
     // alpha bracket
-#ifdef ENABLE_SP_FMDS
+#ifdef ENABLE_SP_FDM
     if (alpha_bracket && ihook == 1) {
         glBegin(GL_LINE_STRIP);
         glVertex2f(vel_x - 20 , vel_y - (16 - alpha) * factor);
@@ -369,7 +365,7 @@ void HudLadder::draw(void)
     // OBJECT STATIC RETICLE
     // TYPE LINE
     // ATTRIB - ON CONDITION
-#ifdef ENABLE_SP_FMDS
+#ifdef ENABLE_SP_FDM
     if (energy_worm && ilcanclaw == 1) {
         glBegin(GL_LINE_STRIP);
         glVertex2f(-15, -134);
@@ -452,8 +448,8 @@ void HudLadder::draw(void)
         LineList.erase();
         StippleLineList.erase();
 
-        int last = FloatToInt(vmax) + 1;
-        int i = FloatToInt(vmin);
+        int last = float_to_int(vmax) + 1;
+        int i = float_to_int(vmin);
 
         if (!scr_hole) {
             x_end = half_span;
@@ -566,7 +562,7 @@ void HudLadder::draw(void)
             // TYPE LINE
             // ATTRIB - ON CONDITION
             // draw appraoch glide slope marker
-#ifdef ENABLE_SP_FMDS
+#ifdef ENABLE_SP_FDM
             if (glide_slope_marker && ihook) {
                 Line(-half_span + 15, (glide_slope-actslope) * factor,
                         -half_span + hole, (glide_slope - actslope) * factor);
@@ -594,15 +590,15 @@ void HudLadder::draw(void)
     //*************************************************************
 
     //*************************************************************
-#ifdef ENABLE_SP_FMDS
+#ifdef ENABLE_SP_FDM
     if (waypoint_marker) {
         //waypoint marker computation
         float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
 
         fromwp_lon = get_longitude() * SGD_DEGREES_TO_RADIANS;
         fromwp_lat = get_latitude() * SGD_DEGREES_TO_RADIANS;
-        towp_lon = get_aux2() * SGD_DEGREES_TO_RADIANS;
-        towp_lat = get_aux1() * SGD_DEGREES_TO_RADIANS;
+        towp_lon = fgGetDouble("/fdm-ada/ship-lon", 0.0) * SGD_DEGREES_TO_RADIANS;
+        towp_lat = fgGetDouble("/fdm-ada/ship-lat", 0.0) * SGD_DEGREES_TO_RADIANS;
 
         dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
                 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));