use String64 for shaderInfo_s::skyParmsImageBase

add variadic template operator to StringFixedSize for inline strings creation
This commit is contained in:
Garux 2021-01-19 17:21:54 +03:00
parent da3b05728c
commit 9590d602d3
4 changed files with 14 additions and 19 deletions

View File

@ -52,8 +52,14 @@ public:
}
StringFixedSize& operator=( const char* string ){
return (*this)( string );
}
template<typename ... Args>
StringFixedSize& operator()( const Args& ... args ){
clear();
write( string, strlen( string ) );
using expander = int[];
(void)expander{ 0, ( (void)( *this << args ), 0 ) ... };
return *this;
}

View File

@ -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 );

View File

@ -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() );
}
}

View File

@ -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;