diff --git a/engine/common/host.c b/engine/common/host.c index 55f42683..d5469702 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -38,7 +38,6 @@ GNU General Public License for more details. #include "tests.h" host_parm_t host; // host parms -static pfnChangeGame pChangeGame = NULL; static jmp_buf return_from_main_buf; /* @@ -389,12 +388,10 @@ static int Host_CalcSleep( void ) static void Host_NewInstance( const char *name, const char *finalmsg ) { - if( !pChangeGame ) return; - host.change_game = true; if( !Sys_NewInstance( name, finalmsg )) - pChangeGame( name ); // call from hl.exe + Con_Printf( S_ERROR "Failed to restart the engine\n" ); } /* @@ -1191,7 +1188,7 @@ static void Sys_Quit_f( void ) Host_Main ================= */ -int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ) +int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame pChangeGame ) { static double oldtime; string demoname, exename; @@ -1201,8 +1198,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa host.starttime = Platform_DoubleTime(); - pChangeGame = func; // may be NULL - Host_InitCommon( argc, argv, progname, bChangeGame, exename, sizeof( exename )); // init commands and vars @@ -1250,7 +1245,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa Netchan_Init(); // allow to change game from the console - if( pChangeGame != NULL ) + if( pChangeGame != NULL && Sys_CanRestart( )) { Cmd_AddRestrictedCommand( "game", Host_ChangeGame_f, "change game" ); Cvar_Get( "host_allow_changegame", "1", FCVAR_READ_ONLY, "allows to change games" ); diff --git a/engine/common/launcher.c b/engine/common/launcher.c index bfc61fe6..9a689b57 100644 --- a/engine/common/launcher.c +++ b/engine/common/launcher.c @@ -21,10 +21,6 @@ GNU General Public License for more details. #include #endif -#if XASH_EMSCRIPTEN -#include -#endif - #ifndef XASH_GAMEDIR #define XASH_GAMEDIR "valve" // !!! Replace with your default (base) game directory !!! #endif @@ -46,20 +42,6 @@ static int Sys_Start( void ) { Q_strncpy( szGameDir, XASH_GAMEDIR, sizeof( szGameDir )); -#if XASH_EMSCRIPTEN -#if !XASH_DEDICATED - EM_ASM( try { - FS.mkdir( '/rwdir' ); - FS.mount( IDBFS, { root: '.' }, '/rwdir' ); - } catch( e ) { };); -#else // XASH_DEDICATED - EM_ASM(try { - FS.mkdir( '/xash' ); - FS.mount( NODEFS, { root: '.'}, '/xash' ); - } catch( e ) { };); -#endif // XASH_DEDICATED -#endif // XASH_EMSCRIPTEN - #if XASH_IOS IOS_LaunchDialog(); szArgc = IOS_GetArgs( &szArgv ); diff --git a/engine/common/system.c b/engine/common/system.c index ae75ee9e..99ac7155 100644 --- a/engine/common/system.c +++ b/engine/common/system.c @@ -523,6 +523,24 @@ void Sys_Print( const char *pMsg ) Rcon_Print( &host.rd, pMsg ); } +/* +================== +Sys_CanRestart + +Returns true if execv-like syscall is available +================== +*/ +qboolean Sys_CanRestart( void ) +{ +#if XASH_NSWITCH || XASH_PSVITA + return true; +#else + int exelen = wai_getExecutablePath( NULL, 0, NULL ); + + return exelen > 0; +#endif +} + /* ================== Sys_ChangeGame diff --git a/engine/common/system.h b/engine/common/system.h index 4425bfd5..cf7c81db 100644 --- a/engine/common/system.h +++ b/engine/common/system.h @@ -67,6 +67,7 @@ qboolean _Sys_GetParmFromCmdLine( const char *parm, char *out, size_t size ); qboolean Sys_GetIntFromCmdLine( const char *parm, int *out ); void Sys_Print( const char *pMsg ); void Sys_Quit( const char *reason ) NORETURN; +qboolean Sys_CanRestart( void ); qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg ); void *Sys_GetNativeObject( const char *obj );