2016-07-12 00:40:13 +00:00
# include "quakedef.h"
# include "fs.h"
# include "errno.h"
2023-01-09 05:12:12 +00:00
# if _POSIX_C_SOURCE >= 200112L
# include <sys/stat.h>
# endif
2016-07-12 00:40:13 +00:00
Added sys_openfile console command(and menu option) to web and flatpak(via cmake+dbus) builds, to 'install' packages on sandboxed systems a bit more easily.
Cmake: Add FTE_WERROR option, defaults to true in debug builds and off in release builds (in case future compilers have issues).
Cmake: Pull in libXscreensaver so we don't get interrupted by screensavers when playing demos.
Make: Added `make webcl-rel` for a web build without server bloat (eg for sites focused on demo playback. Yes, this means you XantoM).
fteqcc: Include the decompiler in fteqcc (non-gui) builds ('-d' arg).
fteqcc: Decompiler can now mostly handle hexen2 mods without any unknown opcodes.
Allow ezHud and OpenSSL to be compiled as in-engine plugins, potentially for web and windows ports respectively.
Web: Fix support for ogg vorbis. Add support for voip.
Web: Added basic support for WebXR.
QTV: Don't try seeking on unseekable qtv streams. Don't spam when developer 1 is set.
QTV: add support for some eztv extensions.
MVD: added hack to use ktx's vweps in mvd where mvdsv doesn't bother to record the info.
qwfwd: hack around a hack in qwfwd, allowing it to work again.
recording: favour qwd in single player, instead of mvd.
Protocol: reduce client memory used for precache names. Bump maximum precache counts - some people are just abusive, yes you Orl.
hexen2: add enough clientside protocol compat to play the demo included with h2mp. lacks effects.
in_xflip: restored this setting.
fs_hidesyspaths: new cvar, defaults to enabled so you won't find your username or whatever turning up in screenshots or the like. change it to 0 before debuging stuff eg via 'path'.
gl_overbright_models: Added cvar to match QS.
netchan: Added MTU determination, we'll no longer fail to connect when routers stupidly drop icmp packets.
Win: try a few other versions of xinput too.
CSQC: Added a CSQC_GenerateMaterial function, to give the csqc a chance to generate custom materials.
MenuQC: Added support for the skeletal objects API.
2024-04-09 17:13:59 +00:00
# if !defined(FTE_TARGET_WEB) && (!defined(_WIN32) || defined(FTE_SDL) || defined(WEBSVONLY))
2016-07-12 00:40:13 +00:00
# ifdef WEBSVONLY
2018-11-19 06:37:25 +00:00
# define Z_Free free
# define Z_Malloc malloc
2023-01-09 05:14:57 +00:00
# define Con_Printf printf
# define fs_readonly true
# define FS_FlushFSHashFull()
int Sys_EnumerateFiles ( const char * gpath , const char * match , int ( QDECL * func ) ( const char * fname , qofs_t fsize , time_t modtime , void * parm , searchpathfuncs_t * spath ) , void * parm , searchpathfuncs_t * spath ) { return 0 ; }
2016-07-12 00:40:13 +00:00
# else
2018-11-19 06:37:25 +00:00
# if !defined(_WIN32) || defined(FTE_SDL) || defined(WINRT) || defined(_XBOX)
# define FSSTDIO_OpenPath VFSOS_OpenPath
# endif
# define FSSTDIO_OpenTemp FS_OpenTemp
2016-07-12 00:40:13 +00:00
# endif
typedef struct {
searchpathfuncs_t pub ;
int depth ;
void ( QDECL * AddFileHash ) ( int depth , const char * fname , fsbucket_t * filehandle , void * pathhandle ) ;
char rootpath [ 1 ] ;
} stdiopath_t ;
typedef struct {
vfsfile_t funcs ;
FILE * handle ;
} vfsstdiofile_t ;
static int QDECL VFSSTDIO_ReadBytes ( struct vfsfile_s * file , void * buffer , int bytestoread )
{
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
return fread ( buffer , 1 , bytestoread , intfile - > handle ) ;
}
static int QDECL VFSSTDIO_WriteBytes ( struct vfsfile_s * file , const void * buffer , int bytestoread )
{
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
return fwrite ( buffer , 1 , bytestoread , intfile - > handle ) ;
}
static qboolean QDECL VFSSTDIO_Seek ( struct vfsfile_s * file , qofs_t pos )
{
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
return fseeko64 ( intfile - > handle , ( off64_t ) pos , SEEK_SET ) = = 0 ;
# elif _POSIX_C_SOURCE >= 200112L
2018-03-24 04:02:09 +00:00
return fseeko ( intfile - > handle , ( off_t ) pos , SEEK_SET ) = = 0 ;
# else
2016-07-12 00:40:13 +00:00
return fseek ( intfile - > handle , pos , SEEK_SET ) = = 0 ;
2018-03-24 04:02:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
}
static qofs_t QDECL VFSSTDIO_Tell ( struct vfsfile_s * file )
{
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
2020-09-08 10:40:21 +00:00
return ( qofs_t ) ftello64 ( intfile - > handle ) ;
2020-09-08 05:11:09 +00:00
# elif _POSIX_C_SOURCE >= 200112L
2018-03-24 04:02:09 +00:00
return ( qofs_t ) ftello ( intfile - > handle ) ;
# else
2016-07-12 00:40:13 +00:00
return ftell ( intfile - > handle ) ;
2018-03-24 04:02:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
}
static void QDECL VFSSTDIO_Flush ( struct vfsfile_s * file )
{
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
fflush ( intfile - > handle ) ;
}
static qofs_t QDECL VFSSTDIO_GetSize ( struct vfsfile_s * file )
{
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
off64_t curpos ;
qofs_t maxlen ;
curpos = ftello64 ( intfile - > handle ) ;
fseeko64 ( intfile - > handle , 0 , SEEK_END ) ;
maxlen = ( qofs_t ) ftello64 ( intfile - > handle ) ;
fseeko64 ( intfile - > handle , curpos , SEEK_SET ) ;
# elif _POSIX_C_SOURCE >= 200112L
2018-03-24 04:02:09 +00:00
off_t curpos ;
qofs_t maxlen ;
curpos = ftello ( intfile - > handle ) ;
fseeko ( intfile - > handle , 0 , SEEK_END ) ;
maxlen = ( qofs_t ) ftello ( intfile - > handle ) ;
fseeko ( intfile - > handle , curpos , SEEK_SET ) ;
# else
2016-07-12 00:40:13 +00:00
unsigned int curpos ;
unsigned int maxlen ;
curpos = ftell ( intfile - > handle ) ;
fseek ( intfile - > handle , 0 , SEEK_END ) ;
maxlen = ftell ( intfile - > handle ) ;
fseek ( intfile - > handle , curpos , SEEK_SET ) ;
2018-03-24 04:02:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
return maxlen ;
}
static qboolean QDECL VFSSTDIO_Close ( vfsfile_t * file )
{
qboolean success ;
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
success = ! ferror ( intfile - > handle ) ;
fclose ( intfile - > handle ) ;
Z_Free ( file ) ;
return success ;
}
# ifdef _WIN32
static qboolean QDECL VFSSTDIO_CloseTemp ( vfsfile_t * file )
{
qboolean success ;
vfsstdiofile_t * intfile = ( vfsstdiofile_t * ) file ;
char * fname = ( char * ) ( intfile + 1 ) ;
success = ! ferror ( intfile - > handle ) ;
fclose ( intfile - > handle ) ;
_unlink ( fname ) ;
Z_Free ( file ) ;
return success ;
}
# endif
vfsfile_t * FSSTDIO_OpenTemp ( void )
{
FILE * f ;
vfsstdiofile_t * file ;
# ifdef _WIN32
2021-06-21 13:45:20 +00:00
/*microsoft's tmpfile will nearly always fail, as it insists on writing to the root directory and that requires running everything with full admin rights.
warning : there ' s a race condition between tempnam and fopen . if the file is not opened exclusively then we can end up with issues
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
on windows , fopen is typically exclusive anyway , but not on unix . but on unix , tmpfile is actually usable , so special - case the windows code
we also have a special close function to ensure the file is deleted too
*/
2016-07-12 00:40:13 +00:00
char * fname = _tempnam ( NULL , " ftemp " ) ;
f = fopen ( fname , " w+b " ) ;
if ( ! f )
return NULL ;
file = Z_Malloc ( sizeof ( vfsstdiofile_t ) + strlen ( fname ) + 1 ) ;
file - > funcs . Close = VFSSTDIO_CloseTemp ;
strcpy ( ( char * ) ( file + 1 ) , fname ) ;
free ( fname ) ;
2020-09-08 05:11:09 +00:00
# else
# ifdef __USE_LARGEFILE64
f = tmpfile64 ( ) ;
2016-07-12 00:40:13 +00:00
# else
f = tmpfile ( ) ;
2020-09-08 05:11:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
if ( ! f )
return NULL ;
file = Z_Malloc ( sizeof ( vfsstdiofile_t ) ) ;
file - > funcs . Close = VFSSTDIO_Close ;
# endif
# ifdef _DEBUG
Q_strncpyz ( file - > funcs . dbgname , " FSSTDIO_OpenTemp " , sizeof ( file - > funcs . dbgname ) ) ;
# endif
file - > funcs . ReadBytes = VFSSTDIO_ReadBytes ;
file - > funcs . WriteBytes = VFSSTDIO_WriteBytes ;
file - > funcs . Seek = VFSSTDIO_Seek ;
file - > funcs . Tell = VFSSTDIO_Tell ;
file - > funcs . GetLen = VFSSTDIO_GetSize ;
file - > funcs . Flush = VFSSTDIO_Flush ;
file - > handle = f ;
return ( vfsfile_t * ) file ;
}
#if 0 //def ANDROID
vfsfile_t * Sys_OpenAsset ( const char * fname ) ;
# endif
2018-11-19 06:37:25 +00:00
vfsfile_t * VFSSTDIO_Open ( const char * osname , const char * mode , qboolean * needsflush )
2016-07-12 00:40:13 +00:00
{
FILE * f ;
vfsstdiofile_t * file ;
qboolean read = ! ! strchr ( mode , ' r ' ) ;
qboolean write = ! ! strchr ( mode , ' w ' ) ;
qboolean append = ! ! strchr ( mode , ' a ' ) ;
qboolean text = ! ! strchr ( mode , ' t ' ) ;
2018-03-24 04:02:09 +00:00
// qboolean dolock = !!strchr(mode, 'l');
2016-07-12 00:40:13 +00:00
char newmode [ 5 ] ;
int modec = 0 ;
if ( needsflush )
* needsflush = false ;
#if 0 //def ANDROID
// if (!strncmp("asset/", osname, 6))
{
if ( append | | write )
return NULL ;
return Sys_OpenAsset ( osname ) ;
}
# endif
if ( read )
newmode [ modec + + ] = ' r ' ;
if ( write )
newmode [ modec + + ] = ' w ' ;
if ( append )
newmode [ modec + + ] = ' a ' ;
// if (append)
// newmode[modec++] = '+';
if ( text )
newmode [ modec + + ] = ' t ' ;
else
newmode [ modec + + ] = ' b ' ;
# ifdef __linux__
newmode [ modec + + ] = ' e ' ; //otherwise forks get messy.
# endif
newmode [ modec + + ] = ' \0 ' ;
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
f = fopen64 ( osname , newmode ) ;
# else
2016-07-12 00:40:13 +00:00
f = fopen ( osname , newmode ) ;
2020-09-08 05:11:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
if ( ! f )
return NULL ;
if ( write | | append )
{
if ( needsflush )
* needsflush = true ;
}
file = Z_Malloc ( sizeof ( vfsstdiofile_t ) ) ;
# ifdef _DEBUG
Q_strncpyz ( file - > funcs . dbgname , osname , sizeof ( file - > funcs . dbgname ) ) ;
# endif
file - > funcs . ReadBytes = VFSSTDIO_ReadBytes ;
file - > funcs . WriteBytes = VFSSTDIO_WriteBytes ;
file - > funcs . Seek = VFSSTDIO_Seek ;
file - > funcs . Tell = VFSSTDIO_Tell ;
file - > funcs . GetLen = VFSSTDIO_GetSize ;
file - > funcs . Close = VFSSTDIO_Close ;
file - > funcs . Flush = VFSSTDIO_Flush ;
file - > handle = f ;
return ( vfsfile_t * ) file ;
}
2017-03-27 21:45:45 +00:00
# if !defined(_WIN32) || defined(FTE_SDL) || defined(WINRT) || defined(_XBOX)
2016-07-12 00:40:13 +00:00
vfsfile_t * VFSOS_Open ( const char * osname , const char * mode )
{
vfsfile_t * f ;
qboolean needsflush ;
f = VFSSTDIO_Open ( osname , mode , & needsflush ) ;
if ( needsflush )
2017-02-19 00:15:42 +00:00
FS_FlushFSHashFull ( ) ;
2016-07-12 00:40:13 +00:00
return f ;
}
# endif
static vfsfile_t * QDECL FSSTDIO_OpenVFS ( searchpathfuncs_t * handle , flocation_t * loc , const char * mode )
{
vfsfile_t * f ;
stdiopath_t * sp = ( void * ) handle ;
qboolean needsflush ;
f = VFSSTDIO_Open ( loc - > rawname , mode , & needsflush ) ;
if ( needsflush & & sp - > AddFileHash )
sp - > AddFileHash ( sp - > depth , loc - > rawname , NULL , sp ) ;
return f ;
}
static void QDECL FSSTDIO_ClosePath ( searchpathfuncs_t * handle )
{
Z_Free ( handle ) ;
}
static qboolean QDECL FSSTDIO_PollChanges ( searchpathfuncs_t * handle )
{
// stdiopath_t *np = handle;
return true ; //can't verify that or not, so we have to assume the worst
}
static int QDECL FSSTDIO_RebuildFSHash ( const char * filename , qofs_t filesize , time_t mtime , void * data , searchpathfuncs_t * spath )
{
stdiopath_t * sp = ( void * ) spath ;
void ( QDECL * AddFileHash ) ( int depth , const char * fname , fsbucket_t * filehandle , void * pathhandle ) = data ;
if ( filename [ strlen ( filename ) - 1 ] = = ' / ' )
{ //this is actually a directory
char childpath [ 256 ] ;
2021-08-05 17:12:41 +00:00
if ( ! Q_snprintfz ( childpath , sizeof ( childpath ) , " %s* " , filename ) )
Sys_EnumerateFiles ( sp - > rootpath , childpath , FSSTDIO_RebuildFSHash , data , spath ) ;
2016-07-12 00:40:13 +00:00
return true ;
}
AddFileHash ( sp - > depth , filename , NULL , sp ) ;
return true ;
}
static void QDECL FSSTDIO_BuildHash ( searchpathfuncs_t * handle , int depth , void ( QDECL * AddFileHash ) ( int depth , const char * fname , fsbucket_t * filehandle , void * pathhandle ) )
{
stdiopath_t * sp = ( void * ) handle ;
sp - > depth = depth ;
sp - > AddFileHash = AddFileHash ;
Sys_EnumerateFiles ( sp - > rootpath , " * " , FSSTDIO_RebuildFSHash , AddFileHash , handle ) ;
}
2019-05-23 15:11:32 +00:00
static unsigned int QDECL FSSTDIO_CreateLoc ( searchpathfuncs_t * handle , flocation_t * loc , const char * filename )
{
stdiopath_t * sp = ( void * ) handle ;
char * ofs ;
2023-01-09 05:14:57 +00:00
if ( fs_readonly )
return FF_NOTFOUND ;
2019-05-23 15:11:32 +00:00
loc - > len = 0 ;
loc - > offset = 0 ;
loc - > fhandle = handle ;
2021-08-05 16:49:25 +00:00
if ( Q_snprintfz ( loc - > rawname , sizeof ( loc - > rawname ) , " %s/%s " , sp - > rootpath , filename ) )
2019-05-23 15:11:32 +00:00
return FF_NOTFOUND ; //too long...
for ( ofs = loc - > rawname + 1 ; * ofs ; ofs + + )
{
if ( * ofs = = ' / ' )
{ // create the directory
* ofs = 0 ;
Sys_mkdir ( loc - > rawname ) ;
* ofs = ' / ' ;
}
}
return FF_FOUND ;
}
2016-07-12 00:40:13 +00:00
static unsigned int QDECL FSSTDIO_FLocate ( searchpathfuncs_t * handle , flocation_t * loc , const char * filename , void * hashedresult )
{
stdiopath_t * sp = ( void * ) handle ;
2020-09-08 05:11:09 +00:00
qofs_t len ;
2016-07-12 00:40:13 +00:00
char netpath [ MAX_OSPATH ] ;
if ( hashedresult & & ( void * ) hashedresult ! = handle )
return FF_NOTFOUND ;
/*
if ( ! static_registered )
{ // if not a registered version, don't ever go beyond base
if ( strchr ( filename , ' / ' ) | | strchr ( filename , ' \\ ' ) )
continue ;
}
*/
// check a file in the directory tree
2021-08-05 16:49:25 +00:00
if ( Q_snprintfz ( netpath , sizeof ( netpath ) , " %s/%s " , sp - > rootpath , filename ) )
2019-05-23 15:11:32 +00:00
return FF_NOTFOUND ;
2016-07-12 00:40:13 +00:00
2023-01-09 05:12:12 +00:00
# if _POSIX_C_SOURCE >= 200112L
{
struct stat sb ;
if ( stat ( netpath , & sb ) = = 0 )
{
len = sb . st_size ;
if ( ( sb . st_mode & S_IFMT ) ! = S_IFREG )
return FF_NOTFOUND ; //no directories nor sockets! boo! (any simlink will already have been resolved)
}
else
return FF_NOTFOUND ; //some kind of screwup.
}
# elif 0 //defined(ANDROID)
2016-07-12 00:40:13 +00:00
{
vfsfile_t * f = VFSSTDIO_Open ( netpath , " rb " , NULL ) ;
if ( ! f )
return false ;
len = VFS_GETLEN ( f ) ;
VFS_CLOSE ( f ) ;
}
# else
{
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
FILE * f = fopen64 ( netpath , " rb " ) ;
# else
2016-07-12 00:40:13 +00:00
FILE * f = fopen ( netpath , " rb " ) ;
2020-09-08 05:11:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
if ( ! f )
return FF_NOTFOUND ;
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
fseeko64 ( f , 0 , SEEK_END ) ;
len = ftello64 ( f ) ;
# elif _POSIX_C_SOURCE >= 200112L
fseeko ( f , 0 , SEEK_END ) ;
len = ftello ( f ) ;
# else
2016-07-12 00:40:13 +00:00
fseek ( f , 0 , SEEK_END ) ;
len = ftell ( f ) ;
2020-09-08 05:11:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
fclose ( f ) ;
}
# endif
if ( loc )
{
loc - > len = len ;
loc - > offset = 0 ;
2017-02-19 00:15:42 +00:00
loc - > fhandle = handle ;
2016-07-12 00:40:13 +00:00
Q_strncpyz ( loc - > rawname , netpath , sizeof ( loc - > rawname ) ) ;
}
return FF_FOUND ;
}
static void QDECL FSSTDIO_ReadFile ( searchpathfuncs_t * handle , flocation_t * loc , char * buffer )
{
FILE * f ;
size_t result ;
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
f = fopen64 ( loc - > rawname , " rb " ) ;
# else
2016-07-12 00:40:13 +00:00
f = fopen ( loc - > rawname , " rb " ) ;
2020-09-08 05:11:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
if ( ! f ) //err...
return ;
2020-09-08 05:11:09 +00:00
# ifdef __USE_LARGEFILE64
fseeko64 ( f , loc - > offset , SEEK_SET ) ;
# elif _POSIX_C_SOURCE >= 200112L
fseeko ( f , loc - > offset , SEEK_SET ) ;
# else
2016-07-12 00:40:13 +00:00
fseek ( f , loc - > offset , SEEK_SET ) ;
2020-09-08 05:11:09 +00:00
# endif
2016-07-12 00:40:13 +00:00
result = fread ( buffer , 1 , loc - > len , f ) ; // do soemthing with result
if ( result ! = loc - > len )
Con_Printf ( " FSSTDIO_ReadFile() fread: Filename: %s, expected %u, result was %u (%s) \n " , loc - > rawname , ( unsigned int ) loc - > len , ( unsigned int ) result , strerror ( errno ) ) ;
fclose ( f ) ;
}
static int QDECL FSSTDIO_EnumerateFiles ( searchpathfuncs_t * handle , const char * match , int ( QDECL * func ) ( const char * , qofs_t , time_t mtime , void * , searchpathfuncs_t * spath ) , void * parm )
{
stdiopath_t * sp = ( stdiopath_t * ) handle ;
return Sys_EnumerateFiles ( sp - > rootpath , match , func , parm , handle ) ;
}
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
# include <sys/stat.h>
static qboolean QDECL FSSTDIO_FileStat ( searchpathfuncs_t * handle , flocation_t * loc , time_t * mtime )
{
struct stat s ;
if ( stat ( loc - > rawname , & s ) ! = - 1 )
{
* mtime = s . st_mtime ;
return true ;
}
return false ;
}
2020-04-19 01:23:32 +00:00
static qboolean QDECL FSSTDIO_RenameFile ( searchpathfuncs_t * handle , const char * oldname , const char * newname )
{
stdiopath_t * sp = ( void * ) handle ;
char oldsyspath [ MAX_OSPATH ] ;
char newsyspath [ MAX_OSPATH ] ;
if ( fs_readonly )
return false ;
2021-08-05 17:12:41 +00:00
if ( Q_snprintfz ( oldsyspath , sizeof ( oldsyspath ) , " %s/%s " , sp - > rootpath , oldname ) )
2020-04-19 01:23:32 +00:00
return false ; //too long
2021-08-05 17:12:41 +00:00
if ( Q_snprintfz ( newsyspath , sizeof ( newsyspath ) , " %s/%s " , sp - > rootpath , newname ) )
2020-04-19 01:23:32 +00:00
return false ; //too long
return Sys_Rename ( oldsyspath , newsyspath ) ;
}
static qboolean QDECL FSSTDIO_RemoveFile ( searchpathfuncs_t * handle , const char * filename )
{
stdiopath_t * sp = ( void * ) handle ;
char syspath [ MAX_OSPATH ] ;
if ( fs_readonly )
return false ;
2021-08-05 17:12:41 +00:00
if ( Q_snprintfz ( syspath , sizeof ( syspath ) , " %s/%s " , sp - > rootpath , filename ) )
2020-04-19 01:23:32 +00:00
return false ; //too long
if ( * filename & & filename [ strlen ( filename ) - 1 ] = = ' / ' )
return Sys_rmdir ( syspath ) ;
return Sys_remove ( syspath ) ;
}
2016-07-12 00:40:13 +00:00
2018-03-04 14:41:16 +00:00
searchpathfuncs_t * QDECL FSSTDIO_OpenPath ( vfsfile_t * mustbenull , searchpathfuncs_t * parent , const char * filename , const char * desc , const char * prefix )
2016-07-12 00:40:13 +00:00
{
stdiopath_t * np ;
int dlen = strlen ( desc ) ;
if ( mustbenull )
return NULL ;
if ( prefix & & * prefix )
return NULL ; //don't try to support this. too risky with absolute paths etc.
np = Z_Malloc ( sizeof ( * np ) + dlen ) ;
if ( np )
{
np - > depth = 0 ;
memcpy ( np - > rootpath , desc , dlen + 1 ) ;
}
np - > pub . fsver = FSVER ;
np - > pub . ClosePath = FSSTDIO_ClosePath ;
np - > pub . BuildHash = FSSTDIO_BuildHash ;
np - > pub . FindFile = FSSTDIO_FLocate ;
np - > pub . ReadFile = FSSTDIO_ReadFile ;
np - > pub . EnumerateFiles = FSSTDIO_EnumerateFiles ;
np - > pub . OpenVFS = FSSTDIO_OpenVFS ;
np - > pub . PollChanges = FSSTDIO_PollChanges ;
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
np - > pub . FileStat = FSSTDIO_FileStat ;
2019-05-23 15:11:32 +00:00
np - > pub . CreateFile = FSSTDIO_CreateLoc ;
2020-04-19 01:23:32 +00:00
np - > pub . RenameFile = FSSTDIO_RenameFile ;
np - > pub . RemoveFile = FSSTDIO_RemoveFile ;
2016-07-12 00:40:13 +00:00
return & np - > pub ;
}
# endif