mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-02-10 17:51:17 +00:00
Fixed a crash when undoing after using the "test from current position" action when no player 1 start is in the map. Fixes #573
This commit is contained in:
parent
3554508ffb
commit
a8c28e3f68
1 changed files with 17 additions and 8 deletions
|
@ -746,9 +746,12 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
}
|
||||
|
||||
if(start == null)
|
||||
if(start == null) // biwa. If there's no existing valid player start create one
|
||||
{
|
||||
// biwa. If there's no existing valid player start create one
|
||||
// Create an undo snapshot that can will be revoked in OnMapTestEnd to remove the temporary player start
|
||||
// This has to be done because just creating and deleting the thing will screw with the undo/redo. See https://github.com/jewalky/UltimateDoomBuilder/issues/573
|
||||
General.Map.UndoRedo.CreateUndo("Create temporary player thing");
|
||||
|
||||
playerStartIsTempThing = true;
|
||||
start = General.Map.Map.CreateThing();
|
||||
|
||||
|
@ -756,12 +759,14 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
{
|
||||
General.Settings.ApplyDefaultThingSettings(start);
|
||||
start.Type = 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
General.MainWindow.DisplayStatus(StatusType.Warning, "Can't test from current position: couldn't create player start!");
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
playerStartIsTempThing = false;
|
||||
}
|
||||
|
@ -780,12 +785,16 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
public override void OnMapTestEnd(bool testFromCurrentPosition)
|
||||
{
|
||||
if(testFromCurrentPosition)
|
||||
{
|
||||
if (playerStartIsTempThing) // biwa
|
||||
{
|
||||
General.Map.UndoRedo.WithdrawUndo();
|
||||
}
|
||||
else
|
||||
{
|
||||
//restore position
|
||||
playerStart.Move(playerStartPosition);
|
||||
|
||||
if (playerStartIsTempThing) // biwa
|
||||
General.Map.Map.RemoveThing(playerStart.Index);
|
||||
}
|
||||
|
||||
playerStart = null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue