mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-03-13 06:21:08 +00:00
engine, filesystem: unify GetNativeObject between all the APIs. Allow getting filesystem APIs through GetNativeObject
This commit is contained in:
parent
5ea074a1fd
commit
597429cf41
@ -181,6 +181,7 @@ typedef struct dll_info_s
|
||||
} dll_info_t;
|
||||
|
||||
typedef void (*setpair_t)( const char *key, const void *value, const void *buffer, void *numpairs );
|
||||
typedef void *(*pfnCreateInterface_t)( const char *, int * );
|
||||
|
||||
// config strings are a general means of communication from
|
||||
// the server to all connected clients.
|
||||
|
@ -87,15 +87,6 @@ static int pfnDrawScaledCharacter( int x, int y, int number, int r, int g, int b
|
||||
return CL_DrawCharacter( x, y, number, color, &g_scaled_font, flags );
|
||||
}
|
||||
|
||||
static void *pfnGetNativeObject( const char *obj )
|
||||
{
|
||||
if( !obj )
|
||||
return NULL;
|
||||
|
||||
// Backend should consider that obj is case-sensitive
|
||||
return Platform_GetNativeObject( obj );
|
||||
}
|
||||
|
||||
static void pfnTouch_HideButtons( const char *name, byte state )
|
||||
{
|
||||
Touch_HideButtons( name, state, true );
|
||||
@ -124,7 +115,7 @@ static mobile_engfuncs_t gpMobileEngfuncs =
|
||||
Touch_ResetDefaultButtons,
|
||||
pfnDrawScaledCharacter,
|
||||
Sys_Warn,
|
||||
pfnGetNativeObject,
|
||||
Sys_GetNativeObject,
|
||||
ID_SetCustomClientID,
|
||||
pfnParseFileSafe
|
||||
};
|
||||
|
@ -381,6 +381,7 @@ typedef void (*xcommand_t)( void );
|
||||
qboolean FS_LoadProgs( void );
|
||||
void FS_Init( void );
|
||||
void FS_Shutdown( void );
|
||||
void *FS_GetNativeObject( const char *obj );
|
||||
|
||||
//
|
||||
// cmd.c
|
||||
|
@ -23,8 +23,17 @@ GNU General Public License for more details.
|
||||
fs_api_t g_fsapi;
|
||||
fs_globals_t *FI;
|
||||
|
||||
static pfnCreateInterface_t fs_pfnCreateInterface;
|
||||
static HINSTANCE fs_hInstance;
|
||||
|
||||
void *FS_GetNativeObject( const char *obj )
|
||||
{
|
||||
if( fs_pfnCreateInterface )
|
||||
return fs_pfnCreateInterface( obj, NULL );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void FS_Rescan_f( void )
|
||||
{
|
||||
FS_Rescan();
|
||||
@ -53,7 +62,7 @@ static fs_interface_t fs_memfuncs =
|
||||
_Mem_Realloc,
|
||||
_Mem_Free,
|
||||
|
||||
Platform_GetNativeObject,
|
||||
Sys_GetNativeObject,
|
||||
};
|
||||
|
||||
static void FS_UnloadProgs( void )
|
||||
@ -98,6 +107,13 @@ qboolean FS_LoadProgs( void )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !( fs_pfnCreateInterface = (pfnCreateInterface_t)COM_GetProcAddress( fs_hInstance, "CreateInterface" )))
|
||||
{
|
||||
FS_UnloadProgs();
|
||||
Host_Error( "FS_LoadProgs: can't find CreateInterface entry point in %s\n", name );
|
||||
return false;
|
||||
}
|
||||
|
||||
Con_DPrintf( "FS_LoadProgs: filesystem_stdio successfully loaded\n" );
|
||||
|
||||
return true;
|
||||
|
@ -649,3 +649,31 @@ qboolean Sys_NewInstance( const char *gamedir )
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
Sys_GetNativeObject
|
||||
|
||||
Get platform-specific native object
|
||||
==================
|
||||
*/
|
||||
void *Sys_GetNativeObject( const char *obj )
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if( !COM_CheckString( obj ))
|
||||
return NULL;
|
||||
|
||||
ptr = FS_GetNativeObject( obj );
|
||||
|
||||
if( ptr )
|
||||
return ptr;
|
||||
|
||||
// Backend should consider that obj is case-sensitive
|
||||
#if XASH_ANDROID
|
||||
ptr = Android_GetNativeObject( obj );
|
||||
#endif // XASH_ANDROID
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ void Sys_InitLog( void );
|
||||
void Sys_CloseLog( void );
|
||||
void Sys_Quit( void ) NORETURN;
|
||||
qboolean Sys_NewInstance( const char *gamedir );
|
||||
void *Sys_GetNativeObject( const char *obj );
|
||||
|
||||
//
|
||||
// sys_con.c
|
||||
|
@ -139,17 +139,6 @@ static inline void Platform_Shutdown( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void *Platform_GetNativeObject( const char *name )
|
||||
{
|
||||
void *ptr = NULL;
|
||||
|
||||
#if XASH_ANDROID
|
||||
ptr = Android_GetNativeObject( name );
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
@ -158,7 +147,6 @@ static inline void *Platform_GetNativeObject( const char *name )
|
||||
==============================================================================
|
||||
*/
|
||||
void Platform_Vibrate( float life, char flags );
|
||||
void*Platform_GetNativeObject( const char *name );
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
@ -150,6 +150,4 @@ public:
|
||||
virtual void AddSearchPathNoWrite(const char *, const char *) = 0; /* linkage=_ZN11IFileSystem20AddSearchPathNoWriteEPKcS1_ */
|
||||
};
|
||||
|
||||
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!
|
||||
|
||||
#endif // VFILESYSTEM009_H
|
||||
|
@ -1386,7 +1386,7 @@ static void _Sys_Error( const char *fmt, ... )
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
static void *_Platform_GetNativeObject_stub( const char *object )
|
||||
static void *Sys_GetNativeObject_stub( const char *object )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -2841,7 +2841,7 @@ fs_interface_t g_engfuncs =
|
||||
_Mem_Alloc,
|
||||
_Mem_Realloc,
|
||||
_Mem_Free,
|
||||
_Platform_GetNativeObject_stub
|
||||
Sys_GetNativeObject_stub
|
||||
};
|
||||
|
||||
static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
|
||||
@ -2883,9 +2883,9 @@ static qboolean FS_InitInterface( int version, fs_interface_t *engfuncs )
|
||||
Con_Reportf( "filesystem_stdio: custom memory allocation functions found\n" );
|
||||
}
|
||||
|
||||
if( engfuncs->_Platform_GetNativeObject )
|
||||
if( engfuncs->_Sys_GetNativeObject )
|
||||
{
|
||||
g_engfuncs._Platform_GetNativeObject = engfuncs->_Platform_GetNativeObject;
|
||||
g_engfuncs._Sys_GetNativeObject = engfuncs->_Sys_GetNativeObject;
|
||||
Con_Reportf( "filesystem_stdio: custom platform-specific functions found\n" );
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,8 @@ extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#define FS_API_VERSION 2 // not stable yet!
|
||||
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!!
|
||||
#define FS_API_CREATEINTERFACE_TAG "XashFileSystem002" // follow FS_API_VERSION!!!
|
||||
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" // never change this!
|
||||
|
||||
// search path flags
|
||||
enum
|
||||
@ -210,7 +211,7 @@ typedef struct fs_interface_t
|
||||
void (*_Mem_Free)( void *data, const char *filename, int fileline );
|
||||
|
||||
// platform
|
||||
void *(*_Platform_GetNativeObject)( const char *object );
|
||||
void *(*_Sys_GetNativeObject)( const char *object );
|
||||
} fs_interface_t;
|
||||
|
||||
typedef int (*FSAPI)( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *interface );
|
||||
|
@ -127,7 +127,7 @@ extern const fs_archive_t g_archives[];
|
||||
#define Con_DPrintf (*g_engfuncs._Con_DPrintf)
|
||||
#define Con_Reportf (*g_engfuncs._Con_Reportf)
|
||||
#define Sys_Error (*g_engfuncs._Sys_Error)
|
||||
#define Platform_GetNativeObject (*g_engfuncs._Platform_GetNativeObject)
|
||||
#define Sys_GetNativeObject (*g_engfuncs._Sys_GetNativeObject)
|
||||
|
||||
//
|
||||
// filesystem.c
|
||||
|
@ -18,7 +18,6 @@ typedef void *HMODULE;
|
||||
|
||||
HMODULE g_hModule;
|
||||
FSAPI g_pfnGetFSAPI;
|
||||
typedef void *(*pfnCreateInterface_t)( const char *, int * );
|
||||
pfnCreateInterface_t g_pfnCreateInterface;
|
||||
fs_api_t g_fs;
|
||||
fs_globals_t *g_nullglobals;
|
||||
|
Loading…
x
Reference in New Issue
Block a user