This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit acd0b9b4911fb14239f571b1a5509873120fad23
Author: m4n4t4...@gmail.com 
<m4n4t4...@gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Sun Sep 28 00:31:49 2014 +0000

    All: Add function for clearing global shader instead of duplicating the code
---
 MP/code/rend2/tr_shader.c    | 78 +++++++++++++++++++-------------------------
 MP/code/renderer/tr_shader.c | 49 ++++++++++++++--------------
 SP/code/rend2/tr_shader.c    | 76 +++++++++++++++++++-----------------------
 SP/code/renderer/tr_shader.c | 49 ++++++++++++++--------------
 4 files changed, 116 insertions(+), 136 deletions(-)

diff --git a/MP/code/rend2/tr_shader.c b/MP/code/rend2/tr_shader.c
index fc8c133..2f74f36 100644
--- a/MP/code/rend2/tr_shader.c
+++ b/MP/code/rend2/tr_shader.c
@@ -2989,6 +2989,33 @@ static void VertexLightingCollapse( void ) {
 }
 
 /*
+===============
+InitShader
+===============
+*/
+static void InitShader( const char *name, int lightmapIndex ) {
+       int i;
+
+       // clear the global shader
+       Com_Memset( &shader, 0, sizeof( shader ) );
+       Com_Memset( &stages, 0, sizeof( stages ) );
+
+       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
+       shader.lightmapIndex = lightmapIndex;
+
+       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
+               stages[i].bundle[0].texMods = texMods[i];
+
+               // default normal/specular
+               VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f);
+               stages[i].specularScale[0] =
+               stages[i].specularScale[1] =
+               stages[i].specularScale[2] = r_baseSpecular->value;
+               stages[i].specularScale[3] = r_baseGloss->value;
+       }
+}
+
+/*
 =========================
 FinishShader
 
@@ -3298,7 +3325,7 @@ most world construction surfaces.
 */
 shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean 
mipRawImage ) {
        char strippedName[MAX_QPATH];
-       int i, hash;
+       int hash;
        char        *shaderText;
        image_t     *image;
        shader_t    *sh;
@@ -3336,21 +3363,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
                }
        }
 
-       // clear the global shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, strippedName, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-
-               // default normal/specular
-               VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f);
-               stages[i].specularScale[0] = 
-               stages[i].specularScale[1] =
-               stages[i].specularScale[2] = r_baseSpecular->value;
-               stages[i].specularScale[3] = r_baseGloss->value;
-       }
+       InitShader( strippedName, lightmapIndex );
 
        //
        // attempt to define shader from an explicit parameter file
@@ -3457,7 +3470,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
 
 
 qhandle_t RE_RegisterShaderFromImage( const char *name, int lightmapIndex, 
image_t *image, qboolean mipRawImage ) {
-       int i, hash;
+       int hash;
        shader_t    *sh;
 
        hash = generateHashValue( name );
@@ -3485,21 +3498,7 @@ qhandle_t RE_RegisterShaderFromImage( const char *name, 
int lightmapIndex, image
                }
        }
 
-       // clear the global shader
-       Com_Memset( &shader, 0, sizeof( shader ) );
-       Com_Memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-
-               // default normal/specular
-               VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f);
-               stages[i].specularScale[0] = 
-               stages[i].specularScale[1] =
-               stages[i].specularScale[2] = r_baseSpecular->value;
-               stages[i].specularScale[3] = r_baseGloss->value;
-       }
+       InitShader( name, lightmapIndex );
 
        //
        // create the default shading commands
@@ -3855,13 +3854,7 @@ CreateInternalShaders
 static void CreateInternalShaders( void ) {
        tr.numShaders = 0;
 
-       // init the default shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-
-       Q_strncpyz( shader.name, "<default>", sizeof( shader.name ) );
-
-       shader.lightmapIndex = LIGHTMAP_NONE;
+       InitShader( "<default>", LIGHTMAP_NONE );
        stages[0].bundle[0].image[0] = tr.defaultImage;
        stages[0].active = qtrue;
        stages[0].stateBits = GLS_DEFAULT;
@@ -3906,12 +3899,7 @@ static void CreateExternalShaders( void ) {
                else
                        image = tr.dlightImage;
 
-               Com_Memset( &shader, 0, sizeof( shader ) );
-               Com_Memset( &stages, 0, sizeof( stages ) );
-
-               Q_strncpyz( shader.name, "sunflare1", sizeof( shader.name ) );
-
-               shader.lightmapIndex = LIGHTMAP_NONE;
+               InitShader( "sunflare1", LIGHTMAP_NONE );
                stages[0].bundle[0].image[0] = image;
                stages[0].active = qtrue;
                stages[0].stateBits = GLS_DEFAULT;
diff --git a/MP/code/renderer/tr_shader.c b/MP/code/renderer/tr_shader.c
index 547bc89..5e986f7 100644
--- a/MP/code/renderer/tr_shader.c
+++ b/MP/code/renderer/tr_shader.c
@@ -2208,6 +2208,26 @@ static void VertexLightingCollapse( void ) {
 }
 
 /*
+===============
+InitShader
+===============
+*/
+static void InitShader( const char *name, int lightmapIndex ) {
+       int i;
+
+       // clear the global shader
+       Com_Memset( &shader, 0, sizeof( shader ) );
+       Com_Memset( &stages, 0, sizeof( stages ) );
+
+       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
+       shader.lightmapIndex = lightmapIndex;
+
+       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
+               stages[i].bundle[0].texMods = texMods[i];
+       }
+}
+
+/*
 =========================
 FinishShader
 
@@ -2516,7 +2536,7 @@ most world construction surfaces.
 */
 shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean 
mipRawImage ) {
        char strippedName[MAX_QPATH];
-       int i, hash;
+       int hash;
        char        *shaderText;
        image_t     *image;
        shader_t    *sh;
@@ -2554,14 +2574,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
                }
        }
 
-       // clear the global shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, strippedName, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-       }
+       InitShader( strippedName, lightmapIndex );
 
        // FIXME: set these "need" values apropriately
        shader.needsNormal = qtrue;
@@ -2671,7 +2684,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
 
 
 qhandle_t RE_RegisterShaderFromImage( const char *name, int lightmapIndex, 
image_t *image, qboolean mipRawImage ) {
-       int i, hash;
+       int hash;
        shader_t    *sh;
 
        hash = generateHashValue( name );
@@ -2699,14 +2712,7 @@ qhandle_t RE_RegisterShaderFromImage( const char *name, 
int lightmapIndex, image
                }
        }
 
-       // clear the global shader
-       Com_Memset( &shader, 0, sizeof( shader ) );
-       Com_Memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-       }
+       InitShader( name, lightmapIndex );
 
        // FIXME: set these "need" values apropriately
        shader.needsNormal = qtrue;
@@ -3061,12 +3067,7 @@ static void CreateInternalShaders( void ) {
        tr.numShaders = 0;
 
        // init the default shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-
-       Q_strncpyz( shader.name, "<default>", sizeof( shader.name ) );
-
-       shader.lightmapIndex = LIGHTMAP_NONE;
+       InitShader( "<default>", LIGHTMAP_NONE );
        stages[0].bundle[0].image[0] = tr.defaultImage;
        stages[0].active = qtrue;
        stages[0].stateBits = GLS_DEFAULT;
diff --git a/SP/code/rend2/tr_shader.c b/SP/code/rend2/tr_shader.c
index ac66772..b728caf 100644
--- a/SP/code/rend2/tr_shader.c
+++ b/SP/code/rend2/tr_shader.c
@@ -3011,6 +3011,33 @@ static void VertexLightingCollapse( void ) {
 }
 
 /*
+===============
+InitShader
+===============
+*/
+static void InitShader( const char *name, int lightmapIndex ) {
+       int i;
+
+       // clear the global shader
+       Com_Memset( &shader, 0, sizeof( shader ) );
+       Com_Memset( &stages, 0, sizeof( stages ) );
+
+       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
+       shader.lightmapIndex = lightmapIndex;
+
+       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
+               stages[i].bundle[0].texMods = texMods[i];
+
+               // default normal/specular
+               VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f);
+               stages[i].specularScale[0] =
+               stages[i].specularScale[1] =
+               stages[i].specularScale[2] = r_baseSpecular->value;
+               stages[i].specularScale[3] = r_baseGloss->value;
+       }
+}
+
+/*
 =========================
 FinishShader
 
@@ -3343,7 +3370,7 @@ most world construction surfaces.
 */
 shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean 
mipRawImage ) {
        char strippedName[MAX_QPATH];
-       int i, hash;
+       int hash;
        char        *shaderText;
        image_t     *image;
        shader_t    *sh;
@@ -3387,21 +3414,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
                }
        }
 
-       // clear the global shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, strippedName, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-
-               // default normal/specular
-               VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f);
-               stages[i].specularScale[0] = 
-               stages[i].specularScale[1] =
-               stages[i].specularScale[2] = r_baseSpecular->value;
-               stages[i].specularScale[3] = r_baseGloss->value;
-       }
+       InitShader( strippedName, lightmapIndex );
 
        //
        // attempt to define shader from an explicit parameter file
@@ -3508,7 +3521,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
 
 
 qhandle_t RE_RegisterShaderFromImage( const char *name, int lightmapIndex, 
image_t *image, qboolean mipRawImage ) {
-       int i, hash;
+       int hash;
        shader_t    *sh;
 
        hash = generateHashValue( name );
@@ -3536,21 +3549,7 @@ qhandle_t RE_RegisterShaderFromImage( const char *name, 
int lightmapIndex, image
                }
        }
 
-       // clear the global shader
-       Com_Memset( &shader, 0, sizeof( shader ) );
-       Com_Memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-
-               // default normal/specular
-               VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f);
-               stages[i].specularScale[0] = 
-               stages[i].specularScale[1] =
-               stages[i].specularScale[2] = r_baseSpecular->value;
-               stages[i].specularScale[3] = r_baseGloss->value;
-       }
+       InitShader( name, lightmapIndex );
 
        //
        // create the default shading commands
@@ -3973,12 +3972,7 @@ static void CreateInternalShaders( void ) {
        tr.numShaders = 0;
 
        // init the default shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-
-       Q_strncpyz( shader.name, "<default>", sizeof( shader.name ) );
-
-       shader.lightmapIndex = LIGHTMAP_NONE;
+       InitShader( "<default>", LIGHTMAP_NONE );
        stages[0].bundle[0].image[0] = tr.defaultImage;
        stages[0].active = qtrue;
        stages[0].stateBits = GLS_DEFAULT;
@@ -4024,12 +4018,8 @@ static void CreateExternalShaders( void ) {
                else
                        image = tr.dlightImage;
 
-               Com_Memset( &shader, 0, sizeof( shader ) );
-               Com_Memset( &stages, 0, sizeof( stages ) );
-
-               Q_strncpyz( shader.name, "sunflare1", sizeof( shader.name ) );
 
-               shader.lightmapIndex = LIGHTMAP_NONE;
+               InitShader( "sunflare1", LIGHTMAP_NONE );
                stages[0].bundle[0].image[0] = image;
                stages[0].active = qtrue;
                stages[0].stateBits = GLS_DEFAULT;
diff --git a/SP/code/renderer/tr_shader.c b/SP/code/renderer/tr_shader.c
index 9073d23..d8da0df 100644
--- a/SP/code/renderer/tr_shader.c
+++ b/SP/code/renderer/tr_shader.c
@@ -2225,6 +2225,26 @@ static void VertexLightingCollapse( void ) {
 }
 
 /*
+===============
+InitShader
+===============
+*/
+static void InitShader( const char *name, int lightmapIndex ) {
+       int i;
+
+       // clear the global shader
+       Com_Memset( &shader, 0, sizeof( shader ) );
+       Com_Memset( &stages, 0, sizeof( stages ) );
+
+       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
+       shader.lightmapIndex = lightmapIndex;
+
+       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
+               stages[i].bundle[0].texMods = texMods[i];
+       }
+}
+
+/*
 =========================
 FinishShader
 
@@ -2556,7 +2576,7 @@ most world construction surfaces.
 */
 shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean 
mipRawImage ) {
        char strippedName[MAX_QPATH];
-       int i, hash;
+       int hash;
        char        *shaderText;
        image_t     *image;
        shader_t    *sh;
@@ -2600,14 +2620,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
                }
        }
 
-       // clear the global shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, strippedName, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-       }
+       InitShader( strippedName, lightmapIndex );
 
        // FIXME: set these "need" values apropriately
        shader.needsNormal = qtrue;
@@ -2717,7 +2730,7 @@ shader_t *R_FindShader( const char *name, int 
lightmapIndex, qboolean mipRawImag
 
 
 qhandle_t RE_RegisterShaderFromImage( const char *name, int lightmapIndex, 
image_t *image, qboolean mipRawImage ) {
-       int i, hash;
+       int hash;
        shader_t    *sh;
 
        hash = generateHashValue( name );
@@ -2745,14 +2758,7 @@ qhandle_t RE_RegisterShaderFromImage( const char *name, 
int lightmapIndex, image
                }
        }
 
-       // clear the global shader
-       Com_Memset( &shader, 0, sizeof( shader ) );
-       Com_Memset( &stages, 0, sizeof( stages ) );
-       Q_strncpyz( shader.name, name, sizeof( shader.name ) );
-       shader.lightmapIndex = lightmapIndex;
-       for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
-               stages[i].bundle[0].texMods = texMods[i];
-       }
+       InitShader( name, lightmapIndex );
 
        // FIXME: set these "need" values apropriately
        shader.needsNormal = qtrue;
@@ -3172,12 +3178,7 @@ static void CreateInternalShaders( void ) {
        tr.numShaders = 0;
 
        // init the default shader
-       memset( &shader, 0, sizeof( shader ) );
-       memset( &stages, 0, sizeof( stages ) );
-
-       Q_strncpyz( shader.name, "<default>", sizeof( shader.name ) );
-
-       shader.lightmapIndex = LIGHTMAP_NONE;
+       InitShader( "<default>", LIGHTMAP_NONE );
        stages[0].bundle[0].image[0] = tr.defaultImage;
        stages[0].active = qtrue;
        stages[0].stateBits = GLS_DEFAULT;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/iortcw.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to