3D Floor Mode: fixed a crash when duplicating 3D floor geometry and there was not enough space in the control sector area

This commit is contained in:
biwa 2020-06-21 01:22:17 +02:00
parent 18834f1fc7
commit 0017caa419

View file

@ -1509,6 +1509,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
{ {
List<Sector> selectedsectors; List<Sector> selectedsectors;
List<ThreeDFloor> duplicatethreedfloors; List<ThreeDFloor> duplicatethreedfloors;
List<DrawnVertex> drawnvertices;
Dictionary<int, int> tagreplacements = new Dictionary<int, int>(); Dictionary<int, int> tagreplacements = new Dictionary<int, int>();
List<int> tagblacklist = new List<int>(); List<int> tagblacklist = new List<int>();
@ -1537,10 +1538,18 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
return; return;
} }
try
{
drawnvertices = BuilderPlug.Me.ControlSectorArea.GetNewControlSectorVertices(duplicatethreedfloors.Count);
}
catch (NoSpaceInCSAException e)
{
General.Interface.DisplayStatus(StatusType.Warning, string.Format("Could not create 3D floor control sector geometry: {0}", e.Message));
return;
}
General.Map.UndoRedo.CreateUndo(duplicateundodescription); General.Map.UndoRedo.CreateUndo(duplicateundodescription);
List<DrawnVertex> drawnvertices = BuilderPlug.Me.ControlSectorArea.GetNewControlSectorVertices(duplicatethreedfloors.Count);
// Create a new control sector for each 3D floor that needs to be duplicated. Force it to generate // Create a new control sector for each 3D floor that needs to be duplicated. Force it to generate
// a new tag, and store the old (current) and new tag // a new tag, and store the old (current) and new tag
foreach (ThreeDFloor tdf in duplicatethreedfloors) foreach (ThreeDFloor tdf in duplicatethreedfloors)
@ -1548,17 +1557,14 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
int newtag; int newtag;
int oldtag = tdf.UDMFTag; int oldtag = tdf.UDMFTag;
try if(!tdf.CreateGeometry(new List<int>(), drawnvertices, true, out newtag))
{ {
tdf.CreateGeometry(new List<int>(), drawnvertices, true, out newtag); // No need to show a warning here, that was already done by CreateGeometry
tagreplacements[oldtag] = newtag;
}
catch(NoSpaceInCSAException e)
{
General.Interface.DisplayStatus(StatusType.Warning, string.Format("Could not create 3D floor control sector geometry: {0}", e.Message));
General.Map.UndoRedo.WithdrawUndo(); General.Map.UndoRedo.WithdrawUndo();
return; return;
} }
tagreplacements[oldtag] = newtag;
} }
// Replace the old tags of the selected sectors with the new tags // Replace the old tags of the selected sectors with the new tags