]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/shaders.c
Merge commit '84881a66140ad93d0b6cd4d55efbbb459bd91f48' into master-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / shaders.c
index 208dec4829782a28963df225bc309fd0addcdc12..3c26a1cda270a3064cd4d495b751344af8590861 100644 (file)
@@ -811,10 +811,12 @@ static void LoadShaderImages( shaderInfo_t *si ){
        if ( VectorLength( si->color ) <= 0.0f ) {
                ColorNormalize( color, si->color );
                VectorScale( color, ( 1.0f / count ), si->averageColor );
+               si->averageColor[ 3 ] = color[ 3 ] / count;
        }
        else
        {
                VectorCopy( si->color, si->averageColor );
+               si->averageColor[ 3 ] = 1.0f;
        }
 }
 
@@ -945,17 +947,17 @@ void Parse1DMatrixAppend( char *buffer, int x, vec_t *m ){
 
 
        if ( !GetTokenAppend( buffer, qtrue ) || strcmp( token, "(" ) ) {
-               Error( "Parse1DMatrixAppend(): line %d: ( not found!", scriptline );
+               Error( "Parse1DMatrixAppend(): line %d: ( not found!\nFile location be: %s\n", scriptline, g_strLoadedFileLocation );
        }
        for ( i = 0; i < x; i++ )
        {
                if ( !GetTokenAppend( buffer, qfalse ) ) {
-                       Error( "Parse1DMatrixAppend(): line %d: Number not found!", scriptline );
+                       Error( "Parse1DMatrixAppend(): line %d: Number not found!\nFile location be: %s\n", scriptline, g_strLoadedFileLocation );
                }
                m[ i ] = atof( token );
        }
        if ( !GetTokenAppend( buffer, qtrue ) || strcmp( token, ")" ) ) {
-               Error( "Parse1DMatrixAppend(): line %d: ) not found!", scriptline );
+               Error( "Parse1DMatrixAppend(): line %d: ) not found!\nFile location be: %s\n", scriptline, g_strLoadedFileLocation );
        }
 }
 
@@ -1017,12 +1019,12 @@ static void ParseShaderFile( const char *filename ){
                }
                if ( strcmp( token, "{" ) ) {
                        if ( si != NULL ) {
-                               Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nLast known shader: %s",
-                                          filename, scriptline, token, si->shader );
+                               Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nLast known shader: %s\nFile location be: %s\n",
+                                          filename, scriptline, token, si->shader, g_strLoadedFileLocation );
                        }
                        else{
-                               Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s",
-                                          filename, scriptline, token );
+                               Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nFile location be: %s\n",
+                                          filename, scriptline, token, g_strLoadedFileLocation );
                        }
                }
 
@@ -1060,7 +1062,6 @@ static void ParseShaderFile( const char *filename ){
                                                         !Q_stricmp( token, "clampMap" ) ||
                                                         !Q_stricmp( token, "animMap" ) ||
                                                         !Q_stricmp( token, "clampAnimMap" ) ||
-                                                        !Q_stricmp( token, "clampMap" ) ||
                                                         !Q_stricmp( token, "mapComp" ) ||
                                                         !Q_stricmp( token, "mapNoComp" ) ) {
                                                        /* skip one token for animated stages */
@@ -1275,8 +1276,7 @@ static void ParseShaderFile( const char *filename ){
                        else if ( !Q_stricmp( token, "sun" ) /* sof2 */ || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) {
                                float a, b;
                                sun_t       *sun;
-                               qboolean ext;
-
+                               qboolean ext = qfalse;
 
                                /* ydnar: extended sun directive? */
                                if ( !Q_stricmp( token, "q3map_sunext" ) ) {
@@ -1284,8 +1284,7 @@ static void ParseShaderFile( const char *filename ){
                                }
 
                                /* allocate sun */
-                               sun = safe_malloc( sizeof( *sun ) );
-                               memset( sun, 0, sizeof( *sun ) );
+                               sun = safe_malloc0( sizeof( *sun ) );
 
                                /* set style */
                                sun->style = si->lightStyle;
@@ -1385,8 +1384,7 @@ static void ParseShaderFile( const char *filename ){
                                        surfaceModel_t  *model;
 
                                        /* allocate new model and attach it */
-                                       model = safe_malloc( sizeof( *model ) );
-                                       memset( model, 0, sizeof( *model ) );
+                                       model = safe_malloc0( sizeof( *model ) );
                                        model->next = si->surfaceModel;
                                        si->surfaceModel = model;
 
@@ -1419,8 +1417,7 @@ static void ParseShaderFile( const char *filename ){
 
 
                                        /* allocate new foliage struct and attach it */
-                                       foliage = safe_malloc( sizeof( *foliage ) );
-                                       memset( foliage, 0, sizeof( *foliage ) );
+                                       foliage = safe_malloc0( sizeof( *foliage ) );
                                        foliage->next = si->foliage;
                                        si->foliage = foliage;
 
@@ -1750,8 +1747,7 @@ static void ParseShaderFile( const char *filename ){
                                        alpha = ( !Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) ? 1 : 0;
 
                                        /* allocate new colormod */
-                                       cm = safe_malloc( sizeof( *cm ) );
-                                       memset( cm, 0, sizeof( *cm ) );
+                                       cm = safe_malloc0( sizeof( *cm ) );
 
                                        /* attach to shader */
                                        if ( si->colorMod == NULL ) {