fix string warnings
This commit is contained in:
parent
aa596f856d
commit
92b2487875
|
|
@ -119,6 +119,10 @@ StringOutputStream& operator()( Args&& ... args ){
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator const char*() const {
|
||||||
|
return c_str();
|
||||||
|
}
|
||||||
|
|
||||||
iterator begin(){
|
iterator begin(){
|
||||||
return m_string.begin();
|
return m_string.begin();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "miniz.h"
|
#include "miniz.h"
|
||||||
|
|
||||||
|
#include "stream/stringstream.h"
|
||||||
|
#include "stream/textstream.h"
|
||||||
|
|
||||||
struct VFS_PAKFILE
|
struct VFS_PAKFILE
|
||||||
{
|
{
|
||||||
char* unzFilePath;
|
char* unzFilePath;
|
||||||
|
|
@ -115,7 +118,7 @@ static void vfsInitPakFile( const char *filename ){
|
||||||
g_pakFiles = g_slist_append( g_pakFiles, file );
|
g_pakFiles = g_slist_append( g_pakFiles, file );
|
||||||
|
|
||||||
FixDOSName( filename_inzip );
|
FixDOSName( filename_inzip );
|
||||||
g_strdown( filename_inzip );
|
strLower( filename_inzip );
|
||||||
|
|
||||||
file->name = strdup( filename_inzip );
|
file->name = strdup( filename_inzip );
|
||||||
file->size = file_info.uncompressed_size;
|
file->size = file_info.uncompressed_size;
|
||||||
|
|
@ -206,13 +209,9 @@ void vfsInitDirectory( const char *path ){
|
||||||
|
|
||||||
// lists all .shader files
|
// lists all .shader files
|
||||||
void vfsListShaderFiles( StrList* list, void pushStringCallback( StrList* list, const char* string ) ){
|
void vfsListShaderFiles( StrList* list, void pushStringCallback( StrList* list, const char* string ) ){
|
||||||
GDir *dir;
|
|
||||||
char path[NAME_MAX];
|
|
||||||
/* search in dirs */
|
/* search in dirs */
|
||||||
for ( int i = 0; i < g_numDirs; i++ ){
|
for ( int i = 0; i < g_numDirs; i++ ){
|
||||||
snprintf( path, NAME_MAX, "%sscripts/", g_strDirs[ i ] );
|
GDir *dir = g_dir_open( StringOutputStream( 256 )( g_strDirs[ i ], "scripts/" ), 0, NULL );
|
||||||
|
|
||||||
dir = g_dir_open( path, 0, NULL );
|
|
||||||
|
|
||||||
if ( dir != NULL ) {
|
if ( dir != NULL ) {
|
||||||
const char* name;
|
const char* name;
|
||||||
|
|
@ -263,7 +262,7 @@ int vfsGetFileCount( const char *filename ){
|
||||||
|
|
||||||
strcpy( fixed, filename );
|
strcpy( fixed, filename );
|
||||||
FixDOSName( fixed );
|
FixDOSName( fixed );
|
||||||
g_strdown( fixed );
|
strLower( fixed );
|
||||||
|
|
||||||
for ( lst = g_pakFiles; lst != NULL; lst = g_slist_next( lst ) )
|
for ( lst = g_pakFiles; lst != NULL; lst = g_slist_next( lst ) )
|
||||||
{
|
{
|
||||||
|
|
@ -322,7 +321,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
|
||||||
*bufferptr = NULL;
|
*bufferptr = NULL;
|
||||||
strcpy( fixed, filename );
|
strcpy( fixed, filename );
|
||||||
FixDOSName( fixed );
|
FixDOSName( fixed );
|
||||||
g_strdown( fixed );
|
strLower( fixed );
|
||||||
|
|
||||||
for ( i = 0; i < g_numDirs; i++ )
|
for ( i = 0; i < g_numDirs; i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -407,7 +406,7 @@ bool vfsPackFile( const char *filename, const char *packname, const int compLeve
|
||||||
byte *bufferptr = NULL;
|
byte *bufferptr = NULL;
|
||||||
strcpy( fixed, filename );
|
strcpy( fixed, filename );
|
||||||
FixDOSName( fixed );
|
FixDOSName( fixed );
|
||||||
g_strdown( fixed );
|
strLower( fixed );
|
||||||
|
|
||||||
for ( i = 0; i < g_numDirs; i++ )
|
for ( i = 0; i < g_numDirs; i++ )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -273,10 +273,11 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
ParseEntities();
|
ParseEntities();
|
||||||
|
|
||||||
|
|
||||||
char nameOFmap[ 1024 ], str[ 1024 ];
|
char str[ 1024 ];
|
||||||
|
StringOutputStream stream( 256 );
|
||||||
|
|
||||||
/* extract map name */
|
/* extract map name */
|
||||||
ExtractFileBase( source, nameOFmap );
|
const CopiedString nameOFmap( PathFilename( source ) );
|
||||||
|
|
||||||
bool drawsurfSHs[numBSPShaders];
|
bool drawsurfSHs[numBSPShaders];
|
||||||
memset( drawsurfSHs, 0, sizeof( drawsurfSHs ) );
|
memset( drawsurfSHs, 0, sizeof( drawsurfSHs ) );
|
||||||
|
|
@ -303,8 +304,8 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
for ( const auto& ep : entities[0].epairs )
|
for ( const auto& ep : entities[0].epairs )
|
||||||
{
|
{
|
||||||
if ( striEqualPrefix( ep.key.c_str(), "vertexremapshader" ) ) {
|
if ( striEqualPrefix( ep.key.c_str(), "vertexremapshader" ) ) {
|
||||||
sscanf( ep.value.c_str(), "%*[^;] %*[;] %s", str ); // textures/remap/from;textures/remap/to
|
if( 1 == sscanf( ep.value.c_str(), "%*[^;] %*[;] %s", str ) ) // textures/remap/from;textures/remap/to
|
||||||
res2list( pk3Shaders, str );
|
res2list( pk3Shaders, str );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,8 +344,7 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
}
|
}
|
||||||
|
|
||||||
//levelshot
|
//levelshot
|
||||||
sprintf( str, "levelshots/%s", nameOFmap );
|
res2list( pk3Shaders, stream( "levelshots/", nameOFmap.c_str() ) );
|
||||||
res2list( pk3Shaders, str );
|
|
||||||
|
|
||||||
|
|
||||||
if( dbg ){
|
if( dbg ){
|
||||||
|
|
@ -380,8 +380,7 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
char* ExReasonShaderFile[4096] = { NULL };
|
char* ExReasonShaderFile[4096] = { NULL };
|
||||||
|
|
||||||
{
|
{
|
||||||
sprintf( str, "%s%s", game->arg, ".exclude" );
|
parseEXfile( stream( game->arg, ".exclude" ), ExTextures, ExShaders, ExShaderfiles, ExSounds, ExVideos );
|
||||||
parseEXfile( str, ExTextures, ExShaders, ExShaderfiles, ExSounds, ExVideos );
|
|
||||||
|
|
||||||
for ( i = 0; i < ExTextures->n; ++i ){
|
for ( i = 0; i < ExTextures->n; ++i ){
|
||||||
if( !StrList_find( ExShaders, ExTextures->s[i] ) )
|
if( !StrList_find( ExShaders, ExTextures->s[i] ) )
|
||||||
|
|
@ -579,8 +578,7 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
GetToken( false );
|
GetToken( false );
|
||||||
FixDOSName( token );
|
FixDOSName( token );
|
||||||
if ( strchr( token, '/' ) == NULL ){
|
if ( strchr( token, '/' ) == NULL ){
|
||||||
sprintf( str, "video/%s", token );
|
strcpy( token, stream( "video/", token ) );
|
||||||
strcpy( token, str );
|
|
||||||
}
|
}
|
||||||
if( !StrList_find( pk3Videos, token ) &&
|
if( !StrList_find( pk3Videos, token ) &&
|
||||||
!StrList_find( ExVideos, token ) )
|
!StrList_find( ExVideos, token ) )
|
||||||
|
|
@ -686,10 +684,9 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make a pack */
|
/* make a pack */
|
||||||
char packname[ 1024 ], packFailName[ 1024 ];
|
auto packname = StringOutputStream( 256 )( EnginePath, "/", nameOFmap.c_str(), "_autopacked.pk3" );
|
||||||
sprintf( packname, "%s/%s_autopacked.pk3", EnginePath, nameOFmap );
|
|
||||||
remove( packname );
|
remove( packname );
|
||||||
sprintf( packFailName, "%s/%s_FAILEDpack.pk3", EnginePath, nameOFmap );
|
auto packFailName = StringOutputStream( 256 )( EnginePath, "/", nameOFmap.c_str(), "_FAILEDpack.pk3" );
|
||||||
remove( packFailName );
|
remove( packFailName );
|
||||||
|
|
||||||
Sys_Printf( "\n--- ZipZip ---\n" );
|
Sys_Printf( "\n--- ZipZip ---\n" );
|
||||||
|
|
@ -723,8 +720,8 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
|
|
||||||
for ( i = 0; i < pk3Shaderfiles->n; ++i ){
|
for ( i = 0; i < pk3Shaderfiles->n; ++i ){
|
||||||
if ( !strEmpty( pk3Shaderfiles->s[i] ) ){
|
if ( !strEmpty( pk3Shaderfiles->s[i] ) ){
|
||||||
sprintf( str, "%s/%s", game->shaderPath, pk3Shaderfiles->s[i] );
|
stream( game->shaderPath, "/", pk3Shaderfiles->s[i] );
|
||||||
if ( !packResource( str, packname, compLevel ) ){
|
if ( !packResource( stream, packname, compLevel ) ){
|
||||||
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Shaders->s[i] );
|
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Shaders->s[i] );
|
||||||
packFAIL = true;
|
packFAIL = true;
|
||||||
}
|
}
|
||||||
|
|
@ -753,34 +750,34 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
|
|
||||||
Sys_Printf( "\n\t.bsp and stuff\n" );
|
Sys_Printf( "\n\t.bsp and stuff\n" );
|
||||||
|
|
||||||
sprintf( str, "maps/%s.bsp", nameOFmap );
|
stream( "maps/", nameOFmap.c_str(), ".bsp" );
|
||||||
//if ( vfsPackFile( str, packname, compLevel ) ){
|
//if ( vfsPackFile( stream, packname, compLevel ) ){
|
||||||
if ( vfsPackFile_Absolute_Path( source, str, packname, compLevel ) ){
|
if ( vfsPackFile_Absolute_Path( source, stream, packname, compLevel ) ){
|
||||||
Sys_Printf( "++%s\n", str );
|
Sys_Printf( "++%s\n", stream.c_str() );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", str );
|
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", stream.c_str() );
|
||||||
packFAIL = true;
|
packFAIL = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf( str, "maps/%s.aas", nameOFmap );
|
stream( "maps/", nameOFmap.c_str(), ".aas" );
|
||||||
if ( !packResource( str, packname, compLevel ) )
|
if ( !packResource( stream, packname, compLevel ) )
|
||||||
Sys_Printf( " ~fail %s\n", str );
|
Sys_Printf( " ~fail %s\n", stream.c_str() );
|
||||||
|
|
||||||
sprintf( str, "scripts/%s.arena", nameOFmap );
|
stream( "scripts/", nameOFmap.c_str(), ".arena" );
|
||||||
if ( !packResource( str, packname, compLevel ) )
|
if ( !packResource( stream, packname, compLevel ) )
|
||||||
Sys_Printf( " ~fail %s\n", str );
|
Sys_Printf( " ~fail %s\n", stream.c_str() );
|
||||||
|
|
||||||
sprintf( str, "scripts/%s.defi", nameOFmap );
|
stream( "scripts/", nameOFmap.c_str(), ".defi" );
|
||||||
if ( !packResource( str, packname, compLevel ) )
|
if ( !packResource( stream, packname, compLevel ) )
|
||||||
Sys_Printf( " ~fail %s\n", str );
|
Sys_Printf( " ~fail %s\n", stream.c_str() );
|
||||||
|
|
||||||
if ( !packFAIL ){
|
if ( !packFAIL ){
|
||||||
Sys_Printf( "\nSaved to %s\n", packname );
|
Sys_Printf( "\nSaved to %s\n", packname.c_str() );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
rename( packname, packFailName );
|
rename( packname, packFailName );
|
||||||
Sys_Printf( "\nSaved to %s\n", packFailName );
|
Sys_Printf( "\nSaved to %s\n", packFailName.c_str() );
|
||||||
}
|
}
|
||||||
/* return to sender */
|
/* return to sender */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -797,7 +794,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
int i, j, compLevel = 0;
|
int i, j, compLevel = 0;
|
||||||
bool dbg = false, png = false, analyze = false;
|
bool dbg = false, png = false, analyze = false;
|
||||||
char str[ 1024 ];
|
char str[ 1024 ];
|
||||||
|
StringOutputStream stream( 256 );
|
||||||
/* process arguments */
|
/* process arguments */
|
||||||
for ( i = 1; i < ( argc - 1 ); ++i ){
|
for ( i = 1; i < ( argc - 1 ); ++i ){
|
||||||
if ( strEqual( argv[ i ], "-dbg" ) ) {
|
if ( strEqual( argv[ i ], "-dbg" ) ) {
|
||||||
|
|
@ -827,8 +824,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
StrList* ExPureTextures = StrList_allocate( 4096 );
|
StrList* ExPureTextures = StrList_allocate( 4096 );
|
||||||
|
|
||||||
{
|
{
|
||||||
sprintf( str, "%s%s", game->arg, ".exclude" );
|
parseEXfile( stream( game->arg, ".exclude" ), ExTextures, ExShaders, ExShaderfiles, ExSounds, ExVideos );
|
||||||
parseEXfile( str, ExTextures, ExShaders, ExShaderfiles, ExSounds, ExVideos );
|
|
||||||
|
|
||||||
for ( i = 0; i < ExTextures->n; ++i ){
|
for ( i = 0; i < ExTextures->n; ++i ){
|
||||||
if( !StrList_find( ExShaders, ExTextures->s[i] ) )
|
if( !StrList_find( ExShaders, ExTextures->s[i] ) )
|
||||||
|
|
@ -927,8 +923,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract input file name */
|
/* extract input file name */
|
||||||
char nameOFrepack[ 1024 ];
|
const CopiedString nameOFrepack( PathFilename( source ) );
|
||||||
ExtractFileBase( source, nameOFrepack );
|
|
||||||
|
|
||||||
/* load bsps */
|
/* load bsps */
|
||||||
StrList* pk3Shaders = StrList_allocate( 65536 );
|
StrList* pk3Shaders = StrList_allocate( 65536 );
|
||||||
|
|
@ -957,8 +952,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
ParseEntities();
|
ParseEntities();
|
||||||
|
|
||||||
/* extract map name */
|
/* extract map name */
|
||||||
char nameOFmap[ 1024 ];
|
const CopiedString nameOFmap( PathFilename( source ) );
|
||||||
ExtractFileBase( source, nameOFmap );
|
|
||||||
|
|
||||||
bool drawsurfSHs[numBSPShaders];
|
bool drawsurfSHs[numBSPShaders];
|
||||||
memset( drawsurfSHs, 0, sizeof( drawsurfSHs ) );
|
memset( drawsurfSHs, 0, sizeof( drawsurfSHs ) );
|
||||||
|
|
@ -977,8 +971,8 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
for ( const auto& ep : entities[0].epairs )
|
for ( const auto& ep : entities[0].epairs )
|
||||||
{
|
{
|
||||||
if ( striEqualPrefix( ep.key.c_str(), "vertexremapshader" ) ) {
|
if ( striEqualPrefix( ep.key.c_str(), "vertexremapshader" ) ) {
|
||||||
sscanf( ep.value.c_str(), "%*[^;] %*[;] %s", str ); // textures/remap/from;textures/remap/to
|
if( 1 == sscanf( ep.value.c_str(), "%*[^;] %*[;] %s", str ) ) // textures/remap/from;textures/remap/to
|
||||||
res2list( pk3Shaders, str );
|
res2list( pk3Shaders, str );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( entities[ 0 ].read_keyvalue( str, "music" ) ){
|
if ( entities[ 0 ].read_keyvalue( str, "music" ) ){
|
||||||
|
|
@ -1016,8 +1010,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
}
|
}
|
||||||
|
|
||||||
//levelshot
|
//levelshot
|
||||||
sprintf( str, "levelshots/%s", nameOFmap );
|
res2list( pk3Shaders, stream( "levelshots/", nameOFmap.c_str() ) );
|
||||||
res2list( pk3Shaders, str );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1300,8 +1293,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
StrBuf_cat2( shaderText, " ", token );
|
StrBuf_cat2( shaderText, " ", token );
|
||||||
FixDOSName( token );
|
FixDOSName( token );
|
||||||
if ( strchr( token, '/' ) == NULL ){
|
if ( strchr( token, '/' ) == NULL ){
|
||||||
sprintf( str, "video/%s", token );
|
strcpy( token, stream( "video/", token ) );
|
||||||
strcpy( token, str );
|
|
||||||
}
|
}
|
||||||
if( !StrList_find( pk3Videos, token ) &&
|
if( !StrList_find( pk3Videos, token ) &&
|
||||||
!StrList_find( ExVideos, token ) &&
|
!StrList_find( ExVideos, token ) &&
|
||||||
|
|
@ -1435,24 +1427,22 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write shader */
|
/* write shader */
|
||||||
sprintf( str, "%s/%s_strippedBYrepacker.shader", EnginePath, nameOFrepack );
|
stream( EnginePath, "/", nameOFrepack.c_str(), "_strippedBYrepacker.shader" );
|
||||||
FILE *f;
|
FILE *f = fopen( stream, "wb" );
|
||||||
f = fopen( str, "wb" );
|
|
||||||
fwrite( allShaders->s, sizeof( char ), allShaders->strlen, f );
|
fwrite( allShaders->s, sizeof( char ), allShaders->strlen, f );
|
||||||
fclose( f );
|
fclose( f );
|
||||||
Sys_Printf( "Shaders saved to %s\n", str );
|
Sys_Printf( "Shaders saved to %s\n", stream.c_str() );
|
||||||
|
|
||||||
/* make a pack */
|
/* make a pack */
|
||||||
char packname[ 1024 ];
|
stream( EnginePath, "/", nameOFrepack.c_str(), "_repacked.pk3" );
|
||||||
sprintf( packname, "%s/%s_repacked.pk3", EnginePath, nameOFrepack );
|
remove( stream );
|
||||||
remove( packname );
|
|
||||||
|
|
||||||
Sys_Printf( "\n--- ZipZip ---\n" );
|
Sys_Printf( "\n--- ZipZip ---\n" );
|
||||||
|
|
||||||
Sys_Printf( "\n\tShader referenced textures....\n" );
|
Sys_Printf( "\n\tShader referenced textures....\n" );
|
||||||
|
|
||||||
for ( i = 0; i < pk3Textures->n; ++i ){
|
for ( i = 0; i < pk3Textures->n; ++i ){
|
||||||
if( !packTexture( pk3Textures->s[i], packname, compLevel, png ) ){
|
if( !packTexture( pk3Textures->s[i], stream, compLevel, png ) ){
|
||||||
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Textures->s[i] );
|
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Textures->s[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1461,7 +1451,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
|
|
||||||
for ( i = 0; i < pk3Shaders->n; ++i ){
|
for ( i = 0; i < pk3Shaders->n; ++i ){
|
||||||
if ( !strEmpty( pk3Shaders->s[i] ) ){
|
if ( !strEmpty( pk3Shaders->s[i] ) ){
|
||||||
if( !packTexture( pk3Shaders->s[i], packname, compLevel, png ) ){
|
if( !packTexture( pk3Shaders->s[i], stream, compLevel, png ) ){
|
||||||
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Shaders->s[i] );
|
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Shaders->s[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1471,7 +1461,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
|
|
||||||
for ( i = 0; i < pk3Sounds->n; ++i ){
|
for ( i = 0; i < pk3Sounds->n; ++i ){
|
||||||
if ( !strEmpty( pk3Sounds->s[i] ) ){
|
if ( !strEmpty( pk3Sounds->s[i] ) ){
|
||||||
if ( !packResource( pk3Sounds->s[i], packname, compLevel ) ){
|
if ( !packResource( pk3Sounds->s[i], stream, compLevel ) ){
|
||||||
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Sounds->s[i] );
|
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Sounds->s[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1480,12 +1470,12 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
Sys_Printf( "\n\tVideos....\n" );
|
Sys_Printf( "\n\tVideos....\n" );
|
||||||
|
|
||||||
for ( i = 0; i < pk3Videos->n; ++i ){
|
for ( i = 0; i < pk3Videos->n; ++i ){
|
||||||
if ( !packResource( pk3Videos->s[i], packname, compLevel ) ){
|
if ( !packResource( pk3Videos->s[i], stream, compLevel ) ){
|
||||||
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Videos->s[i] );
|
Sys_FPrintf( SYS_WRN, " !FAIL! %s\n", pk3Videos->s[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys_Printf( "\nSaved to %s\n", packname );
|
Sys_Printf( "\nSaved to %s\n", stream.c_str() );
|
||||||
|
|
||||||
/* return to sender */
|
/* return to sender */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -36,15 +36,13 @@
|
||||||
static bool g_autocaulk = false;
|
static bool g_autocaulk = false;
|
||||||
|
|
||||||
static void autocaulk_write(){
|
static void autocaulk_write(){
|
||||||
char filename[1024];
|
|
||||||
|
|
||||||
Sys_FPrintf( SYS_VRB, "--- autocaulk_write ---\n" );
|
Sys_FPrintf( SYS_VRB, "--- autocaulk_write ---\n" );
|
||||||
sprintf( filename, "%s.caulk", source );
|
auto filename = StringOutputStream( 256 )( source, ".caulk" );
|
||||||
Sys_Printf( "writing %s\n", filename );
|
Sys_Printf( "writing %s\n", filename.c_str() );
|
||||||
|
|
||||||
FILE* file = fopen( filename, "w" );
|
FILE* file = fopen( filename, "w" );
|
||||||
if ( !file ) {
|
if ( !file ) {
|
||||||
Error( "Error opening %s", filename );
|
Error( "Error opening %s", filename.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
int fslime = 16;
|
int fslime = 16;
|
||||||
|
|
@ -644,14 +642,12 @@ void ProcessModels( void ){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void OnlyEnts( void ){
|
void OnlyEnts( void ){
|
||||||
char out[ 1024 ];
|
|
||||||
|
|
||||||
char save_cmdline[1024], save_version[1024], save_gridsize[1024];
|
char save_cmdline[1024], save_version[1024], save_gridsize[1024];
|
||||||
|
|
||||||
/* note it */
|
/* note it */
|
||||||
Sys_Printf( "--- OnlyEnts ---\n" );
|
Sys_Printf( "--- OnlyEnts ---\n" );
|
||||||
|
|
||||||
sprintf( out, "%s.bsp", source );
|
auto out = StringOutputStream( 256 )( source, ".bsp" );
|
||||||
LoadBSPFile( out );
|
LoadBSPFile( out );
|
||||||
|
|
||||||
ParseEntities();
|
ParseEntities();
|
||||||
|
|
@ -691,7 +687,7 @@ void OnlyEnts( void ){
|
||||||
|
|
||||||
int BSPMain( int argc, char **argv ){
|
int BSPMain( int argc, char **argv ){
|
||||||
int i;
|
int i;
|
||||||
char path[ 1024 ], tempSource[ 1024 ];
|
char tempSource[ 1024 ];
|
||||||
bool onlyents = false;
|
bool onlyents = false;
|
||||||
|
|
||||||
if ( argc >= 2 && strEqual( argv[ 1 ], "-bsp" ) ) {
|
if ( argc >= 2 && strEqual( argv[ 1 ], "-bsp" ) ) {
|
||||||
|
|
@ -1006,19 +1002,15 @@ int BSPMain( int argc, char **argv ){
|
||||||
SetDefaultSampleSize( sampleSize );
|
SetDefaultSampleSize( sampleSize );
|
||||||
|
|
||||||
/* delete portal, line and surface files */
|
/* delete portal, line and surface files */
|
||||||
sprintf( path, "%s.prt", source );
|
remove( StringOutputStream( 256 )( source, ".prt" ) );
|
||||||
remove( path );
|
remove( StringOutputStream( 256 )( source, ".lin" ) );
|
||||||
sprintf( path, "%s.lin", source );
|
//% remove( StringOutputStream( 256 )( source, ".srf" ) ); /* ydnar */
|
||||||
remove( path );
|
|
||||||
//% sprintf( path, "%s.srf", source ); /* ydnar */
|
|
||||||
//% remove( path );
|
|
||||||
|
|
||||||
/* expand mapname */
|
/* expand mapname */
|
||||||
strcpy( name, ExpandArg( argv[ i ] ) );
|
strcpy( name, ExpandArg( argv[ i ] ) );
|
||||||
if ( !striEqual( path_get_filename_base_end( name ), ".reg" ) ) { /* not .reg */
|
if ( !striEqual( path_get_filename_base_end( name ), ".reg" ) ) { /* not .reg */
|
||||||
/* if we are doing a full map, delete the last saved region map */
|
/* if we are doing a full map, delete the last saved region map */
|
||||||
sprintf( path, "%s.reg", source );
|
remove( StringOutputStream( 256 )( source, ".reg" ) );
|
||||||
remove( path );
|
|
||||||
if ( !onlyents || !striEqual( path_get_filename_base_end( name ), ".ent" ) ) {
|
if ( !onlyents || !striEqual( path_get_filename_base_end( name ), ".ent" ) ) {
|
||||||
path_set_extension( name, ".map" ); /* .reg and .ent are ok too */
|
path_set_extension( name, ".map" ); /* .reg and .ent are ok too */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@
|
||||||
xmlNodePtr LeakFile( tree_t *tree ){
|
xmlNodePtr LeakFile( tree_t *tree ){
|
||||||
vec3_t mid;
|
vec3_t mid;
|
||||||
FILE *linefile;
|
FILE *linefile;
|
||||||
char filename[1024];
|
|
||||||
node_t *node;
|
node_t *node;
|
||||||
int count;
|
int count;
|
||||||
xmlNodePtr xml_node, point;
|
xmlNodePtr xml_node, point;
|
||||||
|
|
@ -71,10 +70,10 @@ xmlNodePtr LeakFile( tree_t *tree ){
|
||||||
//
|
//
|
||||||
// write the points to the file
|
// write the points to the file
|
||||||
//
|
//
|
||||||
sprintf( filename, "%s.lin", source );
|
auto filename = StringOutputStream( 256 )( source, ".lin" );
|
||||||
linefile = fopen( filename, "w" );
|
linefile = fopen( filename, "w" );
|
||||||
if ( !linefile ) {
|
if ( !linefile ) {
|
||||||
Error( "Couldn't open %s\n", filename );
|
Error( "Couldn't open %s\n", filename.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_node = xmlNewNode( NULL, (const xmlChar*)"polyline" );
|
xml_node = xmlNewNode( NULL, (const xmlChar*)"polyline" );
|
||||||
|
|
|
||||||
|
|
@ -239,11 +239,11 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, const
|
||||||
|
|
||||||
/* load skin file */
|
/* load skin file */
|
||||||
auto skinfilename = StringOutputStream(99)( PathExtensionless( name ), '_', skin, ".skin" );
|
auto skinfilename = StringOutputStream(99)( PathExtensionless( name ), '_', skin, ".skin" );
|
||||||
skinfilesize = vfsLoadFile( skinfilename.c_str(), (void**) &skinfilecontent, 0 );
|
skinfilesize = vfsLoadFile( skinfilename, (void**) &skinfilecontent, 0 );
|
||||||
if ( skinfilesize < 0 && skin != 0 ) {
|
if ( skinfilesize < 0 && skin != 0 ) {
|
||||||
/* fallback to skin 0 if invalid */
|
/* fallback to skin 0 if invalid */
|
||||||
skinfilename( PathExtensionless( name ), "_0.skin" );
|
skinfilename( PathExtensionless( name ), "_0.skin" );
|
||||||
skinfilesize = vfsLoadFile( skinfilename.c_str(), (void**) &skinfilecontent, 0 );
|
skinfilesize = vfsLoadFile( skinfilename, (void**) &skinfilecontent, 0 );
|
||||||
if ( skinfilesize >= 0 ) {
|
if ( skinfilesize >= 0 ) {
|
||||||
Sys_Printf( "Skin %d of %s does not exist, using 0 instead\n", skin, name );
|
Sys_Printf( "Skin %d of %s does not exist, using 0 instead\n", skin, name );
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +286,7 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, const
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invalid input line -> discard skin struct */
|
/* invalid input line -> discard skin struct */
|
||||||
Sys_Printf( "Discarding skin directive in %s: %s\n", skinfilename, skinfileptr );
|
Sys_Printf( "Discarding skin directive in %s: %s\n", skinfilename.c_str(), skinfileptr );
|
||||||
}
|
}
|
||||||
free( skinfilecontent );
|
free( skinfilecontent );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -367,16 +367,14 @@ void NumberClusters( tree_t *tree ) {
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void WritePortalFile( tree_t *tree ){
|
void WritePortalFile( tree_t *tree ){
|
||||||
char filename[1024];
|
|
||||||
|
|
||||||
Sys_FPrintf( SYS_VRB, "--- WritePortalFile ---\n" );
|
Sys_FPrintf( SYS_VRB, "--- WritePortalFile ---\n" );
|
||||||
|
|
||||||
// write the file
|
// write the file
|
||||||
sprintf( filename, "%s.prt", source );
|
auto filename = StringOutputStream( 256 )( source, ".prt" );
|
||||||
Sys_Printf( "writing %s\n", filename );
|
Sys_Printf( "writing %s\n", filename.c_str() );
|
||||||
pf = fopen( filename, "w" );
|
pf = fopen( filename, "w" );
|
||||||
if ( !pf ) {
|
if ( !pf ) {
|
||||||
Error( "Error opening %s", filename );
|
Error( "Error opening %s", filename.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( pf, "%s\n", PORTALFILE );
|
fprintf( pf, "%s\n", PORTALFILE );
|
||||||
|
|
|
||||||
|
|
@ -1973,7 +1973,7 @@ Q_EXTERN surfaceParm_t custSurfaceParms[ MAX_CUST_SURFACEPARMS ];
|
||||||
Q_EXTERN int numCustSurfaceParms Q_ASSIGN( 0 );
|
Q_EXTERN int numCustSurfaceParms Q_ASSIGN( 0 );
|
||||||
|
|
||||||
Q_EXTERN String64 mapName; /* ydnar: per-map custom shaders for larger lightmaps */
|
Q_EXTERN String64 mapName; /* ydnar: per-map custom shaders for larger lightmaps */
|
||||||
Q_EXTERN char mapShaderFile[ 1024 ];
|
Q_EXTERN StringOutputStream mapShaderFile;
|
||||||
Q_EXTERN bool warnImage Q_ASSIGN( true );
|
Q_EXTERN bool warnImage Q_ASSIGN( true );
|
||||||
|
|
||||||
/* ydnar: sinusoid samples */
|
/* ydnar: sinusoid samples */
|
||||||
|
|
|
||||||
|
|
@ -308,19 +308,17 @@ bool ApplySurfaceParm( const char *name, int *contentFlags, int *surfaceFlags, i
|
||||||
void BeginMapShaderFile( const char *mapFile ){
|
void BeginMapShaderFile( const char *mapFile ){
|
||||||
/* dummy check */
|
/* dummy check */
|
||||||
mapName.clear();
|
mapName.clear();
|
||||||
strClear( mapShaderFile );
|
mapShaderFile.clear();
|
||||||
if ( strEmptyOrNull( mapFile ) ) {
|
if ( strEmptyOrNull( mapFile ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract map name */
|
/* extract map name */
|
||||||
mapName( StringRange( path_get_filename_start( mapFile ), path_get_filename_base_end( mapFile) ) );
|
mapName( PathFilename( mapFile ) );
|
||||||
char path[ 1024 ];
|
|
||||||
ExtractFilePath( mapFile, path );
|
|
||||||
|
|
||||||
/* append ../scripts/q3map2_<mapname>.shader */
|
/* append ../scripts/q3map2_<mapname>.shader */
|
||||||
sprintf( mapShaderFile, "%s../%s/q3map2_%s.shader", path, game->shaderPath, mapName.c_str() );
|
mapShaderFile( PathFilenameless( mapFile ), "../", game->shaderPath, "/q3map2_", mapName.c_str(), ".shader" );
|
||||||
Sys_FPrintf( SYS_VRB, "Map has shader script %s\n", mapShaderFile );
|
Sys_FPrintf( SYS_VRB, "Map has shader script %s\n", mapShaderFile.c_str() );
|
||||||
|
|
||||||
/* remove it */
|
/* remove it */
|
||||||
remove( mapShaderFile );
|
remove( mapShaderFile );
|
||||||
|
|
@ -343,7 +341,7 @@ void WriteMapShaderFile( void ){
|
||||||
|
|
||||||
|
|
||||||
/* dummy check */
|
/* dummy check */
|
||||||
if ( strEmpty( mapShaderFile ) ) {
|
if ( mapShaderFile.empty() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,12 +358,12 @@ void WriteMapShaderFile( void ){
|
||||||
|
|
||||||
/* note it */
|
/* note it */
|
||||||
Sys_FPrintf( SYS_VRB, "--- WriteMapShaderFile ---\n" );
|
Sys_FPrintf( SYS_VRB, "--- WriteMapShaderFile ---\n" );
|
||||||
Sys_FPrintf( SYS_VRB, "Writing %s", mapShaderFile );
|
Sys_FPrintf( SYS_VRB, "Writing %s", mapShaderFile.c_str() );
|
||||||
|
|
||||||
/* open shader file */
|
/* open shader file */
|
||||||
file = fopen( mapShaderFile, "w" );
|
file = fopen( mapShaderFile, "w" );
|
||||||
if ( file == NULL ) {
|
if ( file == NULL ) {
|
||||||
Sys_Warning( "Unable to open map shader file %s for writing\n", mapShaderFile );
|
Sys_Warning( "Unable to open map shader file %s for writing\n", mapShaderFile.c_str() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -953,7 +951,6 @@ void Parse1DMatrixAppend( char *buffer, int x, vec_t *m ){
|
||||||
static void ParseShaderFile( const char *filename ){
|
static void ParseShaderFile( const char *filename ){
|
||||||
int i, val;
|
int i, val;
|
||||||
shaderInfo_t *si;
|
shaderInfo_t *si;
|
||||||
char temp[ 1024 ];
|
|
||||||
char shaderText[ 8192 ]; /* ydnar: fixme (make this bigger?) */
|
char shaderText[ 8192 ]; /* ydnar: fixme (make this bigger?) */
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1336,7 +1333,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
/* subclass it */
|
/* subclass it */
|
||||||
if ( si2 != NULL ) {
|
if ( si2 != NULL ) {
|
||||||
/* preserve name */
|
/* preserve name */
|
||||||
strcpy( temp, si->shader );
|
const String64 temp = si->shader;
|
||||||
|
|
||||||
/* copy shader */
|
/* copy shader */
|
||||||
*si = *si2;
|
*si = *si2;
|
||||||
|
|
@ -1910,8 +1907,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
/* q3map_material (sof2) */
|
/* q3map_material (sof2) */
|
||||||
else if ( striEqual( token, "q3map_material" ) ) {
|
else if ( striEqual( token, "q3map_material" ) ) {
|
||||||
GetTokenAppend( shaderText, false );
|
GetTokenAppend( shaderText, false );
|
||||||
sprintf( temp, "*mat_%s", token );
|
if ( !ApplySurfaceParm( StringOutputStream( 64 )( "*mat_", token ), &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) ) {
|
||||||
if ( !ApplySurfaceParm( temp, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) ) {
|
|
||||||
Sys_Warning( "Unknown material \"%s\"\n", token );
|
Sys_Warning( "Unknown material \"%s\"\n", token );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -388,9 +388,6 @@ void BeginBSPFile( void ){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void EndBSPFile( bool do_write ){
|
void EndBSPFile( bool do_write ){
|
||||||
char path[ 1024 ];
|
|
||||||
|
|
||||||
|
|
||||||
Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" );
|
Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" );
|
||||||
|
|
||||||
EmitPlanes();
|
EmitPlanes();
|
||||||
|
|
@ -403,8 +400,8 @@ void EndBSPFile( bool do_write ){
|
||||||
WriteSurfaceExtraFile( source );
|
WriteSurfaceExtraFile( source );
|
||||||
|
|
||||||
/* write the bsp */
|
/* write the bsp */
|
||||||
sprintf( path, "%s.bsp", source );
|
auto path = StringOutputStream( 256 )( source, ".bsp" );
|
||||||
Sys_Printf( "Writing %s\n", path );
|
Sys_Printf( "Writing %s\n", path.c_str() );
|
||||||
WriteBSPFile( path );
|
WriteBSPFile( path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user