mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Hack to make sure even (extra)subsectors without planepolys have segs adjusted
this fixes a crash in (old) GFZ2 at the ramp as a result of creating pv1/pv2. This probably means before pv1/pv2 there could have been some silly typecasting from vertex_t to polyvertex_t to get fixed vertex coords and such...
This commit is contained in:
parent
90cfa5ef16
commit
09eecd36b4
1 changed files with 23 additions and 21 deletions
|
@ -878,8 +878,8 @@ static void AdjustSegs(void)
|
||||||
count = subsectors[i].numlines;
|
count = subsectors[i].numlines;
|
||||||
lseg = &segs[subsectors[i].firstline];
|
lseg = &segs[subsectors[i].firstline];
|
||||||
p = extrasubsectors[i].planepoly;
|
p = extrasubsectors[i].planepoly;
|
||||||
if (!p)
|
//if (!p)
|
||||||
continue;
|
//continue;
|
||||||
for (; count--; lseg++)
|
for (; count--; lseg++)
|
||||||
{
|
{
|
||||||
float distv1,distv2,tmp;
|
float distv1,distv2,tmp;
|
||||||
|
@ -892,27 +892,29 @@ static void AdjustSegs(void)
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (j = 0; j < p->numpts; j++)
|
if (p) {
|
||||||
{
|
for (j = 0; j < p->numpts; j++)
|
||||||
distv1 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v1->x);
|
|
||||||
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v1->y);
|
|
||||||
distv1 = distv1*distv1+tmp*tmp;
|
|
||||||
if (distv1 <= nearv1)
|
|
||||||
{
|
{
|
||||||
v1found = j;
|
distv1 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v1->x);
|
||||||
nearv1 = distv1;
|
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v1->y);
|
||||||
}
|
distv1 = distv1*distv1+tmp*tmp;
|
||||||
// the same with v2
|
if (distv1 <= nearv1)
|
||||||
distv2 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v2->x);
|
{
|
||||||
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v2->y);
|
v1found = j;
|
||||||
distv2 = distv2*distv2+tmp*tmp;
|
nearv1 = distv1;
|
||||||
if (distv2 <= nearv2)
|
}
|
||||||
{
|
// the same with v2
|
||||||
v2found = j;
|
distv2 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v2->x);
|
||||||
nearv2 = distv2;
|
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v2->y);
|
||||||
|
distv2 = distv2*distv2+tmp*tmp;
|
||||||
|
if (distv2 <= nearv2)
|
||||||
|
{
|
||||||
|
v2found = j;
|
||||||
|
nearv2 = distv2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nearv1 <= NEARDIST*NEARDIST)
|
if (p && nearv1 <= NEARDIST*NEARDIST)
|
||||||
// share vertice with segs
|
// share vertice with segs
|
||||||
lseg->pv1 = &(p->pts[v1found]);
|
lseg->pv1 = &(p->pts[v1found]);
|
||||||
else
|
else
|
||||||
|
@ -927,7 +929,7 @@ static void AdjustSegs(void)
|
||||||
pv->y = FIXED_TO_FLOAT(lseg->v1->y);
|
pv->y = FIXED_TO_FLOAT(lseg->v1->y);
|
||||||
lseg->pv1 = pv;
|
lseg->pv1 = pv;
|
||||||
}
|
}
|
||||||
if (nearv2 <= NEARDIST*NEARDIST)
|
if (p && nearv2 <= NEARDIST*NEARDIST)
|
||||||
lseg->pv2 = &(p->pts[v2found]);
|
lseg->pv2 = &(p->pts[v2found]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue