diff --git a/src/r_defs.h b/src/r_defs.h index 1c41228a8..97594ce58 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -46,7 +46,7 @@ #define SIL_BOTH 3 #define MAXDRAWSEGS 1280 -#define MAXOPENINGS 16384 +#define MAXOPENINGS MAXSCREENAREA // // INTERNAL MAP TYPES diff --git a/src/r_plane.c b/src/r_plane.c index 781e1b5fb..e940f2da0 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -53,7 +53,7 @@ static visplane_t **freehead = &freetail; // killough visplane_t *floorplane; visplane_t *ceilingplane; -int *openings; // dropoff overflow +int openings[MAXOPENINGS]; int *lastopening; // dropoff overflow // Clip values are the solid pixel bounding the range. diff --git a/src/r_plane.h b/src/r_plane.h index eed3712f7..e594896c8 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -44,7 +44,7 @@ extern int floorclip[MAXWIDTH]; extern int ceilingclip[MAXWIDTH]; extern fixed_t *yslope; extern fixed_t yslopes[LOOKDIRS][MAXHEIGHT]; -extern int *openings; // dropoff overflow +extern int openings[MAXOPENINGS]; void R_ClearPlanes(void); void R_DrawPlanes(void); diff --git a/src/r_segs.c b/src/r_segs.c index fddece399..d4cc0ecc8 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -633,40 +633,8 @@ void R_StoreWallRange(const int start, const int stop) ds_p->curline = curline; rw_stopx = stop + 1; - // killough 01/06/98, 02/01/98: remove limit on openings - { - const size_t pos = lastopening - openings; - const size_t need = ((size_t)rw_stopx - start) * sizeof(*lastopening) + pos; - static size_t maxopenings; - - if (need > maxopenings) - { - const int *oldopenings = openings; - const int *oldlast = lastopening; - - do - maxopenings = (maxopenings ? maxopenings * 2 : MAXOPENINGS); - while (need > maxopenings); - - openings = I_Realloc(openings, maxopenings * sizeof(*openings)); - lastopening = openings + pos; - - // jff 08/09/98 borrowed fix for openings from ZDOOM 1.14 - // [RH] We also need to adjust the openings pointers that - // were already stored in drawsegs. - for (drawseg_t *ds = drawsegs; ds < ds_p; ds++) - { - if (ds->maskedtexturecol + ds->x1 >= oldopenings && ds->maskedtexturecol + ds->x1 <= oldlast) - ds->maskedtexturecol = ds->maskedtexturecol - oldopenings + openings; - - if (ds->sprtopclip + ds->x1 >= oldopenings && ds->sprtopclip + ds->x1 <= oldlast) - ds->sprtopclip = ds->sprtopclip - oldopenings + openings; - - if (ds->sprbottomclip + ds->x1 >= oldopenings && ds->sprbottomclip + ds->x1 <= oldlast) - ds->sprbottomclip = ds->sprbottomclip - oldopenings + openings; - } - } - } + if ((rw_stopx - start) * sizeof(*lastopening) + (lastopening - openings) > MAXOPENINGS) + return; worldtop = frontsector->interpceilingheight - viewz; worldbottom = frontsector->interpfloorheight - viewz;