From 0017caa419765ac2a7134fbb1a0485cd8b28867f Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Sun, 21 Jun 2020 01:22:17 +0200 Subject: [PATCH] 3D Floor Mode: fixed a crash when duplicating 3D floor geometry and there was not enough space in the control sector area --- Source/Plugins/3DFloorMode/ThreeDFloorMode.cs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs b/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs index 435caeb3..e8f99fcf 100644 --- a/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs +++ b/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs @@ -1509,6 +1509,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode { List selectedsectors; List duplicatethreedfloors; + List drawnvertices; Dictionary tagreplacements = new Dictionary(); List tagblacklist = new List(); @@ -1537,10 +1538,18 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode 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); - - List 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 // a new tag, and store the old (current) and new tag foreach (ThreeDFloor tdf in duplicatethreedfloors) @@ -1548,17 +1557,14 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode int newtag; int oldtag = tdf.UDMFTag; - try + if(!tdf.CreateGeometry(new List(), drawnvertices, true, out newtag)) { - tdf.CreateGeometry(new List(), drawnvertices, true, out newtag); - tagreplacements[oldtag] = newtag; - } - catch(NoSpaceInCSAException e) - { - General.Interface.DisplayStatus(StatusType.Warning, string.Format("Could not create 3D floor control sector geometry: {0}", e.Message)); + // No need to show a warning here, that was already done by CreateGeometry General.Map.UndoRedo.WithdrawUndo(); return; } + + tagreplacements[oldtag] = newtag; } // Replace the old tags of the selected sectors with the new tags