- fixed a crash when initializing the GL portal data for an incomplete or inactive portal. Also did a bit of cleanup on this code, the 'delta' member was never used.

This commit is contained in:
Christoph Oelckers 2016-07-16 12:45:49 +02:00
parent a2f56b6ef5
commit c5db5dff99
3 changed files with 33 additions and 39 deletions

View File

@ -56,9 +56,8 @@ struct FPortal
struct FGLLinePortal struct FGLLinePortal
{ {
// defines the complete span of this portal // defines the complete span of this portal, if this is of type PORTT_LINKED.
vertex_t *v1, *v2; // vertices, from v1 to v2 vertex_t *v1 = nullptr, *v2 = nullptr; // vertices, from v1 to v2
DVector2 delta; // precalculated v2 - v1 for side checking
TArray<FLinePortal *> lines; TArray<FLinePortal *> lines;
int validcount = 0; int validcount = 0;
}; };

View File

@ -443,16 +443,14 @@ void gl_InitPortals()
tempindex[i] = glLinePortals.Size(); tempindex[i] = glLinePortals.Size();
line_t *pSrcLine = linePortals[i].mOrigin; line_t *pSrcLine = linePortals[i].mOrigin;
line_t *pLine = linePortals[i].mDestination; line_t *pLine = linePortals[i].mDestination;
FGLLinePortal glport; FGLLinePortal &glport = glLinePortals[glLinePortals.Reserve(1)];
glport.v1 = pLine->v1;
glport.v2 = pLine->v2;
glport.delta = { 0, 0 };
glport.lines.Push(&linePortals[i]); glport.lines.Push(&linePortals[i]);
glLinePortals.Push(glport);
// We cannot do this grouping for non-linked portals because they can be changed at run time. // We cannot do this grouping for non-linked portals because they can be changed at run time.
if (linePortals[i].mType == PORTT_LINKED) if (linePortals[i].mType == PORTT_LINKED && pLine != nullptr)
{
glport.v1 = pLine->v1;
glport.v2 = pLine->v2;
do do
{ {
// now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match // now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match
@ -477,9 +475,9 @@ void gl_InitPortals()
// The lines connect and both source and destination are colinear, so this is a match // The lines connect and both source and destination are colinear, so this is a match
gotsome = true; gotsome = true;
tempindex[j] = tempindex[i]; tempindex[j] = tempindex[i];
if (pLine->v1 == pLine2->v2) glLinePortals[tempindex[i]].v1 = pLine2->v1; if (pLine->v1 == pLine2->v2) glport.v1 = pLine2->v1;
else glLinePortals[tempindex[i]].v2 = pLine2->v2; else glport.v2 = pLine2->v2;
glLinePortals[tempindex[i]].lines.Push(&linePortals[j]); glport.lines.Push(&linePortals[j]);
} }
} }
} }
@ -487,9 +485,6 @@ void gl_InitPortals()
} while (gotsome); } while (gotsome);
} }
} }
for (auto glport : glLinePortals)
{
glport.delta = glport.v2->fPos() - glport.v1->fPos();
} }
linePortalToGL.Resize(linePortals.Size()); linePortalToGL.Resize(linePortals.Size());
for (unsigned i = 0; i < linePortals.Size(); i++) for (unsigned i = 0; i < linePortals.Size(); i++)

View File

@ -195,7 +195,7 @@ struct GLLinePortal : public GLPortal
GLLinePortal(FGLLinePortal *line) GLLinePortal(FGLLinePortal *line)
{ {
if (line->lines[0]->mType != PORTT_LINKED) if (line->lines[0]->mType != PORTT_LINKED || line->v1 == nullptr)
{ {
// For non-linked portals we must check the actual linedef. // For non-linked portals we must check the actual linedef.
line_t *lline = line->lines[0]->mDestination; line_t *lline = line->lines[0]->mDestination;