mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 12:22:57 +08:00
Merge pull request #1225 from peppy/non-null-beatmap
Ensure that WorkingBeatmap's Beatmap is never null
This commit is contained in:
commit
6b3b012960
@ -17,7 +17,7 @@ namespace osu.Game.Beatmaps
|
|||||||
public class Beatmap<T>
|
public class Beatmap<T>
|
||||||
where T : HitObject
|
where T : HitObject
|
||||||
{
|
{
|
||||||
public BeatmapInfo BeatmapInfo;
|
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
||||||
public ControlPointInfo ControlPointInfo = new ControlPointInfo();
|
public ControlPointInfo ControlPointInfo = new ControlPointInfo();
|
||||||
public List<BreakPeriod> Breaks = new List<BreakPeriod>();
|
public List<BreakPeriod> Breaks = new List<BreakPeriod>();
|
||||||
public readonly List<Color4> ComboColors = new List<Color4>
|
public readonly List<Color4> ComboColors = new List<Color4>
|
||||||
@ -33,7 +33,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The HitObjects this Beatmap contains.
|
/// The HitObjects this Beatmap contains.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<T> HitObjects;
|
public List<T> HitObjects = new List<T>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Total amount of break time in the beatmap.
|
/// Total amount of break time in the beatmap.
|
||||||
@ -44,12 +44,13 @@ namespace osu.Game.Beatmaps
|
|||||||
/// Constructs a new beatmap.
|
/// Constructs a new beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="original">The original beatmap to use the parameters of.</param>
|
/// <param name="original">The original beatmap to use the parameters of.</param>
|
||||||
public Beatmap(Beatmap original = null)
|
public Beatmap(Beatmap<T> original = null)
|
||||||
{
|
{
|
||||||
BeatmapInfo = original?.BeatmapInfo.DeepClone() ?? BeatmapInfo;
|
BeatmapInfo = original?.BeatmapInfo.DeepClone() ?? BeatmapInfo;
|
||||||
ControlPointInfo = original?.ControlPointInfo ?? ControlPointInfo;
|
ControlPointInfo = original?.ControlPointInfo ?? ControlPointInfo;
|
||||||
Breaks = original?.Breaks ?? Breaks;
|
Breaks = original?.Breaks ?? Breaks;
|
||||||
ComboColors = original?.ComboColors ?? ComboColors;
|
ComboColors = original?.ComboColors ?? ComboColors;
|
||||||
|
HitObjects = original?.HitObjects ?? HitObjects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,6 @@ namespace osu.Game.Beatmaps
|
|||||||
public Beatmap(Beatmap original = null)
|
public Beatmap(Beatmap original = null)
|
||||||
: base(original)
|
: base(original)
|
||||||
{
|
{
|
||||||
HitObjects = original?.HitObjects;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ using osu.Framework.Audio.Track;
|
|||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
@ -42,10 +41,7 @@ namespace osu.Game.Beatmaps
|
|||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Beatmap GetBeatmap() => new Beatmap
|
protected override Beatmap GetBeatmap() => new Beatmap();
|
||||||
{
|
|
||||||
HitObjects = new List<HitObject>(),
|
|
||||||
};
|
|
||||||
|
|
||||||
protected override Texture GetBackground() => game.Textures.Get(@"Backgrounds/bg4");
|
protected override Texture GetBackground() => game.Textures.Get(@"Backgrounds/bg4");
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Formats
|
namespace osu.Game.Beatmaps.Formats
|
||||||
{
|
{
|
||||||
@ -47,7 +46,6 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
var beatmap = new Beatmap
|
var beatmap = new Beatmap
|
||||||
{
|
{
|
||||||
HitObjects = new List<HitObject>(),
|
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metadata = new BeatmapMetadata(),
|
Metadata = new BeatmapMetadata(),
|
||||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
if (beatmap != null) return beatmap;
|
if (beatmap != null) return beatmap;
|
||||||
|
|
||||||
beatmap = GetBeatmap();
|
beatmap = GetBeatmap() ?? new Beatmap();
|
||||||
|
|
||||||
// use the database-backed info.
|
// use the database-backed info.
|
||||||
beatmap.BeatmapInfo = BeatmapInfo;
|
beatmap.BeatmapInfo = BeatmapInfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user