From 37cf586005b34762acf2443873a5567971ebb5e3 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 21 Nov 2005 20:20:42 +0000 Subject: [PATCH] Fix for linux and q3 bots git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1573 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/server/svq3_game.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/engine/server/svq3_game.c b/engine/server/svq3_game.c index d2f5052fd..9ee3cb65a 100644 --- a/engine/server/svq3_game.c +++ b/engine/server/svq3_game.c @@ -49,11 +49,19 @@ #elif defined(__linux__) - #include "dlopen.h" + #include "dlfcn.h" botlib_export_t *FTE_GetBotLibAPI( int apiVersion, botlib_import_t *import ) { + botlib_export_t *(*QDECL pGetBotLibAPI)( int apiVersion, botlib_import_t *import ); void *handle; - dlopen(); + handle = dlopen("botlib.so", RTLD_LAZY); + if (!handle) + return NULL; + + pGetBotLibAPI = dlsym(handle, "GetBotLibAPI"); + if (!pGetBotLibAPI) + return NULL; + return pGetBotLibAPI(apiVersion, import); } #else botlib_export_t *FTE_GetBotLibAPI(int version, int apiVersion, botlib_import_t *import) @@ -1537,6 +1545,10 @@ Con_Printf("builtin %i is not implemented\n", fn); return botlib->aas.AAS_PointReachabilityAreaIndex(VM_POINTER(arg[0])); case BOTLIB_PC_LOAD_SOURCE: + if (!botlib) + { + SV_Error("Botlib is not installed (trap BOTLIB_PC_LOAD_SOURCE)\n"); + } return botlib->PC_LoadSourceHandle(VM_POINTER(arg[0])); case BOTLIB_PC_FREE_SOURCE: return botlib->PC_FreeSourceHandle(VM_LONG(arg[0]));