]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix an off-by-one issue with model->numleafs in PVS related code (dynamic lighting...
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 15 Oct 2001 13:23:19 +0000 (13:23 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 15 Oct 2001 13:23:19 +0000 (13:23 +0000)
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
r_light.c

index 7479d5e31bb327e2c4be0d6f18cb0958461f1782..54f34cc32cf7f09390e84e8fa9d21f288f2eb7bd 100644 (file)
@@ -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)
index 5e05081eae9da30cda8b249a02e1c198ca0edd39..b5757cadf5b3871f2d0bc4692b9ab262057e49b7 100644 (file)
--- 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 ; i<l ; i++)
+                               for (i = 0;i < 8;i++)
                                {
                                        if (c & (1<<i))
                                        {
-                                               leaf = &model->leafs[(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)