20,741
edits
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.. | index 4faf23e..38c38b2 100644 | ||
--- a/src/AIModel/AIManager.cxx | --- a/src/AIModel/AIManager.cxx | ||
+++ b/src/AIModel/AIManager.cxx | +++ b/src/AIModel/AIManager.cxx | ||
@@ - | @@ -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 = 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(), | ||
@@ - | @@ -85,9 +89,11 @@ public: | ||
ai->setDie(true); | |||
} | } | ||
- 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.. | 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); | ||
} | } | ||
@@ - | @@ -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 = 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.. | 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* 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.. | index e6d2b29..fc20c20 100644 | ||
--- a/src/Network/HTTPClient.cxx | --- a/src/Network/HTTPClient.cxx | ||
+++ b/src/Network/HTTPClient.cxx | +++ b/src/Network/HTTPClient.cxx | ||
@@ - | @@ -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 = 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.. | index e4f2269..f59c6a5 100644 | ||
--- a/src/Scripting/NasalModelData.cxx | --- a/src/Scripting/NasalModelData.cxx | ||
+++ b/src/Scripting/NasalModelData.cxx | +++ b/src/Scripting/NasalModelData.cxx | ||
@@ - | @@ -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 = 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:: | @@ -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.. | index 55c79a2..a427c64 100644 | ||
--- a/src/Scripting/NasalPositioned.cxx | --- a/src/Scripting/NasalPositioned.cxx | ||
+++ b/src/Scripting/NasalPositioned.cxx | +++ b/src/Scripting/NasalPositioned.cxx | ||
@@ - | @@ -1830,7 +1830,11 @@ class NasalFPDelegateFactory : public FlightPlan::DelegateFactory | ||
public: | |||
NasalFPDelegateFactory(naRef code) | NasalFPDelegateFactory(naRef code) | ||
{ | { | ||
- _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.. | 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, | @@ -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> |