From 7aa6d50e5283e1e7026fcc18d29353212eddf35e Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 14 Dec 2010 14:17:41 +0000 Subject: [PATCH] do not crash if no matching water plane could be found (BUT WHY DOES THIS HAPPEN TO BEGIN WITH) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10659 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=7a40a91a24fa53b6ef38e0d1fb14dcfe270b8b61 --- gl_rmain.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index ac4edaab..0808d5b1 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -12618,16 +12618,22 @@ static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface // bind lightmap texture // water/refraction/reflection/camera surfaces have to be handled specially - if ((rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_CAMERA | MATERIALFLAG_REFLECTION)) && !r_waterstate.renderingscene) + if ((rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_CAMERA | MATERIALFLAG_REFLECTION))) { int start, end, startplaneindex; for (start = 0;start < texturenumsurfaces;start = end) { startplaneindex = RSurf_FindWaterPlaneForSurface(texturesurfacelist[start]); + if(startplaneindex < 0) + { + Con_Printf("No matching water plane for surface with material flags 0x%08x - PLEASE DEBUG THIS\n", rsurface.texture->currentmaterialflags); + end = start + 1; + continue; + } for (end = start + 1;end < texturenumsurfaces && startplaneindex == RSurf_FindWaterPlaneForSurface(texturesurfacelist[end]);end++) ; // now that we have a batch using the same planeindex, render it - if ((rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_CAMERA)) && !r_waterstate.renderingscene) + if ((rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_CAMERA))) { // render water or distortion background GL_DepthMask(true); -- 2.39.2