void Sys_ChangeGame( const char *progname ) { if( !progname || !progname[0] ) Xash_Error( "Sys_ChangeGame: NULL gamedir" ); if( Xash_Shutdown == NULL ) Xash_Error( "Sys_ChangeGame: missed 'Host_Shutdown' export\n" ); strncpy( szGameDir, progname, sizeof( szGameDir ) - 1 ); Sys_UnloadEngine (); Sys_LoadEngine (); Xash_Main( szArgc, szArgv, szGameDir, true, ( Xash_Shutdown != NULL ) ? Sys_ChangeGame : NULL ); }
void Sys_LoadEngine( void ) { if(( hEngine = dlmount( XASHLIB )) == NULL ) { Xash_Error("Unable to load the " XASHLIB ": %s", dlerror() ); } if(( Xash_Main = (pfnInit)dlsym( hEngine, "Host_Main" )) == NULL ) { Xash_Error( XASHLIB " missed 'Host_Main' export: %s", dlerror() ); } // this is non-fatal for us but change game will not working Xash_Shutdown = (pfnShutdown)dlsym( hEngine, "Host_Shutdown" ); }
int main( int argc, char **argv ) #endif { #if _MSC_VER == 1200 LPWSTR* lpArgv = CommandLineToArgvW(GetCommandLineW(), &szArgc); int size, i = 0; szArgv = (char**)malloc(szArgc*sizeof(char*)); for (; i < szArgc; ++i) { size = wcslen(lpArgv[i]) + 1; szArgv[i] = (char*)malloc(size); wcstombs(szArgv[i], lpArgv[i], size); } LocalFree(lpArgv); #else szArgc = argc; szArgv = argv; #endif #if defined(PANDORA) || defined(RPI) if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS )) { Xash_Error( "Error on SDL_Init" ); return 0; } #endif Sys_LoadEngine(); return Xash_Main( szArgc, szArgv, GAME_PATH, false, ( Xash_Shutdown != NULL ) ? Sys_ChangeGame : NULL ); }