Improve warning for too many skin surfaces

This commit is contained in:
Zack Middleton 2017-07-04 15:20:45 -05:00
parent 904bbc1a8f
commit dd73e19546
2 changed files with 24 additions and 14 deletions

View file

@ -1519,6 +1519,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
char *text_p;
char *token;
char surfName[MAX_QPATH];
int totalSurfaces;
if ( !name || !name[0] ) {
ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" );
@ -1569,6 +1570,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
return 0;
}
totalSurfaces = 0;
text_p = text.c;
while ( text_p && *text_p ) {
// get surface name
@ -1592,19 +1594,22 @@ qhandle_t RE_RegisterSkin( const char *name ) {
// parse the shader name
token = CommaParse( &text_p );
if ( skin->numSurfaces >= MAX_SKIN_SURFACES ) {
ri.Printf( PRINT_WARNING, "WARNING: Ignoring surfaces in '%s', the max is %d surfaces!\n", name, MAX_SKIN_SURFACES );
break;
}
if ( skin->numSurfaces < MAX_SKIN_SURFACES ) {
surf = &parseSurfaces[skin->numSurfaces];
Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );
surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue );
skin->numSurfaces++;
}
totalSurfaces++;
}
ri.FS_FreeFile( text.v );
if ( totalSurfaces > MAX_SKIN_SURFACES ) {
ri.Printf( PRINT_WARNING, "WARNING: Ignoring excess surfaces (found %d, max is %d) in skin '%s'!\n",
totalSurfaces, MAX_SKIN_SURFACES, name );
}
// never let a skin have 0 shaders
if ( skin->numSurfaces == 0 ) {

View file

@ -3071,6 +3071,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
char *text_p;
char *token;
char surfName[MAX_QPATH];
int totalSurfaces;
if ( !name || !name[0] ) {
ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" );
@ -3121,6 +3122,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
return 0;
}
totalSurfaces = 0;
text_p = text.c;
while ( text_p && *text_p ) {
// get surface name
@ -3144,19 +3146,22 @@ qhandle_t RE_RegisterSkin( const char *name ) {
// parse the shader name
token = CommaParse( &text_p );
if ( skin->numSurfaces >= MAX_SKIN_SURFACES ) {
ri.Printf( PRINT_WARNING, "WARNING: Ignoring surfaces in '%s', the max is %d surfaces!\n", name, MAX_SKIN_SURFACES );
break;
}
if ( skin->numSurfaces < MAX_SKIN_SURFACES ) {
surf = &parseSurfaces[skin->numSurfaces];
Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );
surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue );
skin->numSurfaces++;
}
totalSurfaces++;
}
ri.FS_FreeFile( text.v );
if ( totalSurfaces > MAX_SKIN_SURFACES ) {
ri.Printf( PRINT_WARNING, "WARNING: Ignoring excess surfaces (found %d, max is %d) in skin '%s'!\n",
totalSurfaces, MAX_SKIN_SURFACES, name );
}
// never let a skin have 0 shaders
if ( skin->numSurfaces == 0 ) {