Skip to content

Commit eb26858

Browse files
committed
Add fs_gameDllPath to set additional directory to search game DLLs in
If set, it's searched before all other paths when laoding game libs (mymod.dll, mymod.so, mymod.dylib, ...) Useful when developing/testing mods
1 parent 47ae272 commit eb26858

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

neo/framework/Common.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,14 @@ Helper for LoadGameDLL() to make it less painful to try different dll names.
26252625
=================
26262626
*/
26272627
void idCommonLocal::LoadGameDLLbyName( const char *dll, idStr& s ) {
2628+
// try fs_dllpath first, if set
2629+
const char* dllpath = cvarSystem->GetCVarString("fs_gameDllPath");
2630+
if (dllpath != NULL && dllpath[0] != '\0') {
2631+
s = dllpath;
2632+
s.AppendPath(dll);
2633+
gameDLL = sys->DLL_Load(s);
2634+
}
2635+
26282636
s.CapLength(0);
26292637
#if defined(__AROS__)
26302638
// check in the launch (mod) directory first on AROS
@@ -2635,8 +2643,9 @@ void idCommonLocal::LoadGameDLLbyName( const char *dll, idStr& s ) {
26352643
return;
26362644
}
26372645
#endif
2638-
// try next to the binary
2639-
if (Sys_GetPath(PATH_EXE, s)) {
2646+
2647+
// try next to the binary second (build tree)
2648+
if (!gameDLL && Sys_GetPath(PATH_EXE, s)) {
26402649
// "s = " seems superfluous, but works around g++ 4.7 bug else StripFilename()
26412650
// (and possibly even CapLength()) seems to be "optimized" away and the string contains garbage
26422651
s = s.StripFilename();

neo/framework/FileSystem.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ class idFileSystemLocal : public idFileSystem {
415415
static idCVar fs_game_base;
416416
static idCVar fs_caseSensitiveOS;
417417
static idCVar fs_searchAddons;
418+
// DG: additional directory to search for game DLLs
419+
static idCVar fs_gameDllPath;
418420

419421
backgroundDownload_t * backgroundDownloads;
420422
backgroundDownload_t defaultBackgroundDownload;
@@ -483,6 +485,8 @@ idCVar idFileSystemLocal::fs_caseSensitiveOS( "fs_caseSensitiveOS", "1", CVAR_SY
483485
#endif
484486
idCVar idFileSystemLocal::fs_searchAddons( "fs_searchAddons", "0", CVAR_SYSTEM | CVAR_BOOL, "search all addon pk4s ( disables addon functionality )" );
485487

488+
idCVar idFileSystemLocal::fs_gameDllPath( "fs_gameDllPath", "", CVAR_SYSTEM | CVAR_INIT, "additional directory to search the game .dll (.so/.dylib/...) in; searched before all other places (if set)" );
489+
486490
idFileSystemLocal fileSystemLocal;
487491
idFileSystem * fileSystem = &fileSystemLocal;
488492

0 commit comments

Comments
 (0)