@ -2944,8 +2944,20 @@ bool Steam_Init(){
return false ;
}
int main ( )
int main ( char * * args , const int argn )
{
debugLogger . open ( " debug.log " ) ;
LOG ( std : : format ( " Found {} args " , argn ) ) ;
bool usingSteam = true ;
for ( int i = 0 ; i < argn ; i + + ) {
if ( std : : string ( args [ i ] ) = = " nosteam " ) {
LOG ( " nosteam flag detected. Disabling steam API... " ) ;
usingSteam = false ;
}
LOG ( std : : format ( " {}: {} " , i , args [ i ] ) ) ;
}
if ( ! std : : filesystem : : exists ( " assets/config/configuration.txt " ) ) {
ERR ( " WARNING! Could not find initial config file! Aborting. " ) ;
return false ;
@ -2953,7 +2965,8 @@ int main()
{
utils : : datafile configFile ;
utils : : datafile : : Read ( configFile , " assets/config/configuration.txt " ) ;
if ( configFile [ " steam_api " ] . GetBool ( ) ) {
usingSteam & = configFile [ " steam_api " ] . GetBool ( ) ;
if ( usingSteam ) {
# ifndef __EMSCRIPTEN__
if ( SteamAPI_RestartAppIfNecessary ( 2895980U ) ) return false ; //Immediately quit if steam is detected and can be started through it.
if ( Steam_Init ( ) ) {
@ -2967,6 +2980,8 @@ int main()
{
AiL demo ;
demo . UsingSteamAPI ( usingSteam ) ;
# pragma region Load Window Settings
utils : : datafile loadSystemFile ;
@ -3040,10 +3055,42 @@ int main()
return 0 ;
}
void get_command_line_args ( int * argc , char * * * argv )
{
// Get the command line arguments as wchar_t strings
wchar_t * * wargv = CommandLineToArgvW ( GetCommandLineW ( ) , argc ) ;
if ( ! wargv ) { * argc = 0 ; * argv = NULL ; return ; }
// Count the number of bytes necessary to store the UTF-8 versions of those strings
int n = 0 ;
for ( int i = 0 ; i < * argc ; i + + )
n + = WideCharToMultiByte ( CP_UTF8 , 0 , wargv [ i ] , - 1 , NULL , 0 , NULL , NULL ) + 1 ;
// Allocate the argv[] array + all the UTF-8 strings
* argv = ( char * * ) ( malloc ( ( * argc + 1 ) * sizeof ( char * ) + n ) ) ;
if ( ! * argv ) { * argc = 0 ; return ; }
// Convert all wargv[] --> argv[]
char * arg = ( char * ) & ( ( * argv ) [ * argc + 1 ] ) ;
for ( int i = 0 ; i < * argc ; i + + )
{
( * argv ) [ i ] = arg ;
arg + = WideCharToMultiByte ( CP_UTF8 , 0 , wargv [ i ] , - 1 , arg , n , NULL , NULL ) + 1 ;
}
( * argv ) [ * argc ] = NULL ;
}
# ifndef _DEBUG
# ifdef _WIN32
int CALLBACK WinMain ( HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpCmdLine , int nCmdShow ) {
main ( ) ;
int argc ;
char * * argv ;
get_command_line_args ( & argc , & argv ) ;
for ( int n = 0 ; n < argc ; n + + )
printf ( " %d : %s \n " , n , argv [ n ] ) ;
main ( argv , argc ) ;
free ( argv ) ;
}
# endif
# endif
@ -3938,7 +3985,7 @@ void AiL::UpdateDiscordStatus(std::string levelName,std::string className){
}
SteamFriends ( ) - > SetRichPresence ( " steam_display " , " #Status " ) ;
} else {
if ( " steam_api " _B & & Steam_Init ( ) ) {
if ( steamAPIEnabled & & Steam_Init ( ) ) {
retry = true ;
LOG ( " Steam API Initialized successfully! " ) ;
}
@ -4297,4 +4344,8 @@ void AiL::SetWindSpeed(vf2d newWindSpd){
}
const vf2d & AiL : : GetWindSpeed ( ) const {
return windSpd ;
}
void AiL : : UsingSteamAPI ( const bool usingSteam ) {
steamAPIEnabled = usingSteam ;
}