From a6b4691c02f88c03517e206d5637eece7b4d8ca5 Mon Sep 17 00:00:00 2001 From: Mark Olsen Date: Tue, 2 May 2006 00:08:06 +0000 Subject: [PATCH] Load Quake 2 game code. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2233 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_morphos.c | 46 ++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/engine/client/sys_morphos.c b/engine/client/sys_morphos.c index b6368f2a4..4b34e420f 100755 --- a/engine/client/sys_morphos.c +++ b/engine/client/sys_morphos.c @@ -6,6 +6,8 @@ #include #include +#include + #include "quakedef.h" #warning Find a better stack size @@ -195,13 +197,51 @@ qboolean Sys_remove(char *path) } /* Quake 2 stuff */ -void Sys_UnloadGame (void) +static void *gamefile; + +void *Sys_GetGameAPI(void *parms) { + int (*q2_so_init)(void); + void (*q2_so_deinit)(void); + void *(*GetGameAPI)(void *); + void *ret; + + gamefile = dlopen("gameppc.so", 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; + } + + return 0; } -void *Sys_GetGameAPI (void *parms) +void Sys_UnloadGame(void) { - return NULL; + void (*q2_so_deinit)(void); + + if (gamefile) + { + q2_so_deinit = dlsym(gamefile, "q2_so_deinit"); + if (q2_so_deinit) + q2_so_deinit(); + + dlclose(gamefile); + gamefile = 0; + } } int main(int argc, char **argv)