- Check for maps with bad setup of their wall lists.

Lo Wang In Time's map 11 does not include wall 0 into its sector, which caused crashes when trying to triangulate this sector.
This commit is contained in:
Christoph Oelckers 2021-07-06 10:29:24 +02:00
parent 64fc0b66b2
commit 62a5a720e8
2 changed files with 18 additions and 10 deletions

View file

@ -55,6 +55,23 @@ TArray<int> splits;
void hw_BuildSections()
{
for (int i = 0; i < numsectors; i++)
{
// Fix maps which do not set their wallptr to the first wall. Lo Wang In Time's map 11 is such a case.
int wp = sector[i].wallptr;
while (wp > 0 && wall[wp - 1].nextwall >= 0 && wall[wall[wp - 1].nextwall].nextsector == i)
{
sector[i].wallptr--;
sector[i].wallnum++;
wp--;
}
sections[i].sector = i;
sections[i].lines.Resize(sector[i].wallnum);
for (int j = 0; j < sector[i].wallnum; j++) sections[i].lines[j] = sector[i].wallptr + j;
sectionspersector[i].Resize(1);
sectionspersector[i][0] = i;
}
// Initial setup just creates a 1:1 mapping of walls to section lines and sectors to sections.
numsectionlines = numwalls;
numsections = numsectors;
@ -68,15 +85,6 @@ void hw_BuildSections()
sectionLines[i].point2index = wall[i].point2 - sector[wall[i].sector].wallptr;
}
for (int i = 0; i < numsectors; i++)
{
sections[i].sector = i;
sections[i].lines.Resize(sector[i].wallnum);
for (int j = 0; j < sector[i].wallnum; j++) sections[i].lines[j] = sector[i].wallptr + j;
sectionspersector[i].Resize(1);
sectionspersector[i][0] = i;
}
for (unsigned i = 0; i < splits.Size(); i += 3)
hw_SplitSector(splits[i], splits[i + 1], splits[i + 2]);
}

View file

@ -243,7 +243,7 @@ bool SectorGeometry::MakeVertices(unsigned int secnum, int plane, const FVector2
int s = start;
if (start >= 0 && start < numvertices)
{
while (!done[start])
while (start >= 0 && start < numvertices && !done[start])
{
auto sline = &sectionLines[sec->lines[start]];
auto wallp = &wall[sline->startpoint];