From e13c8363440fbabe58442150755d267e8012341d Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Tue, 24 Aug 2021 21:33:57 +0200 Subject: [PATCH] Classic modes: fixed a problem where "test from cursor position" wasn't working correctly when there was no player 1 start in the map and the last edited thing had its argument 0 set. Fixes #603 --- Source/Core/Config/ProgramConfiguration.cs | 37 ++++++++++++++++++++-- Source/Core/Editing/ClassicMode.cs | 3 +- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Source/Core/Config/ProgramConfiguration.cs b/Source/Core/Config/ProgramConfiguration.cs index 28baeb3..a9d988d 100644 --- a/Source/Core/Config/ProgramConfiguration.cs +++ b/Source/Core/Config/ProgramConfiguration.cs @@ -724,7 +724,10 @@ namespace CodeImp.DoomBuilder.Config defaultthingflags = new List(setflags); } - // This applies default settings to a thing + /// + /// This applies the settings of the last edited thing to the given thing. + /// + /// Thing to apply the settings to public void ApplyDefaultThingSettings(Thing t) { t.FullType = defaultthingtype; @@ -742,7 +745,37 @@ namespace CodeImp.DoomBuilder.Config t.Args[4] = (int)tti.Args[4].DefaultValue; } } - + + /// + /// Applies clean thing settings to the given thing, with the flags and aruments set in the game's config. + /// + /// Thing to apply the settings to + /// Optional thing type. If not set the current thing type will be used, otherwise the type will be changed and used + public void ApplyCleanThingSettings(Thing t, int type = 0) + { + if (type > 0) + t.Type = type; + + // Remove all current flags + foreach (string flag in t.GetFlags().Keys) + t.SetFlag(flag, false); + + // Add default flags + foreach(string flag in General.Map.Config.DefaultThingFlags) + t.SetFlag(flag, true); + + // Set default arguments + ThingTypeInfo tti = General.Map.Data.GetThingInfoEx(t.Type); + if (tti != null) + { + t.Args[0] = (int)tti.Args[0].DefaultValue; + t.Args[1] = (int)tti.Args[1].DefaultValue; + t.Args[2] = (int)tti.Args[2].DefaultValue; + t.Args[3] = (int)tti.Args[3].DefaultValue; + t.Args[4] = (int)tti.Args[4].DefaultValue; + } + } + // This attempts to find the default drawing settings public void FindDefaultDrawSettings() { diff --git a/Source/Core/Editing/ClassicMode.cs b/Source/Core/Editing/ClassicMode.cs index f21699c..e087db7 100644 --- a/Source/Core/Editing/ClassicMode.cs +++ b/Source/Core/Editing/ClassicMode.cs @@ -760,8 +760,7 @@ namespace CodeImp.DoomBuilder.Editing { // We have to ignore property changes, otherwise the undo manager will try to record the changes General.Map.UndoRedo.IgnorePropChanges = true; - General.Settings.ApplyDefaultThingSettings(start); - start.Type = 1; + General.Settings.ApplyCleanThingSettings(start, 1); } else {