]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.cxx
Kill off some unnecessary log messages.
[flightgear.git] / src / Scripting / NasalSys.cxx
index 58a9417dc5ebb65c7264447a36a740a662884ea9..a0ebb47046efce309adcfe9d1e8099755b3ad224 100644 (file)
@@ -45,7 +45,6 @@
 #include <Main/globals.hxx>
 #include <Main/util.hxx>
 #include <Main/fg_props.hxx>
-#include <Main/FGInterpolator.hxx>
 
 using std::map;
 
@@ -106,6 +105,8 @@ public:
     _sys->gcRelease(_gcSelf);
   }
   
+  bool isRunning() const { return _isRunning; }
+    
   void stop()
   {
     if (_isRunning) {
@@ -140,6 +141,9 @@ public:
   {
     naRef *args = NULL;
     _sys->callMethod(_func, _self, 0, args, naNil() /* locals */);
+    if (_singleShot) {
+      _isRunning = false;
+    }
   }
   
   void setSingleShot(bool aSingleShot)
@@ -513,19 +517,6 @@ static naRef f_cmdarg(naContext c, naRef me, int argc, naRef* args)
 // value/delta numbers.
 static naRef f_interpolate(naContext c, naRef me, int argc, naRef* args)
 {
-  FGInterpolator* mgr =
-    static_cast<FGInterpolator*>
-    (
-      globals->get_subsystem_mgr()
-             ->get_group(SGSubsystemMgr::INIT)
-             ->get_subsystem("prop-interpolator")
-    );
-  if( !mgr )
-  {
-    SG_LOG(SG_GENERAL, SG_WARN, "No property interpolator available");
-    return naNil();
-  };
-
   SGPropertyNode* node;
   naRef prop = argc > 0 ? args[0] : naNil();
   if(naIsString(prop)) node = fgGetNode(naStr_data(prop), true);
@@ -549,15 +540,7 @@ static naRef f_interpolate(naContext c, naRef me, int argc, naRef* args)
     deltas.push_back(naNumValue(naVec_get(curve, 2*i+1)).num);
   }
 
-  mgr->interpolate
-  (
-    node,
-    "numeric",
-    value_nodes,
-    deltas,
-    "linear"
-  );
-
+  node->interpolate("numeric", value_nodes, deltas, "linear");
   return naNil();
 }
 
@@ -805,7 +788,8 @@ void FGNasalSys::init()
       .method("start", &TimerObj::start)
       .method("stop", &TimerObj::stop)
       .method("restart", &TimerObj::restart)
-      .member("singleShot", &TimerObj::isSingleShot, &TimerObj::setSingleShot);
+      .member("singleShot", &TimerObj::isSingleShot, &TimerObj::setSingleShot)
+      .member("isRunning", &TimerObj::isRunning);
   
     // Now load the various source files in the Nasal directory
     simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal"));
@@ -838,8 +822,7 @@ naRef FGNasalSys::wrappedPropsNode(SGPropertyNode* aProps)
 {
     static naRef wrapNodeFunc = naNil();
     if (naIsNil(wrapNodeFunc)) {
-        nasal::Hash g(_globals, _context);
-        nasal::Hash props = g.get<nasal::Hash>("props");
+        nasal::Hash props = getGlobals().get<nasal::Hash>("props");
         wrapNodeFunc = props.get("wrapNode");
     }
     
@@ -861,8 +844,11 @@ void FGNasalSys::update(double)
 
     if (!_loadList.empty())
     {
-        // process Nasal load hook (only one per update loop to avoid excessive lags)
-        _loadList.pop()->load();
+        if( _delay_load )
+          _delay_load = false;
+        else
+          // process Nasal load hook (only one per update loop to avoid excessive lags)
+          _loadList.pop()->load();
     }
     else
     if (!_unloadList.empty())
@@ -1257,7 +1243,9 @@ naRef FGNasalSys::removeListener(naContext c, int argc, naRef* args)
 
 void FGNasalSys::registerToLoad(FGNasalModelData *data)
 {
-    _loadList.push(data);
+  if( _loadList.empty() )
+    _delay_load = true;
+  _loadList.push(data);
 }
 
 void FGNasalSys::registerToUnload(FGNasalModelData *data)