From 06c6f55995993a72842f15f775afec30556e7d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Mon, 30 Apr 2018 00:43:32 -0700 Subject: [PATCH] Apply offset to end times on legacy converter --- osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs | 5 +++-- .../Rulesets/Objects/Legacy/ConvertHitObjectParser.cs | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs index 366b4f163f..655355913c 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs @@ -373,17 +373,18 @@ namespace osu.Game.Beatmaps.Formats if (parser == null) parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(); - var obj = parser.Parse(line); + var obj = parser.Parse(line, getOffsetTime()); if (obj != null) { - obj.StartTime = getOffsetTime(obj.StartTime); beatmap.HitObjects.Add(obj); } } private int getOffsetTime(int time) => time + (ApplyOffsets ? offset : 0); + private double getOffsetTime() => ApplyOffsets ? offset : 0; + private double getOffsetTime(double time) => time + (ApplyOffsets ? offset : 0); } } diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 95abc4edb3..9edd0f1f34 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -19,6 +19,11 @@ namespace osu.Game.Rulesets.Objects.Legacy public abstract class ConvertHitObjectParser : HitObjectParser { public override HitObject Parse(string text) + { + return Parse(text, 0); + } + + public HitObject Parse(string text, double offset) { try { @@ -146,7 +151,7 @@ namespace osu.Game.Rulesets.Objects.Legacy } else if ((type & ConvertHitObjectType.Spinner) > 0) { - result = CreateSpinner(new Vector2(512, 384) / 2, Convert.ToDouble(split[5], CultureInfo.InvariantCulture)); + result = CreateSpinner(new Vector2(512, 384) / 2, Convert.ToDouble(split[5], CultureInfo.InvariantCulture) + offset); if (split.Length > 6) readCustomSampleBanks(split[6], bankInfo); @@ -164,13 +169,13 @@ namespace osu.Game.Rulesets.Objects.Legacy readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo); } - result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime); + result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime + offset); } if (result == null) throw new InvalidOperationException($@"Unknown hit object type {type}."); - result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture); + result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture) + offset; result.Samples = convertSoundType(soundType, bankInfo); return result;