mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-23 05:14:15 +00:00
ref: gl: simplify strings operations.
This commit is contained in:
parent
f4fb8b4ac2
commit
7555fefc18
@ -1570,6 +1570,8 @@ int GL_LoadTextureArray( const char **names, int flags )
|
|||||||
uint picFlags = 0;
|
uint picFlags = 0;
|
||||||
char name[256];
|
char name[256];
|
||||||
gl_texture_t *tex;
|
gl_texture_t *tex;
|
||||||
|
size_t len = 0;
|
||||||
|
int ret = 0;
|
||||||
uint i, j;
|
uint i, j;
|
||||||
|
|
||||||
if( !names || !names[0] || !glw_state.initialized )
|
if( !names || !names[0] || !glw_state.initialized )
|
||||||
@ -1583,14 +1585,22 @@ int GL_LoadTextureArray( const char **names, int flags )
|
|||||||
if( numLayers <= 0 ) return 0;
|
if( numLayers <= 0 ) return 0;
|
||||||
|
|
||||||
// create complexname from layer names
|
// create complexname from layer names
|
||||||
for( i = 0; i < numLayers; i++ )
|
for( i = 0; i < numLayers - 1; i++ )
|
||||||
{
|
{
|
||||||
COM_FileBase( names[i], basename );
|
COM_FileBase( names[i], basename );
|
||||||
Q_strncat( name, basename, sizeof( name ) );
|
ret = Q_snprintf( &name[len], sizeof( name ) - len, "%s|", basename );
|
||||||
if( i != ( numLayers - 1 )) Q_strncat( name, "|", sizeof( name ));
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_strncat( name, va( "[%i]", numLayers ), sizeof( name ));
|
if( ret == -1 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
len += ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
COM_FileBase( names[i], basename );
|
||||||
|
ret = Q_snprintf( &name[len], sizeof( name ) - len, "%s[%i]", basename, numLayers );
|
||||||
|
|
||||||
|
if( ret == -1 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
if( !GL_CheckTexName( name ))
|
if( !GL_CheckTexName( name ))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -46,14 +46,13 @@ static void R_ParseDetailTextures( const char *filename )
|
|||||||
// NOTE: COM_ParseFile handled some symbols seperately
|
// NOTE: COM_ParseFile handled some symbols seperately
|
||||||
// this code will be fix it
|
// this code will be fix it
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||||
Q_strncat( texname, "{", sizeof( texname ));
|
Q_snprintf( texname, sizeof( texname ), "{%s", token );
|
||||||
Q_strncat( texname, token, sizeof( texname ));
|
|
||||||
}
|
}
|
||||||
else Q_strncpy( texname, token, sizeof( texname ));
|
else Q_strncpy( texname, token, sizeof( texname ));
|
||||||
|
|
||||||
// read detailtexture name
|
// read detailtexture name
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
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 '{'
|
// trying the scales or '{'
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user