From 16be238953e1d3f105bd5db66f65581cbd030121 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 5 Mar 2015 10:48:37 +0000 Subject: [PATCH] Don't crash on too-many-water-planes. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12196 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) 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 { -- 2.39.2