From b20b2203ac92c3c261df43967fe6d6e140e58496 Mon Sep 17 00:00:00 2001 From: PercyDan54 <50285552+PercyDan54@users.noreply.github.com> Date: Mon, 11 Dec 2023 21:06:46 +0800 Subject: [PATCH] Fix mania Autoplay mod missing 0ms hold notes --- .../Mods/TestSceneManiaModAutoplay.cs | 42 +++++++++++++++++++ .../Replays/ManiaAutoGenerator.cs | 17 +++++--- 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModAutoplay.cs diff --git a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModAutoplay.cs b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModAutoplay.cs new file mode 100644 index 0000000000..f653f209c1 --- /dev/null +++ b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModAutoplay.cs @@ -0,0 +1,42 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using NUnit.Framework; +using osu.Game.Rulesets.Mania.Beatmaps; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Tests.Visual; + +namespace osu.Game.Rulesets.Mania.Tests.Mods +{ + public partial class TestSceneManiaModAutoplay : ModTestScene + { + protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset(); + + [Test] + public void TestPerfectScoreOnShortHoldNote() + { + CreateModTest(new ModTestData + { + Autoplay = true, + Beatmap = new ManiaBeatmap(new StageDefinition(1)) + { + HitObjects = new List + { + new HoldNote + { + StartTime = 100, + EndTime = 100, + }, + new HoldNote + { + StartTime = 100.1, + EndTime = 150, + }, + } + }, + PassCondition = () => Player.ScoreProcessor.Combo.Value == 4 + }); + } + } +} diff --git a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs index 7c8afdff12..dd3208bd89 100644 --- a/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs +++ b/osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs @@ -87,15 +87,22 @@ namespace osu.Game.Rulesets.Mania.Replays private double calculateReleaseTime(HitObject currentObject, HitObject? nextObject) { double endTime = currentObject.GetEndTime(); + double releaseDelay = RELEASE_DELAY; - if (currentObject is HoldNote) - // hold note releases must be timed exactly. - return endTime; + if (currentObject is HoldNote hold) + { + if (hold.Duration > 0) + // hold note releases must be timed exactly. + return endTime; + + // Special case for super short hold notes + releaseDelay = 1; + } bool canDelayKeyUpFully = nextObject == null || - nextObject.StartTime > endTime + RELEASE_DELAY; + nextObject.StartTime > endTime + releaseDelay; - return endTime + (canDelayKeyUpFully ? RELEASE_DELAY : (nextObject.AsNonNull().StartTime - endTime) * 0.9); + return endTime + (canDelayKeyUpFully ? releaseDelay : (nextObject.AsNonNull().StartTime - endTime) * 0.9); } protected override HitObject? GetNextObject(int currentIndex)