X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fmain.cxx;h=d120c8f58d5d7ecf63f478416aa63d1d6a1aeffe;hb=45390e0655fffa45a16cba77fafdd9421ed7d6e2;hp=6f3c3bb39c1327a867e7726b6a4d0b87a3530a03;hpb=76a94d8f0278eeddf692850918526df84a73429c;p=flightgear.git diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 6f3c3bb39..d120c8f58 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -26,6 +26,7 @@ #endif #include +#include #ifdef SG_MATH_EXCEPTION_CLASH # include @@ -59,6 +60,7 @@ // # include // #endif +#include #include #include @@ -130,6 +132,7 @@ int objc=0; #include "fg_props.hxx" #include "globals.hxx" #include "splash.hxx" +#include "viewmgr.hxx" #ifdef macintosh # include // -dw- for command line dialog @@ -715,7 +718,7 @@ void fgRenderFrame( void ) { // set up moving parts if (flaps_selector != NULL) { - flaps_selector->select( (controls.get_flaps() > 0.5f) ? 1 : 2 ); + flaps_selector->select( (globals->get_controls()->get_flaps() > 0.5f) ? 1 : 2 ); } if (prop_selector != NULL) { @@ -798,7 +801,7 @@ void fgRenderFrame( void ) { current_input.update(); // update the controls subsystem - controls.update(); + globals->get_controls()->update(); hud_and_panel->apply(); fgCockpitUpdate(); @@ -1174,7 +1177,8 @@ static void fgMainLoop( void ) { s1->set_pitch( pitch ); s1->set_volume( volume ); } else { - double param = controls.get_throttle( 0 ) * 2.0 + 1.0; + double param + = globals->get_controls()->get_throttle( 0 ) * 2.0 + 1.0; s1->set_pitch( param ); s1->set_volume( param ); } @@ -1426,8 +1430,8 @@ int fgGlutInitEvents( void ) { } -// Main ... -int main( int argc, char **argv ) { +// Main loop +int mainLoop( int argc, char **argv ) { #if defined( macintosh ) freopen ("stdout.txt", "w", stdout ); @@ -1462,6 +1466,9 @@ int main( int argc, char **argv ) { SGRoute *route = new SGRoute; globals->set_route( route ); + FGControls *controls = new FGControls; + globals->set_controls( controls ); + FGViewMgr *viewmgr = new FGViewMgr; globals->set_viewmgr( viewmgr ); @@ -1511,7 +1518,10 @@ int main( int argc, char **argv ) { "GLUT event handler initialization failed ..." ); exit(-1); } - + + // Initialize plib net interface + netInit( &argc, argv ); + // Initialize ssg (from plib). Needs to come before we do any // other ssg stuff, but after opengl/glut has been initialized. ssgInit(); @@ -1757,6 +1767,21 @@ int main( int argc, char **argv ) { // $$$ end - added VS Renganathan, 15 Oct 2K // - added Venky , 12 Nov 2K +// Main entry point; catch any exceptions that have made it this far. +int main ( int argc, char **argv ) { + // FIXME: add other, more specific + // exceptions. + try { + mainLoop(argc, argv); + } catch (sg_throwable &t) { + SG_LOG(SG_GENERAL, SG_ALERT, + "Fatal error: " << t.getFormattedMessage() + << "\n (received from " << t.getOrigin() << ')'); + exit(1); + } +} + + void fgLoadDCS(void) { ssgEntity *ship_obj = NULL;