From: divverent Date: Tue, 14 Dec 2010 14:17:41 +0000 (+0000) Subject: do not crash if no matching water plane could be found (BUT WHY DOES THIS HAPPEN... X-Git-Tag: xonotic-v0.5.0~438^2~182 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7a40a91a24fa53b6ef38e0d1fb14dcfe270b8b61;p=xonotic%2Fdarkplaces.git 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 --- 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);