mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:03:08 +08:00
Fix rulesets not matching in dictionary lookups due to missing GetHashCode implementation
This commit is contained in:
parent
80f7d5a0a3
commit
9c1badd2e3
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets
|
namespace osu.Game.Rulesets
|
||||||
@ -23,6 +24,19 @@ namespace osu.Game.Rulesets
|
|||||||
|
|
||||||
public bool Equals(RulesetInfo other) => other != null && ID == other.ID && Available == other.Available && Name == other.Name && InstantiationInfo == other.InstantiationInfo;
|
public bool Equals(RulesetInfo other) => other != null && ID == other.ID && Available == other.Available && Name == other.Name && InstantiationInfo == other.InstantiationInfo;
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
var hashCode = ID.HasValue ? ID.GetHashCode() : 0;
|
||||||
|
hashCode = (hashCode * 397) ^ (InstantiationInfo != null ? InstantiationInfo.GetHashCode() : 0);
|
||||||
|
hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
|
||||||
|
hashCode = (hashCode * 397) ^ Available.GetHashCode();
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Name} ({ShortName}) ID: {ID}";
|
public override string ToString() => $"{Name} ({ShortName}) ID: {ID}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets
|
|||||||
public RulesetStore(IDatabaseContextFactory factory)
|
public RulesetStore(IDatabaseContextFactory factory)
|
||||||
: base(factory)
|
: base(factory)
|
||||||
{
|
{
|
||||||
AddMissingRulesets();
|
addMissingRulesets();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -52,13 +52,13 @@ namespace osu.Game.Rulesets
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// All available rulesets.
|
/// All available rulesets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<RulesetInfo> AvailableRulesets;
|
public IEnumerable<RulesetInfo> AvailableRulesets { get; private set; }
|
||||||
|
|
||||||
private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) => loaded_assemblies.Keys.FirstOrDefault(a => a.FullName == args.Name);
|
private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) => loaded_assemblies.Keys.FirstOrDefault(a => a.FullName == args.Name);
|
||||||
|
|
||||||
private const string ruleset_library_prefix = "osu.Game.Rulesets";
|
private const string ruleset_library_prefix = "osu.Game.Rulesets";
|
||||||
|
|
||||||
protected void AddMissingRulesets()
|
private void addMissingRulesets()
|
||||||
{
|
{
|
||||||
using (var usage = ContextFactory.GetForWrite())
|
using (var usage = ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user