]> git.mxchange.org Git - flightgear.git/commitdiff
- remove "nasal-dir-initialized" signal node after use. This code is executed
authormfranz <mfranz>
Tue, 23 Jan 2007 15:53:04 +0000 (15:53 +0000)
committermfranz <mfranz>
Tue, 23 Jan 2007 15:53:04 +0000 (15:53 +0000)
  before the property tree is stored away for reinit, so the signal would
  be emitted again on reset.
- fix inconsistent style that sneaked in with a previous patch

src/Scripting/NasalSys.cxx

index c486ce90ceef9cf55041011757bac05f6efa699e..9d04fb2952691e5d6cadc3753ad7592faab9596e 100644 (file)
@@ -82,7 +82,7 @@ naRef FGNasalSys::call(naRef code, naRef locals)
 FGNasalSys::~FGNasalSys()
 {
     map<int, FGNasalListener *>::iterator it, end = _listener.end();
-    for (it = _listener.begin(); it != end; ++it)
+    for(it = _listener.begin(); it != end; ++it)
         delete it->second;
 
     // Nasal doesn't have a "destroy context" API yet. :(
@@ -426,7 +426,12 @@ void FGNasalSys::init()
         loadModule(fullpath, file.base().c_str());
     }
     ulCloseDir(dir);
-    fgSetBool("/sim/signals/nasal-dir-initialized", true);
+
+    // set signal and remove node to avoid restoring at reinit
+    const char *s = "nasal-dir-initialized";
+    SGPropertyNode *signal = fgGetNode("/sim/signals", true);
+    signal->setBoolValue(s, true);
+    signal->removeChildren(s);
 
     // Pull scripts out of the property tree, too
     loadPropertyScripts();
@@ -662,7 +667,7 @@ naRef FGNasalSys::setListener(int argc, naRef* args)
     else if(naIsGhost(prop)) node = *(SGPropertyNode_ptr*)naGhost_ptr(prop);
     else return naNil();
 
-    if (node->isTied())
+    if(node->isTied())
         SG_LOG(SG_NASAL, SG_DEBUG, "Attaching listener to tied property " <<
                 node->getPath());
 
@@ -747,12 +752,12 @@ void FGNasalModelData::modelLoaded(const string& path, SGPropertyNode *prop,
                                    osg::Node *)
 {
     SGPropertyNode *n = prop->getNode("nasal"), *load;
-    if (!n)
+    if(!n)
         return;
 
     load = n->getNode("load");
     _unload = n->getNode("unload");
-    if (!load && !_unload)
+    if(!load && !_unload)
         return;
 
     _module = path;
@@ -763,17 +768,17 @@ void FGNasalModelData::modelLoaded(const string& path, SGPropertyNode *prop,
 
 FGNasalModelData::~FGNasalModelData()
 {
-    if (_module.empty())
+    if(_module.empty())
         return;
 
     FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
-    if (!nas) {
+    if(!nas) {
         SG_LOG(SG_NASAL, SG_ALERT, "Trying to run an <unload> script "
                 "without Nasal subsystem present.");
         return;
     }
 
-    if (_unload) {
+    if(_unload) {
         const char *s = _unload->getStringValue();
         nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s));
     }