1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 03:22:55 +08:00

Inline binary reading to avoid polluting RealmAccess with nested class

This commit is contained in:
Dean Herbert 2023-06-09 17:34:27 +09:00
parent a9071e7afd
commit 53f935714e

View File

@ -912,9 +912,14 @@ namespace osu.Game.Database
if (stream == null) if (stream == null)
continue; continue;
int version = new ReplayVersionParser().Parse(stream); // Trimmed down logic from LegacyScoreDecoder to extract the version from replays.
if (version < LegacyScoreEncoder.FIRST_LAZER_VERSION) using (SerializationReader sr = new SerializationReader(stream))
score.IsLegacyScore = true; {
sr.ReadByte(); // Ruleset.
int version = sr.ReadInt32();
if (version < LegacyScoreEncoder.FIRST_LAZER_VERSION)
score.IsLegacyScore = true;
}
} }
} }
catch (Exception e) catch (Exception e)
@ -1145,20 +1150,5 @@ namespace osu.Game.Database
isDisposed = true; isDisposed = true;
} }
} }
/// <summary>
/// A trimmed down <see cref="LegacyScoreDecoder"/> specialised to extract the version from replays.
/// </summary>
private class ReplayVersionParser
{
public int Parse(Stream stream)
{
using (SerializationReader sr = new SerializationReader(stream))
{
sr.ReadByte(); // Ruleset.
return sr.ReadInt32();
}
}
}
} }
} }