From: divverent Date: Thu, 5 Mar 2015 10:48:37 +0000 (+0000) Subject: Don't crash on too-many-water-planes. X-Git-Tag: xonotic-v0.8.1~8^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=16be238953e1d3f105bd5db66f65581cbd030121;p=xonotic%2Fdarkplaces.git Don't crash on too-many-water-planes. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12196 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index ec7917bf..f69ac7b0 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -6004,18 +6004,26 @@ void R_Water_AddWaterPlane(msurface_t *surface, int entno) p = r_fb.water.waterplanes + planeindex; // if this surface does not fit any known plane rendered this frame, add one - if ((planeindex < 0 || bestplanescore > 0.001f) && r_fb.water.numwaterplanes < r_fb.water.maxwaterplanes) - { - // store the new plane - planeindex = r_fb.water.numwaterplanes++; - p = r_fb.water.waterplanes + planeindex; - p->plane = plane; - // clear materialflags and pvs - p->materialflags = 0; - p->pvsvalid = false; - p->camera_entity = t->camera_entity; - VectorCopy(mins, p->mins); - VectorCopy(maxs, p->maxs); + if (planeindex < 0 || bestplanescore > 0.001f) + { + if (r_fb.water.numwaterplanes < r_fb.water.maxwaterplanes) + { + // store the new plane + planeindex = r_fb.water.numwaterplanes++; + p = r_fb.water.waterplanes + planeindex; + p->plane = plane; + // clear materialflags and pvs + p->materialflags = 0; + p->pvsvalid = false; + p->camera_entity = t->camera_entity; + VectorCopy(mins, p->mins); + VectorCopy(maxs, p->maxs); + } + else + { + // We're totally screwed. + return; + } } else {