1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Use hash rather than online ID as primary lookup key when presenting score

Something I ran into when investigating
https://github.com/ppy/osu/issues/28169.

If there are two scores with the same online ID available in the
database - for instance, one being recorded locally, and one recorded by
spectator server, of one single play - the lookup code would use online
ID first to find the score and pick any first one that matched. This
could lead to the wrong replay being refetched and presented / exported.

(In the case of the aforementioned issue, I was confused as to whether
after restarting spectator server midway through a play and importing
the replay saved by spectator server after the restart, I was seeing a
complete replay with no dropped frames, even though there was nothing in
the code that prevented the frame drop. It turns out that I was getting
presented the locally recorded replay instead all along.)

Instead, jiggle the fallback preference to use hash first.
This commit is contained in:
Bartłomiej Dach 2024-05-14 11:14:46 +02:00
parent 7f3fde2a25
commit 03a279a48d
No known key found for this signature in database

View File

@ -88,15 +88,15 @@ namespace osu.Game.Scoring
{
ScoreInfo? databasedScoreInfo = null;
if (originalScoreInfo is ScoreInfo scoreInfo)
databasedScoreInfo = Query(s => s.Hash == scoreInfo.Hash);
if (originalScoreInfo.OnlineID > 0)
databasedScoreInfo = Query(s => s.OnlineID == originalScoreInfo.OnlineID);
databasedScoreInfo ??= Query(s => s.OnlineID == originalScoreInfo.OnlineID);
if (originalScoreInfo.LegacyOnlineID > 0)
databasedScoreInfo ??= Query(s => s.LegacyOnlineID == originalScoreInfo.LegacyOnlineID);
if (originalScoreInfo is ScoreInfo scoreInfo)
databasedScoreInfo ??= Query(s => s.Hash == scoreInfo.Hash);
if (databasedScoreInfo == null)
{
Logger.Log("The requested score could not be found locally.", LoggingTarget.Information);