X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2Ffdm_shell.cxx;h=21a3b79df7e0824168cb6d2e228e8051dcf9292d;hb=948aa70af78626584042b70fdf3c3babfb5aa804;hp=daa37aab7d2dafa3ba74894400b7d802ab790435;hpb=e819a4aaa44da6be816460fe719b1f65e0a2db3c;p=flightgear.git diff --git a/src/FDM/fdm_shell.cxx b/src/FDM/fdm_shell.cxx index daa37aab7..21a3b79df 100644 --- a/src/FDM/fdm_shell.cxx +++ b/src/FDM/fdm_shell.cxx @@ -59,12 +59,6 @@ #include #endif -/* - * Evil global variable required by Network/FGNative, - * see that class for more information - */ -FGInterface* evil_global_fdm_state = NULL; - FDMShell::FDMShell() : _tankProperties( fgGetNode("/consumables/fuel", true) ), _impl(NULL), @@ -99,7 +93,6 @@ void FDMShell::reinit() { if (_impl) { fgSetBool("/sim/fdm-initialized", false); - evil_global_fdm_state = NULL; _impl->unbind(); delete _impl; _impl = NULL; @@ -146,7 +139,6 @@ void FDMShell::update(double dt) } _impl->bind(); - evil_global_fdm_state = _impl; fgSetBool("/sim/fdm-initialized", true); fgSetBool("/sim/signals/fdm-initialized", true); } @@ -196,6 +188,11 @@ void FDMShell::update(double dt) } } +FGInterface* FDMShell::getInterface() const +{ + return _impl; +} + void FDMShell::createImplementation() { assert(!_impl); @@ -203,6 +200,8 @@ void FDMShell::createImplementation() double dt = 1.0 / fgGetInt("/sim/model-hz"); string model = fgGetString("/sim/flight-model"); + bool fdmUnavailable = false; + if ( model == "ufo" ) { _impl = new FGUFO( dt ); } else if ( model == "external" ) { @@ -261,17 +260,21 @@ void FDMShell::createImplementation() _impl = new FGExternalPipe( dt, pipe_path, pipe_protocol ); } else if ( model == "null" ) { _impl = new FGNullFDM( dt ); - } -#ifdef ENABLE_LARCSIM + } else if ( model == "larcsim" ) { +#ifdef ENABLE_LARCSIM _impl = new FGLaRCsim( dt ); - } +#else + fdmUnavailable = true; #endif -#ifdef ENABLE_JSBSIM + } else if ( model == "jsb" ) { +#ifdef ENABLE_JSBSIM _impl = new FGJSBsim( dt ); - } +#else + fdmUnavailable = true; #endif + } #ifdef ENABLE_SP_FDM else if ( model == "ada" ) { _impl = new FGADA( dt ); @@ -282,15 +285,28 @@ void FDMShell::createImplementation() } else if ( model == "magic" ) { _impl = new FGMagicCarpet( dt ); } +#else + else if (( model == "ada" )||(model == "acms")||( model == "balloon" )||( model == "magic" )) + { + fdmUnavailable = true; + } #endif -#ifdef ENABLE_YASIM else if ( model == "yasim" ) { +#ifdef ENABLE_YASIM _impl = new YASim( dt ); - } +#else + fdmUnavailable = true; #endif - else { + } else { throw sg_exception(string("Unrecognized flight model '") + model + "', cannot init flight dynamics model."); } + if (fdmUnavailable) + { + // FDM type is known, but its support was disabled at compile-time. + throw sg_exception(string("Support for flight model '") + model + + ("' is not available with this binary (deprecated/disabled).\n" + "If you still need it, please rebuild FlightGear and enable its support.")); + } }