Load base game's gamelib if mod has no own gamelib

Some mods/mappacks have their own game dir (fs_game) but no own gamelib.
Doom3 defaulted to the base game dll (I think), so we should do the same.

Fixes #44
This commit is contained in:
Daniel Gibson 2012-09-09 23:36:53 +02:00
parent c193e0b98e
commit 768fdb5707

View file

@ -186,6 +186,7 @@ private:
void DumpWarnings( void );
void SingleAsyncTic( void );
void LoadGameDLL( void );
void LoadGameDLLbyName( const char *dll, idStr& s );
void UnloadGameDLL( void );
void PrintLoadingMessage( const char *msg );
void FilterLangList( idStrList* list, idStr lang );
@ -2543,29 +2544,18 @@ void idCommonLocal::Async( void ) {
/*
=================
idCommonLocal::LoadGameDLL
idCommonLocal::LoadGameDLLbyName
Helper for LoadGameDLL() to make it less painfull to try different dll names.
=================
*/
void idCommonLocal::LoadGameDLL( void ) {
#ifdef __DOOM_DLL__
const char *fs_game;
char dll[MAX_OSPATH];
idStr s;
gameImport_t gameImport;
gameExport_t gameExport;
GetGameAPI_t GetGameAPI;
fs_game = cvarSystem->GetCVarString("fs_game");
if (!fs_game || !fs_game[0])
fs_game = BASE_GAMEDIR;
gameDLL = 0;
sys->DLL_GetFileName(fs_game, dll, sizeof(dll));
void idCommonLocal::LoadGameDLLbyName( const char *dll, idStr& s ) {
s.CapLength(0);
// try next to the binary first (build tree)
if (Sys_GetPath(PATH_EXE, s)) {
s.StripFilename();
// "s = " seems superfluous, but works around g++ 4.7 bug else StripFilename()
// (and possibly even CapLength()) seems to be "optimized" away and the string contains garbage
s = s.StripFilename();
s.AppendPath(dll);
gameDLL = sys->DLL_Load(s);
}
@ -2593,6 +2583,38 @@ void idCommonLocal::LoadGameDLL( void ) {
gameDLL = sys->DLL_Load(s);
}
#endif
}
/*
=================
idCommonLocal::LoadGameDLL
=================
*/
void idCommonLocal::LoadGameDLL( void ) {
#ifdef __DOOM_DLL__
const char *fs_game;
char dll[MAX_OSPATH];
idStr s;
gameImport_t gameImport;
gameExport_t gameExport;
GetGameAPI_t GetGameAPI;
fs_game = cvarSystem->GetCVarString("fs_game");
if (!fs_game || !fs_game[0])
fs_game = BASE_GAMEDIR;
gameDLL = 0;
sys->DLL_GetFileName(fs_game, dll, sizeof(dll));
LoadGameDLLbyName(dll, s);
// there was no gamelib for this mod, use default one from base game
if (!gameDLL) {
common->Warning( "couldn't load mod-specific %s, defaulting to base game's library!", dll );
sys->DLL_GetFileName(BASE_GAMEDIR, dll, sizeof(dll));
LoadGameDLLbyName(dll, s);
}
if ( !gameDLL ) {
common->FatalError( "couldn't load game dynamic library" );