mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
engine: Haiku BeGameLauncher support
This commit is contained in:
parent
6063149b93
commit
a89f9fa181
@ -1390,6 +1390,9 @@ void FS_Rescan( void )
|
|||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
const int extrasFlags = FS_NOWRITE_PATH | FS_CUSTOM_PATH;
|
const int extrasFlags = FS_NOWRITE_PATH | FS_CUSTOM_PATH;
|
||||||
|
#if XASH_HAIKU
|
||||||
|
char *dir;
|
||||||
|
#endif
|
||||||
Con_Reportf( "FS_Rescan( %s )\n", GI->title );
|
Con_Reportf( "FS_Rescan( %s )\n", GI->title );
|
||||||
|
|
||||||
FS_ClearSearchPath();
|
FS_ClearSearchPath();
|
||||||
@ -1399,6 +1402,11 @@ void FS_Rescan( void )
|
|||||||
FS_AddPak_Fullpath( va( "%sextras.pak", SDL_GetBasePath() ), NULL, extrasFlags );
|
FS_AddPak_Fullpath( va( "%sextras.pak", SDL_GetBasePath() ), NULL, extrasFlags );
|
||||||
FS_AddPak_Fullpath( va( "%sextras_%s.pak", SDL_GetBasePath(), GI->gamefolder ), NULL, extrasFlags );
|
FS_AddPak_Fullpath( va( "%sextras_%s.pak", SDL_GetBasePath(), GI->gamefolder ), NULL, extrasFlags );
|
||||||
}
|
}
|
||||||
|
#elif XASH_HAIKU
|
||||||
|
if( ( dir = getenv( "XASH3D_MIRRORDIR" ) ) )
|
||||||
|
FS_AddPak_Fullpath( va( "%s/extras.pak", dir ), NULL, extrasFlags );
|
||||||
|
if( ( dir = getenv( "XASH3D_BASEDIR" ) ) )
|
||||||
|
FS_AddPak_Fullpath( va( "%s/%s/extras.pak", dir , GI->gamefolder ), NULL, extrasFlags );
|
||||||
#else
|
#else
|
||||||
str = getenv( "XASH3D_EXTRAS_PAK1" );
|
str = getenv( "XASH3D_EXTRAS_PAK1" );
|
||||||
if( COM_CheckString( str ) )
|
if( COM_CheckString( str ) )
|
||||||
|
@ -79,6 +79,9 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d
|
|||||||
{
|
{
|
||||||
dll_user_t *hInst = NULL;
|
dll_user_t *hInst = NULL;
|
||||||
void *pHandle = NULL;
|
void *pHandle = NULL;
|
||||||
|
#if XASH_HAIKU
|
||||||
|
const char *libdir;
|
||||||
|
#endif
|
||||||
|
|
||||||
COM_ResetLibraryError();
|
COM_ResetLibraryError();
|
||||||
|
|
||||||
@ -87,6 +90,24 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d
|
|||||||
return Platform_POSIX_LoadLibrary( dllname );
|
return Platform_POSIX_LoadLibrary( dllname );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if XASH_HAIKU
|
||||||
|
// First look for libraries in the mirror directory
|
||||||
|
libdir = getenv( "XASH3D_MIRRORDIR" );
|
||||||
|
if( libdir ) {
|
||||||
|
char path[MAX_SYSPATH];
|
||||||
|
char game[MAX_SYSPATH] = { 0 };
|
||||||
|
if( GI && !Q_strstr( dllname, "menu" ) )
|
||||||
|
Q_snprintf( game, MAX_SYSPATH, "/%s", GI->gamefolder );
|
||||||
|
Q_snprintf( path, MAX_SYSPATH, "%s%s/%s", libdir, game, dllname );
|
||||||
|
pHandle = dlopen( path, RTLD_NOW );
|
||||||
|
if( pHandle )
|
||||||
|
return pHandle;
|
||||||
|
|
||||||
|
COM_PushLibraryError( dlerror() );
|
||||||
|
}
|
||||||
|
// Then through FS_FindLibrary() function in the gamebase directory
|
||||||
|
#endif
|
||||||
|
|
||||||
// platforms where gameinfo mechanism is working goes here
|
// platforms where gameinfo mechanism is working goes here
|
||||||
// and use FS_FindLibrary
|
// and use FS_FindLibrary
|
||||||
hInst = FS_FindLibrary( dllname, directpath );
|
hInst = FS_FindLibrary( dllname, directpath );
|
||||||
|
@ -20,8 +20,14 @@ GNU General Public License for more details.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#if defined(__APPLE__) || defined(__unix__) || defined(__HAIKU__)
|
#if defined(__APPLE__) || defined(__unix__)
|
||||||
#define XASHLIB "libxash." OS_LIB_EXT
|
#define XASHLIB "libxash." OS_LIB_EXT
|
||||||
|
#elif __HAIKU__
|
||||||
|
#include <libgen.h>
|
||||||
|
#define XASHLIB "libxash." OS_LIB_EXT
|
||||||
|
#define E_GAME "XASH3D_GAME"
|
||||||
|
#define E_BASEDIR "XASH3D_BASEDIR"
|
||||||
|
#define E_MIRRORDIR "XASH3D_MIRRORDIR"
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
#if !__MINGW32__ && _MSC_VER >= 1200
|
#if !__MINGW32__ && _MSC_VER >= 1200
|
||||||
#define USE_WINMAIN
|
#define USE_WINMAIN
|
||||||
@ -87,7 +93,15 @@ static const char *GetStringLastError()
|
|||||||
|
|
||||||
static void Sys_LoadEngine( void )
|
static void Sys_LoadEngine( void )
|
||||||
{
|
{
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char *engine = getenv( E_MIRRORDIR );
|
||||||
|
strncpy( path, engine, PATH_MAX );
|
||||||
|
strncat( path, "/"XASHLIB, PATH_MAX );
|
||||||
|
if(( hEngine = LoadLibrary( path )) == NULL )
|
||||||
|
#else
|
||||||
if(( hEngine = LoadLibrary( XASHLIB )) == NULL )
|
if(( hEngine = LoadLibrary( XASHLIB )) == NULL )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Xash_Error("Unable to load the " XASHLIB ": %s", dlerror() );
|
Xash_Error("Unable to load the " XASHLIB ": %s", dlerror() );
|
||||||
}
|
}
|
||||||
@ -138,7 +152,13 @@ _inline int Sys_Start( void )
|
|||||||
changeGame = Sys_ChangeGame;
|
changeGame = Sys_ChangeGame;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
const char* game = getenv( E_GAME );
|
||||||
|
ret = Xash_Main( szArgc, szArgv, game, 0, changeGame );
|
||||||
|
#else
|
||||||
ret = Xash_Main( szArgc, szArgv, GAME_PATH, 0, changeGame );
|
ret = Xash_Main( szArgc, szArgv, GAME_PATH, 0, changeGame );
|
||||||
|
#endif
|
||||||
|
|
||||||
Sys_UnloadEngine();
|
Sys_UnloadEngine();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -150,6 +170,35 @@ int main( int argc, char **argv )
|
|||||||
szArgc = argc;
|
szArgc = argc;
|
||||||
szArgv = argv;
|
szArgv = argv;
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
// To make it able to start from Deskbar
|
||||||
|
chdir( dirname( argv[0] ) );
|
||||||
|
char path[PATH_MAX];
|
||||||
|
getcwd( path, PATH_MAX );
|
||||||
|
const char *game = getenv( E_GAME );
|
||||||
|
if( !game )
|
||||||
|
setenv( E_GAME, GAME_PATH, 1 );
|
||||||
|
const char *basedir = getenv( E_BASEDIR );
|
||||||
|
if( !basedir )
|
||||||
|
setenv( E_BASEDIR, path, 1 );
|
||||||
|
const char *mirrordir = getenv( E_MIRRORDIR );
|
||||||
|
// The mirror "extras/" directory structure for Haiku OS which is needeed for the HPGK-package:
|
||||||
|
// extras.pak
|
||||||
|
// libmenu.so
|
||||||
|
// libxash.so
|
||||||
|
// valve/
|
||||||
|
// cl_dlls/
|
||||||
|
// client_haiku_amd64.so
|
||||||
|
// dlls/
|
||||||
|
// hl_haiku_amd64.so
|
||||||
|
if( !mirrordir )
|
||||||
|
{
|
||||||
|
strncpy( path, getenv( E_BASEDIR ), PATH_MAX );
|
||||||
|
strncat( path, "/extras", PATH_MAX );
|
||||||
|
setenv( E_MIRRORDIR, path, 1 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return Sys_Start();
|
return Sys_Start();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user