From 4dffc52c1dac517073123e29d19cc7c4b9452541 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 2 Jul 2017 16:57:49 -0500 Subject: [PATCH] Add warnings for animMap and videoMap shader keywords --- code/renderergl1/tr_shader.c | 10 ++++++++++ code/renderergl2/tr_shader.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/code/renderergl1/tr_shader.c b/code/renderergl1/tr_shader.c index c931326f..c1d9628b 100644 --- a/code/renderergl1/tr_shader.c +++ b/code/renderergl1/tr_shader.c @@ -687,6 +687,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) // else if ( !Q_stricmp( token, "animMap" ) ) { + int totalImages = 0; + token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { @@ -721,6 +723,12 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } stage->bundle[0].numImageAnimations++; } + totalImages++; + } + + if ( totalImages > MAX_IMAGE_ANIMATIONS ) { + ri.Printf( PRINT_WARNING, "WARNING: ignoring excess images for 'animMap' (found %d, max is %d) in shader '%s'\n", + totalImages, MAX_IMAGE_ANIMATIONS, shader.name ); } } else if ( !Q_stricmp( token, "videoMap" ) ) @@ -735,6 +743,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) if (stage->bundle[0].videoMapHandle != -1) { stage->bundle[0].isVideoMap = qtrue; stage->bundle[0].image[0] = tr.scratchImage[stage->bundle[0].videoMapHandle]; + } else { + ri.Printf( PRINT_WARNING, "WARNING: could not load '%s' for 'videoMap' keyword in shader '%s'\n", token, shader.name ); } } // diff --git a/code/renderergl2/tr_shader.c b/code/renderergl2/tr_shader.c index 574cfb15..1df374e6 100644 --- a/code/renderergl2/tr_shader.c +++ b/code/renderergl2/tr_shader.c @@ -744,6 +744,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) // else if ( !Q_stricmp( token, "animMap" ) ) { + int totalImages = 0; + token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { @@ -778,6 +780,12 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } stage->bundle[0].numImageAnimations++; } + totalImages++; + } + + if ( totalImages > MAX_IMAGE_ANIMATIONS ) { + ri.Printf( PRINT_WARNING, "WARNING: ignoring excess images for 'animMap' (found %d, max is %d) in shader '%s'\n", + totalImages, MAX_IMAGE_ANIMATIONS, shader.name ); } } else if ( !Q_stricmp( token, "videoMap" ) ) @@ -792,6 +800,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) if (stage->bundle[0].videoMapHandle != -1) { stage->bundle[0].isVideoMap = qtrue; stage->bundle[0].image[0] = tr.scratchImage[stage->bundle[0].videoMapHandle]; + } else { + ri.Printf( PRINT_WARNING, "WARNING: could not load '%s' for 'videoMap' keyword in shader '%s'\n", token, shader.name ); } } //