1
0
Fork 0

Build with revised SGPropertyNode alias() API

This commit is contained in:
James Turner 2023-06-13 11:37:45 +01:00
parent 760fe3eee7
commit d3d4a8615a
9 changed files with 26 additions and 20 deletions

View file

@ -805,7 +805,7 @@ void FGAIBase::bind() {
// The property above was incorrectly labelled 'longitude-mode' up until
// FG 2018.4, so create an alias in case anyone is relying on the old name
auto node = props->getNode("controls/flight/longitude-mode", true);
node->alias(props->getNode("controls/flight/vertical-mode"));
node->alias(props->getNode("controls/flight/vertical-mode"), false);
props->setDoubleValue("controls/flight/target-alt", altitude_ft);
props->setDoubleValue("controls/flight/target-pitch", pitch);

View file

@ -248,7 +248,7 @@ void FGReplayInternal::init()
m_log_frame_times = fgGetNode("/sim/replay/log-frame-times", true);
// alias to keep backward compatibility
fgGetNode("/sim/freeze/replay-state", true)->alias(m_replay_master);
fgGetNode("/sim/freeze/replay-state", true)->alias(m_replay_master, false);
reinit();
}

View file

@ -198,7 +198,7 @@ FGJSBsim::FGJSBsim( double dt )
// deprecate sim-time-sec for simulation/sim-time-sec
// remove alias with increased configuration file version number (2.1 or later)
SGPropertyNode * node = fgGetNode("/fdm/jsbsim/simulation/sim-time-sec");
fgGetNode("/fdm/jsbsim/sim-time-sec", true)->alias( node );
fgGetNode("/fdm/jsbsim/sim-time-sec", true)->alias(node, false);
// end of sim-time-sec deprecation patch
_ai_wake_enabled = fgGetNode("fdm/ai-wake/enabled", true);

View file

@ -115,7 +115,7 @@ void FGFDM::init()
_gross_weight_lbs = _yasimN->getNode("gross-weight-lbs", true);
// alias to older name
fgGetNode("/yasim/gross-weight-lbs", true)->alias(_gross_weight_lbs);
fgGetNode("/yasim/gross-weight-lbs", true)->alias(_gross_weight_lbs, false);
// write some compile time information to property tree
_yasimN->getNode("config-version",true)->setIntValue(_airplane.getVersion());

View file

@ -155,7 +155,7 @@ GPS::init ()
// waypoints
// for compatibility, alias selected course down to wp/wp[1]/desired-course-deg
SGPropertyNode* wp1Crs = _currentWayptNode->getChild("desired-course-deg", 0, true);
wp1Crs->alias(_gpsNode->getChild("desired-course-deg", 0, true));
wp1Crs->alias(_gpsNode->getChild("desired-course-deg", 0, true), true);
_tracking_bug_node = _gpsNode->getChild("tracking-bug", 0, true);
@ -167,10 +167,10 @@ GPS::init ()
// navradio slaving properties
SGPropertyNode* toFlag = _gpsNode->getChild("to-flag", 0, true);
toFlag->alias(_currentWayptNode->getChild("to-flag"));
toFlag->alias(_currentWayptNode->getChild("to-flag"), true);
SGPropertyNode* fromFlag = _gpsNode->getChild("from-flag", 0, true);
fromFlag->alias(_currentWayptNode->getChild("from-flag"));
fromFlag->alias(_currentWayptNode->getChild("from-flag"), true);
// autopilot drive properties
_apDrivingFlag = fgGetNode("/autopilot/settings/gps-driving-true-heading", true);

View file

@ -266,7 +266,7 @@ FGNavRadio::init ()
// dme-in-range is deprecated,
// temporarily create dme-in-range alias for instrumentation/dme[0]/in-range
// remove after flightgear 2.6.0
node->getNode( "dme-in-range", true )->alias( fgGetNode("/instrumentation/dme[0]/in-range", true ) );
node->getNode("dme-in-range", true)->alias(fgGetNode("/instrumentation/dme[0]/in-range", true), false);
}
void

View file

@ -147,9 +147,9 @@ void Transponder::init()
if (_kt70Compat) {
// alias the properties through
SGPropertyNode_ptr output = node->getChild("outputs", 0, true);
output->getChild("flight-level", 0, true)->alias(_altitude_node);
output->getChild("id-code", 0, true)->alias(_idCode_node);
in_node->getChild("func-knob", 0, true)->alias(_knob_node);
output->getChild("flight-level", 0, true)->alias(_altitude_node, true);
output->getChild("id-code", 0, true)->alias(_idCode_node, true);
in_node->getChild("func-knob", 0, true)->alias(_knob_node, true);
}
}

View file

@ -1864,7 +1864,7 @@ naRef FGNasalSys::setListener(naContext c, int argc, naRef* args)
return naNil();
}
if (node->isTied()) {
if (node->isTied() || node->isAlias()) {
const auto isSafe = node->getAttribute(SGPropertyNode::LISTENER_SAFE);
if (!isSafe) {
SG_LOG(SG_NASAL, SG_DEV_ALERT, "ERROR: Cannot add listener to tied property " <<

View file

@ -801,12 +801,18 @@ static naRef f_alias(naContext c, naRef me, int argc, naRef* args)
try {
if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true);
else if(naIsGhost(prop)) al = static_cast<SGPropertyNode*>(naGhost_ptr(prop));
else throw string("props.alias() with bad argument");
} catch (const string& err) {
naRuntimeError(c, (char *)err.c_str());
else
throw sg_exception("props.alias() with bad argument");
} catch (sg_exception& err) {
naRuntimeError(c, err.what());
return naNil();
}
return naNum(node->alias(al));
bool withListeners = false;
if (naVec_size(argv) > 1) {
withListeners = static_cast<int>(naVec_get(argv, 1).num) != 0;
}
return naNum(node->alias(al, withListeners));
}