shithub: cstory

Download patch

ref: 58fc9a392ac3d868292eebdc0991247a9bca03be
parent: aa9e48608679f4d35df1ec237e8529284c5a3869
author: Clownacy <[email protected]>
date: Mon Apr 13 09:56:29 EDT 2020

More cleanup

--- a/src/Backends/SDL2/Controller.cpp
+++ b/src/Backends/SDL2/Controller.cpp
@@ -6,8 +6,8 @@
 
 #include "SDL.h"
 
-#include "../../WindowsWrapper.h"
 #include "../Misc.h"
+#include "../../WindowsWrapper.h"
 
 #define DEADZONE 10000
 
@@ -142,6 +142,7 @@
 void ControllerBackend_JoystickConnect(Sint32 joystick_id)
 {
 	const char *joystick_name = SDL_JoystickNameForIndex(joystick_id);
+
 	if (joystick_name != NULL)
 	{
 		Backend_PrintInfo("Joystick #%d connected - %s", joystick_id, joystick_name);
@@ -172,17 +173,22 @@
 
 				// Set up neutral axes
 				axis_neutrals = (Sint16*)malloc(sizeof(Sint16) * total_axes);
+
 				if (axis_neutrals != NULL)
+				{
 					for (int i = 0; i < total_axes; ++i)
 						axis_neutrals[i] = SDL_JoystickGetAxis(joystick, i);
+
+					return;
+				}
 				else
+				{
 					Backend_PrintError("Couldn't allocate memory for neutral axes");
+				}
 			}
-			else
-			{
-				SDL_JoystickClose(joystick);
-				joystick = NULL;
-			}
+
+			SDL_JoystickClose(joystick);
+			joystick = NULL;
 		}
 		else
 		{
--- a/src/Backends/SDL2/Misc.cpp
+++ b/src/Backends/SDL2/Misc.cpp
@@ -45,23 +45,30 @@
 			const char *driver = SDL_GetCurrentVideoDriver();
 
 			if (driver != NULL)
+			{
 				Backend_PrintInfo("Selected SDL video driver: %s", driver);
-			else
-				Backend_PrintError("No SDL video driver initialized !");
 
-			return TRUE;
+				return TRUE;
+			}
+			else
+			{
+				Backend_PrintError("No SDL video driver initialized!");
+			}
 		}
+		else
+		{
+			std::string error_message = std::string("Could not initialise SDL video subsystem: ") + SDL_GetError();
+			Backend_ShowMessageBox("Fatal error", error_message.c_str());
+		}
 
-		std::string error_message = std::string("Could not initialise SDL video subsystem: ") + SDL_GetError();
-		Backend_ShowMessageBox("Fatal error", error_message.c_str());
-
 		SDL_Quit();
-		return FALSE;
 	}
+	else
+	{
+		std::string error_message = std::string("Could not initialise SDL: ") + SDL_GetError();
+		Backend_ShowMessageBox("Fatal error", error_message.c_str());
+	}
 
-	std::string error_message = std::string("Could not initialise SDL: ") + SDL_GetError();
-	Backend_ShowMessageBox("Fatal error", error_message.c_str());
-
 	return FALSE;
 }
 
@@ -301,6 +308,7 @@
 void Backend_ShowMessageBox(const char *title, const char *message)
 {
 	fprintf(stderr, "ShowMessageBox - '%s' - '%s'\n", title, message);
+
 	if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, window) != 0)
 		Backend_PrintError("Was also unable to display a message box containing the error: %s", SDL_GetError());
 }