feat: add rhr version validation

This commit is contained in:
2026-07-24 19:57:04 -04:00
parent 7dc29acc7d
commit 8508176a31
2 changed files with 12 additions and 0 deletions
+1
View File
@@ -17,6 +17,7 @@ namespace RhythiaLib.Rhr.Internal
try try
{ {
int version = reader.ReadInt32(); int version = reader.ReadInt32();
RhrVersions.Validate(version);
RhrScoreData scoreData = RhrScoreDataCodec.Read(reader, version); RhrScoreData scoreData = RhrScoreDataCodec.Read(reader, version);
+11
View File
@@ -10,5 +10,16 @@ namespace RhythiaLib.Rhr
public const int FailTime = 2026_02_22; public const int FailTime = 2026_02_22;
public const int Int32Time = 2026_05_10; public const int Int32Time = 2026_05_10;
public const int BeatmapHash = 2026_05_17; public const int BeatmapHash = 2026_05_17;
public const int LatestSupported = BeatmapHash;
public static void Validate(int version)
{
// oldest version isnt validated since idk when the format was made and if it breaks before 2026/01/18
if (version <= 0)
throw new InvalidRhrFormatException($"Invalid RHR version: {version}.");
else if (version > LatestSupported)
throw new InvalidRhrFormatException($"RHR version {version} is newer than the latest supported version, {version}");
}
} }
} }