Improve warning for too many skin surfaces
This commit is contained in:
parent
904bbc1a8f
commit
dd73e19546
2 changed files with 24 additions and 14 deletions
|
@ -1519,6 +1519,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
|
||||||
char *text_p;
|
char *text_p;
|
||||||
char *token;
|
char *token;
|
||||||
char surfName[MAX_QPATH];
|
char surfName[MAX_QPATH];
|
||||||
|
int totalSurfaces;
|
||||||
|
|
||||||
if ( !name || !name[0] ) {
|
if ( !name || !name[0] ) {
|
||||||
ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" );
|
ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" );
|
||||||
|
@ -1569,6 +1570,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalSurfaces = 0;
|
||||||
text_p = text.c;
|
text_p = text.c;
|
||||||
while ( text_p && *text_p ) {
|
while ( text_p && *text_p ) {
|
||||||
// get surface name
|
// get surface name
|
||||||
|
@ -1592,19 +1594,22 @@ qhandle_t RE_RegisterSkin( const char *name ) {
|
||||||
// parse the shader name
|
// parse the shader name
|
||||||
token = CommaParse( &text_p );
|
token = CommaParse( &text_p );
|
||||||
|
|
||||||
if ( skin->numSurfaces >= MAX_SKIN_SURFACES ) {
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
surf = &parseSurfaces[skin->numSurfaces];
|
surf = &parseSurfaces[skin->numSurfaces];
|
||||||
Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );
|
Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );
|
||||||
surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue );
|
surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue );
|
||||||
skin->numSurfaces++;
|
skin->numSurfaces++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalSurfaces++;
|
||||||
|
}
|
||||||
|
|
||||||
ri.FS_FreeFile( text.v );
|
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
|
// never let a skin have 0 shaders
|
||||||
if ( skin->numSurfaces == 0 ) {
|
if ( skin->numSurfaces == 0 ) {
|
||||||
|
|
|
@ -3071,6 +3071,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
|
||||||
char *text_p;
|
char *text_p;
|
||||||
char *token;
|
char *token;
|
||||||
char surfName[MAX_QPATH];
|
char surfName[MAX_QPATH];
|
||||||
|
int totalSurfaces;
|
||||||
|
|
||||||
if ( !name || !name[0] ) {
|
if ( !name || !name[0] ) {
|
||||||
ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" );
|
ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" );
|
||||||
|
@ -3121,6 +3122,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalSurfaces = 0;
|
||||||
text_p = text.c;
|
text_p = text.c;
|
||||||
while ( text_p && *text_p ) {
|
while ( text_p && *text_p ) {
|
||||||
// get surface name
|
// get surface name
|
||||||
|
@ -3144,19 +3146,22 @@ qhandle_t RE_RegisterSkin( const char *name ) {
|
||||||
// parse the shader name
|
// parse the shader name
|
||||||
token = CommaParse( &text_p );
|
token = CommaParse( &text_p );
|
||||||
|
|
||||||
if ( skin->numSurfaces >= MAX_SKIN_SURFACES ) {
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
surf = &parseSurfaces[skin->numSurfaces];
|
surf = &parseSurfaces[skin->numSurfaces];
|
||||||
Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );
|
Q_strncpyz( surf->name, surfName, sizeof( surf->name ) );
|
||||||
surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue );
|
surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue );
|
||||||
skin->numSurfaces++;
|
skin->numSurfaces++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalSurfaces++;
|
||||||
|
}
|
||||||
|
|
||||||
ri.FS_FreeFile( text.v );
|
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
|
// never let a skin have 0 shaders
|
||||||
if ( skin->numSurfaces == 0 ) {
|
if ( skin->numSurfaces == 0 ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue