]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix a crash on vertex lighting q1bsp/hlbsp surfaces with no lightmap samples data
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Sep 2005 12:02:02 +0000 (12:02 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Sep 2005 12:02:02 +0000 (12:02 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5721 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index 14d17f723c1997b75a9e4119dacaa1ba03a89d49..deaa8db42a0eaaecb661103bc8a06612dd512d9d 100644 (file)
@@ -1665,27 +1665,32 @@ void RSurf_SetColorPointer(const entity_render_t *ent, const msurface_t *surface
                        for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
                        {
                                const qbyte *lm = surface->lightmapinfo->samples + (surface->groupmesh->data_lightmapoffsets + surface->num_firstvertex)[i];
-                               float scale = d_lightstylevalue[surface->lightmapinfo->styles[0]] * (1.0f / 32768.0f);
-                               VectorScale(lm, scale, c);
-                               if (surface->lightmapinfo->styles[1] != 255)
+                               if (lm)
                                {
-                                       int size3 = ((surface->lightmapinfo->extents[0]>>4)+1)*((surface->lightmapinfo->extents[1]>>4)+1)*3;
-                                       lm += size3;
-                                       scale = d_lightstylevalue[surface->lightmapinfo->styles[1]] * (1.0f / 32768.0f);
-                                       VectorMA(c, scale, lm, c);
-                                       if (surface->lightmapinfo->styles[2] != 255)
+                                       float scale = d_lightstylevalue[surface->lightmapinfo->styles[0]] * (1.0f / 32768.0f);
+                                       VectorScale(lm, scale, c);
+                                       if (surface->lightmapinfo->styles[1] != 255)
                                        {
+                                               int size3 = ((surface->lightmapinfo->extents[0]>>4)+1)*((surface->lightmapinfo->extents[1]>>4)+1)*3;
                                                lm += size3;
-                                               scale = d_lightstylevalue[surface->lightmapinfo->styles[2]] * (1.0f / 32768.0f);
+                                               scale = d_lightstylevalue[surface->lightmapinfo->styles[1]] * (1.0f / 32768.0f);
                                                VectorMA(c, scale, lm, c);
-                                               if (surface->lightmapinfo->styles[3] != 255)
+                                               if (surface->lightmapinfo->styles[2] != 255)
                                                {
                                                        lm += size3;
-                                                       scale = d_lightstylevalue[surface->lightmapinfo->styles[3]] * (1.0f / 32768.0f);
+                                                       scale = d_lightstylevalue[surface->lightmapinfo->styles[2]] * (1.0f / 32768.0f);
                                                        VectorMA(c, scale, lm, c);
+                                                       if (surface->lightmapinfo->styles[3] != 255)
+                                                       {
+                                                               lm += size3;
+                                                               scale = d_lightstylevalue[surface->lightmapinfo->styles[3]] * (1.0f / 32768.0f);
+                                                               VectorMA(c, scale, lm, c);
+                                                       }
                                                }
                                        }
                                }
+                               else
+                                       VectorClear(c);
                        }
                        rsurface_lightmapcolor4f = varray_color4f;
                }