diff --git a/RhythiaLib/Rhr/Internal/RhrReader.cs b/RhythiaLib/Rhr/Internal/RhrReader.cs index f8cad2f..9bcb09b 100644 --- a/RhythiaLib/Rhr/Internal/RhrReader.cs +++ b/RhythiaLib/Rhr/Internal/RhrReader.cs @@ -17,6 +17,7 @@ namespace RhythiaLib.Rhr.Internal try { int version = reader.ReadInt32(); + RhrVersions.Validate(version); RhrScoreData scoreData = RhrScoreDataCodec.Read(reader, version); diff --git a/RhythiaLib/Rhr/RhrVersions.cs b/RhythiaLib/Rhr/RhrVersions.cs index 97307e5..0c2034c 100644 --- a/RhythiaLib/Rhr/RhrVersions.cs +++ b/RhythiaLib/Rhr/RhrVersions.cs @@ -10,5 +10,16 @@ namespace RhythiaLib.Rhr public const int FailTime = 2026_02_22; public const int Int32Time = 2026_05_10; 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}"); + } } }