From d57438adf3e24b6ee01cb5ab0e173cb6eb7dee6d Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 25 Apr 2010 13:52:27 +0000 Subject: [PATCH] Ported the linux q2dll stuff over to SDL, attempts to load gamei386.so still. This is wrong. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3530 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_sdl.c | 66 +++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/engine/client/sys_sdl.c b/engine/client/sys_sdl.c index b7ed77ae3..4c7bd38aa 100644 --- a/engine/client/sys_sdl.c +++ b/engine/client/sys_sdl.c @@ -139,18 +139,6 @@ void Sys_ServerActivity(void) { } - - -//Without these two we cannot run Q2 gamecode. -void Sys_UnloadGame (void) -{ -} -void *Sys_GetGameAPI (void *parms) -{ - return NULL; -} - - void Sys_CloseLibrary(dllhandle_t *lib) { SDL_UnloadObject((void*)lib); @@ -179,6 +167,60 @@ dllhandle_t *Sys_LoadLibrary(char *name, dllfunction_t *funcs) return (dllhandle_t*)lib; } +//Without these two we cannot run Q2 gamecode. +dllhandle_t *q2gamedll; +void Sys_UnloadGame (void) +{ + if (q2gamedll) + Sys_CloseLibrary(q2gamedll); + q2gamedll = NULL; +} +void *Sys_GetGameAPI (void *parms) +{ + void *(*GetGameAPI)(void *); + dllfunction_t funcs[] = + { + {(void**)GetGameAPI, "GetGameAPI"}, + {NULL,NULL} + }; + + char name[MAX_OSPATH]; + char curpath[MAX_OSPATH]; + char *searchpath; + const char *gamename = "gamei386.so"; + + void *ret; + + Con_DPrintf("Searching for %s\n", gamename); + + getcwd(curpath, sizeof(curpath)); + + searchpath = 0; + while((searchpath = COM_NextPath(searchpath))) + { + if (searchpath[0] == '/') + snprintf(name, sizeof(name), "%s/%s", searchpath, gamename); + else + snprintf(name, sizeof(name), "%s/%s/%s", curpath, searchpath, gamename); + + q2gamedll = Sys_LoadLibrary(name, funcs); + if (q2gamedll && gamename) + { + ret = GetGameAPI(parms); + if (ret) + { + return ret; + } + + Sys_CloseLibrary(q2gamedll); + q2gamedll = 0; + } + } + + return NULL; +} + + //used to see if a file exists or not. int Sys_FileTime (char *path)