]> git.mxchange.org Git - flightgear.git/commitdiff
Changed 'exit' command to quit immediately, rather than displaying a
authordavid <david>
Fri, 24 Jan 2003 03:08:23 +0000 (03:08 +0000)
committerdavid <david>
Fri, 24 Jan 2003 03:08:23 +0000 (03:08 +0000)
built-in dialog (use an XML dialog instead).

Added an fgExit() function to simplify exit and cleanup.

src/Main/fg_commands.cxx
src/Main/util.cxx
src/Main/util.hxx

index 74318a43713157dfc967f31d52f8b70326655d0f..8d5e987b9cd069f3d864d7e342afef33ced1b1ab 100644 (file)
@@ -35,6 +35,7 @@ SG_USING_STD(ofstream);
 #include "fg_props.hxx"
 #include "fg_io.hxx"
 #include "globals.hxx"
+#include "util.hxx"
 #include "viewmgr.hxx"
 
 
@@ -169,13 +170,13 @@ do_script (const SGPropertyNode * arg)
 /**
  * Built-in command: exit FlightGear.
  *
- * TODO: show a confirm dialog.
+ * status: the exit status to return to the operating system (defaults to 0)
  */
 static bool
 do_exit (const SGPropertyNode * arg)
 {
-  SG_LOG(SG_INPUT, SG_ALERT, "Program exit requested.");
-  ConfirmExitDialog();
+  SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
+  fgExit(arg->getIntValue("status", 0));
   return true;
 }
 
index 61e0681654dde59ba06a15967d8b7f67b7740ba8..4e952685b5033e925902793a666bb3df6d16fd13 100644 (file)
 
 
 #include <math.h>
+
+#include <simgear/debug/logstream.hxx>
+
+#include "fg_io.hxx"
+#include "fg_props.hxx"
+#include "globals.hxx"
 #include "util.hxx"
 
+#if defined(FG_NETWORK_OLK)
+#include <NetworkOLK/network.h>
+#endif
+
+
+void
+fgExit (int status)
+{
+    SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status);
+
+#if defined(FG_NETWORK_OLK)
+    if (fgGetBool("/sim/networking/network-olk"))
+       fgd_send_com("8", FGFS_host);
+#endif
+
+    globals->get_io()->shutdown_all();
+    exit(status);
+}
+
 
 // Originally written by Alex Perry.
 double
index 91c34a1b95b18b1c9dade82f6a852631b63b2757..20507033c5e4c8bda43f5efd2ac8c7feb73b9a10 100644 (file)
 #endif
 
 
+/**
+ * Clean up and exit FlightGear.
+ *
+ * This function makes sure that network connections and I/O streams
+ * are cleaned up.
+ *
+ * @param status The exit status to pass to the operating system.
+ */
+extern void fgExit (int status = 0);
+
+
 /**
  * Move a value towards a target.
  *