From: curt Date: Fri, 5 Jan 2001 16:04:21 +0000 (+0000) Subject: 1. Patched simgear/magvar/magvar.[ch]xx to allow retrieval of the X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=60e61a0627fe06b2472006b1e05e79a2686b2409;p=simgear.git 1. Patched simgear/magvar/magvar.[ch]xx to allow retrieval of the magnetic variation for a specific location and date without running an update cycle (I use this for setting up VOR default offsets in some FlightGear patches). 2. [CRITICAL] Fixed some null-pointer bugs in simgear/misc/props.cxx. --- diff --git a/simgear/magvar/magvar.cxx b/simgear/magvar/magvar.cxx index 01e44e79..f078aae5 100644 --- a/simgear/magvar/magvar.cxx +++ b/simgear/magvar/magvar.cxx @@ -49,3 +49,8 @@ void SGMagVar::update( double lon, double lat, double alt_m, double jd ) { magdip = atan(field[5]/sqrt(field[3]*field[3]+field[4]*field[4])); } + +double sgGetMagVar( double lon, double lat, double alt_m, double jd ) { + double field[6]; + return calc_magvar( lat, lon, alt_m / 1000.0, (long)jd, field ); +} diff --git a/simgear/magvar/magvar.hxx b/simgear/magvar/magvar.hxx index a08ea98c..a270f5a2 100644 --- a/simgear/magvar/magvar.hxx +++ b/simgear/magvar/magvar.hxx @@ -55,4 +55,9 @@ public: }; -#endif // _LIGHT_HXX +// lookup the magvar for any arbitrary location (doesn't save state +// and note that this is a fair amount of cpu work) +double sgGetMagVar( double lon, double lat, double alt_m, double jd ); + + +#endif // _MAGVAR_HXX diff --git a/simgear/misc/props.cxx b/simgear/misc/props.cxx index 0e888871..d1d69678 100644 --- a/simgear/misc/props.cxx +++ b/simgear/misc/props.cxx @@ -1,4 +1,4 @@ -// props.hxx - interface definition for a property list. +// props.cxx - implementation of a property list. // Started Fall 2000 by David Megginson, david@megginson.com // This code is released into the Public Domain. // @@ -1050,31 +1050,41 @@ SGPropertyNode::isTied () const bool SGPropertyNode::tie (const SGRawValue &rawValue, bool useDefault) { - return (_value == 0 ? false : _value->tie(rawValue, useDefault)); + if (_value == 0) + _value = new SGValue(); + return _value->tie(rawValue, useDefault); } bool SGPropertyNode::tie (const SGRawValue &rawValue, bool useDefault) { - return (_value == 0 ? false : _value->tie(rawValue, useDefault)); + if (_value == 0) + _value = new SGValue(); + return _value->tie(rawValue, useDefault); } bool SGPropertyNode::tie (const SGRawValue &rawValue, bool useDefault) { - return (_value == 0 ? false : _value->tie(rawValue, useDefault)); + if (_value == 0) + _value = new SGValue(); + return _value->tie(rawValue, useDefault); } bool SGPropertyNode::tie (const SGRawValue &rawValue, bool useDefault) { - return (_value == 0 ? false : _value->tie(rawValue, useDefault)); + if (_value == 0) + _value = new SGValue(); + return _value->tie(rawValue, useDefault); } bool SGPropertyNode::tie (const SGRawValue &rawValue, bool useDefault) { - return (_value == 0 ? false : _value->tie(rawValue, useDefault)); + if (_value == 0) + _value = new SGValue(); + return _value->tie(rawValue, useDefault); } bool @@ -1308,7 +1318,7 @@ SGPropertyNode::isTied (const string &relative_path) const bool SGPropertyNode::tie (const string &relative_path, const SGRawValue &rawValue, - bool useDefault = true) + bool useDefault) { return getNode(relative_path, true)->tie(rawValue, useDefault); } @@ -1320,7 +1330,7 @@ SGPropertyNode::tie (const string &relative_path, bool SGPropertyNode::tie (const string &relative_path, const SGRawValue &rawValue, - bool useDefault = true) + bool useDefault) { return getNode(relative_path, true)->tie(rawValue, useDefault); } @@ -1332,7 +1342,7 @@ SGPropertyNode::tie (const string &relative_path, bool SGPropertyNode::tie (const string &relative_path, const SGRawValue &rawValue, - bool useDefault = true) + bool useDefault) { return getNode(relative_path, true)->tie(rawValue, useDefault); } @@ -1344,7 +1354,7 @@ SGPropertyNode::tie (const string &relative_path, bool SGPropertyNode::tie (const string &relative_path, const SGRawValue &rawValue, - bool useDefault = true) + bool useDefault) { return getNode(relative_path, true)->tie(rawValue, useDefault); } @@ -1356,7 +1366,7 @@ SGPropertyNode::tie (const string &relative_path, bool SGPropertyNode::tie (const string &relative_path, const SGRawValue &rawValue, - bool useDefault = true) + bool useDefault) { return getNode(relative_path, true)->tie(rawValue, useDefault); }