diff --git a/tools/quake3/common/stringfixedsize.h b/tools/quake3/common/stringfixedsize.h index b69de45c..3b4e2bf2 100644 --- a/tools/quake3/common/stringfixedsize.h +++ b/tools/quake3/common/stringfixedsize.h @@ -52,8 +52,14 @@ public: } StringFixedSize& operator=( const char* string ){ + return (*this)( string ); + } + + template + StringFixedSize& operator()( const Args& ... args ){ clear(); - write( string, strlen( string ) ); + using expander = int[]; + (void)expander{ 0, ( (void)( *this << args ), 0 ) ... }; return *this; } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 2e7bd5e7..09ba928c 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -765,7 +765,7 @@ typedef struct shaderInfo_s float vertexScale; /* vertex light scale */ - char skyParmsImageBase[ MAX_QPATH ]; /* ydnar: for skies */ + String64 skyParmsImageBase; /* ydnar: for skies */ char editorImagePath[ MAX_QPATH ]; /* use this image to generate texture coordinates */ char lightImagePath[ MAX_QPATH ]; /* use this image to generate color / averageColor */ @@ -1700,7 +1700,7 @@ void AddEntitySurfaceModels( entity_t *e ); mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, winding_t *w ); mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh ); mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec3_t normal, vec3_t color, const char *flareShader, int lightStyle ); -mapDrawSurface_t *DrawSurfaceForShader( char *shader ); +mapDrawSurface_t *DrawSurfaceForShader( const char *shader ); void ClipSidesIntoTree( entity_t *e, tree_t *tree ); void MakeDebugPortalSurfs( tree_t *tree ); void MakeFogHullSurfs( entity_t *e, tree_t *tree, char *shader ); diff --git a/tools/quake3/q3map2/shaders.cpp b/tools/quake3/q3map2/shaders.cpp index 51c42e61..96f35fb5 100644 --- a/tools/quake3/q3map2/shaders.cpp +++ b/tools/quake3/q3map2/shaders.cpp @@ -1240,11 +1240,11 @@ static void ParseShaderFile( const char *filename ){ /* ignore bogus paths */ if ( !strEqual( token, "-" ) && !striEqual( token, "full" ) ) { - strcpy( si->skyParmsImageBase, token ); + si->skyParmsImageBase = token; /* use top image as sky light image */ if ( strEmpty( si->lightImagePath ) ) { - sprintf( si->lightImagePath, "%s_up.tga", si->skyParmsImageBase ); + sprintf( si->lightImagePath, "%s_up.tga", si->skyParmsImageBase.c_str() ); } } diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index a0025924..7ad8c0b8 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -882,7 +882,6 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin bool indexed; byte shaderIndexes[ 256 ]; float offsets[ 256 ]; - char tempShader[ MAX_QPATH ]; /* ydnar: don't make a drawsurf for culled sides */ @@ -922,18 +921,8 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin /* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */ if ( skyFixHack && !strEmpty( si->skyParmsImageBase ) ) { //% Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase ); - sprintf( tempShader, "%s_lf", si->skyParmsImageBase ); - DrawSurfaceForShader( tempShader ); - sprintf( tempShader, "%s_rt", si->skyParmsImageBase ); - DrawSurfaceForShader( tempShader ); - sprintf( tempShader, "%s_ft", si->skyParmsImageBase ); - DrawSurfaceForShader( tempShader ); - sprintf( tempShader, "%s_bk", si->skyParmsImageBase ); - DrawSurfaceForShader( tempShader ); - sprintf( tempShader, "%s_up", si->skyParmsImageBase ); - DrawSurfaceForShader( tempShader ); - sprintf( tempShader, "%s_dn", si->skyParmsImageBase ); - DrawSurfaceForShader( tempShader ); + for( const auto suffix : { "_lf", "_rt", "_ft", "_bk", "_up", "_dn" } ) + DrawSurfaceForShader( String64()( si->skyParmsImageBase, suffix ) ); } /* ydnar: gs mods */ @@ -1284,7 +1273,7 @@ mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec3_t normal, creates a bogus surface to forcing the game to load a shader */ -mapDrawSurface_t *DrawSurfaceForShader( char *shader ){ +mapDrawSurface_t *DrawSurfaceForShader( const char *shader ){ int i; shaderInfo_t *si; mapDrawSurface_t *ds;