@@ -41,14 +41,27 @@ static byte *fileBase;
4141
4242// ===============================================================================
4343
44+ static bool cannotColorShiftLighting ()
45+ {
46+ if ( tr.overbrightBits >= tr.mapOverBrightBits )
47+ {
48+ return true ;
49+ }
50+
51+ return false ;
52+ }
53+
4454/*
4555===============
4656R_ColorShiftLightingBytes
4757===============
4858*/
4959static void R_ColorShiftLightingBytes ( byte bytes[ 4 ] )
5060{
51- ASSERT_LT ( tr.overbrightBits , tr.mapOverBrightBits );
61+ if ( cannotColorShiftLighting () )
62+ {
63+ return ;
64+ }
5265
5366 int shift = tr.mapOverBrightBits - tr.overbrightBits ;
5467
@@ -76,7 +89,10 @@ static void R_ColorShiftLightingBytes( byte bytes[ 4 ] )
7689
7790static void R_ColorShiftLightingBytesCompressed ( byte bytes[ 8 ] )
7891{
79- ASSERT_LT ( tr.overbrightBits , tr.mapOverBrightBits );
92+ if ( cannotColorShiftLighting () )
93+ {
94+ return ;
95+ }
8096
8197 // color shift the endpoint colors in the dxt block
8298 unsigned short rgb565 = bytes[1 ] << 8 | bytes[0 ];
@@ -117,7 +133,7 @@ R_ProcessLightmap
117133*/
118134void R_ProcessLightmap ( byte *bytes, int width, int height, int bits )
119135{
120- if ( tr. overbrightBits >= tr. mapOverBrightBits )
136+ if ( cannotColorShiftLighting () )
121137 {
122138 return ;
123139 }
@@ -621,10 +637,7 @@ static void R_LoadLightmaps( lump_t *l, const char *bspName )
621637 lightMapBuffer[( index * 4 ) + 2 ] = buf_p[( ( x + ( y * internalLightMapSize ) ) * 3 ) + 2 ];
622638 lightMapBuffer[( index * 4 ) + 3 ] = 255 ;
623639
624- if ( tr.overbrightBits < tr.mapOverBrightBits )
625- {
626- R_ColorShiftLightingBytes ( &lightMapBuffer[( index * 4 ) + 0 ] );
627- }
640+ R_ColorShiftLightingBytes ( &lightMapBuffer[( index * 4 ) + 0 ] );
628641 }
629642 }
630643
@@ -972,9 +985,7 @@ static void ParseTriangleSurface( dsurface_t* ds, drawVert_t* verts, bspSurface_
972985
973986 cv->verts [ i ].lightColor = Color::Adapt ( verts[ i ].color );
974987
975- if ( tr.overbrightBits < tr.mapOverBrightBits ) {
976- R_ColorShiftLightingBytes ( cv->verts [ i ].lightColor .ToArray () );
977- }
988+ R_ColorShiftLightingBytes ( cv->verts [ i ].lightColor .ToArray () );
978989 }
979990
980991 // Copy triangles
@@ -1206,10 +1217,7 @@ static void ParseMesh( dsurface_t *ds, drawVert_t *verts, bspSurface_t *surf )
12061217
12071218 points[ i ].lightColor = Color::Adapt ( verts[ i ].color );
12081219
1209- if ( tr.overbrightBits < tr.mapOverBrightBits )
1210- {
1211- R_ColorShiftLightingBytes ( points[ i ].lightColor .ToArray () );
1212- }
1220+ R_ColorShiftLightingBytes ( points[ i ].lightColor .ToArray () );
12131221 }
12141222
12151223 // center texture coords
@@ -3494,11 +3502,8 @@ void R_LoadLightGrid( lump_t *l )
34943502 tmpDirected[ 2 ] = in->directed [ 2 ];
34953503 tmpDirected[ 3 ] = 255 ;
34963504
3497- if ( tr.overbrightBits < tr.mapOverBrightBits )
3498- {
3499- R_ColorShiftLightingBytes ( tmpAmbient );
3500- R_ColorShiftLightingBytes ( tmpDirected );
3501- }
3505+ R_ColorShiftLightingBytes ( tmpAmbient );
3506+ R_ColorShiftLightingBytes ( tmpDirected );
35023507
35033508 for ( j = 0 ; j < 3 ; j++ )
35043509 {
0 commit comments