1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 06:52:55 +08:00

Merge pull request #16622 from peppy/fix-results-score-switch-crash

Fix crash at results screen when viewing another score panel after playing
This commit is contained in:
Dan Balasescu 2022-01-26 16:59:39 +09:00 committed by GitHub
commit 4a51bab9ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

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

View File

@ -11,7 +11,7 @@ namespace osu.Game.Models
{
public int OnlineID { get; set; } = 1;
public string Username { get; set; }
public string Username { get; set; } = string.Empty;
public bool IsBot => false;

View File

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