- made RRRA E1L3 fix a bit more robust by neutralizing the unconnected one of the two walls.

Also fix thw 'warning C4456: declaration of 'i' hides previous local declaration' warning.
This commit is contained in:
Christoph Oelckers 2021-12-30 00:37:08 +01:00
parent 4d8028831b
commit c61d82cead
2 changed files with 21 additions and 8 deletions

View file

@ -763,14 +763,27 @@ void setWallSectors()
i++;
}
for (unsigned i = 1; i < wall.Size() - 1; i++)
//
for (unsigned ii = 1; ii < wall.Size() - 1; ii++)
{
// two maps in RRRA have this error. Delete one of those 2 walls.
if (wall[i].point2 == wall[i + 1].point2)
if (wall[ii].point2 == wall[ii + 1].point2)
{
wall[i].nextwall = -1;
wall[i].nextsector = -1;
wall[i].point2 = i;
auto w1 = wall[ii].lastWall(false);
auto w2 = wall[ii + 1].lastWall(false);
// Neutralize the bad one of the two walls.
if (w1 == nullptr)
{
wall[ii].nextwall = -1;
wall[ii].nextsector = -1;
wall[ii].point2 = ii;
}
else if (w2 == nullptr)
{
wall[ii+1].nextwall = -1;
wall[ii+1].nextsector = -1;
wall[ii+1].point2 = ii;
}
}
}

View file

@ -391,7 +391,7 @@ struct walltype
sectortype* nextSector() const;
sectortype* sectorp() const;
walltype* nextWall() const;
walltype* lastWall() const;
walltype* lastWall(bool fast = true) const;
walltype* point2Wall() const;
vec2_t delta() const { return point2Wall()->pos - pos; }
vec2_t center() const { return(point2Wall()->pos + pos) / 2; }
@ -671,10 +671,10 @@ inline sectortype* walltype::sectorp() const
return &::sector[sector]; // cannot be -1 in a proper map.
}
inline walltype* walltype::lastWall() const
inline walltype* walltype::lastWall(bool fast) const
{
int index = wall.IndexOf(this);
if (index > 0 && wall[index - 1].point2 == index) return &wall[index - 1];
if (fast && index > 0 && wall[index - 1].point2 == index) return &wall[index - 1];
int check = index;
for (int i = 0; i < 16384; i++) // don't run endlessly in case of malformed sectors.