void
fgExit (int status)
{
- // remove subsystems first, which need access to other subsystems in their
- // destructors (e.g. "nasal")
- SGSubsystem *sub;
-
- sub = globals->get_subsystem("ai_model");
- globals->get_subsystem_mgr()->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("ai_model");
- delete sub;
-
- sub = globals->get_subsystem("submodel_mgr");
- globals->get_subsystem_mgr()->get_group(SGSubsystemMgr::GENERAL)->remove_subsystem("submodel_mgr");
- delete sub;
-
#ifdef OSG_LIBRARY_STATIC
osgDB::Registry::instance( true);
#endif
fgGetLowPass (double current, double target, double timeratio)
{
if ( timeratio < 0.0 ) {
- if ( timeratio < -1.0 ) {
+ if ( timeratio < -1.0 ) {
// time went backwards; kill the filter
current = target;
} else {
#include "NasalSys.hxx"
+static FGNasalSys* nasalSys = 0;
+
+
// Read and return file contents in a single buffer. Note use of
// stat() to get the file size. This is a win32 function, believe it
// or not. :) Note the REALLY IMPORTANT use of the "b" flag to fopen.
FGNasalSys::FGNasalSys()
{
+ nasalSys = this;
_context = 0;
_globals = naNil();
_gcHash = naNil();
FGNasalSys::~FGNasalSys()
{
+ nasalSys = 0;
map<int, FGNasalListener *>::iterator it, end = _listener.end();
for(it = _listener.begin(); it != end; ++it)
delete it->second;
// FGNasalSys::setTimer(). See there for docs.
static naRef f_settimer(naContext c, naRef me, int argc, naRef* args)
{
- FGNasalSys* nasal = (FGNasalSys*)globals->get_subsystem("nasal");
- nasal->setTimer(argc, args);
+ nasalSys->setTimer(argc, args);
return naNil();
}
// FGNasalSys::setListener(). See there for docs.
static naRef f_setlistener(naContext c, naRef me, int argc, naRef* args)
{
- FGNasalSys* nasal = (FGNasalSys*)globals->get_subsystem("nasal");
- return nasal->setListener(c, argc, args);
+ return nasalSys->setListener(c, argc, args);
}
// removelistener(int) extension function. Falls through to
// FGNasalSys::removeListener(). See there for docs.
static naRef f_removelistener(naContext c, naRef me, int argc, naRef* args)
{
- FGNasalSys* nasal = (FGNasalSys*)globals->get_subsystem("nasal");
- return nasal->removeListener(c, argc, args);
+ return nasalSys->removeListener(c, argc, args);
}
// Returns a ghost handle to the argument to the currently executing
// command
static naRef f_cmdarg(naContext c, naRef me, int argc, naRef* args)
{
- FGNasalSys* nasal = (FGNasalSys*)globals->get_subsystem("nasal");
- return nasal->cmdArgGhost();
+ return nasalSys->cmdArgGhost();
}
// Sets up a property interpolation. The first argument is either a
_module = path;
const char *s = load ? load->getStringValue() : "";
- FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
- nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props);
+ nasalSys->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props);
}
FGNasalModelData::~FGNasalModelData()
if(_module.empty())
return;
- FGNasalSys *nas = (FGNasalSys *)globals->get_subsystem("nasal");
- if(!nas) {
+ if(!nasalSys) {
SG_LOG(SG_NASAL, SG_ALERT, "Trying to run an <unload> script "
"without Nasal subsystem present.");
return;
if(_unload) {
const char *s = _unload->getStringValue();
- nas->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props);
+ nasalSys->createModule(_module.c_str(), _module.c_str(), s, strlen(s), _props);
}
- nas->deleteModule(_module.c_str());
+ nasalSys->deleteModule(_module.c_str());
}