mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-22 06:06:50 +00:00
tier1: rewrite Sys_LoadModule
This commit is contained in:
parent
653e08bce4
commit
e5eaf0fa9e
@ -5042,10 +5042,11 @@ CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPat
|
||||
|
||||
char tempPathID[ MAX_PATH ];
|
||||
ParsePathID( pFileName, pPathID, tempPathID );
|
||||
|
||||
|
||||
CUtlSymbol lookup = g_PathIDTable.AddString( pPathID );
|
||||
|
||||
// a pathID has been specified, find the first match in the path list
|
||||
#ifndef ANDROID
|
||||
int c = m_SearchPaths.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
@ -5071,14 +5072,6 @@ CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPat
|
||||
return pModule;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef POSIX
|
||||
if( !pModule )
|
||||
{
|
||||
Q_snprintf( tempPathID, sizeof(tempPathID), "lib%s", pFileName );
|
||||
pModule = Sys_LoadModule( tempPathID );
|
||||
}
|
||||
#endif
|
||||
|
||||
if( !pModule )
|
||||
|
@ -258,7 +258,7 @@ HMODULE Sys_LoadLibrary( const char *pLibraryName, Sys_Flags flags )
|
||||
const char *pError = dlerror();
|
||||
if ( pError && ( strstr( pError, "No such file" ) == 0 ) && ( strstr( pError, "image not found" ) == 0 ) )
|
||||
{
|
||||
Msg( " failed to dlopen %s error=%s\n", str, pError );
|
||||
Msg( "failed to dlopen %s error=%s\n", str, pError );
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,6 +267,36 @@ HMODULE Sys_LoadLibrary( const char *pLibraryName, Sys_Flags flags )
|
||||
}
|
||||
static bool s_bRunningWithDebugModules = false;
|
||||
|
||||
#ifdef POSIX
|
||||
|
||||
#ifdef ANDROID
|
||||
#define DEFAULT_LIB_PATH ""
|
||||
#else
|
||||
#define DEFAULT_LIB_PATH "bin/"
|
||||
#endif
|
||||
|
||||
bool foundLibraryWithPrefix( char *pModuleAbsolutePath, size_t AbsolutePathSize, const char *pPath, const char *pModuleName )
|
||||
{
|
||||
char str[1024];
|
||||
Q_strncpy( str, pModuleName, sizeof(str) );
|
||||
V_SetExtension( str, DLL_EXT_STRING, sizeof(str) );
|
||||
bool bFound = false;
|
||||
|
||||
struct stat statBuf;
|
||||
Q_snprintf(pModuleAbsolutePath, AbsolutePathSize, "%s/" DEFAULT_LIB_PATH "lib%s", pPath, str);
|
||||
bFound |= stat(pModuleAbsolutePath, &statBuf) == 0;
|
||||
|
||||
if( !bFound )
|
||||
{
|
||||
Q_snprintf(pModuleAbsolutePath, AbsolutePathSize, "%s/" DEFAULT_LIB_PATH "%s", pPath, str);
|
||||
bFound |= stat(pModuleAbsolutePath, &statBuf) == 0;
|
||||
}
|
||||
|
||||
return bFound;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads a DLL/component from disk and returns a handle to it
|
||||
// Input : *pModuleName - filename of the component
|
||||
@ -301,52 +331,61 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
|
||||
szCwd[strlen(szCwd) - 1] = 0;
|
||||
}
|
||||
|
||||
char szAbsoluteModuleName[1024];
|
||||
bool bUseLibPrefix = false;
|
||||
|
||||
char szAbsoluteModuleName[2048];
|
||||
#ifdef ANDROID
|
||||
struct stat statBuf;
|
||||
char *libPath = getenv("APP_LIB_PATH");
|
||||
|
||||
char *modLibPath = getenv("APP_MOD_LIB");
|
||||
bool bFound;
|
||||
|
||||
if( modLibPath && *modLibPath ) // first load library from mod launcher
|
||||
{
|
||||
bool bFound = true;
|
||||
Q_snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/lib%s", modLibPath, pModuleName);
|
||||
if( stat(szAbsoluteModuleName, &statBuf) != 0 )
|
||||
{
|
||||
Q_snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", modLibPath, pModuleName);
|
||||
if( stat(szAbsoluteModuleName, &statBuf) != 0 )
|
||||
bFound = false;
|
||||
}
|
||||
bFound = foundLibraryWithPrefix( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), modLibPath, pModuleName );
|
||||
|
||||
hDLL = Sys_LoadLibrary(szAbsoluteModuleName, flags);
|
||||
if( bFound )
|
||||
hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags );
|
||||
|
||||
if( !hDLL && bFound )
|
||||
Error("Can't load mod library %s\n", szAbsoluteModuleName);
|
||||
Error("Can't find mod library %s\n", szAbsoluteModuleName);
|
||||
}
|
||||
|
||||
Q_snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/lib%s", libPath ,pModuleName);
|
||||
if( stat(szAbsoluteModuleName, &statBuf) != 0 )
|
||||
Q_snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", libPath ,pModuleName);
|
||||
if( !foundLibraryWithPrefix( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), libPath, pModuleName ) )
|
||||
{
|
||||
Warning("Can't find module - %s\n", pModuleName);
|
||||
return reinterpret_cast<CSysModule *>(hDLL);
|
||||
}
|
||||
|
||||
#elif defined( POSIX )
|
||||
if( !foundLibraryWithPrefix(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), szCwd, pModuleName) )
|
||||
{
|
||||
Warning("Can't find module - %s\n", pModuleName);
|
||||
return reinterpret_cast<CSysModule *>(hDLL);
|
||||
}
|
||||
#else
|
||||
#ifdef POSIX
|
||||
struct stat statBuf;
|
||||
Q_snprintf(szModuleName, sizeof(szModuleName), "bin/lib%s", pModuleName);
|
||||
bUseLibPrefix |= stat(szModuleName, &statBuf) == 0;
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName );
|
||||
#endif
|
||||
if( bUseLibPrefix )
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/lib%s", szCwd, pModuleName );
|
||||
else
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName );
|
||||
#endif // ANDROID
|
||||
Msg("LoadLibrary: pModule: %s, path: %s\n", pModuleName, szAbsoluteModuleName);
|
||||
|
||||
if( !hDLL )
|
||||
hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags );
|
||||
}
|
||||
else
|
||||
Msg("LoadLibrary: path: %s\n", pModuleName);
|
||||
{
|
||||
#ifdef POSIX
|
||||
Q_strncpy( szModuleName, pModuleName, sizeof(szModuleName) );
|
||||
V_SetExtension( szModuleName, DLL_EXT_STRING, sizeof(szModuleName) );
|
||||
|
||||
struct stat statBuf;
|
||||
bool bFound = stat(szModuleName, &statBuf) == 0;
|
||||
|
||||
if( !bFound )
|
||||
{
|
||||
Warning("Can't find module - %s\n", pModuleName);
|
||||
return reinterpret_cast<CSysModule *>(hDLL);
|
||||
}
|
||||
|
||||
Msg("LoadLibrary: path: %s\n", szModuleName);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if ( !hDLL )
|
||||
|
@ -155,7 +155,7 @@ m_HideTooltip( this, &HTML::BrowserHideToolTip )
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning("Unable to access SteamHTMLSurface");
|
||||
Warning("Unable to access SteamHTMLSurface\n");
|
||||
}
|
||||
m_iScrollBorderX=m_iScrollBorderY=0;
|
||||
m_bScrollBarEnabled = true;
|
||||
|
Loading…
Reference in New Issue
Block a user