mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-01-27 15:24:28 +00:00
fix dedicated and allow to start from everywhere
This commit is contained in:
parent
49cde1ac27
commit
84745a2085
@ -360,12 +360,9 @@ void CDedicatedAppSystemGroup::Destroy()
|
|||||||
bool GetExecutableName( char *out, int nMaxLen )
|
bool GetExecutableName( char *out, int nMaxLen )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if ( !::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, nMaxLen ) )
|
return !!::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, nMaxLen );
|
||||||
|
#else
|
||||||
return false;
|
return false;
|
||||||
return true;
|
|
||||||
#elif POSIX
|
|
||||||
Q_strncpy( out, g_szEXEName, nMaxLen );
|
|
||||||
return true;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,23 +188,6 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
|
|||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
// Must add 'bin' to the path....
|
|
||||||
char* pPath = getenv("LD_LIBRARY_PATH");
|
|
||||||
char szBuffer[4096];
|
|
||||||
char cwd[ MAX_PATH ];
|
|
||||||
if ( !getcwd( cwd, sizeof(cwd)) )
|
|
||||||
{
|
|
||||||
printf( "getcwd failed (%s)", strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf( szBuffer, sizeof( szBuffer ) - 1, "LD_LIBRARY_PATH=%s/bin:%s", cwd, pPath );
|
|
||||||
int ret = putenv( szBuffer );
|
|
||||||
if ( ret )
|
|
||||||
{
|
|
||||||
printf( "%s\n", strerror(errno) );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
void *dedicated = dlopen( "libdedicated" DLL_EXT_STRING, RTLD_NOW );
|
void *dedicated = dlopen( "libdedicated" DLL_EXT_STRING, RTLD_NOW );
|
||||||
if ( !dedicated )
|
if ( !dedicated )
|
||||||
dedicated = dlopen( "dedicated" DLL_EXT_STRING, RTLD_NOW );
|
dedicated = dlopen( "dedicated" DLL_EXT_STRING, RTLD_NOW );
|
||||||
|
@ -342,9 +342,11 @@ bool Sys_MessageBox(const char *title, const char *info, bool bShowOkAndCancel)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
#else
|
||||||
#elif defined( USE_SDL )
|
#if defined( USE_SDL )
|
||||||
|
SDL_Window *dialogParent = GetAssertDialogParent();
|
||||||
|
if (dialogParent)
|
||||||
|
{
|
||||||
int buttonid = 0;
|
int buttonid = 0;
|
||||||
SDL_MessageBoxData messageboxdata = { 0 };
|
SDL_MessageBoxData messageboxdata = { 0 };
|
||||||
SDL_MessageBoxButtonData buttondata[] =
|
SDL_MessageBoxButtonData buttondata[] =
|
||||||
@ -361,14 +363,13 @@ bool Sys_MessageBox(const char *title, const char *info, bool bShowOkAndCancel)
|
|||||||
|
|
||||||
SDL_ShowMessageBox( &messageboxdata, &buttonid );
|
SDL_ShowMessageBox( &messageboxdata, &buttonid );
|
||||||
return ( buttonid == 1 );
|
return ( buttonid == 1 );
|
||||||
|
}
|
||||||
#elif defined( POSIX )
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
Warning( "%s\n", info );
|
Warning( "%s\n", info );
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
#else
|
|
||||||
#error "implement me"
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,11 +239,7 @@ void SetGameDirectory( const char *game )
|
|||||||
bool GetExecutableName( char *out, int outSize )
|
bool GetExecutableName( char *out, int outSize )
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if ( !::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, outSize ) )
|
return !!::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, outSize );
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -216,27 +216,6 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
|
|||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
char ld_path[4196];
|
|
||||||
char *path = "bin/";
|
|
||||||
char *ld_env;
|
|
||||||
|
|
||||||
if( (ld_env = getenv("LD_LIBRARY_PATH")) != NULL )
|
|
||||||
{
|
|
||||||
snprintf(ld_path, sizeof(ld_path), "%s:bin/", ld_env);
|
|
||||||
path = ld_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
setenv("LD_LIBRARY_PATH", path, 1);
|
|
||||||
|
|
||||||
extern char** environ;
|
|
||||||
if( getenv("NO_EXECVE_AGAIN") == NULL )
|
|
||||||
{
|
|
||||||
setenv("NO_EXECVE_AGAIN", "1", 1);
|
|
||||||
execve(argv[0], argv, environ);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *launcher = dlopen( "liblauncher" DLL_EXT_STRING, RTLD_NOW );
|
void *launcher = dlopen( "liblauncher" DLL_EXT_STRING, RTLD_NOW );
|
||||||
if ( !launcher )
|
if ( !launcher )
|
||||||
{
|
{
|
||||||
|
@ -672,7 +672,7 @@ bool CMaterialSystem::Connect( CreateInterfaceFn factory )
|
|||||||
g_pLauncherMgr = (ILauncherMgr *)factory( "SDLMgrInterface001" /*SDL_MGR_INTERFACE_VERSION*/, NULL );
|
g_pLauncherMgr = (ILauncherMgr *)factory( "SDLMgrInterface001" /*SDL_MGR_INTERFACE_VERSION*/, NULL );
|
||||||
if ( !g_pLauncherMgr )
|
if ( !g_pLauncherMgr )
|
||||||
{
|
{
|
||||||
return false;
|
Warning("Cannot connect SDL\n");
|
||||||
}
|
}
|
||||||
#endif // USE_SDL
|
#endif // USE_SDL
|
||||||
#endif // !DEDICATED
|
#endif // !DEDICATED
|
||||||
|
@ -310,58 +310,10 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
Q_strncpy( exedir, getenv("APP_LIB_PATH"), exeDirLen );
|
Q_strncpy( exedir, getenv("APP_LIB_PATH"), exeDirLen );
|
||||||
#else
|
#else
|
||||||
# if 0
|
# ifdef _WIN32
|
||||||
exedir[0] = 0;
|
|
||||||
|
|
||||||
if ( s_bUseVProjectBinDir )
|
|
||||||
{
|
|
||||||
const char *pProject = GetVProjectCmdLineValue();
|
|
||||||
if ( !pProject )
|
|
||||||
{
|
|
||||||
// Check their registry.
|
|
||||||
pProject = getenv( GAMEDIR_TOKEN );
|
|
||||||
}
|
|
||||||
if ( pProject )
|
|
||||||
{
|
|
||||||
Q_snprintf( exedir, exeDirLen, "%s%c..%cbin", pProject, CORRECT_PATH_SEPARATOR, CORRECT_PATH_SEPARATOR );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !Sys_GetExecutableName( exedir, exeDirLen ) )
|
|
||||||
return false;
|
|
||||||
Q_StripFilename( exedir );
|
|
||||||
|
|
||||||
if ( IsX360() )
|
|
||||||
{
|
|
||||||
// The 360 can have its exe and dlls reside on different volumes
|
|
||||||
// use the optional basedir as the exe dir
|
|
||||||
if ( CommandLine()->FindParm( "-basedir" ) )
|
|
||||||
{
|
|
||||||
strcpy( exedir, CommandLine()->ParmValue( "-basedir", "" ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_FixSlashes( exedir );
|
|
||||||
|
|
||||||
const char* libDir = "bin";
|
|
||||||
|
|
||||||
// Return the bin directory as the executable dir if it's not in there
|
|
||||||
// because that's really where we're running from...
|
|
||||||
char ext[MAX_PATH];
|
|
||||||
Q_StrRight( exedir, 4, ext, sizeof( ext ) );
|
|
||||||
if ( ext[0] != CORRECT_PATH_SEPARATOR || Q_stricmp( ext+1, libDir ) != 0 )
|
|
||||||
{
|
|
||||||
Q_strncat( exedir, CORRECT_PATH_SEPARATOR_S, exeDirLen, COPY_ALL_CHARACTERS );
|
|
||||||
Q_strncat( exedir, libDir, exeDirLen, COPY_ALL_CHARACTERS );
|
|
||||||
Q_FixSlashes( exedir );
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
# ifdef POSIX
|
|
||||||
Q_strncpy( exedir, LIBDIR, exeDirLen );
|
|
||||||
# else
|
|
||||||
Q_strncpy( exedir, "./bin", exeDirLen );
|
Q_strncpy( exedir, "./bin", exeDirLen );
|
||||||
|
# else
|
||||||
|
Q_strncpy( exedir, LIBDIR, exeDirLen );
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -374,17 +326,12 @@ static bool FileSystem_GetBaseDir( char *baseDir, int baseDirLen )
|
|||||||
Q_strncpy(baseDir, getenv("VALVE_GAME_PATH"), baseDirLen);
|
Q_strncpy(baseDir, getenv("VALVE_GAME_PATH"), baseDirLen);
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
# if 0
|
// get relative base dir which appends to other paths
|
||||||
if ( FileSystem_GetExecutableDir( baseDir, baseDirLen ) )
|
// allows to run from everywhere
|
||||||
{
|
// "hl2/portal" -> "hl2"; "hl2" -> ""
|
||||||
|
Q_strncpy( baseDir, CommandLine()->ParmValue("-game"), baseDirLen );
|
||||||
Q_StripFilename( baseDir );
|
Q_StripFilename( baseDir );
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
# else
|
|
||||||
return getcwd(baseDir, baseDirLen) != NULL;
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1116,7 +1063,11 @@ FSReturnCode_t FileSystem_SetBasePaths( IFileSystem *pFileSystem )
|
|||||||
|
|
||||||
pFileSystem->AddSearchPath( path, "BASE_PATH" );
|
pFileSystem->AddSearchPath( path, "BASE_PATH" );
|
||||||
|
|
||||||
Q_snprintf( path, MAX_PATH, "%s/%s", LIBDIR, CommandLine()->ParmValue("-game") );
|
// path for client/server libraries
|
||||||
|
// "hl2/portal" -> "LIBDIR/portal"; "hl2" -> "LIBDIR/hl2"
|
||||||
|
char gamePath[MAX_PATH];
|
||||||
|
V_FileBase( CommandLine()->ParmValue("-game"), gamePath, MAX_PATH );
|
||||||
|
Q_snprintf( path, MAX_PATH, "%s/%s", LIBDIR, gamePath );
|
||||||
pFileSystem->AddSearchPath( path, "GAMEBIN" );
|
pFileSystem->AddSearchPath( path, "GAMEBIN" );
|
||||||
|
|
||||||
return FS_OK;
|
return FS_OK;
|
||||||
|
@ -369,6 +369,16 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent()
|
|||||||
{
|
{
|
||||||
return g_SDLWindow;
|
return g_SDLWindow;
|
||||||
}
|
}
|
||||||
|
#elif !defined( _WIN32 )
|
||||||
|
DBG_INTERFACE void SetAssertDialogParent( void *window)
|
||||||
|
{
|
||||||
|
(void)window;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_INTERFACE void * GetAssertDialogParent()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBG_INTERFACE bool ShouldUseNewAssertDialog()
|
DBG_INTERFACE bool ShouldUseNewAssertDialog()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user