built-in dialog (use an XML dialog instead).
Added an fgExit() function to simplify exit and cleanup.
#include "fg_props.hxx"
#include "fg_io.hxx"
#include "globals.hxx"
+#include "util.hxx"
#include "viewmgr.hxx"
/**
* 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;
}
#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
#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.
*