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

Fix ScoreInfo.RealmUser not getting deep cloned correctly

I'm still not at all happy with the play-to-results flow (with multiple
clones), but this will have to do for now.
This commit is contained in:
Dean Herbert 2022-01-26 14:25:55 +09:00
parent cdd63e428c
commit 3491b77c8c
2 changed files with 9 additions and 0 deletions

View File

@ -26,12 +26,16 @@ namespace osu.Game.Tests.NonVisual
score.Statistics[HitResult.Good]++; score.Statistics[HitResult.Good]++;
score.Rank = ScoreRank.X; score.Rank = ScoreRank.X;
score.RealmUser.Username = "test";
Assert.That(scoreCopy.Statistics[HitResult.Good], Is.EqualTo(10)); Assert.That(scoreCopy.Statistics[HitResult.Good], Is.EqualTo(10));
Assert.That(score.Statistics[HitResult.Good], Is.EqualTo(11)); Assert.That(score.Statistics[HitResult.Good], Is.EqualTo(11));
Assert.That(scoreCopy.Rank, Is.EqualTo(ScoreRank.B)); Assert.That(scoreCopy.Rank, Is.EqualTo(ScoreRank.B));
Assert.That(score.Rank, Is.EqualTo(ScoreRank.X)); Assert.That(score.Rank, Is.EqualTo(ScoreRank.X));
Assert.That(scoreCopy.RealmUser.Username, Is.EqualTo("test"));
Assert.That(score.Rank, Is.Empty);
} }
[Test] [Test]

View File

@ -133,6 +133,11 @@ namespace osu.Game.Scoring
var clone = (ScoreInfo)this.Detach().MemberwiseClone(); var clone = (ScoreInfo)this.Detach().MemberwiseClone();
clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics); clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics);
clone.RealmUser = new RealmUser
{
OnlineID = RealmUser.OnlineID,
Username = RealmUser.Username,
};
return clone; return clone;
} }