Merge pull request #4496 from smoogipoo/reinstantiate-mods

Fix mods being reused for difficulty calculation
This commit is contained in:
Dean Herbert 2019-03-20 19:10:52 +09:00 committed by GitHub
commit fe255c54d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Difficulty
/// <returns>A structure describing the difficulty of the beatmap.</returns>
public DifficultyAttributes Calculate(params Mod[] mods)
{
mods = mods.Select(m => m.CreateCopy()).ToArray();
beatmap.Mods.Value = mods;
IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo);

View File

@ -65,5 +65,10 @@ namespace osu.Game.Rulesets.Mods
/// </summary>
[JsonIgnore]
public virtual Type[] IncompatibleMods => new Type[] { };
/// <summary>
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
/// </summary>
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
}
}