From b77cb344d56ee1d92eee8b6d9fefc269ad7b165a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jan 2022 13:23:41 +0900 Subject: [PATCH] Use `ctor` rather than `MemberwiseClone` to guarantee a safer clone of `BeatmapDifficulty` --- osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs | 2 ++ osu.Game/Beatmaps/BeatmapDifficulty.cs | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index 61f932fd98..613874b7d6 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -208,6 +208,8 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps #region Overrides of BeatmapDifficulty + public override BeatmapDifficulty Clone() => new TaikoMultiplierAppliedDifficulty(this); + public override void CopyTo(BeatmapDifficulty other) { base.CopyTo(other); diff --git a/osu.Game/Beatmaps/BeatmapDifficulty.cs b/osu.Game/Beatmaps/BeatmapDifficulty.cs index f6e8b8c57d..7e0462f1e8 100644 --- a/osu.Game/Beatmaps/BeatmapDifficulty.cs +++ b/osu.Game/Beatmaps/BeatmapDifficulty.cs @@ -37,12 +37,7 @@ namespace osu.Game.Beatmaps /// /// Returns a shallow-clone of this . /// - public BeatmapDifficulty Clone() - { - var diff = (BeatmapDifficulty)MemberwiseClone(); - CopyTo(diff); - return diff; - } + public virtual BeatmapDifficulty Clone() => new BeatmapDifficulty(this); public virtual void CopyTo(BeatmapDifficulty difficulty) {