1
0
Fork 0

YASim: fix warnings from bind()

Add a version of fgUntie which is quiet, if the property does not
currently exist.
This commit is contained in:
James Turner 2021-04-21 21:56:33 +01:00
parent 8aec2710b6
commit fba1e9fa61
3 changed files with 30 additions and 5 deletions

View file

@ -94,11 +94,16 @@ void YASim::bind()
char buf[256];
for(int i=0; i<_fdm->getAirplane()->getModel()->numThrusters(); i++) {
sprintf(buf, "/engines/engine[%d]/fuel-flow-gph", i); fgUntie(buf);
sprintf(buf, "/engines/engine[%d]/rpm", i); fgUntie(buf);
sprintf(buf, "/engines/engine[%d]/mp-osi", i); fgUntie(buf);
sprintf(buf, "/engines/engine[%d]/egt-degf", i); fgUntie(buf);
sprintf(buf, "/engines/engine[%d]/oil-temperature-degf", i); fgUntie(buf);
sprintf(buf, "/engines/engine[%d]/fuel-flow-gph", i);
fgUntieIfDefined(buf);
sprintf(buf, "/engines/engine[%d]/rpm", i);
fgUntieIfDefined(buf);
sprintf(buf, "/engines/engine[%d]/mp-osi", i);
fgUntieIfDefined(buf);
sprintf(buf, "/engines/engine[%d]/egt-degf", i);
fgUntieIfDefined(buf);
sprintf(buf, "/engines/engine[%d]/oil-temperature-degf", i);
fgUntieIfDefined(buf);
}
}

View file

@ -720,5 +720,21 @@ fgUntie(const char * name)
}
}
void fgUntieIfDefined(const std::string& name)
{
SGPropertyNode* node = globals->get_props()->getNode(name);
if (!node) {
return;
}
if (!node->isTied()) {
return;
}
if (!node->untie()) {
SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
}
}
// end of fg_props.cxx

View file

@ -716,6 +716,10 @@ extern void fgSetWritable (const char * name, bool state = true);
*/
extern void fgUntie (const char * name);
/**
@brfief variant of the above which doesn't warn if the property does not exist
*/
void fgUntieIfDefined(const std::string& name);
/**
* Tie a property to a pair of simple functions.