mirror of
https://github.com/UberGames/ioef.git
synced 2024-11-24 05:01:40 +00:00
Backport ignoring values outside lightgrid to OpenGL1
Fixes possibly of reading memory past end of lightGridData or reading wrong light grid data (wrapping around to next row).
This commit is contained in:
parent
1bb2bc370d
commit
9f57fea0ee
2 changed files with 10 additions and 6 deletions
|
@ -182,6 +182,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
|
||||||
data = gridData;
|
data = gridData;
|
||||||
for ( j = 0 ; j < 3 ; j++ ) {
|
for ( j = 0 ; j < 3 ; j++ ) {
|
||||||
if ( i & (1<<j) ) {
|
if ( i & (1<<j) ) {
|
||||||
|
if ( pos[j] + 1 > tr.world->lightGridBounds[j] - 1 ) {
|
||||||
|
break; // ignore values outside lightgrid
|
||||||
|
}
|
||||||
factor *= frac[j];
|
factor *= frac[j];
|
||||||
data += gridStep[j];
|
data += gridStep[j];
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,6 +192,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( j != 3 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( !(data[0]+data[1]+data[2]) ) {
|
if ( !(data[0]+data[1]+data[2]) ) {
|
||||||
continue; // ignore samples in walls
|
continue; // ignore samples in walls
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,18 +180,15 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) {
|
||||||
byte *data;
|
byte *data;
|
||||||
int lat, lng;
|
int lat, lng;
|
||||||
vec3_t normal;
|
vec3_t normal;
|
||||||
qboolean ignore;
|
|
||||||
#if idppc
|
#if idppc
|
||||||
float d0, d1, d2, d3, d4, d5;
|
float d0, d1, d2, d3, d4, d5;
|
||||||
#endif
|
#endif
|
||||||
factor = 1.0;
|
factor = 1.0;
|
||||||
data = gridData;
|
data = gridData;
|
||||||
ignore = qfalse;
|
|
||||||
for ( j = 0 ; j < 3 ; j++ ) {
|
for ( j = 0 ; j < 3 ; j++ ) {
|
||||||
if ( i & (1<<j) ) {
|
if ( i & (1<<j) ) {
|
||||||
if ((pos[j] + 1) > world->lightGridBounds[j] - 1)
|
if ( pos[j] + 1 > world->lightGridBounds[j] - 1 ) {
|
||||||
{
|
break; // ignore values outside lightgrid
|
||||||
ignore = qtrue; // ignore values outside lightgrid
|
|
||||||
}
|
}
|
||||||
factor *= frac[j];
|
factor *= frac[j];
|
||||||
data += gridStep[j];
|
data += gridStep[j];
|
||||||
|
@ -200,8 +197,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ignore )
|
if ( j != 3 ) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (world->hdrLightGrid)
|
if (world->hdrLightGrid)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue