* packer: +warnings on implicitMaps, mapNoComps
	* packer: known problem: minizip crash, when trying to get file with 2039 year date from disk
	* -repack: repacks multiple maps, strips out only required shaders; main argument is single bsp path or txt with full pathes to bsps
		switches: -dbg: talkative mode; -png: include pngs, at highest priority; -complevel: -1..10, def 0, compression level
		uses additional exclusions file repack.exclude with different logic
This commit is contained in:
Garux 2017-08-01 13:56:25 +03:00
parent 2b85b7c20c
commit 7d7436ec3d
6 changed files with 1097 additions and 30 deletions

View File

@ -480,7 +480,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
qboolean vfsPackFile( const char *filename, const char *packname ){
qboolean vfsPackFile( const char *filename, const char *packname, const int compLevel ){
int i;
char tmp[NAME_MAX], fixed[NAME_MAX];
GSList *lst;
@ -502,7 +502,7 @@ qboolean vfsPackFile( const char *filename, const char *packname ){
mz_zip_writer_init_from_reader( &zip, packname );
mz_bool success = MZ_TRUE;
success &= mz_zip_writer_add_file( &zip, filename, tmp, 0, 0, 10 );
success &= mz_zip_writer_add_file( &zip, filename, tmp, 0, 0, compLevel );
if ( !success || !mz_zip_writer_finalize_archive( &zip ) ){
Error( "Failed creating zip archive \"%s\"!\n", packname );
}
@ -516,7 +516,7 @@ qboolean vfsPackFile( const char *filename, const char *packname ){
Error( "Failed creating zip archive \"%s\"!\n", packname );
}
mz_bool success = MZ_TRUE;
success &= mz_zip_writer_add_file( &zip, filename, tmp, 0, 0, 10 );
success &= mz_zip_writer_add_file( &zip, filename, tmp, 0, 0, compLevel );
if ( !success || !mz_zip_writer_finalize_archive( &zip ) ){
Error( "Failed creating zip archive \"%s\"!\n", packname );
}
@ -555,7 +555,7 @@ qboolean vfsPackFile( const char *filename, const char *packname ){
}
else{
mz_bool success = MZ_TRUE;
success &= mz_zip_add_mem_to_archive_file_in_place_with_time( packname, filename, bufferptr, i, 0, 0, 10, DOS_time, DOS_date );
success &= mz_zip_add_mem_to_archive_file_in_place_with_time( packname, filename, bufferptr, i, 0, 0, compLevel, DOS_time, DOS_date );
if ( !success ){
Error( "Failed creating zip archive \"%s\"!\n", packname );
}

View File

@ -52,7 +52,7 @@ void vfsShutdown();
int vfsGetFileCount( const char *filename );
int vfsLoadFile( const char *filename, void **buffer, int index );
void vfsListShaderFiles( char* list, int *num );
qboolean vfsPackFile( const char *filename, const char *packname );
qboolean vfsPackFile( const char *filename, const char *packname, const int compLevel );
extern char g_strForbiddenDirs[VFS_MAXDIRS][PATH_MAX + 1];
extern int g_numForbiddenDirs;

View File

@ -263,8 +263,6 @@ void SwapBSPFile( void ){
}
}
/*
GetLumpElements()
gets the number of elements in a bsp lump
@ -375,7 +373,37 @@ void LoadBSPFile( const char *filename ){
SwapBSPFile();
}
/*
PartialLoadBSPFile()
partially loads a bsp file into memory
for autopacker
*/
void PartialLoadBSPFile( const char *filename ){
/* dummy check */
if ( game == NULL || game->load == NULL ) {
Error( "LoadBSPFile: unsupported BSP file format" );
}
/* load it, then byte swap the in-memory version */
//game->load( filename );
PartialLoadIBSPFile( filename );
/* PartialSwapBSPFile() */
int i, j;
shaderInfo_t *si;
/* shaders (don't swap the name) */
for ( i = 0; i < numBSPShaders ; i++ )
{
bspShaders[ i ].contentFlags = LittleLong( bspShaders[ i ].contentFlags );
bspShaders[ i ].surfaceFlags = LittleLong( bspShaders[ i ].surfaceFlags );
}
/* drawsurfs */
/* note: rbsp files (and hence q3map2 abstract bsp) have byte lightstyles index arrays, this follows sof2map convention */
SwapBlock( (int*) bspDrawSurfaces, numBSPDrawSurfaces * sizeof( bspDrawSurfaces[ 0 ] ) );
}
/*
WriteBSPFile()

View File

@ -519,7 +519,39 @@ void LoadIBSPFile( const char *filename ){
free( header );
}
/*
PartialLoadIBSPFile()
loads a part of quake 3 bsp file, required by packer, into memory
*/
void PartialLoadIBSPFile( const char *filename ){
ibspHeader_t *header;
/* load the file header */
LoadFile( filename, (void**) &header );
/* swap the header (except the first 4 bytes) */
SwapBlock( (int*) ( (byte*) header + sizeof( int ) ), sizeof( *header ) - sizeof( int ) );
/* make sure it matches the format we're trying to load */
if ( force == qfalse && *( (int*) header->ident ) != *( (int*) game->bspIdent ) ) {
Error( "%s is not a %s file", filename, game->bspIdent );
}
if ( force == qfalse && header->version != game->bspVersion ) {
Error( "%s is version %d, not %d", filename, header->version, game->bspVersion );
}
/* load/convert lumps */
numBSPShaders = CopyLump_Allocate( (bspHeader_t*) header, LUMP_SHADERS, (void **) &bspShaders, sizeof( bspShader_t ), &allocatedBSPShaders );
CopyDrawSurfacesLump( header );
bspEntDataSize = CopyLump_Allocate( (bspHeader_t*) header, LUMP_ENTITIES, (void **) &bspEntData, 1, &allocatedBSPEntData );
/* free the file buffer */
free( header );
}
/*
WriteIBSPFile()

File diff suppressed because it is too large Load Diff

View File

@ -1885,6 +1885,7 @@ int CopyLump_Allocate( bspHeader_t *header, int lump, vo
void AddLump( FILE *file, bspHeader_t *header, int lumpNum, const void *data, int length );
void LoadBSPFile( const char *filename );
void PartialLoadBSPFile( const char *filename );
void WriteBSPFile( const char *filename );
void PrintBSPFileSizes( void );
@ -1907,6 +1908,8 @@ void InjectCommandLine( char **argv, int beginArgs, int endArgs );
/* bspfile_ibsp.c */
void LoadIBSPFile( const char *filename );
void WriteIBSPFile( const char *filename );
void PartialLoadIBSPFile( const char *filename );
/* bspfile_rbsp.c */