From 6c4d997a497cb5afde74b4bf16f6a9ade5aca37e Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 24 Apr 2007 06:56:37 +0000 Subject: [PATCH] audited all Sys_Quit calls and gave them return values indicating 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 | 2 +- sys.h | 2 +- sys_shared.c | 4 ++-- vid_agl.c | 7 +++---- vid_glx.c | 7 +++---- vid_null.c | 3 +-- vid_sdl.c | 2 +- vid_wgl.c | 4 ++-- 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/host_cmd.c b/host_cmd.c index 2ea15b81..a740a416 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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 41deb017..42838e31 100644 --- 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); diff --git a/sys_shared.c b/sys_shared.c index 9abc08d4..f636ff31 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -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); } /* diff --git a/vid_agl.c b/vid_agl.c index cc1bb0c6..4ecbd2ee 100644 --- 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; diff --git a/vid_glx.c b/vid_glx.c index 5f92ed1a..291f5d5a 100644 --- 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) diff --git a/vid_null.c b/vid_null.c index e70e7457..28f92f8c 100644 --- a/vid_null.c +++ b/vid_null.c @@ -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) diff --git a/vid_sdl.c b/vid_sdl.c index af30f9cb..7ac1e4ec 100644 --- 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: diff --git a/vid_wgl.c b/vid_wgl.c index 104f2837..79505efd 100644 --- 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; -- 2.39.2