From bbd033c254bbbb03c6f8eaa072053536089cca16 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 19 Jan 2020 07:38:37 +0700 Subject: [PATCH] lib: restore dll loader support --- engine/client/vgui/vgui_draw.c | 2 +- engine/common/common.c | 2 +- engine/common/host.c | 5 ----- engine/platform/posix/lib_posix.c | 24 +++++++++++++++++------- engine/server/sv_game.c | 12 ++++++------ engine/wscript | 3 ++- wscript | 3 ++- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/engine/client/vgui/vgui_draw.c b/engine/client/vgui/vgui_draw.c index 02a54f54..f0ea6edf 100644 --- a/engine/client/vgui/vgui_draw.c +++ b/engine/client/vgui/vgui_draw.c @@ -318,7 +318,7 @@ void VGui_Startup( const char *clientlib, int width, int height ) width = 1280; else if( width <= 1600 ) width = 1600; -#ifdef DLL_LOADER +#ifdef XASH_DLL_LOADER else if ( Q_strstr( vguiloader, ".dll" ) ) width = 1600; #endif diff --git a/engine/common/common.c b/engine/common/common.c index 2d937c84..7d96b5b4 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -1062,7 +1062,7 @@ COM_CompareFileTime ============= */ -int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare ) +int GAME_EXPORT COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare ) { int bRet = 0; diff --git a/engine/common/host.c b/engine/common/host.c index d741a42f..41c8827a 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -769,11 +769,6 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha host.enabledll = !Sys_CheckParm( "-nodll" ); -#ifdef DLL_LOADER - if( host.enabledll ) - Setup_LDT_Keeper( ); // Must call before creating any thread -#endif - host.change_game = bChangeGame; host.config_executed = false; host.status = HOST_INIT; // initialzation started diff --git a/engine/platform/posix/lib_posix.c b/engine/platform/posix/lib_posix.c index 4e134ec9..9aaa8576 100644 --- a/engine/platform/posix/lib_posix.c +++ b/engine/platform/posix/lib_posix.c @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#define _GNU_SOURCE #include "platform/platform.h" #if XASH_LIB == LIB_POSIX @@ -25,6 +25,16 @@ GNU General Public License for more details. #include "platform/emscripten/lib_em.h" #include "platform/apple/lib_ios.h" +#ifdef XASH_DLL_LOADER // wine-based dll loader +void * Loader_LoadLibrary (const char *name); +void * Loader_GetProcAddress (void *hndl, const char *name); +void Loader_FreeLibrary(void *hndl); +void *Loader_GetDllHandle( void *hndl ); +const char * Loader_GetFuncName( void *hndl, void *func); +const char * Loader_GetFuncName_int( void *wm , void *func); +#endif + + #ifdef XASH_NO_LIBDL #ifndef XASH_DLL_LOADER #error Enable at least one dll backend!!! @@ -83,7 +93,7 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d if( !hInst ) { // HACKHACK: direct load dll -#ifdef DLL_LOADER +#ifdef XASH_DLL_LOADER if( host.enabledll && ( pHandle = Loader_LoadLibrary(dllname)) ) { return pHandle; @@ -110,8 +120,8 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d return NULL; } -#ifdef DLL_LOADER - if( host.enabledll && ( !Q_stricmp( FS_FileExtension( hInst->shortPath ), "dll" ) ) ) +#ifdef XASH_DLL_LOADER + if( host.enabledll && ( !Q_stricmp( COM_FileExtension( hInst->shortPath ), "dll" ) ) ) { if( hInst->encrypted ) { @@ -147,7 +157,7 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d void COM_FreeLibrary( void *hInstance ) { -#ifdef DLL_LOADER +#ifdef XASH_DLL_LOADER void *wm; if( host.enabledll && (wm = Loader_GetDllHandle( hInstance )) ) return Loader_FreeLibrary( hInstance ); @@ -164,7 +174,7 @@ void COM_FreeLibrary( void *hInstance ) void *COM_GetProcAddress( void *hInstance, const char *name ) { -#ifdef DLL_LOADER +#ifdef XASH_DLL_LOADER void *wm; if( host.enabledll && (wm = Loader_GetDllHandle( hInstance )) ) return Loader_GetProcAddress(hInstance, name); @@ -206,7 +216,7 @@ int d_dladdr( void *sym, Dl_info *info ) const char *COM_NameForFunction( void *hInstance, void *function ) { -#ifdef DLL_LOADER +#ifdef XASH_DLL_LOADER void *wm; if( host.enabledll && (wm = Loader_GetDllHandle( hInstance )) ) return Loader_GetFuncName_int(wm, function); diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index b778294d..c4d57d3b 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -1263,7 +1263,7 @@ pfnPrecacheModel ========= */ -int pfnPrecacheModel( const char *s ) +int GAME_EXPORT pfnPrecacheModel( const char *s ) { qboolean optional = false; int i; @@ -1291,7 +1291,7 @@ pfnSetModel ================= */ -void pfnSetModel( edict_t *e, const char *m ) +void GAME_EXPORT pfnSetModel( edict_t *e, const char *m ) { char name[MAX_QPATH]; qboolean found = false; @@ -2418,7 +2418,7 @@ pfnServerExecute ========= */ -void pfnServerExecute( void ) +void GAME_EXPORT pfnServerExecute( void ) { Cbuf_Execute(); @@ -2444,8 +2444,8 @@ pfnClientCommand ========= */ -void pfnClientCommand( edict_t* pEdict, char* szFmt, ... ) _format( 2 ); -void pfnClientCommand( edict_t* pEdict, char* szFmt, ... ) +void GAME_EXPORT pfnClientCommand( edict_t* pEdict, char* szFmt, ... ) _format( 2 ); +void GAME_EXPORT pfnClientCommand( edict_t* pEdict, char* szFmt, ... ) { sv_client_t *cl; string buffer; @@ -2876,7 +2876,7 @@ pfnAlertMessage ============= */ static void pfnAlertMessage( ALERT_TYPE type, char *szFmt, ... ) _format( 2 ); -static void pfnAlertMessage( ALERT_TYPE type, char *szFmt, ... ) +static void GAME_EXPORT pfnAlertMessage( ALERT_TYPE type, char *szFmt, ... ) { char buffer[2048]; va_list args; diff --git a/engine/wscript b/engine/wscript index 3b8703b4..4b19dd54 100644 --- a/engine/wscript +++ b/engine/wscript @@ -69,6 +69,7 @@ def configure(conf): conf.define_cond('XASH_STATIC_LIBS', conf.env.STATIC_LINKING) conf.define_cond('XASH_CUSTOM_SWAP', conf.options.CUSTOM_SWAP) + conf.define_cond('XASH_DLL_LOADER', conf.options.DLLEMU) conf.define_cond('SINGLE_BINARY', conf.env.SINGLE_BINARY) conf.define_cond('XASH_NO_ASYNC_NS_RESOLVE', conf.options.NO_ASYNC_RESOLVE) conf.define_cond('XASH_USE_SELECT', conf.options.USE_SELECT or conf.options.DEDICATED) @@ -79,7 +80,7 @@ def configure(conf): def build(bld): is_cxx_link = False - libs = [ 'public' ] + libs = [ 'public', 'dllemu' ] source = bld.path.ant_glob([ 'common/*.c', 'common/imagelib/*.c', diff --git a/wscript b/wscript index 34567616..4882a393 100644 --- a/wscript +++ b/wscript @@ -54,7 +54,8 @@ SUBDIRS = [ Subproject('vgui_support'), Subproject('stub/server', dedicated=False), Subproject('stub/client'), - Subproject('engine', dedicated=False, mandatory = False), + Subproject('dllemu'), + Subproject('engine', dedicated=False), ] def subdirs():