From: david Date: Fri, 24 Jan 2003 03:08:23 +0000 (+0000) Subject: Changed 'exit' command to quit immediately, rather than displaying a X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9679c7da15442707bf57b133aeeb2c8f68214038;p=flightgear.git Changed 'exit' command to quit immediately, rather than displaying a built-in dialog (use an XML dialog instead). Added an fgExit() function to simplify exit and cleanup. --- diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 74318a437..8d5e987b9 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -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; } diff --git a/src/Main/util.cxx b/src/Main/util.cxx index 61e068165..4e952685b 100644 --- a/src/Main/util.cxx +++ b/src/Main/util.cxx @@ -19,8 +19,33 @@ #include + +#include + +#include "fg_io.hxx" +#include "fg_props.hxx" +#include "globals.hxx" #include "util.hxx" +#if defined(FG_NETWORK_OLK) +#include +#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 diff --git a/src/Main/util.hxx b/src/Main/util.hxx index 91c34a1b9..20507033c 100644 --- a/src/Main/util.hxx +++ b/src/Main/util.hxx @@ -26,6 +26,17 @@ #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. *