mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:02:55 +08:00
Inline binary reading to avoid polluting RealmAccess
with nested class
This commit is contained in:
parent
a9071e7afd
commit
53f935714e
@ -912,11 +912,16 @@ 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.
|
||||||
|
using (SerializationReader sr = new SerializationReader(stream))
|
||||||
|
{
|
||||||
|
sr.ReadByte(); // Ruleset.
|
||||||
|
int version = sr.ReadInt32();
|
||||||
if (version < LegacyScoreEncoder.FIRST_LAZER_VERSION)
|
if (version < LegacyScoreEncoder.FIRST_LAZER_VERSION)
|
||||||
score.IsLegacyScore = true;
|
score.IsLegacyScore = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error(e, $"Failed to read replay {replayFilename}", LoggingTarget.Database);
|
Logger.Error(e, $"Failed to read replay {replayFilename}", LoggingTarget.Database);
|
||||||
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user