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

This commit is contained in:
biwa 2021-08-24 21:33:57 +02:00 committed by spherallic
parent 199108ba64
commit e13c836344
2 changed files with 36 additions and 4 deletions

View file

@ -724,7 +724,10 @@ namespace CodeImp.DoomBuilder.Config
defaultthingflags = new List<string>(setflags); defaultthingflags = new List<string>(setflags);
} }
// This applies default settings to a thing /// <summary>
/// This applies the settings of the last edited thing to the given thing.
/// </summary>
/// <param name="t">Thing to apply the settings to</param>
public void ApplyDefaultThingSettings(Thing t) public void ApplyDefaultThingSettings(Thing t)
{ {
t.FullType = defaultthingtype; t.FullType = defaultthingtype;
@ -743,6 +746,36 @@ namespace CodeImp.DoomBuilder.Config
} }
} }
/// <summary>
/// Applies clean thing settings to the given thing, with the flags and aruments set in the game's config.
/// </summary>
/// <param name="t">Thing to apply the settings to</param>
/// <param name="type">Optional thing type. If not set the current thing type will be used, otherwise the type will be changed and used</param>
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 // This attempts to find the default drawing settings
public void FindDefaultDrawSettings() public void FindDefaultDrawSettings()
{ {

View file

@ -760,8 +760,7 @@ namespace CodeImp.DoomBuilder.Editing
{ {
// We have to ignore property changes, otherwise the undo manager will try to record the changes // We have to ignore property changes, otherwise the undo manager will try to record the changes
General.Map.UndoRedo.IgnorePropChanges = true; General.Map.UndoRedo.IgnorePropChanges = true;
General.Settings.ApplyDefaultThingSettings(start); General.Settings.ApplyCleanThingSettings(start, 1);
start.Type = 1;
} }
else else
{ {