mirror of
https://github.com/ppy/osu
synced 2024-12-14 10:57:41 +00:00
Merge pull request #3627 from smoogipoo/fix-beatmap-version
Preserve the beatmap's version when using databased BeatmapInfo
This commit is contained in:
commit
7ed6520052
@ -8,11 +8,13 @@ using OpenTK.Graphics;
|
||||
using osu.Game.Tests.Resources;
|
||||
using System.Linq;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
@ -21,6 +23,25 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
[TestFixture]
|
||||
public class LegacyBeatmapDecoderTest
|
||||
{
|
||||
[Test]
|
||||
public void TestDecodeBeatmapVersion()
|
||||
{
|
||||
using (var resStream = Resource.OpenResource("beatmap-version.osu"))
|
||||
using (var stream = new StreamReader(resStream))
|
||||
{
|
||||
var decoder = Decoder.GetDecoder<Beatmap>(stream);
|
||||
|
||||
stream.BaseStream.Position = 0;
|
||||
stream.DiscardBufferedData();
|
||||
|
||||
var working = new TestWorkingBeatmap(decoder.Decode(stream));
|
||||
|
||||
Assert.AreEqual(6, working.BeatmapInfo.BeatmapVersion);
|
||||
Assert.AreEqual(6, working.Beatmap.BeatmapInfo.BeatmapVersion);
|
||||
Assert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapVersion);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeBeatmapGeneral()
|
||||
{
|
||||
|
1
osu.Game.Tests/Resources/beatmap-version.osu
Normal file
1
osu.Game.Tests/Resources/beatmap-version.osu
Normal file
@ -0,0 +1 @@
|
||||
osu file format v6
|
@ -19,7 +19,6 @@ namespace osu.Game.Beatmaps
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
//TODO: should be in database
|
||||
public int BeatmapVersion;
|
||||
|
||||
private int? onlineBeatmapID;
|
||||
|
@ -41,8 +41,13 @@ namespace osu.Game.Beatmaps
|
||||
beatmap = new RecyclableLazy<IBeatmap>(() =>
|
||||
{
|
||||
var b = GetBeatmap() ?? new Beatmap();
|
||||
// use the database-backed info.
|
||||
|
||||
// The original beatmap version needs to be preserved as the database doesn't contain it
|
||||
BeatmapInfo.BeatmapVersion = b.BeatmapInfo.BeatmapVersion;
|
||||
|
||||
// Use the database-backed info for more up-to-date values (beatmap id, ranked status, etc)
|
||||
b.BeatmapInfo = BeatmapInfo;
|
||||
|
||||
return b;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user