1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Add bare minimum sanity checking of beatmap input values to make broken maps load

Resolves ppy/osu#1988.
This commit is contained in:
Dean Herbert 2018-02-28 18:12:24 +09:00
parent 968291c61e
commit 5b4fef0180
3 changed files with 10 additions and 7 deletions

View File

@ -3,7 +3,6 @@
using OpenTK;
using osu.Game.Rulesets.Objects.Types;
using System;
using System.Collections.Generic;
using osu.Game.Rulesets.Objects;
using System.Linq;
@ -120,14 +119,16 @@ namespace osu.Game.Rulesets.Osu.Objects
private void createTicks()
{
if (TickDistance == 0) return;
var length = Curve.Distance;
var tickDistance = Math.Min(TickDistance, length);
var tickDistance = MathHelper.Clamp(TickDistance, 0, length);
if (tickDistance == 0) return;
var minDistanceFromEnd = Velocity * 0.01;
for (var span = 0; span < this.SpanCount(); span++)
var spanCount = this.SpanCount();
for (var span = 0; span < spanCount; span++)
{
var spanStartTime = StartTime + span * SpanDuration;
var reversed = span % 2 == 1;

View File

@ -8,6 +8,7 @@ using OpenTK.Graphics;
using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Beatmaps.ControlPoints;
using OpenTK;
namespace osu.Game.Beatmaps.Formats
{
@ -319,7 +320,7 @@ namespace osu.Game.Beatmaps.Formats
beatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint
{
Time = time,
BeatLength = beatLength,
BeatLength = MathHelper.Clamp(beatLength, 100, 60000),
TimeSignature = timeSignature
});
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK;
using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
@ -29,7 +30,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
Position = position,
NewCombo = newCombo,
ControlPoints = controlPoints,
Distance = length,
Distance = Math.Max(0, length),
CurveType = curveType,
RepeatSamples = repeatSamples,
RepeatCount = repeatCount