From 6764f17ab91bd53252ef57369d8fba97087ba3bb Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 17 Jan 2020 10:35:43 +0000 Subject: [PATCH] Added bugfix for StartDirectDraw failure The original code didn't account for it failing, which leads to annoying bugs happening whenever it does fail. Now, the game just closes, like it does with any other init error. --- src/Main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index 88bd7d0e..03e0d5d5 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -275,10 +275,24 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL hMenu = GetMenu(hWnd); + #ifdef FIX_BUGS + if (conf.display_mode == 1) + { + if (!StartDirectDraw(hWnd, 0, 0)) + return 0; + } + else + { + if !(StartDirectDraw(hWnd, 1, 0)) + return 0; + } + #else + // Doesn't handle StartDirectDraw failing if (conf.display_mode == 1) StartDirectDraw(hWnd, 0, 0); else StartDirectDraw(hWnd, 1, 0); + #endif break; @@ -322,7 +336,14 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL break; } + #ifdef FIX_BUGS + if (!StartDirectDraw(hWnd, 2, depth)) + return 0; + #else + // Doesn't handle StartDirectDraw failing StartDirectDraw(hWnd, 2, depth); + #endif + bFullscreen = TRUE; ShowCursor(FALSE);