Fix FOFs with transferline flag and many linedefs randomly crashing

linenum could go out of bounds if you use more than 4 linedefs for such setup, hence making the game unable to retrieve textures and therefore crashing the games sometimes

many thanks to indev for helping me figuring this one out c:
This commit is contained in:
Alug 2024-02-01 18:57:55 +01:00
parent bae687a1b9
commit e892cc1d4b
2 changed files with 3 additions and 3 deletions

View file

@ -1631,7 +1631,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
size_t linenum = min(gl_curline->linedef-gl_backsector->lines[0], rover->master->frontsector->linecount);
newline = rover->master->frontsector->lines[0] + linenum;
side = &sides[newline->sidenum[0]];
do_texture_skew = newline->flags & ML_SKEWTD;
@ -1785,7 +1785,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
size_t linenum = min(gl_curline->linedef-gl_backsector->lines[0], rover->master->frontsector->linecount);
newline = rover->master->frontsector->lines[0] + linenum;
side = &sides[newline->sidenum[0]];
}

View file

@ -571,7 +571,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (pfloor->master->flags & ML_TFERLINE)
{
size_t linenum = curline->linedef-backsector->lines[0];
size_t linenum = min(curline->linedef-backsector->lines[0], pfloor->master->frontsector->linecount);
line_t *newline = pfloor->master->frontsector->lines[0] + linenum;
sidedef = &sides[newline->sidenum[0]];
do_texture_skew = newline->flags & ML_SKEWTD;