- Don't crash when loading UDMF maps with invalid sidedef references.

SVN r3569 (trunk)
This commit is contained in:
Randy Heit 2012-04-19 02:14:34 +00:00
parent 93694dadc1
commit c1f3621a4c

View file

@ -1438,8 +1438,9 @@ public:
numsides = sidecount;
lines = new line_t[numlines];
sides = new side_t[numsides];
int line, side;
for(int line = 0, side = 0; line < numlines; line++)
for(line = 0, side = 0; line < numlines; line++)
{
short tempalpha[2] = { SHRT_MIN, SHRT_MIN };
@ -1450,6 +1451,8 @@ public:
if (lines[line].sidedef[sd] != NULL)
{
int mapside = int(intptr_t(lines[line].sidedef[sd]))-1;
if (mapside < sidecount)
{
sides[side] = ParsedSides[mapside];
sides[side].linedef = &lines[line];
sides[side].sector = &sectors[intptr_t(sides[side].sector)];
@ -1460,11 +1463,22 @@ public:
side++;
}
else
{
lines[line].sidedef[sd] = NULL;
}
}
}
P_AdjustLine(&lines[line]);
P_FinishLoadingLineDef(&lines[line], tempalpha[0]);
}
assert(side <= numsides);
if (side < numsides)
{
Printf("Map had %d invalid side references\n", numsides - side);
numsides = side;
}
}
//===========================================================================