mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: common: add host.default_gamedir containing gamedir passed to us from game launcher
This commit is contained in:
@@ -344,6 +344,9 @@ typedef struct host_parm_s
|
|||||||
string gamedll;
|
string gamedll;
|
||||||
string clientlib;
|
string clientlib;
|
||||||
string menulib;
|
string menulib;
|
||||||
|
|
||||||
|
// default game directory, passed to us from game launcher
|
||||||
|
string default_gamedir;
|
||||||
} host_parm_t;
|
} host_parm_t;
|
||||||
|
|
||||||
extern host_parm_t host;
|
extern host_parm_t host;
|
||||||
@@ -389,7 +392,7 @@ void Mem_Stats_f( void );
|
|||||||
//
|
//
|
||||||
// filesystem_engine.c
|
// filesystem_engine.c
|
||||||
//
|
//
|
||||||
void FS_Init( const char *basedir );
|
void FS_Init( void );
|
||||||
void FS_Shutdown( void );
|
void FS_Shutdown( void );
|
||||||
void *FS_GetNativeObject( const char *obj );
|
void *FS_GetNativeObject( const char *obj );
|
||||||
int FS_Close( file_t *file );
|
int FS_Close( file_t *file );
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ static qboolean FS_DetermineReadOnlyRootDirectory( char *out, size_t size )
|
|||||||
FS_Init
|
FS_Init
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void FS_Init( const char *basedir )
|
void FS_Init( void )
|
||||||
{
|
{
|
||||||
string gamedir;
|
string gamedir;
|
||||||
char rodir[MAX_OSPATH], rootdir[MAX_OSPATH];
|
char rodir[MAX_OSPATH], rootdir[MAX_OSPATH];
|
||||||
@@ -352,7 +352,7 @@ void FS_Init( const char *basedir )
|
|||||||
if( env )
|
if( env )
|
||||||
Q_strncpy( gamedir, env, sizeof( gamedir ));
|
Q_strncpy( gamedir, env, sizeof( gamedir ));
|
||||||
else
|
else
|
||||||
Q_strncpy( gamedir, basedir, sizeof( gamedir )); // gamedir == basedir
|
Q_strncpy( gamedir, host.default_gamedir, sizeof( gamedir )); // gamedir == basedir
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_LoadProgs();
|
FS_LoadProgs();
|
||||||
@@ -364,7 +364,7 @@ void FS_Init( const char *basedir )
|
|||||||
// and this better be reworked at some point
|
// and this better be reworked at some point
|
||||||
g_fsapi.SetCurrentDirectory( rootdir );
|
g_fsapi.SetCurrentDirectory( rootdir );
|
||||||
|
|
||||||
if( !g_fsapi.InitStdio( true, rootdir, basedir, gamedir, rodir ))
|
if( !g_fsapi.InitStdio( true, rootdir, host.default_gamedir, gamedir, rodir ))
|
||||||
{
|
{
|
||||||
Sys_Error( "Can't init filesystem_stdio!\n" );
|
Sys_Error( "Can't init filesystem_stdio!\n" );
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -892,6 +892,7 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
|
|||||||
host.config_executed = false;
|
host.config_executed = false;
|
||||||
host.status = HOST_INIT; // initialzation started
|
host.status = HOST_INIT; // initialzation started
|
||||||
host.type = HOST_DEDICATED; // predict state
|
host.type = HOST_DEDICATED; // predict state
|
||||||
|
Q_strncpy( host.default_gamedir, basedir, sizeof( host.default_gamedir ));
|
||||||
|
|
||||||
#ifndef XASH_DEDICATED
|
#ifndef XASH_DEDICATED
|
||||||
if( !Sys_CheckParm( "-dedicated" ))
|
if( !Sys_CheckParm( "-dedicated" ))
|
||||||
@@ -964,8 +965,8 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
|
|||||||
#if XASH_DEDICATED
|
#if XASH_DEDICATED
|
||||||
Platform_SetupSigtermHandling();
|
Platform_SetupSigtermHandling();
|
||||||
#endif
|
#endif
|
||||||
Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED, basedir );
|
Platform_Init( Host_IsDedicated( ) || developer >= DEV_EXTENDED );
|
||||||
FS_Init( basedir );
|
FS_Init();
|
||||||
|
|
||||||
// print current developer level to simplify processing users feedback
|
// print current developer level to simplify processing users feedback
|
||||||
if( developer > 0 )
|
if( developer > 0 )
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "dlfcn.h"
|
#include "dlfcn.h"
|
||||||
|
|
||||||
#ifndef XASH_GAMEDIR
|
|
||||||
#define XASH_GAMEDIR "valve" // !!! Replace with your default (base) game directory !!!
|
|
||||||
#endif
|
|
||||||
#define XASHLIB "@rpath/libxash.dylib"
|
#define XASHLIB "@rpath/libxash.dylib"
|
||||||
|
|
||||||
|
|
||||||
@@ -331,4 +328,4 @@ int IOS_GetArgs( char ***out )
|
|||||||
{
|
{
|
||||||
*out = szArgv;
|
*out = szArgv;
|
||||||
return szArgc;
|
return szArgc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ GNU General Public License for more details.
|
|||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
#include "crtlib.h"
|
#include "crtlib.h"
|
||||||
#include "fscallback.h"
|
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "platform/ios/lib_ios.h"
|
#include "platform/ios/lib_ios.h"
|
||||||
#include <dlfcn.h>
|
#include "common.h"
|
||||||
|
|
||||||
#define EXT_LENGTH 5
|
#define EXT_LENGTH 5
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ void *IOS_LoadLibrary( const char *dllname )
|
|||||||
|
|
||||||
if( !postfix )
|
if( !postfix )
|
||||||
{
|
{
|
||||||
if ( Q_strcmp(FS_Gamedir(), "valve" ) )
|
if ( Q_strcmp(FS_Gamedir(), host.default_gamedir ) )
|
||||||
{
|
{
|
||||||
postfix = FS_Gamedir( );
|
postfix = FS_Gamedir( );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,10 +66,15 @@ qboolean Platform_DebuggerPresent( void )
|
|||||||
tracer_pid = (const byte*)Q_strstr( buf, TracerPid );
|
tracer_pid = (const byte*)Q_strstr( buf, TracerPid );
|
||||||
if( !tracer_pid )
|
if( !tracer_pid )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//printf( "%s\n", tracer_pid );
|
//printf( "%s\n", tracer_pid );
|
||||||
while( *tracer_pid < '0' || *tracer_pid > '9' )
|
|
||||||
|
while(( *tracer_pid < '0' ) || ( *tracer_pid > '9' ))
|
||||||
|
{
|
||||||
if( *tracer_pid++ == '\n' )
|
if( *tracer_pid++ == '\n' )
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//printf( "%s\n", tracer_pid );
|
//printf( "%s\n", tracer_pid );
|
||||||
return !!Q_atoi( (const char*)tracer_pid );
|
return !!Q_atoi( (const char*)tracer_pid );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ char *Posix_Input( void );
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if XASH_SDL
|
#if XASH_SDL
|
||||||
void SDLash_Init( const char *basedir );
|
void SDLash_Init( void );
|
||||||
void SDLash_Shutdown( void );
|
void SDLash_Shutdown( void );
|
||||||
void SDLash_NanoSleep( int nsec );
|
void SDLash_NanoSleep( int nsec );
|
||||||
#endif
|
#endif
|
||||||
@@ -111,7 +111,7 @@ void Linux_SetTimer( float time );
|
|||||||
int Linux_GetProcessID( void );
|
int Linux_GetProcessID( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void Platform_Init( qboolean con_showalways, const char *basedir )
|
static inline void Platform_Init( qboolean con_showalways )
|
||||||
{
|
{
|
||||||
#if XASH_POSIX
|
#if XASH_POSIX
|
||||||
// daemonize as early as possible, because we need to close our file descriptors
|
// daemonize as early as possible, because we need to close our file descriptors
|
||||||
@@ -119,7 +119,7 @@ static inline void Platform_Init( qboolean con_showalways, const char *basedir )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if XASH_SDL
|
#if XASH_SDL
|
||||||
SDLash_Init( basedir );
|
SDLash_Init( );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if XASH_ANDROID
|
#if XASH_ANDROID
|
||||||
|
|||||||
@@ -79,20 +79,23 @@ static void SDLCALL SDLash_LogOutputFunction( void *userdata, int category, SDL_
|
|||||||
case SDL_LOG_PRIORITY_INFO:
|
case SDL_LOG_PRIORITY_INFO:
|
||||||
str = S_NOTE;
|
str = S_NOTE;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
str = "";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Reportf( "%s" S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", str, SDLash_CategoryToString( category ), message );
|
Con_Reportf( "%s" S_BLUE "SDL" S_DEFAULT ": [%s] %s\n", str, SDLash_CategoryToString( category ), message );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLash_Init( const char *basedir )
|
void SDLash_Init( void )
|
||||||
{
|
{
|
||||||
#if XASH_APPLE
|
#if XASH_IOS
|
||||||
char *path = SDL_GetBasePath();
|
char *path = SDL_GetBasePath();
|
||||||
if( path != NULL )
|
if( path != NULL )
|
||||||
{
|
{
|
||||||
char buf[MAX_VA_STRING];
|
char buf[MAX_VA_STRING];
|
||||||
|
|
||||||
Q_snprintf( buf, sizeof( buf ), "%s%s/extras.pk3", path, basedir );
|
Q_snprintf( buf, sizeof( buf ), "%s%s/extras.pk3", path, host.default_gamedir );
|
||||||
setenv( "XASH3D_EXTRAS_PAK1", buf, true );
|
setenv( "XASH3D_EXTRAS_PAK1", buf, true );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ extern fs_globals_t *FI;
|
|||||||
#define FS_Gamedir() GI->gamefolder
|
#define FS_Gamedir() GI->gamefolder
|
||||||
#define FS_Title() GI->title
|
#define FS_Title() GI->title
|
||||||
|
|
||||||
#define FS_InitStdio (*g_fsapi.InitStdio)
|
|
||||||
#define FS_ShutdownStdio (*g_fsapi.ShutdownStdio)
|
|
||||||
|
|
||||||
// search path utils
|
// search path utils
|
||||||
#define FS_Rescan (*g_fsapi.Rescan)
|
#define FS_Rescan (*g_fsapi.Rescan)
|
||||||
#define FS_ClearSearchPath (*g_fsapi.ClearSearchPath)
|
#define FS_ClearSearchPath (*g_fsapi.ClearSearchPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user