From 771828d5fbc11b2e54aa2e1aa143743ac9843cf0 Mon Sep 17 00:00:00 2001 From: Mark Olsen Date: Tue, 2 May 2006 00:25:16 +0000 Subject: [PATCH] Slight finetuning of Q2 game code loading. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2235 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_morphos.c | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/engine/client/sys_morphos.c b/engine/client/sys_morphos.c index 4b34e420f..185c5ed5a 100755 --- a/engine/client/sys_morphos.c +++ b/engine/client/sys_morphos.c @@ -205,25 +205,35 @@ void *Sys_GetGameAPI(void *parms) void (*q2_so_deinit)(void); void *(*GetGameAPI)(void *); void *ret; + char *searchpath; + char path[256]; - gamefile = dlopen("gameppc.so", RTLD_NOW); - if (gamefile) + searchpath = 0; + + while((searchpath = COM_NextPath(searchpath))) { - q2_so_init = dlsym(gamefile, "q2_so_init"); - q2_so_deinit = dlsym(gamefile, "q2_so_deinit"); - if (q2_so_init && q2_so_init()) - { - GetGameAPI = dlsym(gamefile, "GetGameAPI"); - if (GetGameAPI && (ret = GetGameAPI(parms))) - { - return ret; - } - if (q2_so_deinit) - q2_so_deinit(); + snprintf(path, sizeof(path), "%s%sgameppc.so", searchpath[0]!='.'?searchpath:"", searchpath[0]&&searchpath[0]!='.'?"/":""); + + gamefile = dlopen(path, RTLD_NOW); + if (gamefile) + { + q2_so_init = dlsym(gamefile, "q2_so_init"); + q2_so_deinit = dlsym(gamefile, "q2_so_deinit"); + if (q2_so_init && q2_so_init()) + { + GetGameAPI = dlsym(gamefile, "GetGameAPI"); + if (GetGameAPI && (ret = GetGameAPI(parms))) + { + return ret; + } + + if (q2_so_deinit) + q2_so_deinit(); + } + dlclose(gamefile); + gamefile = 0; } - dlclose(gamefile); - gamefile = 0; } return 0;