- 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,21 +1451,34 @@ public:
if (lines[line].sidedef[sd] != NULL)
{
int mapside = int(intptr_t(lines[line].sidedef[sd]))-1;
sides[side] = ParsedSides[mapside];
sides[side].linedef = &lines[line];
sides[side].sector = &sectors[intptr_t(sides[side].sector)];
lines[line].sidedef[sd] = &sides[side];
if (mapside < sidecount)
{
sides[side] = ParsedSides[mapside];
sides[side].linedef = &lines[line];
sides[side].sector = &sectors[intptr_t(sides[side].sector)];
lines[line].sidedef[sd] = &sides[side];
P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside],
lines[line].special, lines[line].args[0], &tempalpha[sd], missingTex);
P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside],
lines[line].special, lines[line].args[0], &tempalpha[sd], missingTex);
side++;
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;
}
}
//===========================================================================