Fixed a potential crash when changing the ceiling texture to or from sky. Fixes #517

This commit is contained in:
biwa 2021-01-06 19:37:58 +01:00
parent 7cec462a15
commit 478690e08f

View file

@ -218,13 +218,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
else if(side.Other != null && side.Other.Sector != null && side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName)
{
// Update upper side of the neightbouring sector
BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
if(other != null && other.Sides != null)
// Update upper side of the neightbouring sector, but only when the visual sector already exists. GetVisualSector will create
// the visual sector when it does not exist yet, which in turn modifies the mode's allsectors list, which is illegal when done
// from the mode's UpdateChangedObjects method, since that method iterates over allsectors.
// See https://github.com/jewalky/UltimateDoomBuilder/issues/517
if (mode.VisualSectorExists(side.Other.Sector))
{
parts = other.GetSidedefParts(side.Other);
if(parts.upper != null && parts.upper.Triangles > 0)
parts.upper.UpdateSkyRenderFlag();
BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
if (other != null && other.Sides != null)
{
parts = other.GetSidedefParts(side.Other);
if (parts.upper != null && parts.upper.Triangles > 0)
parts.upper.UpdateSkyRenderFlag();
}
}
}
}