From 53a665a034cfa95f926c3334c4a8e77bf370a803 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 12 Dec 2019 20:04:46 +0900 Subject: [PATCH] Fix sound types and banks not being written correctly --- .../Beatmaps/Formats/LegacyBeatmapEncoder.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index 0eeacf733d..4c8b83820d 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -236,6 +236,10 @@ namespace osu.Game.Beatmaps.Formats writer.Write(FormattableString.Invariant($"{positionData.Y},")); writer.Write(FormattableString.Invariant($"{hitObject.StartTime},")); writer.Write(FormattableString.Invariant($"{(int)hitObjectType},")); + + if (hitObject is IHasCurve _) + writer.Write(FormattableString.Invariant($"0,")); // A sound type of "none" is written since it's stored per-node + else writer.Write(FormattableString.Invariant($"{(int)toLegacyHitSoundType(hitObject.Samples)},")); if (hitObject is IHasCurve curveData) @@ -303,7 +307,11 @@ namespace osu.Game.Beatmaps.Formats else if (hitObject is IHasEndTime endTimeData) writer.Write(FormattableString.Invariant($"{endTimeData.EndTime},")); - writer.Write(getSampleBank(hitObject.Samples)); + if (hitObject is IHasCurve _) + writer.Write(getSampleBank(hitObject.Samples, zeroBanks: true)); // A bank of "none" is written since it's stored per-node + else + writer.Write(getSampleBank(hitObject.Samples)); + writer.Write(Environment.NewLine); } @@ -319,14 +327,11 @@ namespace osu.Game.Beatmaps.Formats { } - private string getSampleBank(IList samples, bool banksOnly = false) + private string getSampleBank(IList samples, bool banksOnly = false, bool zeroBanks = false) { LegacySampleBank normalBank = toLegacySampleBank(samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)?.Bank); LegacySampleBank addBank = toLegacySampleBank(samples.FirstOrDefault(s => !string.IsNullOrEmpty(s.Name) && s.Name != HitSampleInfo.HIT_NORMAL)?.Bank); - if (addBank == LegacySampleBank.None) - addBank = normalBank; - string customSampleBank = toLegacyCustomSampleBank(samples.FirstOrDefault()?.Suffix); string sampleFilename = samples.FirstOrDefault(s => string.IsNullOrEmpty(s.Name))?.LookupNames.First() ?? string.Empty; @@ -334,8 +339,8 @@ namespace osu.Game.Beatmaps.Formats StringBuilder sb = new StringBuilder(); - sb.Append(FormattableString.Invariant($"{(int)normalBank}:")); - sb.Append(FormattableString.Invariant($"{(int)addBank}")); + sb.Append(FormattableString.Invariant($"{(zeroBanks ? 0 : (int)normalBank)}:")); + sb.Append(FormattableString.Invariant($"{(zeroBanks ? 0 : (int)addBank)}")); if (!banksOnly) {