]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/main.cxx
Renamed to hud_gaug.cxx
[flightgear.git] / src / Main / main.cxx
index 6f3c3bb39c1327a867e7726b6a4d0b87a3530a03..d120c8f58d5d7ecf63f478416aa63d1d6a1aeffe 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include <simgear/compiler.h>
+#include <simgear/misc/exception.hxx>
 
 #ifdef SG_MATH_EXCEPTION_CLASH
 #  include <math.h>
@@ -59,6 +60,7 @@
 // #  include <GL/glext.h>
 // #endif
 
+#include <plib/netChat.h>
 #include <plib/pu.h>
 #include <plib/ssg.h>
 
@@ -130,6 +132,7 @@ int objc=0;
 #include "fg_props.hxx"
 #include "globals.hxx"
 #include "splash.hxx"
+#include "viewmgr.hxx"
 
 #ifdef macintosh
 #  include <console.h>         // -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;