Skip to content

Commit

Permalink
filesystem: copy absolute path to library in FS_FindLibrary for compa…
Browse files Browse the repository at this point in the history
…tibility

Extend fullPath for longer absolute paths.
  • Loading branch information
a1batross committed Apr 22, 2024
1 parent 75451cc commit 60c6767
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
12 changes: 6 additions & 6 deletions engine/common/filesystem_engine.c
Expand Up @@ -89,32 +89,32 @@ qboolean FS_LoadProgs( void )

if( !fs_hInstance )
{
Host_Error( "FS_LoadProgs: can't load filesystem library %s: %s\n", name, COM_GetLibraryError() );
Host_Error( "%s: can't load filesystem library %s: %s\n", __func__, name, COM_GetLibraryError() );
return false;
}

if( !( GetFSAPI = (FSAPI)COM_GetProcAddress( fs_hInstance, GET_FS_API )))
{
FS_UnloadProgs();
Host_Error( "FS_LoadProgs: can't find GetFSAPI entry point in %s\n", name );
Host_Error( "%s: can't find GetFSAPI entry point in %s\n", __func__, name );
return false;
}

if( !GetFSAPI( FS_API_VERSION, &g_fsapi, &FI, &fs_memfuncs ))
if( GetFSAPI( FS_API_VERSION, &g_fsapi, &FI, &fs_memfuncs ) != FS_API_VERSION )
{
FS_UnloadProgs();
Host_Error( "FS_LoadProgs: can't initialize filesystem API: wrong version\n" );
Host_Error( "%s: can't initialize filesystem API: wrong version\n", __func__ );
return false;
}

if( !( fs_pfnCreateInterface = (pfnCreateInterface_t)COM_GetProcAddress( fs_hInstance, "CreateInterface" )))
{
FS_UnloadProgs();
Host_Error( "FS_LoadProgs: can't find CreateInterface entry point in %s\n", name );
Host_Error( "%s: can't find CreateInterface entry point in %s\n", __func__, name );
return false;
}

Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" );
Con_DPrintf( "%s: filesystem_stdio successfully loaded\n", __func__ );

return true;
}
Expand Down
3 changes: 2 additions & 1 deletion engine/common/library.h
Expand Up @@ -24,7 +24,8 @@ typedef struct dll_user_s
qboolean custom_loader; // a bit who indicated loader type
qboolean encrypted; // dll is crypted (some client.dll in HL, CS etc)
char dllName[32]; // for debug messages
string fullPath, shortPath; // actual dll paths
char fullPath[2048];
string shortPath; // actual dll paths

// ordinals stuff, valid only on Win32
word *ordinals;
Expand Down
9 changes: 7 additions & 2 deletions filesystem/filesystem.c
Expand Up @@ -1363,8 +1363,13 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll

if( index >= 0 && !dllInfo->encrypted && search )
{
Q_snprintf( dllInfo->fullPath, sizeof( dllInfo->fullPath ),
"%s%s", search->filename, dllInfo->shortPath );
// gamedll might resolve it's own path using dladdr()
// combine it with engine returned path to gamedir
// it might lead to double gamedir like this
// - valve/valve/dlls/hl.so
// instead of expected
// - valve/dlls/hl.so
Q_snprintf( dllInfo->fullPath, sizeof( dllInfo->fullPath ), "%s/%s%s", fs_rootdir, search->filename, dllInfo->shortPath );
dllInfo->custom_loader = false; // we can loading from disk and use normal debugging
}
else
Expand Down
6 changes: 3 additions & 3 deletions filesystem/filesystem.h
Expand Up @@ -31,7 +31,7 @@ extern "C"
{
#endif // __cplusplus

#define FS_API_VERSION 2 // not stable yet!
#define FS_API_VERSION 3 // not stable yet!
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!!
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!

Expand Down Expand Up @@ -121,8 +121,8 @@ typedef enum

typedef struct fs_dllinfo_t
{
string fullPath;
string shortPath;
char fullPath[2048]; // absolute disk path
string shortPath; // vfs path
qboolean encrypted;
qboolean custom_loader;
} fs_dllinfo_t;
Expand Down

0 comments on commit 60c6767

Please sign in to comment.