Fixed a bug that could cause a crash when going over the maximum linedef limit

This commit is contained in:
biwa 2021-07-16 17:56:55 +02:00
parent e0515c3209
commit 9944748cbf
3 changed files with 21 additions and 8 deletions

View file

@ -1400,7 +1400,8 @@ namespace CodeImp.DoomBuilder.Geometry
// Before this point, the new geometry is not linked with the existing geometry.
// Now perform standard geometry stitching to merge the new geometry with the rest
// of the map. The marked vertices indicate the new geometry.
map.StitchGeometry();
if (!map.StitchGeometry())
return false;
map.Update(true, false);
// Find our new lines again, because they have been merged with the other geometry

View file

@ -2129,22 +2129,36 @@ namespace CodeImp.DoomBuilder.Map
// Split moving lines with unselected vertices
ICollection<Vertex> nearbyfixedverts = FilterByArea(fixedverts, ref editarea);
if(!SplitLinesByVertices(movinglines, nearbyfixedverts, STITCH_DISTANCE, movinglines, mergemode))
if (!SplitLinesByVertices(movinglines, nearbyfixedverts, STITCH_DISTANCE, movinglines, mergemode))
{
EndAddRemove(); // Unfreeze arrays before returning
return false;
}
// Split non-moving lines with selected vertices
fixedlines = new HashSet<Linedef>(fixedlines.Where(fixedline => !fixedline.IsDisposed));
if(!SplitLinesByVertices(fixedlines, movingverts, STITCH_DISTANCE, movinglines, mergemode))
if (!SplitLinesByVertices(fixedlines, movingverts, STITCH_DISTANCE, movinglines, mergemode))
{
EndAddRemove(); // Unfreeze arrays before returning
return false;
}
//mxd. Split moving lines with fixed lines
if(!SplitLinesByLines(fixedlines, movinglines, mergemode)) return false;
if (!SplitLinesByLines(fixedlines, movinglines, mergemode))
{
EndAddRemove(); // Unfreeze arrays before returning
return false;
}
// Remove looped linedefs
RemoveLoopedLinedefs(movinglines);
// Join overlapping lines
if(!JoinOverlappingLines(movinglines)) return false;
if (!JoinOverlappingLines(movinglines))
{
EndAddRemove(); // Unfreeze arrays before returning
return false;
}
//mxd. Remove remaining new verts from dragged shape if possible
if(mergemode == MergeGeometryMode.REPLACE)

View file

@ -839,8 +839,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
else
{
// Drawing failed
// NOTE: I have to call this twice, because the first time only cancels this volatile mode
General.Map.UndoRedo.WithdrawUndo();
General.Map.UndoRedo.WithdrawUndo();
}
}