From a8a45ad2563d4eea3874b7531aa9deed0f5129c4 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Mon, 8 Jun 2020 15:33:26 +0000 Subject: [PATCH] Fix (workaround?) crashes with quake15 mod git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12653 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rsurf.c | 4 +++- model_brush.c | 8 +++++++- model_shared.c | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index 62d51e32..056687c7 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -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; diff --git a/model_brush.c b/model_brush.c index 05b25ded..8fb07d00 100644 --- a/model_brush.c +++ b/model_brush.c @@ -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; diff --git a/model_shared.c b/model_shared.c index 9a51f98c..c8d67bd3 100644 --- a/model_shared.c +++ b/model_shared.c @@ -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; } -- 2.39.2