mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch 'fix-segfault-polyvertex-null' into 'next'
Fix segfaults on some systems due to polyvertex being NULL See merge request STJr/SRB2!2065
This commit is contained in:
commit
9989cbe3e3
1 changed files with 80 additions and 16 deletions
|
@ -584,10 +584,26 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
P_ClosestPointOnLine(viewx, viewy, line->linedef, &v);
|
||||
dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y));
|
||||
|
||||
x1 = ((polyvertex_t *)line->pv1)->x;
|
||||
y1 = ((polyvertex_t *)line->pv1)->y;
|
||||
xd = ((polyvertex_t *)line->pv2)->x - x1;
|
||||
yd = ((polyvertex_t *)line->pv2)->y - y1;
|
||||
if (line->pv1)
|
||||
{
|
||||
x1 = ((polyvertex_t *)line->pv1)->x;
|
||||
y1 = ((polyvertex_t *)line->pv1)->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = FIXED_TO_FLOAT(line->v1->x);
|
||||
y1 = FIXED_TO_FLOAT(line->v1->x);
|
||||
}
|
||||
if (line->pv2)
|
||||
{
|
||||
xd = ((polyvertex_t *)line->pv2)->x - x1;
|
||||
yd = ((polyvertex_t *)line->pv2)->y - y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
xd = FIXED_TO_FLOAT(line->v2->x) - x1;
|
||||
yd = FIXED_TO_FLOAT(line->v2->y) - y1;
|
||||
}
|
||||
|
||||
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
|
||||
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
|
||||
|
@ -1070,10 +1086,26 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
|||
gl_sidedef = gl_curline->sidedef;
|
||||
gl_linedef = gl_curline->linedef;
|
||||
|
||||
vs.x = ((polyvertex_t *)gl_curline->pv1)->x;
|
||||
vs.y = ((polyvertex_t *)gl_curline->pv1)->y;
|
||||
ve.x = ((polyvertex_t *)gl_curline->pv2)->x;
|
||||
ve.y = ((polyvertex_t *)gl_curline->pv2)->y;
|
||||
if (gl_curline->pv1)
|
||||
{
|
||||
vs.x = ((polyvertex_t *)gl_curline->pv1)->x;
|
||||
vs.y = ((polyvertex_t *)gl_curline->pv1)->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
vs.x = FIXED_TO_FLOAT(gl_curline->v1->x);
|
||||
vs.y = FIXED_TO_FLOAT(gl_curline->v1->y);
|
||||
}
|
||||
if (gl_curline->pv2)
|
||||
{
|
||||
ve.x = ((polyvertex_t *)gl_curline->pv2)->x;
|
||||
ve.y = ((polyvertex_t *)gl_curline->pv2)->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ve.x = FIXED_TO_FLOAT(gl_curline->v2->x);
|
||||
ve.y = FIXED_TO_FLOAT(gl_curline->v2->y);
|
||||
}
|
||||
|
||||
v1x = FLOAT_TO_FIXED(vs.x);
|
||||
v1y = FLOAT_TO_FIXED(vs.y);
|
||||
|
@ -1868,10 +1900,26 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks
|
|||
if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope)
|
||||
{
|
||||
fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t
|
||||
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
|
||||
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
|
||||
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
|
||||
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
|
||||
if (gl_curline->pv1)
|
||||
{
|
||||
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
|
||||
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
|
||||
}
|
||||
else
|
||||
{
|
||||
v1x = gl_curline->v1->x;
|
||||
v1y = gl_curline->v1->y;
|
||||
}
|
||||
if (gl_curline->pv2)
|
||||
{
|
||||
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
|
||||
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
|
||||
}
|
||||
else
|
||||
{
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
}
|
||||
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
||||
end1 = P_GetZAt(slope, v1x, v1y, normalheight); \
|
||||
end2 = P_GetZAt(slope, v2x, v2y, normalheight);
|
||||
|
@ -2244,10 +2292,26 @@ static void HWR_AddLine(seg_t * line)
|
|||
|
||||
gl_curline = line;
|
||||
|
||||
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
|
||||
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
|
||||
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
|
||||
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
|
||||
if (gl_curline->pv1)
|
||||
{
|
||||
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
|
||||
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
|
||||
}
|
||||
else
|
||||
{
|
||||
v1x = gl_curline->v1->x;
|
||||
v1y = gl_curline->v1->y;
|
||||
}
|
||||
if (gl_curline->pv2)
|
||||
{
|
||||
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
|
||||
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
|
||||
}
|
||||
else
|
||||
{
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
}
|
||||
|
||||
// OPTIMIZE: quickly reject orthogonal back sides.
|
||||
angle1 = R_PointToAngle64(v1x, v1y);
|
||||
|
|
Loading…
Reference in a new issue