Browse Source

ref: gl: simplify strings operations.

pull/2/head
Andrey Akhmichin 2 years ago committed by Alibek Omarov
parent
commit
7555fefc18
  1. 18
      ref/gl/gl_image.c
  2. 5
      ref/gl/gl_rmisc.c

18
ref/gl/gl_image.c

@ -1570,6 +1570,8 @@ int GL_LoadTextureArray( const char **names, int flags ) @@ -1570,6 +1570,8 @@ int GL_LoadTextureArray( const char **names, int flags )
uint picFlags = 0;
char name[256];
gl_texture_t *tex;
size_t len = 0;
int ret = 0;
uint i, j;
if( !names || !names[0] || !glw_state.initialized )
@ -1583,14 +1585,22 @@ int GL_LoadTextureArray( const char **names, int flags ) @@ -1583,14 +1585,22 @@ int GL_LoadTextureArray( const char **names, int flags )
if( numLayers <= 0 ) return 0;
// create complexname from layer names
for( i = 0; i < numLayers; i++ )
for( i = 0; i < numLayers - 1; i++ )
{
COM_FileBase( names[i], basename );
Q_strncat( name, basename, sizeof( name ) );
if( i != ( numLayers - 1 )) Q_strncat( name, "|", sizeof( name ));
ret = Q_snprintf( &name[len], sizeof( name ) - len, "%s|", basename );
if( ret == -1 )
return 0;
len += ret;
}
COM_FileBase( names[i], basename );
ret = Q_snprintf( &name[len], sizeof( name ) - len, "%s[%i]", basename, numLayers );
Q_strncat( name, va( "[%i]", numLayers ), sizeof( name ));
if( ret == -1 )
return 0;
if( !GL_CheckTexName( name ))
return 0;

5
ref/gl/gl_rmisc.c

@ -46,14 +46,13 @@ static void R_ParseDetailTextures( const char *filename ) @@ -46,14 +46,13 @@ static void R_ParseDetailTextures( const char *filename )
// NOTE: COM_ParseFile handled some symbols seperately
// this code will be fix it
pfile = COM_ParseFile( pfile, token, sizeof( token ));
Q_strncat( texname, "{", sizeof( texname ));
Q_strncat( texname, token, sizeof( texname ));
Q_snprintf( texname, sizeof( texname ), "{%s", token );
}
else Q_strncpy( texname, token, sizeof( texname ));
// read detailtexture name
pfile = COM_ParseFile( pfile, token, sizeof( token ));
Q_strncat( detail_texname, token, sizeof( detail_texname ));
Q_strncpy( detail_texname, token, sizeof( detail_texname ));
// trying the scales or '{'
pfile = COM_ParseFile( pfile, token, sizeof( token ));

Loading…
Cancel
Save