@@ -113,7 +113,7 @@ R_ColorShiftLightingBytes
113113
114114===============
115115*/
116- static void R_ColorShiftLightingBytes ( byte in [4 ], byte out [4 ] ) {
116+ static void R_ColorShiftLightingBytes ( int inSize , byte in [4 ], byte out [4 ] ) {
117117 int shift , r , g , b ;
118118
119119 // shift the color data based on overbright range
@@ -138,7 +138,11 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) {
138138 out [0 ] = r ;
139139 out [1 ] = g ;
140140 out [2 ] = b ;
141- out [3 ] = in [3 ];
141+ if ( inSize == 4 ) {
142+ out [3 ] = in [3 ];
143+ } else {
144+ out [3 ] = 255 ;
145+ }
142146}
143147
144148/*
@@ -192,8 +196,7 @@ float R_ProcessLightmap( byte **pic, int in_padding, int width, int height, byte
192196 }
193197 } else {
194198 for ( j = 0 ; j < width * height ; j ++ ) {
195- R_ColorShiftLightingBytes ( & ( * pic )[j * in_padding ], & ( * pic_out )[j * 4 ] );
196- ( * pic_out )[j * 4 + 3 ] = 255 ;
199+ R_ColorShiftLightingBytes ( 3 , & ( * pic )[j * in_padding ], & ( * pic_out )[j * 4 ] );
197200 }
198201 }
199202
@@ -492,7 +495,7 @@ static void ParseMesh( dsurface_t *ds, drawVert_t *verts, msurface_t *surf ) {
492495 points [i ].st [j ] = LittleFloat ( verts [i ].st [j ] );
493496 points [i ].lightmap [j ] = LittleFloat ( verts [i ].lightmap [j ] );
494497 }
495- R_ColorShiftLightingBytes ( verts [i ].color , points [i ].color );
498+ R_ColorShiftLightingBytes ( 4 , verts [i ].color , points [i ].color );
496499 }
497500
498501 // pre-tesseleate
@@ -582,7 +585,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, i
582585 tri -> verts [i ].lightmap [j ] = LittleFloat ( verts [i ].lightmap [j ] );
583586 }
584587
585- R_ColorShiftLightingBytes ( verts [i ].color , tri -> verts [i ].color );
588+ R_ColorShiftLightingBytes ( 4 , verts [i ].color , tri -> verts [i ].color );
586589 }
587590
588591 // copy indexes
@@ -723,7 +726,7 @@ static void ParseFoliage( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, i
723726 AddPointToBounds ( boundsTranslated [ 1 ], foliage -> bounds [ 0 ], foliage -> bounds [ 1 ] );
724727
725728 // copy color
726- R_ColorShiftLightingBytes ( verts [ i ].color , foliage -> instances [ i ].color );
729+ R_ColorShiftLightingBytes ( 4 , verts [ i ].color , foliage -> instances [ i ].color );
727730 }
728731
729732 // finish surface
@@ -1987,8 +1990,8 @@ void R_LoadLightGrid( const bspFile_t *bsp ) {
19871990
19881991 // deal with overbright bits
19891992 for ( i = 0 ; i < bsp -> numGridPoints ; i ++ ) {
1990- R_ColorShiftLightingBytes ( & w -> lightGridData [i * 8 ], & w -> lightGridData [i * 8 ] );
1991- R_ColorShiftLightingBytes ( & w -> lightGridData [i * 8 + 3 ], & w -> lightGridData [i * 8 + 3 ] );
1993+ R_ColorShiftLightingBytes ( 4 , & w -> lightGridData [i * 8 ], & w -> lightGridData [i * 8 ] );
1994+ R_ColorShiftLightingBytes ( 4 , & w -> lightGridData [i * 8 + 3 ], & w -> lightGridData [i * 8 + 3 ] );
19921995 }
19931996}
19941997
0 commit comments