1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 14:12:56 +08:00

Fix conversion regression.

This commit is contained in:
Dean Herbert 2017-04-20 11:36:50 +09:00
parent 2a422ca5fa
commit 873599b359
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
3 changed files with 18 additions and 9 deletions

View File

@ -44,8 +44,10 @@ namespace osu.Game.Database
using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename))) using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename)))
using (SerializationReader sr = new SerializationReader(s)) using (SerializationReader sr = new SerializationReader(s))
{ {
var ruleset = rulesets.GetRuleset(sr.ReadByte()).CreateInstance(); score = new Score
score = new Score(); {
Ruleset = rulesets.GetRuleset(sr.ReadByte())
};
/* score.Pass = true;*/ /* score.Pass = true;*/
var version = sr.ReadInt32(); var version = sr.ReadInt32();

View File

@ -17,6 +17,12 @@ namespace osu.Game.Rulesets
public abstract IEnumerable<Mod> GetModsFor(ModType type); public abstract IEnumerable<Mod> GetModsFor(ModType type);
/// <summary>
/// Attempt to create a HitRenderer for the provided beatmap.
/// </summary>
/// <param name="beatmap"></param>
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
/// <returns></returns>
public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap); public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap);
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap); public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);

View File

@ -81,20 +81,21 @@ namespace osu.Game.Screens.Play
if (Beatmap == null) if (Beatmap == null)
throw new Exception("Beatmap was not loaded"); throw new Exception("Beatmap was not loaded");
ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset;
rulesetInstance = ruleset.CreateInstance();
try try
{ {
// Try using the preferred user ruleset HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap);
ruleset = osu == null ? Beatmap.BeatmapInfo.Ruleset : osu.Ruleset.Value;
} }
catch (BeatmapInvalidForModeException) catch (BeatmapInvalidForModeException)
{ {
// Default to the beatmap ruleset // we may fail to create a HitRenderer if the beatmap cannot be loaded with the user's preferred ruleset
// let's try again forcing the beatmap's ruleset.
ruleset = Beatmap.BeatmapInfo.Ruleset; ruleset = Beatmap.BeatmapInfo.Ruleset;
rulesetInstance = ruleset.CreateInstance();
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap);
} }
rulesetInstance = ruleset.CreateInstance();
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap);
} }
catch (Exception e) catch (Exception e)
{ {