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