From be1d330d56fc7e698094abb3f217b8c7cccc0c87 Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Mon, 15 Oct 2001 13:23:19 +0000 Subject: [PATCH] fix an off-by-one issue with model->numleafs in PVS related code (dynamic lighting and world rendering), numleafs excludes leaf 0, how strange... no missing (black) leaf bug anymore... git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@918 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rsurf.c | 4 ++-- r_light.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index 7479d5e3..54f34cc3 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1759,10 +1759,10 @@ void R_PVSWorldNode() if (c & bit) { leafnum = (k << 3)+i+1; - if (leafnum >= numleafs) + if (leafnum > numleafs) return; c -= bit; - leaf = &model->leafs[leafnum]; + leaf = &model->leafs[i]; if (R_NotCulledBox(leaf->mins, leaf->maxs)) { //for (portal = leaf->portals;portal;portal = portal->next) diff --git a/r_light.c b/r_light.c index 5e05081e..b5757cad 100644 --- a/r_light.c +++ b/r_light.c @@ -249,7 +249,7 @@ void R_VisMarkLights (vec3_t lightorigin, dlight_t *light, int bit, int bitindex } else { - int i, k, l, m, c; + int i, k, m, c, leafnum; msurface_t *surf, **mark; mleaf_t *leaf; byte *in = pvsleaf->compressed_vis; @@ -276,14 +276,14 @@ void R_VisMarkLights (vec3_t lightorigin, dlight_t *light, int bit, int bitindex c = *in++; if (c) { - l = model->numleafs - (k << 3); - if (l > 8) - l = 8; - for (i=0 ; ileafs[(k << 3)+i+1]; + leafnum = (k << 3)+i+1; + if (leafnum > model->numleafs) + return; + leaf = &model->leafs[leafnum]; // if (leaf->visframe != r_framecount) // continue; // if (leaf->contents == CONTENTS_SOLID) -- 2.39.2