]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
deduplicate Sys_Error()
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 2 Jan 2024 06:21:27 +0000 (16:21 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 3 Jan 2024 00:36:00 +0000 (10:36 +1000)
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys.h
sys_sdl.c
sys_shared.c
sys_unix.c

diff --git a/sys.h b/sys.h
index 82134615407092afe3705719e486ace42952f4dd..5dac380d8613bc03f3929946be77a66d122bdbc7 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -241,6 +241,7 @@ char *Sys_ConsoleInput (void);
 /// called to yield for a little bit so as not to hog cpu when paused or debugging
 double Sys_Sleep(double time);
 
+void Sys_SDL_Dialog(const char *title, const char *string);
 void Sys_SDL_Init(void);
 /// Perform Key_Event () callbacks until the input que is empty
 void Sys_SDL_HandleEvents(void);
index 4ce2d75e0d3d2734ce2ffa5308eac483f1447b13..bb9bb2b1703bb33bee8038c94f4ee9fc8676b94d 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -46,29 +46,10 @@ void Sys_Shutdown (void)
 // Sys_Error early in startup might screw with automated
 // workflows or something if we show the dialog by default.
 static qbool nocrashdialog = true;
-void Sys_Error (const char *error, ...)
+void Sys_SDL_Dialog(const char *title, const char *string)
 {
-       va_list argptr;
-       char string[MAX_INPUTLINE];
-
-// change stdin to non blocking
-#ifndef WIN32
-       fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
-#endif
-
-       va_start (argptr,error);
-       dpvsnprintf (string, sizeof (string), error, argptr);
-       va_end (argptr);
-
-       Con_Printf(CON_ERROR "Engine Error: %s\n", string);
-       
-       // don't want a dead window left blocking the OS UI or the crash dialog
-       Host_Shutdown();
-
        if(!nocrashdialog)
-               SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Engine Error", string, NULL);
-
-       exit (1);
+               SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, string, NULL);
 }
 
 void Sys_Print(const char *text)
index 7b33f3a32a8acaa419cdc0fee89db15bd7d43678..aa028fdddc77b3a428263fd8d96717739a64e06d 100644 (file)
@@ -615,6 +615,31 @@ char *Sys_ConsoleInput(void)
        return NULL;
 }
 
+
+void Sys_Error (const char *error, ...)
+{
+       va_list argptr;
+       char string[MAX_INPUTLINE];
+
+// change stdin to non blocking
+#ifndef WIN32
+       fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
+#endif
+
+       va_start (argptr,error);
+       dpvsnprintf (string, sizeof (string), error, argptr);
+       va_end (argptr);
+
+       Con_Printf(CON_ERROR "Engine Error: %s\n", string);
+
+       // don't want a dead window left blocking the OS UI or the crash dialog
+       Host_Shutdown();
+
+       Sys_SDL_Dialog("Engine Error", string);
+
+       exit (1);
+}
+
 #ifndef WIN32
 static const char *Sys_FindInPATH(const char *name, char namesep, const char *PATH, char pathsep, char *buf, size_t bufsize)
 {
index d7b2ad9e7382510a01e94f2558f74adb7928a427..86a373c9ef82829e70630bd9b457c91f2d5c3e82 100644 (file)
@@ -24,23 +24,8 @@ void Sys_Shutdown (void)
        fflush(stdout);
 }
 
-void Sys_Error (const char *error, ...)
+void Sys_SDL_Dialog(const char *title, const char *string)
 {
-       va_list argptr;
-       char string[MAX_INPUTLINE];
-
-// change stdin to non blocking
-#ifndef WIN32
-       fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
-#endif
-       va_start (argptr,error);
-       dpvsnprintf (string, sizeof (string), error, argptr);
-       va_end (argptr);
-
-       Con_Printf(CON_ERROR "Engine Error: %s\n", string);
-
-       //Host_Shutdown ();
-       exit (1);
 }
 
 void Sys_Print(const char *text)