mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
- Fixed crash on maps with out of range sidedef and sector numbers, adapted from PRBoom.
This commit is contained in:
parent
332dfa4d6f
commit
8c539539df
1 changed files with 18 additions and 9 deletions
|
@ -1702,13 +1702,6 @@ void MapLoader::LoadLineDefs (MapData * map)
|
|||
}
|
||||
else
|
||||
{
|
||||
// patch missing first sides instead of crashing out.
|
||||
// Visual glitches are better than not being able to play.
|
||||
if (LittleShort(mld->sidenum[0]) == NO_INDEX)
|
||||
{
|
||||
Printf("Line %d has no first side.\n", i);
|
||||
mld->sidenum[0] = 0;
|
||||
}
|
||||
sidecount++;
|
||||
if (LittleShort(mld->sidenum[1]) != NO_INDEX)
|
||||
sidecount++;
|
||||
|
@ -1747,6 +1740,22 @@ void MapLoader::LoadLineDefs (MapData * map)
|
|||
ProcessEDLinedef(ld, mld->tag);
|
||||
}
|
||||
#endif
|
||||
// cph 2006/09/30 - fix sidedef errors right away.
|
||||
for (int j=0; j < 2; j++)
|
||||
{
|
||||
if (LittleShort(mld->sidenum[j]) != NO_INDEX && mld->sidenum[j] >= Level->sides.Size())
|
||||
{
|
||||
mld->sidenum[j] = 0; // dummy sidedef
|
||||
Printf("Linedef %d has a bad sidedef\n", i);
|
||||
}
|
||||
}
|
||||
// patch missing first sides instead of crashing out.
|
||||
// Visual glitches are better than not being able to play.
|
||||
if (LittleShort(mld->sidenum[0]) == NO_INDEX)
|
||||
{
|
||||
Printf("Line %d has no first side.\n", i);
|
||||
mld->sidenum[0] = 0;
|
||||
}
|
||||
|
||||
ld->v1 = &Level->vertexes[LittleShort(mld->v1)];
|
||||
ld->v2 = &Level->vertexes[LittleShort(mld->v2)];
|
||||
|
@ -2180,11 +2189,11 @@ void MapLoader::LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex)
|
|||
// killough 4/4/98: allow sidedef texture names to be overloaded
|
||||
// killough 4/11/98: refined to allow colormaps to work as wall
|
||||
// textures if invalid as colormaps but valid as textures.
|
||||
|
||||
// cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead
|
||||
if ((unsigned)LittleShort(msd->sector)>=Level->sectors.Size())
|
||||
{
|
||||
Printf (PRINT_HIGH, "Sidedef %d has a bad sector\n", i);
|
||||
sd->sector = sec = nullptr;
|
||||
sd->sector = sec = &Level->sectors[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue