1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Fix crash when same ruleset loaded more than once

If the same ruleset assembly was present more than once in the current
AppDomain, the game would crash. We recently saw this in Rider EAP9.
While this behaviour may change going forward, this is a good safety
measure regardless.
This commit is contained in:
Dean Herbert 2020-08-11 11:09:02 +09:00
parent dd2f677aa4
commit 471ed968e3

View File

@ -191,6 +191,11 @@ namespace osu.Game.Rulesets
if (loadedAssemblies.ContainsKey(assembly))
return;
// the same assembly may be loaded twice in the same AppDomain (currently a thing in certain Rider versions https://youtrack.jetbrains.com/issue/RIDER-48799).
// as a failsafe, also compare by FullName.
if (loadedAssemblies.Any(a => a.Key.FullName == assembly.FullName))
return;
try
{
loadedAssemblies[assembly] = assembly.GetTypes().First(t => t.IsPublic && t.IsSubclassOf(typeof(Ruleset)));