include/Checks.h
int RunChecks ( void ) {

	/* We first verify the OS.  `SDL_GetPlatform` is used to get this information.  If the OS is invalid, the program is crashed.  If the OS is questionable, the user is warned appropriately.  If the OS is fine, nothing happens. */
	SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "Verifying OS…" ) ;
	const char * Platform = SDL_GetPlatform ( ) ;
	if ( strstr ( Platform , "Linux" ) != NULL ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "OS verified!" ) ; }
	else if ( strstr ( Platform , "Unknown" ) != NULL ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , "User's OS could not be verified; assuming good faith." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Could not verify OS!" ,\
				"Your operating system could not be verified.  Please\n\
				see the non-binding section of the License to see why\n\
				this might be a problem.  However, good faith will be\n\
				assumed, and you will be allowed to play.", NULL ) ; }
	else if ( strstr ( Platform , "Windows" ) != NULL || strstr ( Platform , "Mac OS X" ) || strstr ( Platform , "iOS" ) ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ERROR , SDL_LOG_PRIORITY_CRITICAL , "Invalid OS!  Crashing program…" ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Invalid OS!" ,\
				"You are attempting to run this software\n\
				under a bad ooperating system.  Please do\n\
				not do this.  For more information, please\n\
				see the non-binding section of the License.\n\
				\n\
				The program will now crash." , NULL ) ;
		return 2 ; }
	else if ( strstr ( Platform , "Android" ) != NULL ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , "User is on Android and may or may not have acquired program through illegitimate means; assuming good faith." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Acquiration concerns" ,\
				"You are playing this game on an Android device.  Where\n\
				you obtained this from cannot be checked, so good faith\n\
				will be assumed and you will be allowed to continue\n\
				playing.  (For more information about these concerns,\n\
				see the non-binding section of the License.)" , NULL ) ; }
	
	/* We now need to check the battery with `SDL_GetPowerInfo`.  This uses the following logic:
	 *
	 * - If the player is not on a battery, continue, and don't run rechecks.
	 * - If the player is on a battery, but it's plugged in, don't do anything at first, but run rechecks later.
	 * - If the player is on a battery that isn't plugged in, then:
	 *   	- If the battery is below 15% or has less than 15 minutes left, crash the game.
	 *   	- Otherwise, notify the user that they may want to plug in if they play for a while, but continue which running rechecks.
	 * - If the power state can't be determined, warn the user, but continue as normal.
	 *
	 * I have no idea why the output of `SDL_GetPowerInfo` is stored both in its arguments _and_ in it's return.  Ah well. */
	
	SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "Verifying battery…" ) ;
	int Seconds = -1 ;
	int Percent = -1 ;
	SDL_PowerState PowerState = SDL_GetPowerInfo ( &Seconds , &Percent ) ;
	if ( PowerState == SDL_POWERSTATE_UNKNOWN || ( Seconds == -1 && Percent == -1 ) ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , "Battery state unknown; warning user, rechecks will be run." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Battery state unknown" ,\
				"Your battery state could not be determined.  Please\n\
				check this before continuing." , NULL ) ; }
	else if ( PowerState == SDL_POWERSTATE_ON_BATTERY ) {
		if ( ( Seconds < 900 && Seconds != -1 ) || ( Percent < 15 && Percent != -1 ) ) {
			SDL_LogMessage ( SDL_LOG_CATEGORY_ERROR , SDL_LOG_PRIORITY_CRITICAL , "Battery too low!  Crashing program…" ) ;
			SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_ERROR , "Your battery is too low!" ,\
					"Your battery is very low, and Ex Nihilo has\n\
					been stopped to prevent loss of data.  Please\n\
					plug in your battery and relaunch the game if\n\
					you want to play." , NULL ) ;
			return 3 ; }
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "User is on battery; will run rechecks." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_INFORMATION , "You are on battery" ,\
				"If you are planning on playing for a long period\n\
				of time, you may want to plug in your battery." , NULL ) ; }
	else if ( PowerState == SDL_POWERSTATE_NO_BATTERY ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "User doesn't have battery; will not run rechecks." ) ;
		BatteryRechecks = 0 ; }
	else if ( PowerState == SDL_POWERSTATE_CHARGED || PowerState == SDL_POWERSTATE_CHARGING ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "User battery is plugged in; will run rechecks." ) ; }
	return 0 ; }
/* And now, we get to the meat of the file. */
And now, we get to the meat of the file.
And now we get to the meat of the file .
int RunChecks ( void ) {
	SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "Verifying OS…" ) ;
	const char * Platform = SDL_GetPlatform ( ) ;
	if ( strstr ( Platform , "Linux" ) != NULL ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "OS verified!" ) ; }
	else if ( strstr ( Platform , "Unknown" ) != NULL ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , "User's OS could not be verified; assuming good faith." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Could not verify OS!" ,\
				"Your operating system could not be verified.  Please\n\
				see the non-binding section of the License to see why\n\
				this might be a problem.  However, good faith will be\n\
				assumed, and you will be allowed to play.", NULL ) ; }
	else if ( strstr ( Platform , "Windows" ) != NULL || strstr ( Platform , "Mac OS X" ) || strstr ( Platform , "iOS" ) ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ERROR , SDL_LOG_PRIORITY_CRITICAL , "Invalid OS!  Crashing program…" ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Invalid OS!" ,\
				"You are attempting to run this software\n\
				under a bad ooperating system.  Please do\n\
				not do this.  For more information, please\n\
				see the non-binding section of the License.\n\
				\n\
				The program will now crash." , NULL ) ;
		return 2 ; }
	else if ( strstr ( Platform , "Android" ) != NULL ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , "User is on Android and may or may not have acquired program through illegitimate means; assuming good faith." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Acquiration concerns" ,\
				"You are playing this game on an Android device.  Where\n\
				you obtained this from cannot be checked, so good faith\n\
				will be assumed and you will be allowed to continue\n\
				playing.  (For more information about these concerns,\n\
				see the non-binding section of the License.)" , NULL ) ; }
	SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "Verifying battery…" ) ;
	int Seconds = -1 ;
	int Percent = -1 ;
	SDL_PowerState PowerState = SDL_GetPowerInfo ( &Seconds , &Percent ) ;
	if ( PowerState == SDL_POWERSTATE_UNKNOWN || ( Seconds == -1 && Percent == -1 ) ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , "Battery state unknown; warning user, rechecks will be run." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , "Battery state unknown" ,\
				"Your battery state could not be determined.  Please\n\
				check this before continuing." , NULL ) ; }
	else if ( PowerState == SDL_POWERSTATE_ON_BATTERY ) {
		if ( ( Seconds < 900 && Seconds != -1 ) || ( Percent < 15 && Percent != -1 ) ) {
			SDL_LogMessage ( SDL_LOG_CATEGORY_ERROR , SDL_LOG_PRIORITY_CRITICAL , "Battery too low!  Crashing program…" ) ;
			SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_ERROR , "Your battery is too low!" ,\
					"Your battery is very low, and Ex Nihilo has\n\
					been stopped to prevent loss of data.  Please\n\
					plug in your battery and relaunch the game if\n\
					you want to play." , NULL ) ;
			return 3 ; }
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "User is on battery; will run rechecks." ) ;
		SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_INFORMATION , "You are on battery" ,\
				"If you are planning on playing for a long period\n\
				of time, you may want to plug in your battery." , NULL ) ; }
	else if ( PowerState == SDL_POWERSTATE_NO_BATTERY ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "User doesn't have battery; will not run rechecks." ) ;
		BatteryRechecks = 0 ; }
	else if ( PowerState == SDL_POWERSTATE_CHARGED || PowerState == SDL_POWERSTATE_CHARGING ) {
		SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , "User battery is plugged in; will run rechecks." ) ; }
	return 0 ; }
int RunChecks ( void ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , " ) ; const char * Platform = SDL_GetPlatform ( ) ; if ( strstr ( Platform , " " ) != NULL ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , " " ) ; } else if ( strstr ( Platform , " " ) != NULL ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , " " ) ; SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , " " , " \n \
 \n \
 \n \
 " , NULL ) ; } else if ( strstr ( Platform , " " ) != NULL || strstr ( Platform , " " ) || strstr ( Platform , " " ) ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ERROR , SDL_LOG_PRIORITY_CRITICAL , " ) ; SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , " " , " \n \
 \n \
 \n \
 \n \
 \n \
 " , NULL ) ; return 2 ; } else if ( strstr ( Platform , " " ) != NULL ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , " " ) ; SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , " " , " \n \
 \n \
 \n \
 \n \
 " , NULL ) ; } SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , " ) ; int Seconds = -1 ; int Percent = -1 ; SDL_PowerState PowerState = SDL_GetPowerInfo ( & Seconds , & Percent ) ; if ( PowerState == SDL_POWERSTATE_UNKNOWN || ( Seconds == -1 && Percent == -1 ) ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_WARN , " " ) ; SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_WARNING , " " , " \n \
 " , NULL ) ; } else if ( PowerState == SDL_POWERSTATE_ON_BATTERY ) { if ( ( Seconds < 900 && Seconds != -1 ) || ( Percent < 15 && Percent != -1 ) ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ERROR , SDL_LOG_PRIORITY_CRITICAL , " ) ; SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_ERROR , " " , " \n \
 \n \
 \n \
 " , NULL ) ; return 3 ; } SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , " " ) ; SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_INFORMATION , " " , " \n \
 " , NULL ) ; } else if ( PowerState == SDL_POWERSTATE_NO_BATTERY ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , " " ) ; BatteryRechecks = 0 ; } else if ( PowerState == SDL_POWERSTATE_CHARGED || PowerState == SDL_POWERSTATE_CHARGING ) { SDL_LogMessage ( SDL_LOG_CATEGORY_ASSERT , SDL_LOG_PRIORITY_VERBOSE , " " ) ; } return 0 ; }
And now, we get to the meat of the file.
And now we get to the meat of the file .
/* We first verify the OS.  `SDL_GetPlatform` is used to get this information.  If the OS is invalid, the program is crashed.  If the OS is questionable, the user is warned appropriately.  If the OS is fine, nothing happens. */ /* We now need to check the battery with `SDL_GetPowerInfo`.  This uses the following logic:
	 *
	 * - If the player is not on a battery, continue, and don't run rechecks.
	 * - If the player is on a battery, but it's plugged in, don't do anything at first, but run rechecks later.
	 * - If the player is on a battery that isn't plugged in, then:
	 *   	- If the battery is below 15% or has less than 15 minutes left, crash the game.
	 *   	- Otherwise, notify the user that they may want to plug in if they play for a while, but continue which running rechecks.
	 * - If the power state can't be determined, warn the user, but continue as normal.
	 *
	 * I have no idea why the output of `SDL_GetPowerInfo` is stored both in its arguments _and_ in it's return.  Ah well. */