mirror of
https://git.code.sf.net/p/quake/quake2forge
synced 2024-12-12 13:42:21 +00:00
- Added PKGLIBDIR to game search path, so that the game.so
shared object is found. - Reverted the game loader in main.c to iterate through the search path.
This commit is contained in:
parent
a5b3a4adb2
commit
27ab9f9b47
2 changed files with 27 additions and 13 deletions
|
@ -904,6 +904,7 @@ void FS_InitFilesystem (void)
|
|||
// add baseq2 to search path
|
||||
//
|
||||
/*FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_basedir->string) );*/
|
||||
FS_AddGameDirectory(PKGLIBDIR"/"BASEDIRNAME);
|
||||
FS_AddGameDirectory(PKGDATADIR"/"BASEDIRNAME);
|
||||
|
||||
//
|
||||
|
|
33
src/main.c
33
src/main.c
|
@ -221,8 +221,9 @@ void Sys_UnloadGame(void) {
|
|||
/* Loads the game dll */
|
||||
void *Sys_GetGameAPI (void *parms) {
|
||||
gameapi_t * GetGameAPI;
|
||||
char path[MAX_OSPATH];
|
||||
cvar_t * gamename;
|
||||
FILE * fp;
|
||||
char name[MAX_OSPATH];
|
||||
char * path;
|
||||
|
||||
setreuid(getuid(), getuid());
|
||||
setegid(getgid());
|
||||
|
@ -230,19 +231,31 @@ void *Sys_GetGameAPI (void *parms) {
|
|||
if (game_library)
|
||||
Com_Error (ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame");
|
||||
|
||||
/* now run through the search paths */
|
||||
gamename = Cvar_Get("gamedir", BASEDIRNAME, CVAR_LATCH|CVAR_SERVERINFO);
|
||||
Com_Printf("------- Loading %s -------\n", gamename->string);
|
||||
Com_Printf("------- Loading game.so -------\n");
|
||||
|
||||
/* set the module search path */
|
||||
snprintf(path, MAX_OSPATH, PKGLIBDIR"/%s/game.so", gamename->string);
|
||||
game_library = dlopen(path, RTLD_NOW);
|
||||
/* now run through the search paths */
|
||||
path = NULL;
|
||||
while (1) {
|
||||
path = FS_NextPath(path);
|
||||
if (!path)
|
||||
return NULL;
|
||||
snprintf(name, MAX_OSPATH, "%s/game.so", path);
|
||||
|
||||
/* skip it if it doesn't exist */
|
||||
fp = fopen(name, "rb");
|
||||
if (fp == NULL)
|
||||
continue;
|
||||
fclose(fp);
|
||||
|
||||
game_library = dlopen(name, RTLD_NOW);
|
||||
if (game_library) {
|
||||
Com_MDPrintf("LoadLibrary (%s)\n", gamename->string);
|
||||
Com_MDPrintf("LoadLibrary (%s)\n", name);
|
||||
break;
|
||||
} else {
|
||||
Com_MDPrintf("LoadLibrary (%s)\n", gamename->string);
|
||||
Com_MDPrintf("LoadLibrary (%s)\n", name);
|
||||
Com_MDPrintf("%s\n", dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
GetGameAPI = (gameapi_t *) dlsym(game_library, "GetGameAPI");
|
||||
|
||||
|
|
Loading…
Reference in a new issue