]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Tweaks to base version check code.
[flightgear.git] / src / Main / fg_init.cxx
index 1550b111b97138d8cdc32fff45baf3af416bfac1..699765c32d3dabf6a282d014514260b63121dfa1 100644 (file)
@@ -181,6 +181,30 @@ bool fgInitFGRoot ( int argc, char **argv ) {
 }
 
 
+// Return the current base package version
+string fgBasePackageVersion() {
+    SGPath base_path( globals->get_fg_root() );
+    base_path.append("version");
+
+    sg_gzifstream in( base_path.str() );
+    if ( !in.is_open() ) {
+       SGPath old_path( globals->get_fg_root() );
+       old_path.append( "Thanks" );
+       sg_gzifstream old( old_path.str() );
+       if ( !old.is_open() ) {
+           return "[none]";
+       } else {
+           return "[old version]";
+       }
+    }
+
+    string version;
+    in >> version;
+
+    return version;
+}
+
+
 // Read in configuration (file and command line)
 bool fgInitConfig ( int argc, char **argv ) {
 
@@ -509,24 +533,30 @@ bool fgInitSubsystems( void ) {
 
     aircraft_dir = fgGetString("/sim/aircraft-dir");
     const string &model = fgGetString("/sim/flight-model");
-    if (model == "larcsim") {
-       cur_fdm_state = new FGLaRCsim( dt );
-    } else if (model == "jsb") {
-       cur_fdm_state = new FGJSBsim( dt );
-    } else if (model == "ada") {
-       cur_fdm_state = new FGADA( dt );
-    } else if (model == "balloon") {
-       cur_fdm_state = new FGBalloonSim( dt );
-    } else if (model == "magic") {
-       cur_fdm_state = new FGMagicCarpet( dt );
-    } else if (model == "external") {
-       cur_fdm_state = new FGExternal( dt );
-    } else {
-       SG_LOG(SG_GENERAL, SG_ALERT,
-              "Unrecognized flight model '" << model
-              << ", can't init aircraft");
+    try {
+       if (model == "larcsim") {
+           cur_fdm_state = new FGLaRCsim( dt );
+       } else if (model == "jsb") {
+           cur_fdm_state = new FGJSBsim( dt );
+       } else if (model == "ada") {
+           cur_fdm_state = new FGADA( dt );
+       } else if (model == "balloon") {
+           cur_fdm_state = new FGBalloonSim( dt );
+       } else if (model == "magic") {
+           cur_fdm_state = new FGMagicCarpet( dt );
+       } else if (model == "external") {
+           cur_fdm_state = new FGExternal( dt );
+       } else {
+           SG_LOG(SG_GENERAL, SG_ALERT,
+                  "Unrecognized flight model '" << model
+                  << ", can't init aircraft");
+           exit(-1);
+       }
+    } catch ( ... ) {
+       SG_LOG(SG_GENERAL, SG_ALERT, "FlightGear aborting\n\n");
        exit(-1);
     }
+
     cur_fdm_state->init();
     cur_fdm_state->bind();