mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-12-24 17:55:31 +01:00
engine: prevent rescanning filesystem when new player connects or on late precache
By reusing a padding hole in resource_t structure, we put a bit indicating that this archive was already mounted by filesystem and skip it. Because we associate this with resource, theoretical use of late precache with archives will rescan filesystem and allow using newly downloaded assets.
This commit is contained in:
parent
1fc7547a53
commit
5ea2e295c1
@ -2830,19 +2830,26 @@ static void CL_Physinfo_f( void )
|
||||
static qboolean CL_ShouldRescanFilesystem( void )
|
||||
{
|
||||
resource_t *res;
|
||||
qboolean retval = false;
|
||||
|
||||
for( res = cl.resourcesonhand.pNext; res && res != &cl.resourcesonhand; res = res->pNext )
|
||||
{
|
||||
if( res->type == t_generic )
|
||||
{
|
||||
const char *ext = COM_FileExtension( res->szFileName );
|
||||
// TODO: query supported archives format from fs_stdio
|
||||
// TODO: query if was already opened
|
||||
if( !Q_stricmp( ext, "wad" ) || !Q_stricmp( ext, "pk3" ) || !Q_stricmp( ext, "pak" ))
|
||||
return true;
|
||||
|
||||
if( !g_fsapi.IsArchiveExtensionSupported( ext, IAES_ONLY_REAL_ARCHIVES ))
|
||||
continue;
|
||||
|
||||
if( FBitSet( res->ucExtraFlags, RES_EXTRA_ARCHIVE_CHECKED ))
|
||||
continue;
|
||||
|
||||
SetBits( res->ucExtraFlags, RES_EXTRA_ARCHIVE_CHECKED );
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
qboolean CL_PrecacheResources( void )
|
||||
|
@ -53,6 +53,10 @@ typedef struct resourceinfo_s
|
||||
#define RES_ALWAYS (1<<5) // Download always even if available on client
|
||||
#define RES_CHECKFILE (1<<7) // Check file on client
|
||||
|
||||
// this archive was already mounted after rescan
|
||||
// only makes sense for archives and on client
|
||||
#define RES_EXTRA_ARCHIVE_CHECKED BIT( 0 )
|
||||
|
||||
typedef struct resource_s
|
||||
{
|
||||
char szFileName[64]; // File name to download/precache.
|
||||
@ -67,6 +71,7 @@ typedef struct resource_s
|
||||
// if it's a custom resource.
|
||||
|
||||
unsigned char rguc_reserved[32]; // For future expansion
|
||||
unsigned short ucExtraFlags; // fwgs extension, doesn't change the size of struct because of compiler padding
|
||||
struct resource_s *pNext; // Next in chain.
|
||||
struct resource_s *pPrev;
|
||||
} resource_t;
|
||||
|
Loading…
Reference in New Issue
Block a user