mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-01-25 22:34:25 +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 )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if ( !::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, nMaxLen ) )
|
||||
return false;
|
||||
return true;
|
||||
#elif POSIX
|
||||
Q_strncpy( out, g_szEXEName, nMaxLen );
|
||||
return true;
|
||||
return !!::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, nMaxLen );
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -188,23 +188,6 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
|
||||
|
||||
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 );
|
||||
if ( !dedicated )
|
||||
dedicated = dlopen( "dedicated" DLL_EXT_STRING, RTLD_NOW );
|
||||
|
@ -342,33 +342,34 @@ bool Sys_MessageBox(const char *title, const char *info, bool bShowOkAndCancel)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
#elif defined( USE_SDL )
|
||||
|
||||
int buttonid = 0;
|
||||
SDL_MessageBoxData messageboxdata = { 0 };
|
||||
SDL_MessageBoxButtonData buttondata[] =
|
||||
{
|
||||
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK" },
|
||||
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "Cancel" },
|
||||
};
|
||||
|
||||
messageboxdata.window = GetAssertDialogParent();
|
||||
messageboxdata.title = title;
|
||||
messageboxdata.message = info;
|
||||
messageboxdata.numbuttons = bShowOkAndCancel ? 2 : 1;
|
||||
messageboxdata.buttons = buttondata;
|
||||
|
||||
SDL_ShowMessageBox( &messageboxdata, &buttonid );
|
||||
return ( buttonid == 1 );
|
||||
|
||||
#elif defined( POSIX )
|
||||
|
||||
Warning( "%s\n", info );
|
||||
return true;
|
||||
|
||||
#else
|
||||
#error "implement me"
|
||||
#if defined( USE_SDL )
|
||||
SDL_Window *dialogParent = GetAssertDialogParent();
|
||||
if (dialogParent)
|
||||
{
|
||||
int buttonid = 0;
|
||||
SDL_MessageBoxData messageboxdata = { 0 };
|
||||
SDL_MessageBoxButtonData buttondata[] =
|
||||
{
|
||||
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK" },
|
||||
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "Cancel" },
|
||||
};
|
||||
|
||||
messageboxdata.window = GetAssertDialogParent();
|
||||
messageboxdata.title = title;
|
||||
messageboxdata.message = info;
|
||||
messageboxdata.numbuttons = bShowOkAndCancel ? 2 : 1;
|
||||
messageboxdata.buttons = buttondata;
|
||||
|
||||
SDL_ShowMessageBox( &messageboxdata, &buttonid );
|
||||
return ( buttonid == 1 );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Warning( "%s\n", info );
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -239,11 +239,7 @@ void SetGameDirectory( const char *game )
|
||||
bool GetExecutableName( char *out, int outSize )
|
||||
{
|
||||
#ifdef WIN32
|
||||
if ( !::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, outSize ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !!::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, outSize );
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -216,27 +216,6 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
|
||||
|
||||
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 );
|
||||
if ( !launcher )
|
||||
{
|
||||
|
@ -672,7 +672,7 @@ bool CMaterialSystem::Connect( CreateInterfaceFn factory )
|
||||
g_pLauncherMgr = (ILauncherMgr *)factory( "SDLMgrInterface001" /*SDL_MGR_INTERFACE_VERSION*/, NULL );
|
||||
if ( !g_pLauncherMgr )
|
||||
{
|
||||
return false;
|
||||
Warning("Cannot connect SDL\n");
|
||||
}
|
||||
#endif // USE_SDL
|
||||
#endif // !DEDICATED
|
||||
|
@ -310,58 +310,10 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
|
||||
#ifdef ANDROID
|
||||
Q_strncpy( exedir, getenv("APP_LIB_PATH"), exeDirLen );
|
||||
#else
|
||||
# if 0
|
||||
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
|
||||
# ifdef _WIN32
|
||||
Q_strncpy( exedir, "./bin", exeDirLen );
|
||||
# else
|
||||
Q_strncpy( exedir, LIBDIR, exeDirLen );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -374,17 +326,12 @@ static bool FileSystem_GetBaseDir( char *baseDir, int baseDirLen )
|
||||
Q_strncpy(baseDir, getenv("VALVE_GAME_PATH"), baseDirLen);
|
||||
return true;
|
||||
#else
|
||||
# if 0
|
||||
if ( FileSystem_GetExecutableDir( baseDir, baseDirLen ) )
|
||||
{
|
||||
Q_StripFilename( baseDir );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
# else
|
||||
return getcwd(baseDir, baseDirLen) != NULL;
|
||||
# endif
|
||||
// get relative base dir which appends to other paths
|
||||
// allows to run from everywhere
|
||||
// "hl2/portal" -> "hl2"; "hl2" -> ""
|
||||
Q_strncpy( baseDir, CommandLine()->ParmValue("-game"), baseDirLen );
|
||||
Q_StripFilename( baseDir );
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1116,7 +1063,11 @@ FSReturnCode_t FileSystem_SetBasePaths( IFileSystem *pFileSystem )
|
||||
|
||||
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" );
|
||||
|
||||
return FS_OK;
|
||||
|
@ -369,6 +369,16 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent()
|
||||
{
|
||||
return g_SDLWindow;
|
||||
}
|
||||
#elif !defined( _WIN32 )
|
||||
DBG_INTERFACE void SetAssertDialogParent( void *window)
|
||||
{
|
||||
(void)window;
|
||||
}
|
||||
|
||||
DBG_INTERFACE void * GetAssertDialogParent()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
DBG_INTERFACE bool ShouldUseNewAssertDialog()
|
||||
|
Loading…
x
Reference in New Issue
Block a user