audited all Sys_Quit calls and gave them return values indicating
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 24 Apr 2007 06:56:37 +0000 (06:56 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 24 Apr 2007 06:56:37 +0000 (06:56 +0000)
whether the game quit normally, so shell scripts get a useful value

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7165 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c
sys.h
sys_shared.c
vid_agl.c
vid_glx.c
vid_null.c
vid_sdl.c
vid_wgl.c

index 2ea15b8..a740a41 100644 (file)
@@ -38,7 +38,7 @@ Host_Quit_f
 
 void Host_Quit_f (void)
 {
-       Sys_Quit ();
+       Sys_Quit (0);
 }
 
 
diff --git a/sys.h b/sys.h
index 41deb01..42838e3 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -68,7 +68,7 @@ void Sys_PrintToTerminal(const char *text);
 // (may) output text to terminal which launched program
 
 void Sys_Shutdown (void); //INFO: This is only called by Host_Shutdown so we dont need testing for recursion
-void Sys_Quit (void);
+void Sys_Quit (int returnvalue);
 
 double Sys_DoubleTime (void);
 
index 9abc08d..f636ff3 100644 (file)
@@ -17,11 +17,11 @@ char *Sys_TimeString(const char *timeformat)
 
 
 extern qboolean host_shuttingdown;
-void Sys_Quit (void)
+void Sys_Quit (int returnvalue)
 {
        host_shuttingdown = true;
        Host_Shutdown();
-       exit(0);
+       exit(returnvalue);
 }
 
 /*
index cc1bb0c..4ecbd2e 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -254,8 +254,7 @@ void signal_handler(int sig)
 {
        printf("Received signal %d, exiting...\n", sig);
        VID_RestoreSystemGamma();
-       Sys_Quit();
-       exit(0);
+       Sys_Quit(1);
 }
 
 void InitSig(void)
@@ -422,7 +421,7 @@ static void VID_ProcessPendingAsyncEvents (void)
 
        // Closed
        if (AsyncEvent_Quitting)
-               Sys_Quit();
+               Sys_Quit(0);
 }
 
 static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscreen, qboolean stereobuffer)
@@ -980,7 +979,7 @@ void Sys_SendKeyEvents(void)
                                                VID_AppFocusChanged(false);
                                                break;
                                        case kEventAppQuit:
-                                               Sys_Quit();
+                                               Sys_Quit(0);
                                                break;
                                        case kEventAppActiveWindowChanged:
                                                break;
index 5f92ed1..291f5d5 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -425,12 +425,12 @@ static void HandleEvents(void)
                        break;
                case DestroyNotify:
                        // window has been destroyed
-                       Sys_Quit();
+                       Sys_Quit(0);
                        break;
                case ClientMessage:
                        // window manager messages
                        if ((event.xclient.format == 32) && ((unsigned int)event.xclient.data.l[0] == wm_delete_window_atom))
-                               Sys_Quit();
+                               Sys_Quit(0);
                        break;
                case MapNotify:
                        // window restored
@@ -537,8 +537,7 @@ void signal_handler(int sig)
 {
        Con_Printf("Received signal %d, exiting...\n", sig);
        VID_RestoreSystemGamma();
-       Sys_Quit();
-       exit(0);
+       Sys_Quit(1);
 }
 
 void InitSig(void)
index e70e745..28f92f8 100644 (file)
@@ -31,8 +31,7 @@ void VID_Shutdown(void)
 void signal_handler(int sig)
 {
        Con_Printf("Received signal %d, exiting...\n", sig);
-       Sys_Quit();
-       exit(0);
+       Sys_Quit(1);
 }
 
 void InitSig(void)
index af30f9c..7ac1e4e 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -341,7 +341,7 @@ void Sys_SendKeyEvents( void )
        while( SDL_PollEvent( &event ) )
                switch( event.type ) {
                        case SDL_QUIT:
-                               Sys_Quit();
+                               Sys_Quit(0);
                                break;
                        case SDL_KEYDOWN:
                        case SDL_KEYUP:
index 104f283..79505ef 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -465,7 +465,7 @@ void Sys_SendKeyEvents (void)
        while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
        {
                if (!GetMessage (&msg, NULL, 0, 0))
-                       Sys_Quit ();
+                       Sys_Quit (1);
 
                TranslateMessage (&msg);
                DispatchMessage (&msg);
@@ -618,7 +618,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM lParam)
 
                case WM_CLOSE:
                        if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
-                               Sys_Quit ();
+                               Sys_Quit (0);
 
                        break;