Skip to content

Commit d4fc669

Browse files
committed
Fix stable scores importing with a LegacyOnlineID of 0
Closes #33435. The root cause of the issue is that the user's database contained a whole lot of scores with `LegacyOnlineID` of 0, which would trip up https://github.com/ppy/osu/blob/97e6187f0d7c3dbee896596a623e34627135bf0e/osu.Game/Extensions/ModelExtensions.cs#L128-L129 as that method would thus consider scores that are not the same as the same because of the zero, which later trips up https://github.com/ppy/osu/blob/97e6187f0d7c3dbee896596a623e34627135bf0e/osu.Game/Screens/Ranking/SoloResultsScreen.cs#L79 which ends up inserting `Score` into the list several times, which causes the crash. You might remember that I tried to fix this once before in #24794. What I did not realise, however, is that stable *can still produce replays* that have an online ID of zero in them, because zero *is just `default(long)`*: https://github.com/peppy/osu-stable-reference/blob/7205341bb70000a87fa1bd54e7642772e2af85d7/osu!/GameplayElements/Scoring/Score.cs#L123 https://github.com/peppy/osu-stable-reference/blob/7205341bb70000a87fa1bd54e7642772e2af85d7/osu!/GameplayElements/Scoring/Score.cs#L350 The alternative way of fixing this would be just to change `MatchesOnlineID` to reject zeroes, but I think this is a saner overall direction.
1 parent 909440a commit d4fc669

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

osu.Game/Database/RealmAccess.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ public class RealmAccess : IDisposable
9898
/// 46 2024-12-26 Change beat snap divisor bindings to match stable directionality ¯\_(ツ)_/¯.
9999
/// 47 2025-01-21 Remove right mouse button binding for absolute scroll. Never use mouse buttons (or scroll) for global actions.
100100
/// 48 2025-03-19 Clear online status for all qualified beatmaps (some were stuck in a qualified state due to local caching issues).
101+
/// 49 2025-06-10 Reset the LegacyOnlineID to -1 for all scores that have it set to 0 (which is semantically the same) for consistency of handling with OnlineID.
101102
/// </summary>
102-
private const int schema_version = 48;
103+
private const int schema_version = 49;
103104

104105
/// <summary>
105106
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
@@ -1255,6 +1256,12 @@ void remapKeyBinding(int oldAction, int newAction)
12551256
foreach (var beatmap in beatmaps)
12561257
beatmap.ResetOnlineInfo(resetOnlineId: false);
12571258
break;
1259+
1260+
case 49:
1261+
foreach (var score in migration.NewRealm.All<ScoreInfo>().Where(s => s.LegacyOnlineID == 0))
1262+
score.LegacyOnlineID = -1;
1263+
1264+
break;
12581265
}
12591266

12601267
Logger.Log($"Migration completed in {stopwatch.ElapsedMilliseconds}ms");

osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public Score Parse(Stream stream)
110110
else if (version >= 20121008)
111111
scoreInfo.LegacyOnlineID = sr.ReadInt32();
112112

113+
if (scoreInfo.LegacyOnlineID == 0)
114+
scoreInfo.LegacyOnlineID = -1;
115+
113116
byte[] compressedScoreInfo = null;
114117

115118
if (version >= 30000001)

0 commit comments

Comments
 (0)