Browse Source

ref_gl: simplified strings operations.

pull/2/head
Andrey Akhmichin 4 years ago committed by Alibek Omarov
parent
commit
5f54582692
  1. 10
      ref_gl/gl_image.c
  2. 8
      ref_gl/gl_warp.c

10
ref_gl/gl_image.c

@ -1299,13 +1299,17 @@ GL_CheckTexName @@ -1299,13 +1299,17 @@ GL_CheckTexName
*/
qboolean GL_CheckTexName( const char *name )
{
int len;
if( !COM_CheckString( name ))
return false;
len = Q_strlen( name );
// because multi-layered textures can exceed name string
if( Q_strlen( name ) >= sizeof( gl_textures->name ))
if( len >= sizeof( gl_textures->name ))
{
gEngfuncs.Con_Printf( S_ERROR "LoadTexture: too long name %s (%d)\n", name, Q_strlen( name ));
gEngfuncs.Con_Printf( S_ERROR "LoadTexture: too long name %s (%d)\n", name, len );
return false;
}
@ -1529,7 +1533,7 @@ int GL_LoadTextureArray( const char **names, int flags ) @@ -1529,7 +1533,7 @@ int GL_LoadTextureArray( const char **names, int flags )
for( i = 0; i < numLayers; i++ )
{
COM_FileBase( names[i], basename );
Q_strncat( name, va( "%s", basename ), sizeof( name ));
Q_strncat( name, basename, sizeof( name ) );
if( i != ( numLayers - 1 )) Q_strncat( name, "|", sizeof( name ));
}

8
ref_gl/gl_warp.c

@ -412,7 +412,7 @@ void R_SetupSky( const char *skyboxname ) @@ -412,7 +412,7 @@ void R_SetupSky( const char *skyboxname )
{
char loadname[MAX_STRING];
char sidename[MAX_STRING];
int i, result;
int i, result, len;
if( !COM_CheckString( skyboxname ))
{
@ -424,8 +424,10 @@ void R_SetupSky( const char *skyboxname ) @@ -424,8 +424,10 @@ void R_SetupSky( const char *skyboxname )
COM_StripExtension( loadname );
// kill the underline suffix to find them manually later
if( loadname[Q_strlen( loadname ) - 1] == '_' )
loadname[Q_strlen( loadname ) - 1] = '\0';
len = Q_strlen( loadname );
if( loadname[len - 1] == '_' )
loadname[len - 1] = '\0';
result = CheckSkybox( loadname );
// to prevent infinite recursion if default skybox was missed

Loading…
Cancel
Save