From 626a46d5926adcf26394a3b67cf8fc83b8ed307d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 19 Mar 2022 11:07:05 +1100 Subject: [PATCH] Improve crash dialogs when can't start game due to system being unable to support the current graphics backend --- misc/buildbot.sh | 8 ++++---- src/Graphics_D3D11.c | 4 ++-- src/Graphics_D3D9.c | 8 ++++---- src/Graphics_GL1.c | 2 +- src/Logger.c | 9 +++++++++ src/Logger.h | 1 + 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/misc/buildbot.sh b/misc/buildbot.sh index 7163e024f..65923043c 100644 --- a/misc/buildbot.sh +++ b/misc/buildbot.sh @@ -36,9 +36,9 @@ build_win32() { cp $ROOT_DIR/misc/CCicon_32.res $ROOT_DIR/src/CCicon_32.res rm cc-w32-d3d.exe cc-w32-ogl.exe - $WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-d3d.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 + $WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-d3d.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -lwininet -lwinmm -limagehlp if [ $? -ne 0 ]; then echo "Failed to compile Windows 32 bit" >> "$ERRS_FILE"; fi - $WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-ogl.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -lopengl32 + $WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-ogl.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lwininet -lwinmm -limagehlp -lopengl32 if [ $? -ne 0 ]; then echo "Failed to compile Windows 32 bit (OpenGL)" >> "$ERRS_FILE"; fi } @@ -47,9 +47,9 @@ build_win64() { cp $ROOT_DIR/misc/CCicon_64.res $ROOT_DIR/src/CCicon_64.res rm cc-w64-d3d.exe cc-w64-ogl.exe - $WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-d3d.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 + $WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-d3d.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -lwininet -lwinmm -limagehlp if [ $? -ne 0 ]; then echo "Failed to compile Windows 64 bit" >> "$ERRS_FILE"; fi - $WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-ogl.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -lopengl32 + $WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-ogl.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lwininet -lwinmm -limagehlp -lopengl32 if [ $? -ne 0 ]; then echo "Failed to compile Windows 64 bit (OpenGL)" >> "$ERRS_FILE"; fi } diff --git a/src/Graphics_D3D11.c b/src/Graphics_D3D11.c index b8f113780..04b4dd2be 100644 --- a/src/Graphics_D3D11.c +++ b/src/Graphics_D3D11.c @@ -59,7 +59,7 @@ static void LoadD3D11Library(void) { if (!lib) { Logger_DynamicLibWarn("loading", &path); - Logger_Abort("Failed to load d3d11.dll. You may need to install Direct3D11.\n\nNOTE: Direct3D11 requires Windows 7 or later\nYou may need to use the Direct3D9 version instead.\n"); + Logger_FailToStart("Failed to load d3d11.dll. You may need to install Direct3D11.\n\nNOTE: Direct3D11 requires Windows 7 or later\nYou may need to use the Direct3D9 version instead.\n"); } DynamicLib_GetAll(lib, funcs, Array_Elems(funcs)); } @@ -96,7 +96,7 @@ static void CreateDeviceAndSwapChain(void) { // https://github.com/MonoGame/MonoGame/issues/5789 // I decided to just not support GPUs that do not support at least feature level 10 if (fl < D3D_FEATURE_LEVEL_10_0) - Logger_Abort("Your GPU is too old to support the Direct3D11 version.\nTry using the Direct3D9 version instead.\n"); + Logger_FailToStart("Your GPU is too old to support the Direct3D11 version.\nTry using the Direct3D9 version instead.\n"); // https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_texture2d_desc // https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-limits diff --git a/src/Graphics_D3D9.c b/src/Graphics_D3D9.c index 5a0ffcfff..7e822fcf9 100644 --- a/src/Graphics_D3D9.c +++ b/src/Graphics_D3D9.c @@ -63,7 +63,7 @@ static void LoadD3D9Library(void) { if (!lib) { Logger_DynamicLibWarn("loading", &path); - Logger_Abort("Failed to load d3d9.dll. You may need to install Direct3D9."); + Logger_FailToStart("Failed to load d3d9.dll. You may need to install Direct3D9."); } DynamicLib_GetAll(lib, funcs, Array_Elems(funcs)); } @@ -83,10 +83,10 @@ static void FindCompatibleViewFormat(void) { for (i = 0; i < Array_Elems(formats); i++) { viewFormat = formats[i]; - res = IDirect3D9_CheckDeviceType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, viewFormat, viewFormat, true); + res = IDirect3D9_CheckDeviceType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_SW, viewFormat, viewFormat, true); if (!res) return; } - Logger_Abort("Failed to create back buffer. Graphics drivers may not be installed."); + Logger_FailToStart("Failed to create back buffer. Graphics drivers may not be installed.\n\nIf that still does not work, try the OpenGL build instead"); } static void FindCompatibleDepthFormat(void) { @@ -99,7 +99,7 @@ static void FindCompatibleDepthFormat(void) { res = IDirect3D9_CheckDepthStencilMatch(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, viewFormat, viewFormat, depthFormat); if (!res) return; } - Logger_Abort("Failed to create depth buffer. Graphics drivers may not be installed."); + Logger_FailToStart("Failed to create depth buffer. Graphics drivers may not be installed.\n\nIf that still does not work, try the OpenGL build instead"); } static void D3D9_FillPresentArgs(D3DPRESENT_PARAMETERS* args) { diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index 54561933a..c82d603ac 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -558,7 +558,7 @@ static void OpenGL11Fallback(void) { #else /* No point in even trying for other systems */ static void OpenGL11Fallback(void) { - Logger_Abort("Only OpenGL 1.1 supported.\n\n" \ + Logger_FailToStart("Only OpenGL 1.1 supported.\n\n" \ "Compile the game with CC_BUILD_GL11, or ask on the ClassiCube forums for it"); } #endif diff --git a/src/Logger.c b/src/Logger.c index c058950d8..dd071597e 100644 --- a/src/Logger.c +++ b/src/Logger.c @@ -984,3 +984,12 @@ static void AbortCommon(cc_result result, const char* raw_msg, void* ctx) { } void Logger_Abort(const char* raw_msg) { Logger_Abort2(0, raw_msg); } + +void Logger_FailToStart(const char* raw_msg) { + cc_string msg = String_FromReadonly(raw_msg); + + Window_ShowDialog("Failed to start ClassiCube", raw_msg); + LogCrashHeader(); + Logger_Log(&msg); + Process_Exit(1); +} diff --git a/src/Logger.h b/src/Logger.h index 4e38c4029..8e999c3eb 100644 --- a/src/Logger.h +++ b/src/Logger.h @@ -52,4 +52,5 @@ void Logger_Abort(const char* raw_msg); /* Displays a message box with raw_msg body, logs state to disc, then immediately terminates/quits. */ /* Typically used to abort due to an unrecoverable error. (e.g. out of memory) */ CC_NOINLINE void Logger_Abort2(cc_result result, const char* raw_msg); +void Logger_FailToStart(const char* raw_msg); #endif