diff --git a/dedicated/sys_ded.cpp b/dedicated/sys_ded.cpp index f1ff4449..1f37318a 100644 --- a/dedicated/sys_ded.cpp +++ b/dedicated/sys_ded.cpp @@ -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 } diff --git a/dedicated_main/main.cpp b/dedicated_main/main.cpp index 7629f07a..5f56c578 100644 --- a/dedicated_main/main.cpp +++ b/dedicated_main/main.cpp @@ -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 ); diff --git a/engine/sys_dll.cpp b/engine/sys_dll.cpp index 0c2d255e..3c00cdc3 100644 --- a/engine/sys_dll.cpp +++ b/engine/sys_dll.cpp @@ -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 } diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index 0b27da73..ca1f1393 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -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 diff --git a/launcher_main/main.cpp b/launcher_main/main.cpp index 0e7201d2..1929915b 100644 --- a/launcher_main/main.cpp +++ b/launcher_main/main.cpp @@ -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 ) { diff --git a/materialsystem/cmaterialsystem.cpp b/materialsystem/cmaterialsystem.cpp index 5a2a98e7..d0db83ea 100644 --- a/materialsystem/cmaterialsystem.cpp +++ b/materialsystem/cmaterialsystem.cpp @@ -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 diff --git a/public/filesystem_init.cpp b/public/filesystem_init.cpp index c6baf73a..fa69ae6a 100644 --- a/public/filesystem_init.cpp +++ b/public/filesystem_init.cpp @@ -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; diff --git a/tier0/assert_dialog.cpp b/tier0/assert_dialog.cpp index d0a73b8e..a5ab80d0 100644 --- a/tier0/assert_dialog.cpp +++ b/tier0/assert_dialog.cpp @@ -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()