shithub: cstory

Download patch

ref: 6764f17ab91bd53252ef57369d8fba97087ba3bb
parent: 727b3eee0dbd1980e3125172ebac930ee17cbce1
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Jan 17 05:35:43 EST 2020

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.

--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -275,10 +275,24 @@
 
 			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 @@
 					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);