Howto:Disable Nasal entirely: Difference between revisions

Jump to navigation Jump to search
m
→‎Patch: find . -type f -name *.cxx -exec sed -i 's/(FGNasalSys\*) globals->get_subsystem("nasal")/globals->get_subsystem<FGNasalSys>()/g' {} \;
No edit summary
m (→‎Patch: find . -type f -name *.cxx -exec sed -i 's/(FGNasalSys\*) globals->get_subsystem("nasal")/globals->get_subsystem<FGNasalSys>()/g' {} \;)
Line 131: Line 131:


<syntaxhighlight lang="diff">diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx
<syntaxhighlight lang="diff">diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx
index 4faf23e..e09db60 100644
index 4faf23e..38c38b2 100644
--- a/src/AIModel/AIManager.cxx
--- a/src/AIModel/AIManager.cxx
+++ b/src/AIModel/AIManager.cxx
+++ b/src/AIModel/AIManager.cxx
@@ -72,6 +72,10 @@ public:
@@ -71,7 +71,11 @@ public:
        _unloadScript = nasalScripts->getStringValue("unload");
         std::string loadScript = nasalScripts->getStringValue("load");
         std::string loadScript = nasalScripts->getStringValue("load");
         if (!loadScript.empty()) {
         if (!loadScript.empty()) {
            FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
-            FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+            FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+     if(!nasalSys) {  
+     if(!nasalSys) {  
+ NASAL_DISABLED("AI scenarios");
+ NASAL_DISABLED("AI scenarios");
Line 145: Line 147:
             nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
             nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
                                     loadScript.c_str(), loadScript.size(),
                                     loadScript.c_str(), loadScript.size(),
@@ -86,8 +90,10 @@ public:
@@ -85,9 +89,11 @@ public:
            ai->setDie(true);
         }
         }
          
          
        FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
-        FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
-        if (!nasalSys)
-        if (!nasalSys)
-            return;
-            return;
+        FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+        if(!nasalSys) {  
+        if(!nasalSys) {  
+ NASAL_DISABLED("AI scenarios");
+ NASAL_DISABLED("AI scenarios");
Line 178: Line 182:
                           + cprops->getStringValue("name");
                           + cprops->getStringValue("name");
diff --git a/src/GUI/FGPUIDialog.cxx b/src/GUI/FGPUIDialog.cxx
diff --git a/src/GUI/FGPUIDialog.cxx b/src/GUI/FGPUIDialog.cxx
index 30cbef7..f66f40e 100644
index 30cbef7..604fd18 100644
--- a/src/GUI/FGPUIDialog.cxx
--- a/src/GUI/FGPUIDialog.cxx
+++ b/src/GUI/FGPUIDialog.cxx
+++ b/src/GUI/FGPUIDialog.cxx
Line 191: Line 195:
     display(props);
     display(props);
  }
  }
@@ -1056,7 +1058,11 @@ FGPUIDialog::makeObject (SGPropertyNode *props, int parentWidth, int parentHeigh
@@ -1055,8 +1057,12 @@ FGPUIDialog::makeObject (SGPropertyNode *props, int parentWidth, int parentHeigh
            obj->setBuffer(tsync->log());
           }
           }
         } else {
         } else {
          FGNasalSys* nasal = (FGNasalSys*) globals->get_subsystem("nasal");
-          FGNasalSys* nasal = (FGNasalSys*) globals->get_subsystem("nasal");
+          FGNasalSys* nasal = globals->get_subsystem<FGNasalSys>();
+   if(nasal)    
+   if(nasal)    
           obj->setBuffer(nasal->log());
           obj->setBuffer(nasal->log());
Line 303: Line 309:
   for (unsigned int i = 0; i < keys.size(); i++) {
   for (unsigned int i = 0; i < keys.size(); i++) {
diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx
diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx
index 1e93a0b..e07d4b9 100644
index 1e93a0b..26ed72c 100644
--- a/src/Main/fg_commands.cxx
--- a/src/Main/fg_commands.cxx
+++ b/src/Main/fg_commands.cxx
+++ b/src/Main/fg_commands.cxx
Line 311: Line 317:
  {
  {
-    return ((FGNasalSys*)globals->get_subsystem("nasal"))->handleCommand(arg);
-    return ((FGNasalSys*)globals->get_subsystem("nasal"))->handleCommand(arg);
+    FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+    FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+    if(!nasalSys) {
+    if(!nasalSys) {
+ NASAL_DISABLED("fgcomand nasal (bindings)");
+ NASAL_DISABLED("fgcomand nasal (bindings)");
Line 376: Line 382:
     if ( output0 != NULL && board0_locked ) {
     if ( output0 != NULL && board0_locked ) {
diff --git a/src/Network/HTTPClient.cxx b/src/Network/HTTPClient.cxx
diff --git a/src/Network/HTTPClient.cxx b/src/Network/HTTPClient.cxx
index e6d2b29..48376ab 100644
index e6d2b29..fc20c20 100644
--- a/src/Network/HTTPClient.cxx
--- a/src/Network/HTTPClient.cxx
+++ b/src/Network/HTTPClient.cxx
+++ b/src/Network/HTTPClient.cxx
@@ -327,6 +327,10 @@ void FGHTTPClient::postinit()
@@ -326,7 +326,11 @@ void FGHTTPClient::postinit()
 
   pkg::Root* packageRoot = globals->packageRoot();
   pkg::Root* packageRoot = globals->packageRoot();
   if (packageRoot) {
   if (packageRoot) {
    FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
-    FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+    FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+    if(!nasalSys) {
+    if(!nasalSys) {
+ NASAL_DISABLED("package manager");
+ NASAL_DISABLED("package manager");
Line 391: Line 399:
     nasalPkg.set("root", packageRoot);
     nasalPkg.set("root", packageRoot);
diff --git a/src/Scripting/NasalModelData.cxx b/src/Scripting/NasalModelData.cxx
diff --git a/src/Scripting/NasalModelData.cxx b/src/Scripting/NasalModelData.cxx
index e4f2269..930790d 100644
index e4f2269..f59c6a5 100644
--- a/src/Scripting/NasalModelData.cxx
--- a/src/Scripting/NasalModelData.cxx
+++ b/src/Scripting/NasalModelData.cxx
+++ b/src/Scripting/NasalModelData.cxx
@@ -118,6 +118,11 @@ void FGNasalModelData::load()
@@ -116,7 +116,12 @@ void FGNasalModelData::load()
  SG_LOG(SG_NASAL, SG_DEBUG, "Loading nasal module " << _module.c_str());
   const char *s = _load ? _load->getStringValue() : "";
   const char *s = _load ? _load->getStringValue() : "";
  FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
   
+ FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
+
+  if(!nasalSys) {
+  if(!nasalSys) {
+ NASAL_DISABLED("NasalModelData");
+ NASAL_DISABLED("NasalModelData");
+ return;
+ return;
+  }
+  }
+
   // Add _module_id to script local hash to allow placing canvasses on objects
   // Add _module_id to script local hash to allow placing canvasses on objects
   // inside the model.
   // inside the model.
   nasal::Hash module = nasalSys->getGlobals().createHash(_module);
@@ -140,7 +145,7 @@ void FGNasalModelData::unload()
    if (_module.empty())
        return;
-   FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+    FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
    if(!nasalSys) {
        SG_LOG(SG_NASAL, SG_WARN, "Trying to run an <unload> script "
                "without Nasal subsystem present.");
@@ -183,7 +188,7 @@ FGNasalModelData* FGNasalModelData::getByModuleId(unsigned int id)
//------------------------------------------------------------------------------
FGNasalModelDataProxy::~FGNasalModelDataProxy()
{
-    FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+    FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
    // when necessary, register Nasal module to be destroyed/unloaded
    // in the main thread.
    if ((_data.valid())&&(nasalSys))
@@ -205,7 +210,7 @@ void FGNasalModelDataProxy::modelLoaded( const std::string& path,
    if(!nasal)
        return;
   
-    FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+    FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
    if(!nasalSys)
    {
        SG_LOG
diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx
diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx
index 55c79a2..cf45960 100644
index 55c79a2..a427c64 100644
--- a/src/Scripting/NasalPositioned.cxx
--- a/src/Scripting/NasalPositioned.cxx
+++ b/src/Scripting/NasalPositioned.cxx
+++ b/src/Scripting/NasalPositioned.cxx
@@ -1831,6 +1831,10 @@ public:
@@ -1830,7 +1830,11 @@ class NasalFPDelegateFactory : public FlightPlan::DelegateFactory
public:
   NasalFPDelegateFactory(naRef code)
   NasalFPDelegateFactory(naRef code)
   {
   {
    _nasal = (FGNasalSys*) globals->get_subsystem("nasal");
-    _nasal = (FGNasalSys*) globals->get_subsystem("nasal");
+    _nasal = globals->get_subsystem<FGNasalSys>();
+    if(!_nasal) {
+    if(!_nasal) {
+ NASAL_DISABLED("Nasal flightplan delegates");
+ NASAL_DISABLED("Nasal flightplan delegates");
Line 422: Line 461:
   }
   }
diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx
diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx
index 096a591..af01ff2 100644
index 096a591..d0124be 100644
--- a/src/Scripting/NasalSys.hxx
--- a/src/Scripting/NasalSys.hxx
+++ b/src/Scripting/NasalSys.hxx
+++ b/src/Scripting/NasalSys.hxx
@@ -30,11 +30,14 @@ namespace simgear { class BufferedLogCallback; }
@@ -30,11 +30,15 @@ namespace simgear { class BufferedLogCallback; }
   
   
  SGPropertyNode* ghostToPropNode(naRef ref);
  SGPropertyNode* ghostToPropNode(naRef ref);
Line 436: Line 475:
     FGNasalSys();
     FGNasalSys();
     virtual ~FGNasalSys();
     virtual ~FGNasalSys();
+    static const char* subsystemName() { return "nasal"; }
+
+
     virtual void init();
     virtual void init();
     virtual void shutdown();
     virtual void shutdown();
      
      
</syntaxhighlight>
</syntaxhighlight>

Navigation menu