]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.cxx
FGNasalModelData: use model XML path as module source
[flightgear.git] / src / Scripting / NasalSys.cxx
index a41179366142f0afd823fa66d556db536c4b5afd..215f007015ae8b05bf3dad54182d6d047bcab6c3 100644 (file)
@@ -12,6 +12,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fstream>
+#include <sstream>
 
 #include <plib/ul.h>
 
@@ -1099,6 +1100,8 @@ bool FGNasalListener::changed(SGPropertyNode* node)
 // destructor the <unload> script. The latter happens when the model branch
 // is removed from the scene graph.
 
+unsigned int FGNasalModelData::_module_id = 0;
+
 void FGNasalModelData::modelLoaded(const string& path, SGPropertyNode *prop,
                                    osg::Node *)
 {
@@ -1113,15 +1116,16 @@ void FGNasalModelData::modelLoaded(const string& path, SGPropertyNode *prop,
     if(!load && !_unload)
         return;
 
-    _module = path;
-    if(_props)
-        _module += ':' + _props->getPath();
+    std::stringstream m;
+    m << "__model" << _module_id++;
+    _module = m.str();
+
     const char *s = load ? load->getStringValue() : "";
 
     naRef arg[2];
     arg[0] = nasalSys->propNodeGhost(_root);
     arg[1] = nasalSys->propNodeGhost(prop);
-    nasalSys->createModule(_module.c_str(), _module.c_str(), s, strlen(s),
+    nasalSys->createModule(_module.c_str(), path.c_str(), s, strlen(s),
                            _root, 2, arg);
     _props = 0;
 }