]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix (workaround?) crashes with quake15 mod
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 8 Jun 2020 15:33:26 +0000 (15:33 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 8 Jun 2020 15:33:26 +0000 (15:33 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12653 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c
model_brush.c
model_shared.c

index 62d51e3208b79e273e1d3bfe4e3e4d057c890157..056687c73d72bb2a27cf3f32194968b9a29b68f4 100644 (file)
@@ -918,10 +918,12 @@ static void R_Q1BSP_RecursiveGetLightInfo_BSP(r_q1bsp_getlightinfo_t *info, qboo
                                for (leafsurfaceindex = 0;leafsurfaceindex < numleafsurfaces;leafsurfaceindex++)
                                {
                                        surfaceindex = leafsurfaceindices[leafsurfaceindex];
+                                       surface = surfaces + surfaceindex;
+                                       if(!surface->texture)
+                                               continue;       
                                        if (CHECKPVSBIT(info->outsurfacepvs, surfaceindex))
                                                continue;
                                        SETPVSBIT(info->outsurfacepvs, surfaceindex);
-                                       surface = surfaces + surfaceindex;
                                        if (!BoxesOverlap(info->lightmins, info->lightmaxs, surface->mins, surface->maxs))
                                                continue;
                                        addedtris = false;
index 05b25ded5ba0394dbaf9d0670df5b11124eadc1f..8fb07d0064e3705e474835865601c3259a08dbe6 100644 (file)
@@ -566,6 +566,8 @@ static void Mod_Q1BSP_FindNonSolidLocation_r_Leaf(findnonsolidlocationinfo_t *in
        for (surfacenum = 0, mark = leaf->firstleafsurface;surfacenum < leaf->numleafsurfaces;surfacenum++, mark++)
        {
                surface = info->model->data_surfaces + *mark;
+               if(!surface->texture)
+                       continue;
                if (surface->texture->supercontents & SUPERCONTENTS_SOLID)
                {
                        for (k = 0;k < surface->num_triangles;k++)
@@ -1242,6 +1244,8 @@ static int Mod_Q1BSP_LightPoint_RecursiveBSPNode(dp_model_t *model, vec3_t ambie
                        surface = model->data_surfaces + node->firstsurface;
                        for (i = 0;i < node->numsurfaces;i++, surface++)
                        {
+                               if(!surface->texture)
+                                       continue;
                                if (!(surface->texture->basematerialflags & MATERIALFLAG_WALL) || !surface->lightmapinfo || !surface->lightmapinfo->samples)
                                        continue;       // no lightmaps
 
@@ -1358,6 +1362,8 @@ static const texture_t *Mod_Q1BSP_TraceLineAgainstSurfacesFindTextureOnNode(Recu
        surface = model->data_surfaces + node->firstsurface;
        for (i = 0;i < node->numsurfaces;i++, surface++)
        {
+               if(!surface->texture)
+                       continue;
                // skip surfaces whose bounding box does not include the point
 //             if (!BoxesOverlap(mid, mid, surface->mins, surface->maxs))
 //                     continue;
@@ -4122,7 +4128,7 @@ void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
                                mod->DrawSky = R_Q1BSP_DrawSky;
 
                        for (j = 0, surface = &mod->data_surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surface++)
-                               if (surface->texture->basematerialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA))
+                               if (surface->texture && surface->texture->basematerialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA))
                                        break;
                        if (j < mod->nummodelsurfaces)
                                mod->DrawAddWaterPlanes = R_Q1BSP_DrawAddWaterPlanes;
index 9a51f98c234cbb1cb8b54badfd02d4998ca9a62f..c8d67bd361ef21546cf275a364921e42b7219219 100644 (file)
@@ -2863,6 +2863,8 @@ void Mod_MakeSortedSurfaces(dp_model_t *mod)
        for (j = 0;j < mod->nummodelsurfaces;j++)
        {
                const msurface_t *surface = mod->data_surfaces + j + mod->firstmodelsurface;
+               if(!surface->texture)
+                       continue;
                t = (int)(surface->texture - mod->data_textures);
                numsurfacesfortexture[t]++;
        }
@@ -2875,6 +2877,8 @@ void Mod_MakeSortedSurfaces(dp_model_t *mod)
        for (j = 0;j < mod->nummodelsurfaces;j++)
        {
                const msurface_t *surface = mod->data_surfaces + j + mod->firstmodelsurface;
+               if (!surface->texture)
+                       continue;
                t = (int)(surface->texture - mod->data_textures);
                mod->sortedmodelsurfaces[firstsurfacefortexture[t]++] = j + mod->firstmodelsurface;
        }