]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/heading_indicator.cxx
Compile with MSVC 9
[flightgear.git] / src / Instrumentation / heading_indicator.cxx
index 53046480a5e1826155730e6d2f358f56c923cfc4..2cbbb9f2469b31e9fbf2dd39e318d24a17d8d3fa 100644 (file)
@@ -3,6 +3,10 @@
 //
 // This file is in the Public Domain and comes with no warranty.
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <simgear/compiler.h>
 #include <simgear/sg_inlines.h>
 #include <iostream>
@@ -13,6 +17,7 @@
 #include <Main/fg_props.hxx>
 #include <Main/util.hxx>
 
+#include <simgear/magvar/magvar.hxx>
 
 HeadingIndicator::HeadingIndicator ( SGPropertyNode *node )
     :
@@ -29,11 +34,14 @@ HeadingIndicator::~HeadingIndicator ()
 void
 HeadingIndicator::init ()
 {
-    string branch;
+    std::string branch;
     branch = "/instrumentation/" + _name;
 
     SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
-    _offset_node = node->getChild("offset-deg", 0, true);
+    if( NULL == (_offset_node = node->getChild("offset-deg", 0, false)) ) {
+      _offset_node = node->getChild("offset-deg", 0, true);
+      _offset_node->setDoubleValue( -globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES );
+    }
     _heading_in_node = fgGetNode("/orientation/heading-deg", true);
     _suction_node = fgGetNode(_suction.c_str(), true);
     _heading_out_node = node->getChild("indicated-heading-deg", 0, true);
@@ -47,7 +55,7 @@ void
 HeadingIndicator::bind ()
 {
     std::ostringstream temp;
-    string branch;
+    std::string branch;
     temp << _num;
     branch = "/instrumentation/" + _name + "[" + temp.str() + "]";
 
@@ -61,7 +69,7 @@ void
 HeadingIndicator::unbind ()
 {
     std::ostringstream temp;
-    string branch;
+    std::string branch;
     temp << _num;
     branch = "/instrumentation/" + _name + "[" + temp.str() + "]";