ignore excessive number of openings (#2070)

* remove limit on openings and fix from ZDOOM1.14a

* Revert "remove limit on openings and fix from ZDOOM1.14a"

* apply Fabian's patch
This commit is contained in:
Roman Fomin 2024-12-05 19:38:56 +07:00 committed by GitHub
parent 99c6bdba55
commit 82eb547b96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 4 deletions

View File

@ -71,8 +71,8 @@ visplane_t *floorplane, *ceilingplane;
// killough 8/1/98: set static number of openings to be large enough
// (a static limit is okay in this case and avoids difficulties in r_segs.c)
static int *openings = NULL;
int *lastopening; // [FG] 32-bit integer math
int maxopenings;
int *openings, *lastopening; // [FG] 32-bit integer math
// Clip values are the solid pixel bounding the range.
// floorclip starts out SCREENHEIGHT
@ -128,7 +128,8 @@ void R_InitPlanesRes(void)
yslope = Z_Calloc(1, video.height * sizeof(*yslope), PU_RENDERER, NULL);
distscale = Z_Calloc(1, video.width * sizeof(*distscale), PU_RENDERER, NULL);
openings = Z_Calloc(1, video.width * video.height * sizeof(*openings), PU_RENDERER, NULL);
maxopenings = video.width * video.height;
openings = Z_Calloc(1, maxopenings * sizeof(*openings), PU_RENDERER, NULL);
xtoskyangle = linearsky ? linearskyangle : xtoviewangle;
}

View File

@ -28,7 +28,8 @@ struct visplane_s;
#define PL_SKYFLAT (0x80000000)
// Visplane related.
extern int *lastopening; // [FG] 32-bit integer math
extern int maxopenings;
extern int *openings, *lastopening; // [FG] 32-bit integer math
extern int *floorclip, *ceilingclip; // [FG] 32-bit integer math
extern fixed_t *yslope, *distscale;

View File

@ -566,6 +566,13 @@ void R_StoreWallRange(const int start, const int stop)
ds_p->curline = curline;
rw_stopx = stop+1;
ptrdiff_t pos = lastopening - openings;
size_t need = (rw_stopx - start) * sizeof(*lastopening) + pos;
if (need > maxopenings)
{
return;
}
// WiggleFix: add this line, in r_segs.c:R_StoreWallRange,
// right before calls to R_ScaleFromGlobalAngle
R_FixWiggle(frontsector);