Merge pull request #25916 from OliBomby/fix-zero-length

Fix near zero-length sliders being placeable and crashing the game
This commit is contained in:
Dan Balasescu 2023-12-20 12:38:45 +09:00 committed by GitHub
commit ff6a02be82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 6 deletions

View File

@ -3,6 +3,7 @@
using System;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Edit;
@ -17,7 +18,7 @@ public partial class BananaShowerPlacementBlueprint : CatchPlacementBlueprint<Ba
private double placementStartTime;
private double placementEndTime;
protected override bool IsValidForPlacement => HitObject.Duration > 0;
protected override bool IsValidForPlacement => Precision.DefinitelyBigger(HitObject.Duration, 0);
public BananaShowerPlacementBlueprint()
{

View File

@ -4,6 +4,7 @@
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Edit;
@ -24,7 +25,7 @@ public partial class JuiceStreamPlacementBlueprint : CatchPlacementBlueprint<Jui
private InputManager inputManager = null!;
protected override bool IsValidForPlacement => HitObject.Duration > 0;
protected override bool IsValidForPlacement => Precision.DefinitelyBigger(HitObject.Duration, 0);
public JuiceStreamPlacementBlueprint()
{

View File

@ -5,6 +5,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
@ -23,7 +24,7 @@ public partial class HoldNotePlacementBlueprint : ManiaPlacementBlueprint<HoldNo
[Resolved]
private IScrollingInfo scrollingInfo { get; set; } = null!;
protected override bool IsValidForPlacement => HitObject.Duration > 0;
protected override bool IsValidForPlacement => Precision.DefinitelyBigger(HitObject.Duration, 0);
public HoldNotePlacementBlueprint()
: base(new HoldNote())

View File

@ -6,6 +6,7 @@
using System;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
@ -25,7 +26,7 @@ public partial class TaikoSpanPlacementBlueprint : PlacementBlueprint
private readonly IHasDuration spanPlacementObject;
protected override bool IsValidForPlacement => spanPlacementObject.Duration > 0;
protected override bool IsValidForPlacement => Precision.DefinitelyBigger(spanPlacementObject.Duration, 0);
public TaikoSpanPlacementBlueprint(HitObject hitObject)
: base(hitObject)

View File

@ -31,7 +31,7 @@ public class SliderPath
/// </summary>
public readonly Bindable<double?> ExpectedDistance = new Bindable<double?>();
public bool HasValidLength => Distance > 0;
public bool HasValidLength => Precision.DefinitelyBigger(Distance, 0);
/// <summary>
/// The control points of the path.

View File

@ -409,7 +409,7 @@ protected override void OnDrag(DragEvent e)
double lengthOfOneRepeat = repeatHitObject.Duration / (repeatHitObject.RepeatCount + 1);
int proposedCount = Math.Max(0, (int)Math.Round(proposedDuration / lengthOfOneRepeat) - 1);
if (proposedCount == repeatHitObject.RepeatCount || lengthOfOneRepeat == 0)
if (proposedCount == repeatHitObject.RepeatCount || Precision.AlmostEquals(lengthOfOneRepeat, 0))
return;
repeatHitObject.RepeatCount = proposedCount;