Fix mania notelock crashing with overlapping hitwindows

This commit is contained in:
smoogipoo 2020-11-11 12:37:00 +09:00
parent 6593aac3f2
commit 1173ef0890
4 changed files with 26 additions and 3 deletions

View File

@ -47,7 +47,7 @@ public void TestNoInput()
assertHeadJudgement(HitResult.Miss);
assertTickJudgement(HitResult.LargeTickMiss);
assertTailJudgement(HitResult.Miss);
assertNoteJudgement(HitResult.IgnoreHit);
assertNoteJudgement(HitResult.IgnoreMiss);
}
/// <summary>

View File

@ -54,6 +54,29 @@ public void TestPreviousHitWindowDoesNotExtendPastNextObject()
}
}
[Test]
public void TestMissAfterNextObjectStartTime()
{
var objects = new List<ManiaHitObject>
{
new HoldNote
{
StartTime = 1000,
EndTime = 1200,
},
new HoldNote
{
StartTime = 1220,
EndTime = 1420
}
};
performTest(objects, new List<ReplayFrame>());
addJudgementAssert(objects[0], HitResult.IgnoreMiss);
addJudgementAssert(objects[1], HitResult.IgnoreMiss);
}
private void addJudgementAssert(ManiaHitObject hitObject, HitResult result)
{
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}",

View File

@ -233,7 +233,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (Tail.AllJudged)
{
ApplyResult(r => r.Type = r.Judgement.MaxResult);
ApplyResult(r => r.Type = Tail.IsHit ? r.Judgement.MaxResult : r.Judgement.MinResult);
endHold();
}

View File

@ -44,7 +44,7 @@ public bool IsHittable(DrawableHitObject hitObject, double time)
/// <param name="hitObject">The <see cref="HitObject"/> that was hit.</param>
public void HandleHit(DrawableHitObject hitObject)
{
if (!IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset))
if (hitObject.IsHit && !IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset))
throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!");
foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime))