mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 19:12:57 +08:00
Merge branch 'master' into realm-integration/faster-migration
This commit is contained in:
commit
0b1736def6
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
|
Difficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
|
||||||
Ruleset = ruleset
|
Ruleset = ruleset
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
|
Difficulty = new BeatmapDifficulty { CircleSize = 6 },
|
||||||
Ruleset = ruleset
|
Ruleset = ruleset
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
|
Difficulty = new BeatmapDifficulty { CircleSize = 6 },
|
||||||
Ruleset = ruleset
|
Ruleset = ruleset
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
HitObjects = new List<HitObject> { new Fruit() },
|
HitObjects = new List<HitObject> { new Fruit() },
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
Artist = @"Unknown",
|
Artist = @"Unknown",
|
||||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 3.6f }
|
Difficulty = new BeatmapDifficulty { CircleSize = 3.6f }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 5, SliderMultiplier = 2 },
|
Difficulty = new BeatmapDifficulty { CircleSize = 5, SliderMultiplier = 2 },
|
||||||
Ruleset = ruleset
|
Ruleset = ruleset
|
||||||
},
|
},
|
||||||
HitObjects = new List<HitObject>
|
HitObjects = new List<HitObject>
|
||||||
|
@ -264,7 +264,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
},
|
},
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
SliderTickRate = 4,
|
SliderTickRate = 4,
|
||||||
OverallDifficulty = 10,
|
OverallDifficulty = 10,
|
||||||
@ -306,7 +306,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
},
|
},
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = tick_rate },
|
Difficulty = new BeatmapDifficulty { SliderTickRate = tick_rate },
|
||||||
Ruleset = new ManiaRuleset().RulesetInfo
|
Ruleset = new ManiaRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -383,7 +383,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
},
|
},
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
||||||
Ruleset = new ManiaRuleset().RulesetInfo
|
Ruleset = new ManiaRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
|
|
||||||
public static int GetColumnCountForNonConvert(BeatmapInfo beatmapInfo)
|
public static int GetColumnCountForNonConvert(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
double roundedCircleSize = Math.Round(beatmapInfo.BaseDifficulty.CircleSize);
|
double roundedCircleSize = Math.Round(beatmapInfo.Difficulty.CircleSize);
|
||||||
return (int)Math.Max(1, roundedCircleSize);
|
return (int)Math.Max(1, roundedCircleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
|||||||
var beatmap = new Beatmap<HitObject>
|
var beatmap = new Beatmap<HitObject>
|
||||||
{
|
{
|
||||||
HitObjects = hitObjects,
|
HitObjects = hitObjects,
|
||||||
BeatmapInfo = new BeatmapInfo { BaseDifficulty = new BeatmapDifficulty(beatmapDifficulty) }
|
BeatmapInfo = new BeatmapInfo { Difficulty = new BeatmapDifficulty(beatmapDifficulty) }
|
||||||
};
|
};
|
||||||
|
|
||||||
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
|
||||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
CircleSize = 8
|
CircleSize = 8
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
|
Difficulty = new BeatmapDifficulty { CircleSize = 6 },
|
||||||
Ruleset = ruleset
|
Ruleset = ruleset
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { OverallDifficulty = 10 },
|
Difficulty = new BeatmapDifficulty { OverallDifficulty = 10 },
|
||||||
Ruleset = ruleset
|
Ruleset = ruleset
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -358,7 +358,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
},
|
},
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
||||||
Ruleset = new OsuRuleset().RulesetInfo
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -364,7 +364,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
HitObjects = hitObjects,
|
HitObjects = hitObjects,
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
||||||
Ruleset = new OsuRuleset().RulesetInfo
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
|
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
Artist = @"Unknown",
|
Artist = @"Unknown",
|
||||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
|||||||
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
|
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
Artist = "Unknown",
|
Artist = "Unknown",
|
||||||
|
@ -128,7 +128,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
MD5Hash = md5Hash,
|
MD5Hash = md5Hash,
|
||||||
Ruleset = new OsuRuleset().RulesetInfo,
|
Ruleset = new OsuRuleset().RulesetInfo,
|
||||||
BaseDifficulty = new BeatmapDifficulty()
|
Difficulty = new BeatmapDifficulty()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,9 @@ namespace osu.Game.Tests.Database
|
|||||||
{
|
{
|
||||||
detachedBeatmapSet = live.Detach();
|
detachedBeatmapSet = live.Detach();
|
||||||
|
|
||||||
Assert.AreEqual(live.Files.Count, detachedBeatmapSet.Files.Count);
|
// files are omitted
|
||||||
Assert.AreEqual(live.Files.Select(f => f.File).Count(), detachedBeatmapSet.Files.Select(f => f.File).Count());
|
Assert.AreEqual(0, detachedBeatmapSet.Files.Count);
|
||||||
|
|
||||||
Assert.AreEqual(live.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count);
|
Assert.AreEqual(live.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count);
|
||||||
Assert.AreEqual(live.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
|
Assert.AreEqual(live.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
|
||||||
Assert.AreEqual(live.Metadata, detachedBeatmapSet.Metadata);
|
Assert.AreEqual(live.Metadata, detachedBeatmapSet.Metadata);
|
||||||
@ -67,11 +68,9 @@ namespace osu.Game.Tests.Database
|
|||||||
Debug.Assert(detachedBeatmapSet != null);
|
Debug.Assert(detachedBeatmapSet != null);
|
||||||
|
|
||||||
// Check detached instances can all be accessed without throwing.
|
// Check detached instances can all be accessed without throwing.
|
||||||
Assert.NotNull(detachedBeatmapSet.Files.Count);
|
Assert.AreEqual(0, detachedBeatmapSet.Files.Count);
|
||||||
Assert.NotZero(detachedBeatmapSet.Files.Select(f => f.File).Count());
|
|
||||||
Assert.NotNull(detachedBeatmapSet.Beatmaps.Count);
|
Assert.NotNull(detachedBeatmapSet.Beatmaps.Count);
|
||||||
Assert.NotZero(detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
|
Assert.NotZero(detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
|
||||||
Assert.NotNull(detachedBeatmapSet.Beatmaps.First().Path);
|
|
||||||
Assert.NotNull(detachedBeatmapSet.Metadata);
|
Assert.NotNull(detachedBeatmapSet.Metadata);
|
||||||
|
|
||||||
// Check cyclic reference to beatmap set
|
// Check cyclic reference to beatmap set
|
||||||
@ -96,9 +95,12 @@ namespace osu.Game.Tests.Database
|
|||||||
Assert.NotNull(beatmapSet);
|
Assert.NotNull(beatmapSet);
|
||||||
Debug.Assert(beatmapSet != null);
|
Debug.Assert(beatmapSet != null);
|
||||||
|
|
||||||
BeatmapSetInfo? detachedBeatmapSet = null;
|
// Detach at the BeatmapInfo point, similar to what GetWorkingBeatmap does.
|
||||||
|
BeatmapInfo? detachedBeatmap = null;
|
||||||
|
|
||||||
beatmapSet.PerformRead(s => detachedBeatmapSet = s.Detach());
|
beatmapSet.PerformRead(s => detachedBeatmap = s.Beatmaps.First().Detach());
|
||||||
|
|
||||||
|
BeatmapSetInfo? detachedBeatmapSet = detachedBeatmap?.BeatmapSet;
|
||||||
|
|
||||||
Debug.Assert(detachedBeatmapSet != null);
|
Debug.Assert(detachedBeatmapSet != null);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
{
|
{
|
||||||
Ruleset = new RulesetInfo { OnlineID = 0 },
|
Ruleset = new RulesetInfo { OnlineID = 0 },
|
||||||
StarRating = 4.0d,
|
StarRating = 4.0d,
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
ApproachRate = 5.0f,
|
ApproachRate = 5.0f,
|
||||||
DrainRate = 3.0f,
|
DrainRate = 3.0f,
|
||||||
|
@ -133,7 +133,7 @@ namespace osu.Game.Tests.Resources
|
|||||||
Hash = Guid.NewGuid().ToString().ComputeMD5Hash(),
|
Hash = Guid.NewGuid().ToString().ComputeMD5Hash(),
|
||||||
Ruleset = rulesetInfo,
|
Ruleset = rulesetInfo,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
OverallDifficulty = diff,
|
OverallDifficulty = diff,
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
|
Difficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
|
||||||
Ruleset = ruleset
|
Ruleset = ruleset
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Length = length,
|
Length = length,
|
||||||
BPM = bpm,
|
BPM = bpm,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
BaseDifficulty = new BeatmapDifficulty()
|
Difficulty = new BeatmapDifficulty()
|
||||||
};
|
};
|
||||||
|
|
||||||
beatmaps.Add(beatmap);
|
beatmaps.Add(beatmap);
|
||||||
|
@ -114,14 +114,14 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
{
|
{
|
||||||
OnlineID = i * 1024,
|
OnlineID = i * 1024,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineID = i * 2048,
|
OnlineID = i * 2048,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
Author = { Username = "SomeAuthor" },
|
Author = { Username = "SomeAuthor" },
|
||||||
Title = "import"
|
Title = "import"
|
||||||
},
|
},
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Ruleset = new OsuRuleset().RulesetInfo
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
Author = { Username = "SomeAuthor" },
|
Author = { Username = "SomeAuthor" },
|
||||||
Title = "import"
|
Title = "import"
|
||||||
},
|
},
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Ruleset = new OsuRuleset().RulesetInfo
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private BeatmapInfo exampleBeatmapInfo => new BeatmapInfo
|
private BeatmapInfo exampleBeatmapInfo => new BeatmapInfo
|
||||||
{
|
{
|
||||||
Ruleset = rulesets.AvailableRulesets.First(),
|
Ruleset = rulesets.AvailableRulesets.First(),
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
CircleSize = 7.2f,
|
CircleSize = 7.2f,
|
||||||
DrainRate = 3,
|
DrainRate = 3,
|
||||||
@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException(),
|
Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException(),
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
CircleSize = 5,
|
CircleSize = 5,
|
||||||
DrainRate = 4.3f,
|
DrainRate = 4.3f,
|
||||||
|
@ -216,7 +216,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
StarRating = 6,
|
StarRating = 6,
|
||||||
DifficultyName = $"{ruleset.ShortName}Version",
|
DifficultyName = $"{ruleset.ShortName}Version",
|
||||||
BaseDifficulty = new BeatmapDifficulty()
|
Difficulty = new BeatmapDifficulty()
|
||||||
},
|
},
|
||||||
HitObjects = objects
|
HitObjects = objects
|
||||||
};
|
};
|
||||||
|
@ -267,7 +267,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
OverallDifficulty = value,
|
OverallDifficulty = value,
|
||||||
CircleSize = value,
|
CircleSize = value,
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps
|
|||||||
difficulty = value;
|
difficulty = value;
|
||||||
|
|
||||||
if (beatmapInfo != null)
|
if (beatmapInfo != null)
|
||||||
beatmapInfo.BaseDifficulty = difficulty.Clone();
|
beatmapInfo.Difficulty = difficulty.Clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
beatmapInfo = value;
|
beatmapInfo = value;
|
||||||
|
|
||||||
if (beatmapInfo?.BaseDifficulty != null)
|
if (beatmapInfo?.Difficulty != null)
|
||||||
Difficulty = beatmapInfo.BaseDifficulty.Clone();
|
Difficulty = beatmapInfo.Difficulty.Clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Beatmaps
|
|||||||
Author = { Username = @"Unknown Creator" },
|
Author = { Username = @"Unknown Creator" },
|
||||||
},
|
},
|
||||||
DifficultyName = @"Normal",
|
DifficultyName = @"Normal",
|
||||||
BaseDifficulty = Difficulty,
|
Difficulty = Difficulty,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +167,7 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Ignored]
|
[Ignored]
|
||||||
|
[Obsolete("Use BeatmapInfo.Difficulty instead.")] // can be removed 20220719
|
||||||
public BeatmapDifficulty BaseDifficulty
|
public BeatmapDifficulty BaseDifficulty
|
||||||
{
|
{
|
||||||
get => Difficulty;
|
get => Difficulty;
|
||||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
WidescreenStoryboard = true,
|
WidescreenStoryboard = true,
|
||||||
@ -299,7 +299,23 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
#region Implementation of IWorkingBeatmapCache
|
#region Implementation of IWorkingBeatmapCache
|
||||||
|
|
||||||
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo? importedBeatmap) => workingBeatmapCache.GetWorkingBeatmap(importedBeatmap);
|
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo? importedBeatmap)
|
||||||
|
{
|
||||||
|
// Detached sets don't come with files.
|
||||||
|
// If we seem to be missing files, now is a good time to re-fetch.
|
||||||
|
if (importedBeatmap?.BeatmapSet?.Files.Count == 0)
|
||||||
|
{
|
||||||
|
using (var realm = contextFactory.CreateContext())
|
||||||
|
{
|
||||||
|
var refetch = realm.Find<BeatmapInfo>(importedBeatmap.ID)?.Detach();
|
||||||
|
|
||||||
|
if (refetch != null)
|
||||||
|
importedBeatmap = refetch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return workingBeatmapCache.GetWorkingBeatmap(importedBeatmap);
|
||||||
|
}
|
||||||
|
|
||||||
public WorkingBeatmap GetWorkingBeatmap(ILive<BeatmapInfo>? importedBeatmap)
|
public WorkingBeatmap GetWorkingBeatmap(ILive<BeatmapInfo>? importedBeatmap)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Beatmaps
|
|||||||
// Warning: The directionality here is important. Changes have to be copied *from* beatmapContent (which comes from editor and is being saved)
|
// Warning: The directionality here is important. Changes have to be copied *from* beatmapContent (which comes from editor and is being saved)
|
||||||
// *to* the beatmapInfo (which is a database model and needs to receive values without the taiko slider velocity multiplier for correct operation).
|
// *to* the beatmapInfo (which is a database model and needs to receive values without the taiko slider velocity multiplier for correct operation).
|
||||||
// CopyTo() will undo such adjustments, while CopyFrom() will not.
|
// CopyTo() will undo such adjustments, while CopyFrom() will not.
|
||||||
beatmapContent.Difficulty.CopyTo(beatmapInfo.BaseDifficulty);
|
beatmapContent.Difficulty.CopyTo(beatmapInfo.Difficulty);
|
||||||
|
|
||||||
// All changes to metadata are made in the provided beatmapInfo, so this should be copied to the `IBeatmap` before encoding.
|
// All changes to metadata are made in the provided beatmapInfo, so this should be copied to the `IBeatmap` before encoding.
|
||||||
beatmapContent.BeatmapInfo = beatmapInfo;
|
beatmapContent.BeatmapInfo = beatmapInfo;
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Beatmaps
|
|||||||
Title = "no beatmaps available!"
|
Title = "no beatmaps available!"
|
||||||
},
|
},
|
||||||
BeatmapSet = new BeatmapSetInfo(),
|
BeatmapSet = new BeatmapSetInfo(),
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
Difficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
DrainRate = 0,
|
DrainRate = 0,
|
||||||
CircleSize = 0,
|
CircleSize = 0,
|
||||||
|
@ -21,6 +21,7 @@ using osu.Game.Stores;
|
|||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using Realms;
|
using Realms;
|
||||||
|
using Realms.Exceptions;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
@ -105,8 +106,20 @@ namespace osu.Game.Database
|
|||||||
if (!Filename.EndsWith(realm_extension, StringComparison.Ordinal))
|
if (!Filename.EndsWith(realm_extension, StringComparison.Ordinal))
|
||||||
Filename += realm_extension;
|
Filename += realm_extension;
|
||||||
|
|
||||||
// This method triggers the first `CreateContext` call, which will implicitly run realm migrations and bring the schema up-to-date.
|
try
|
||||||
cleanupPendingDeletions();
|
{
|
||||||
|
// This method triggers the first `CreateContext` call, which will implicitly run realm migrations and bring the schema up-to-date.
|
||||||
|
cleanupPendingDeletions();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error(e, "Realm startup failed with unrecoverable error; starting with a fresh database. A backup of your database has been made.");
|
||||||
|
|
||||||
|
CreateBackup($"{Filename.Replace(realm_extension, string.Empty)}_{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}_corrupt{realm_extension}");
|
||||||
|
storage.Delete(Filename);
|
||||||
|
|
||||||
|
cleanupPendingDeletions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupPendingDeletions()
|
private void cleanupPendingDeletions()
|
||||||
@ -403,14 +416,23 @@ namespace osu.Game.Database
|
|||||||
const int sleep_length = 200;
|
const int sleep_length = 200;
|
||||||
int timeout = 5000;
|
int timeout = 5000;
|
||||||
|
|
||||||
// see https://github.com/realm/realm-dotnet/discussions/2657
|
try
|
||||||
while (!Compact())
|
|
||||||
{
|
{
|
||||||
Thread.Sleep(sleep_length);
|
// see https://github.com/realm/realm-dotnet/discussions/2657
|
||||||
timeout -= sleep_length;
|
while (!Compact())
|
||||||
|
{
|
||||||
|
Thread.Sleep(sleep_length);
|
||||||
|
timeout -= sleep_length;
|
||||||
|
|
||||||
if (timeout < 0)
|
if (timeout < 0)
|
||||||
throw new TimeoutException(@"Took too long to acquire lock");
|
throw new TimeoutException(@"Took too long to acquire lock");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (RealmException e)
|
||||||
|
{
|
||||||
|
// Compact may fail if the realm is in a bad state.
|
||||||
|
// We still want to continue with the blocking operation, though.
|
||||||
|
Logger.Log($"Realm compact failed with error {e}", LoggingTarget.Database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -74,21 +74,18 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private static readonly IMapper mapper = new MapperConfiguration(c =>
|
private static readonly IMapper mapper = new MapperConfiguration(c =>
|
||||||
{
|
{
|
||||||
c.ShouldMapField = fi => false;
|
applyCommonConfiguration(c);
|
||||||
|
|
||||||
// This is specifically to avoid mapping explicit interface implementations.
|
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
||||||
// If we want to limit this further, we can avoid mapping properties with no setter that are not IList<>.
|
.MaxDepth(2)
|
||||||
// Takes a bit of effort to determine whether this is the case though, see https://stackoverflow.com/questions/951536/how-do-i-tell-whether-a-type-implements-ilist
|
.AfterMap((s, d) =>
|
||||||
c.ShouldMapProperty = pi => pi.GetMethod?.IsPublic == true;
|
{
|
||||||
|
foreach (var beatmap in d.Beatmaps)
|
||||||
|
beatmap.BeatmapSet = d;
|
||||||
|
});
|
||||||
|
|
||||||
c.CreateMap<RealmKeyBinding, RealmKeyBinding>();
|
// This can be further optimised to reduce cyclic retrievals, similar to the optimised set mapper below.
|
||||||
c.CreateMap<BeatmapMetadata, BeatmapMetadata>();
|
// Only hasn't been done yet as we detach at the point of BeatmapInfo less often.
|
||||||
c.CreateMap<BeatmapDifficulty, BeatmapDifficulty>();
|
|
||||||
c.CreateMap<RulesetInfo, RulesetInfo>();
|
|
||||||
c.CreateMap<ScoreInfo, ScoreInfo>();
|
|
||||||
c.CreateMap<RealmUser, RealmUser>();
|
|
||||||
c.CreateMap<RealmFile, RealmFile>();
|
|
||||||
c.CreateMap<RealmNamedFileUsage, RealmNamedFileUsage>();
|
|
||||||
c.CreateMap<BeatmapInfo, BeatmapInfo>()
|
c.CreateMap<BeatmapInfo, BeatmapInfo>()
|
||||||
.MaxDepth(2)
|
.MaxDepth(2)
|
||||||
.AfterMap((s, d) =>
|
.AfterMap((s, d) =>
|
||||||
@ -102,14 +99,39 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}).CreateMapper();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A slightly optimised mapper that avoids double-fetches in cyclic reference.
|
||||||
|
/// </summary>
|
||||||
|
private static readonly IMapper beatmap_set_mapper = new MapperConfiguration(c =>
|
||||||
|
{
|
||||||
|
applyCommonConfiguration(c);
|
||||||
|
|
||||||
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
||||||
.MaxDepth(2)
|
.MaxDepth(2)
|
||||||
|
.ForMember(b => b.Files, cc => cc.Ignore())
|
||||||
.AfterMap((s, d) =>
|
.AfterMap((s, d) =>
|
||||||
{
|
{
|
||||||
foreach (var beatmap in d.Beatmaps)
|
foreach (var beatmap in d.Beatmaps)
|
||||||
beatmap.BeatmapSet = d;
|
beatmap.BeatmapSet = d;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
c.CreateMap<BeatmapInfo, BeatmapInfo>()
|
||||||
|
.MaxDepth(1)
|
||||||
|
// This is not required as it will be populated in the `AfterMap` call from the `BeatmapInfo`'s parent.
|
||||||
|
.ForMember(b => b.BeatmapSet, cc => cc.Ignore());
|
||||||
|
}).CreateMapper();
|
||||||
|
|
||||||
|
private static void applyCommonConfiguration(IMapperConfigurationExpression c)
|
||||||
|
{
|
||||||
|
c.ShouldMapField = fi => false;
|
||||||
|
|
||||||
|
// This is specifically to avoid mapping explicit interface implementations.
|
||||||
|
// If we want to limit this further, we can avoid mapping properties with no setter that are not IList<>.
|
||||||
|
// Takes a bit of effort to determine whether this is the case though, see https://stackoverflow.com/questions/951536/how-do-i-tell-whether-a-type-implements-ilist
|
||||||
|
c.ShouldMapProperty = pi => pi.GetMethod?.IsPublic == true;
|
||||||
|
|
||||||
c.Internal().ForAllMaps((typeMap, expression) =>
|
c.Internal().ForAllMaps((typeMap, expression) =>
|
||||||
{
|
{
|
||||||
expression.ForAllMembers(m =>
|
expression.ForAllMembers(m =>
|
||||||
@ -118,7 +140,16 @@ namespace osu.Game.Database
|
|||||||
m.Ignore();
|
m.Ignore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).CreateMapper();
|
|
||||||
|
c.CreateMap<RealmKeyBinding, RealmKeyBinding>();
|
||||||
|
c.CreateMap<BeatmapMetadata, BeatmapMetadata>();
|
||||||
|
c.CreateMap<BeatmapDifficulty, BeatmapDifficulty>();
|
||||||
|
c.CreateMap<RulesetInfo, RulesetInfo>();
|
||||||
|
c.CreateMap<ScoreInfo, ScoreInfo>();
|
||||||
|
c.CreateMap<RealmUser, RealmUser>();
|
||||||
|
c.CreateMap<RealmFile, RealmFile>();
|
||||||
|
c.CreateMap<RealmNamedFileUsage, RealmNamedFileUsage>();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a detached copy of the each item in the collection.
|
/// Create a detached copy of the each item in the collection.
|
||||||
@ -153,6 +184,9 @@ namespace osu.Game.Database
|
|||||||
if (!item.IsManaged)
|
if (!item.IsManaged)
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
|
if (item is BeatmapSetInfo)
|
||||||
|
return beatmap_set_mapper.Map<T>(item);
|
||||||
|
|
||||||
return mapper.Map<T>(item);
|
return mapper.Map<T>(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var difficulty = beatmap.Value.BeatmapInfo.BaseDifficulty;
|
var difficulty = beatmap.Value.BeatmapInfo.Difficulty;
|
||||||
|
|
||||||
// generally should always be implemented, else the slider will have a zero default.
|
// generally should always be implemented, else the slider will have a zero default.
|
||||||
if (difficultyBindable.ReadCurrentFromDifficulty == null)
|
if (difficultyBindable.ReadCurrentFromDifficulty == null)
|
||||||
|
@ -39,10 +39,10 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}
|
}
|
||||||
|
|
||||||
match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(BeatmapInfo.StarRating);
|
match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(BeatmapInfo.StarRating);
|
||||||
match &= !criteria.ApproachRate.HasFilter || criteria.ApproachRate.IsInRange(BeatmapInfo.BaseDifficulty.ApproachRate);
|
match &= !criteria.ApproachRate.HasFilter || criteria.ApproachRate.IsInRange(BeatmapInfo.Difficulty.ApproachRate);
|
||||||
match &= !criteria.DrainRate.HasFilter || criteria.DrainRate.IsInRange(BeatmapInfo.BaseDifficulty.DrainRate);
|
match &= !criteria.DrainRate.HasFilter || criteria.DrainRate.IsInRange(BeatmapInfo.Difficulty.DrainRate);
|
||||||
match &= !criteria.CircleSize.HasFilter || criteria.CircleSize.IsInRange(BeatmapInfo.BaseDifficulty.CircleSize);
|
match &= !criteria.CircleSize.HasFilter || criteria.CircleSize.IsInRange(BeatmapInfo.Difficulty.CircleSize);
|
||||||
match &= !criteria.OverallDifficulty.HasFilter || criteria.OverallDifficulty.IsInRange(BeatmapInfo.BaseDifficulty.OverallDifficulty);
|
match &= !criteria.OverallDifficulty.HasFilter || criteria.OverallDifficulty.IsInRange(BeatmapInfo.Difficulty.OverallDifficulty);
|
||||||
match &= !criteria.Length.HasFilter || criteria.Length.IsInRange(BeatmapInfo.Length);
|
match &= !criteria.Length.HasFilter || criteria.Length.IsInRange(BeatmapInfo.Length);
|
||||||
match &= !criteria.BPM.HasFilter || criteria.BPM.IsInRange(BeatmapInfo.BPM);
|
match &= !criteria.BPM.HasFilter || criteria.BPM.IsInRange(BeatmapInfo.BPM);
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ namespace osu.Game.Stores
|
|||||||
}
|
}
|
||||||
|
|
||||||
var decodedInfo = decoded.BeatmapInfo;
|
var decodedInfo = decoded.BeatmapInfo;
|
||||||
var decodedDifficulty = decodedInfo.BaseDifficulty;
|
var decodedDifficulty = decodedInfo.Difficulty;
|
||||||
|
|
||||||
var ruleset = realm.All<RulesetInfo>().FirstOrDefault(r => r.OnlineID == decodedInfo.RulesetID);
|
var ruleset = realm.All<RulesetInfo>().FirstOrDefault(r => r.OnlineID == decodedInfo.RulesetID);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user