Browse Source

engine: make use of platform-unique library naming scheme

pull/2/head
Alibek Omarov 5 years ago
parent
commit
89a3fd6323
  1. 24
      engine/client/cl_gameui.c
  2. 12
      engine/client/cl_main.c
  3. 2
      engine/client/vgui/vgui_draw.c
  4. 1
      engine/common/common.h
  5. 23
      engine/common/filesystem.c
  6. 15
      engine/server/sv_init.c

24
engine/client/cl_gameui.c

@ -888,6 +888,7 @@ pfnCheckGameDll @@ -888,6 +888,7 @@ pfnCheckGameDll
*/
int pfnCheckGameDll( void )
{
string dllpath;
void *hInst;
#if TARGET_OS_IPHONE
@ -900,7 +901,9 @@ int pfnCheckGameDll( void ) @@ -900,7 +901,9 @@ int pfnCheckGameDll( void )
if( svgame.hInstance )
return true;
if(( hInst = COM_LoadLibrary( SI.gamedll, true, false )) != NULL )
COM_GetCommonLibraryName( LIBRARY_SERVER, dllpath, sizeof( dllpath ));
if(( hInst = COM_LoadLibrary( dllpath, true, false )) != NULL )
{
COM_FreeLibrary( hInst ); // don't increase linker's reference counter
return true;
@ -1075,6 +1078,7 @@ qboolean UI_LoadProgs( void ) @@ -1075,6 +1078,7 @@ qboolean UI_LoadProgs( void )
static ui_textfuncs_t gpTextfuncs;
static ui_globalvars_t gpGlobals;
UITEXTAPI GiveTextApi;
string dllpath;
int i;
if( gameui.hInstance ) UI_UnloadProgs();
@ -1082,23 +1086,23 @@ qboolean UI_LoadProgs( void ) @@ -1082,23 +1086,23 @@ qboolean UI_LoadProgs( void )
// setup globals
gameui.globals = &gpGlobals;
#ifdef XASH_INTERNAL_GAMELIBS
if(!( gameui.hInstance = COM_LoadLibrary( "menu", false, false )))
return false;
#else
if(!( gameui.hInstance = COM_LoadLibrary( va( "%s/" MENUDLL, GI->dll_path ), false, false )))
COM_GetCommonLibraryName( LIBRARY_GAMEUI, dllpath, sizeof( dllpath ));
if(!( gameui.hInstance = COM_LoadLibrary( dllpath, false, false )))
{
FS_AllowDirectPaths( true );
if(!( gameui.hInstance = COM_LoadLibrary( "../" MENUDLL, false, false ))
&& !( gameui.hInstance = COM_LoadLibrary( MENUDLL, false, false )))
// no use to load it from engine directory, as library loader
// that implements internal gamelibs already knows how to load it
#ifndef XASH_INTERNAL_GAMELIBS
if(!( gameui.hInstance = COM_LoadLibrary( OS_LIB_PREFIX "menu." OS_LIB_EXT, false, false )))
#endif
{
FS_AllowDirectPaths( false );
return false;
}
}
#endif
FS_AllowDirectPaths( false );
if(( GetMenuAPI = (MENUAPI)COM_GetProcAddress( gameui.hInstance, "GetMenuAPI" )) == NULL )

12
engine/client/cl_main.c

@ -2967,6 +2967,8 @@ CL_Init @@ -2967,6 +2967,8 @@ CL_Init
*/
void CL_Init( void )
{
string libpath;
if( host.type == HOST_DEDICATED )
return; // nothing running on the client
@ -2981,12 +2983,10 @@ void CL_Init( void ) @@ -2981,12 +2983,10 @@ void CL_Init( void )
// IN_TouchInit();
Con_LoadHistory();
#ifdef XASH_INTERNAL_GAMELIBS
if( !CL_LoadProgs( "client" ) )
#else
if( !CL_LoadProgs( va( "%s/%s", GI->dll_path, SI.clientlib)))
#endif
Host_Error( "can't initialize %s: %s\n", SI.clientlib, COM_GetLibraryError() );
COM_GetCommonLibraryName( LIBRARY_CLIENT, libpath, sizeof( libpath ));
if( !CL_LoadProgs( libpath ) )
Host_Error( "can't initialize %s: %s\n", libpath, COM_GetLibraryError() );
cls.initialized = true;
cl.maxclients = 1; // allow to drawing player in menu

2
engine/client/vgui/vgui_draw.c

@ -266,7 +266,7 @@ void VGui_Startup( const char *clientlib, int width, int height ) @@ -266,7 +266,7 @@ void VGui_Startup( const char *clientlib, int width, int height )
Con_Reportf( S_WARN "VGUI preloading failed. Default library will be used! Reason: %s\n", COM_GetLibraryError());
}
if( Q_strstr( GI->client_lib, ".dll" ) )
if( Q_strstr( clientlib, ".dll" ) )
Q_strncpy( vguiloader, "vgui_support.dll", 256 );
if( !vguiloader[0] && !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ) )

1
engine/common/common.h

@ -234,7 +234,6 @@ typedef struct gameinfo_s @@ -234,7 +234,6 @@ typedef struct gameinfo_s
char game_dll_linux[64]; // custom path for game.dll
char game_dll_osx[64]; // custom path for game.dll
char client_lib[64]; // custom name of client library
qboolean added;
} gameinfo_t;

23
engine/common/filesystem.c

@ -1489,7 +1489,6 @@ void FS_InitGameInfo( gameinfo_t *GameInfo, const char *gamedir ) @@ -1489,7 +1489,6 @@ void FS_InitGameInfo( gameinfo_t *GameInfo, const char *gamedir )
Q_strncpy( GameInfo->game_dll, "dlls/hl.dll", sizeof( GameInfo->game_dll ));
Q_strncpy( GameInfo->game_dll_linux, "dlls/hl.so", sizeof( GameInfo->game_dll_linux ));
Q_strncpy( GameInfo->game_dll_osx, "dlls/hl.dylib", sizeof( GameInfo->game_dll_osx ));
Q_strncpy( GameInfo->client_lib, CLIENTDLL, sizeof( GameInfo->client_lib ));
// .ico path
Q_strncpy( GameInfo->iconpath, "game.ico", sizeof( GameInfo->iconpath ));
@ -1654,10 +1653,6 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool @@ -1654,10 +1653,6 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool
{
pfile = COM_ParseFile( pfile, GameInfo->sp_entity );
}
else if( !Q_stricmp( token, "clientlib" ))
{
pfile = COM_ParseFile( pfile, GameInfo->client_lib );
}
else if( isGameInfo && !Q_stricmp( token, "dllpath" ))
{
pfile = COM_ParseFile( pfile, GameInfo->dll_path );
@ -1941,25 +1936,15 @@ void FS_LoadGameInfo( const char *rootfolder ) @@ -1941,25 +1936,15 @@ void FS_LoadGameInfo( const char *rootfolder )
Sys_Error( "Couldn't find game directory '%s'\n", fs_gamedir );
SI.GameInfo = SI.games[i];
if( !Sys_GetParmFromCmdLine( "-dll", SI.gamedll ) )
{
#ifdef XASH_INTERNAL_GAMELIBS
Q_strncpy( SI.gamedll, "server", sizeof( SI.gamedll ) );
#elif defined(_WIN32)
Q_strncpy( SI.gamedll, GI->game_dll, sizeof( SI.gamedll ) );
#elif defined(__APPLE__)
Q_strncpy( SI.gamedll, GI->game_dll_osx, sizeof( SI.gamedll ) );
#else
Q_strncpy( SI.gamedll, GI->game_dll_linux, sizeof( SI.gamedll ) );
#endif
SI.gamedll[0] = 0;
}
if( !Sys_GetParmFromCmdLine( "-clientlib", SI.clientlib ) )
{
#ifdef XASH_INTERNAL_GAMELIBS
Q_strncpy( SI.clientlib, "client", sizeof( SI.clientlib ) );
#else
Q_strncpy( SI.clientlib, GI->client_lib, sizeof( SI.clientlib ) );
#endif
SI.clientlib[0] = 0;
}
FS_Rescan(); // create new filesystem

15
engine/server/sv_init.c

@ -665,14 +665,19 @@ A brand new game has been started @@ -665,14 +665,19 @@ A brand new game has been started
*/
qboolean SV_InitGame( void )
{
string dllpath;
if( svs.initialized )
return true; // already initialized ?
// first initialize?
COM_ResetLibraryError();
if( !SV_LoadProgs( SI.gamedll ))
COM_GetCommonLibraryName( LIBRARY_SERVER, dllpath, sizeof( dllpath ));
if( !SV_LoadProgs( dllpath ))
{
Con_Printf( S_ERROR "can't initialize %s: %s\n", SI.gamedll, COM_GetLibraryError() );
Con_Printf( S_ERROR "can't initialize %s: %s\n", dllpath, COM_GetLibraryError() );
return false; // failed to loading server.dll
}
@ -991,10 +996,14 @@ int SV_GetMaxClients( void ) @@ -991,10 +996,14 @@ int SV_GetMaxClients( void )
void SV_InitGameProgs( void )
{
string dllpath;
if( svgame.hInstance ) return; // already loaded
COM_GetCommonLibraryName( LIBRARY_SERVER, dllpath, sizeof( dllpath ));
// just try to initialize
SV_LoadProgs( GI->game_dll );
SV_LoadProgs( dllpath );
}
void SV_FreeGameProgs( void )

Loading…
Cancel
Save