Browse Source

game_launch: declare environ variable, by standard it must be declared by user program

pull/2/head
Alibek Omarov 3 years ago
parent
commit
a717b7fc49
  1. 12
      engine/common/launcher.c
  2. 3
      game_launch/game.cpp

12
engine/common/launcher.c

@ -25,6 +25,9 @@ GNU General Public License for more details. @@ -25,6 +25,9 @@ GNU General Public License for more details.
#include <emscripten.h>
#endif
#include <unistd.h>
extern char **environ;
static char szGameDir[128]; // safe place to keep gamedir
static int g_iArgc;
static char **g_pszArgv;
@ -40,17 +43,18 @@ static char **g_pszArgv; @@ -40,17 +43,18 @@ static char **g_pszArgv;
void Launcher_ChangeGame( const char *progname )
{
char envstr[256];
#if USE_EXECVE_FOR_CHANGE_GAME
Host_Shutdown();
#if XASH_WIN32
_putenv_s( E_GAME, progname );
_execve( szArgv[0], szArgv, environ );
_execve( g_pszArgv[0], g_pszArgv, _environ );
#else
char envstr[256];
snprintf( envstr, sizeof( envstr ), E_GAME "=%s", progname );
putenv( envstr );
execve( szArgv[0], szArgv, environ );
execve( g_pszArgv[0], g_pszArgv, environ );
#endif
#else
@ -100,7 +104,7 @@ int main( int argc, char** argv ) @@ -100,7 +104,7 @@ int main( int argc, char** argv )
if( !game )
game = GAME_PATH;
Q_strncpy( szGameDir, gamedir, sizeof( szGameDir ));
Q_strncpy( szGameDir, game, sizeof( szGameDir ));
#if XASH_EMSCRIPTEN
#ifdef EMSCRIPTEN_LIB_FS

3
game_launch/game.cpp

@ -56,6 +56,7 @@ typedef void (*pfnChangeGame)( const char *progname ); @@ -56,6 +56,7 @@ typedef void (*pfnChangeGame)( const char *progname );
typedef int (*pfnInit)( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
typedef void (*pfnShutdown)( void );
extern char **environ;
static pfnInit Xash_Main;
static pfnShutdown Xash_Shutdown = NULL;
static char szGameDir[128]; // safe place to keep gamedir
@ -129,7 +130,7 @@ static void Sys_ChangeGame( const char *progname ) @@ -129,7 +130,7 @@ static void Sys_ChangeGame( const char *progname )
_putenv_s( E_GAME, progname );
Sys_UnloadEngine();
_execve( szArgv[0], szArgv, environ );
_execve( szArgv[0], szArgv, _environ );
#else
char envstr[256];
snprintf( envstr, sizeof( envstr ), E_GAME "=%s", progname );

Loading…
Cancel
Save