1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 06:07:28 +08:00

limited max Date comparison

This commit is contained in:
Elvendir 2023-03-18 21:35:10 +01:00
parent 102576cd8c
commit 216a88e18d
2 changed files with 13 additions and 4 deletions

View File

@ -48,7 +48,7 @@ namespace osu.Game.Screens.Select.Carousel
match &= !criteria.CircleSize.HasFilter || criteria.CircleSize.IsInRange(BeatmapInfo.Difficulty.CircleSize);
match &= !criteria.OverallDifficulty.HasFilter || criteria.OverallDifficulty.IsInRange(BeatmapInfo.Difficulty.OverallDifficulty);
match &= !criteria.Length.HasFilter || criteria.Length.IsInRange(BeatmapInfo.Length);
match &= !criteria.LastPlayed.HasFilter || criteria.LastPlayed.IsInRange(BeatmapInfo.LastPlayed);
match &= !criteria.LastPlayed.HasFilter || criteria.LastPlayed.IsInRange(BeatmapInfo.LastPlayed ?? DateTimeOffset.MinValue);
match &= !criteria.BPM.HasFilter || criteria.BPM.IsInRange(BeatmapInfo.BPM);
match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(BeatmapInfo.BeatDivisor);

View File

@ -381,7 +381,7 @@ namespace osu.Game.Screens.Select
GroupCollection? match = null;
match ??= tryMatchRegex(val, @"^((?<hours>\d+):)?(?<minutes>\d+):(?<seconds>\d+)$");
match ??= tryMatchRegex(val, @"^((?<hours>\d+(\.\d+)?)h)?((?<minutes>\d+(\.\d+)?)m)?((?<seconds>\d+(\.\d+)?)s)?$");
match ??= tryMatchRegex(val, @"^((?<days>\d+(\.\d+)?)d)?((?<hours>\d+(\.\d+)?)h)?((?<minutes>\d+(\.\d+)?)m)?((?<seconds>\d+(\.\d+)?)s)?$");
match ??= tryMatchRegex(val, @"^(?<seconds>\d+(\.\d+)?)$");
if (match == null)
@ -403,7 +403,7 @@ namespace osu.Game.Screens.Select
for (int i = 0; i < parts.Count; i++)
{
string part = parts[i];
string partNoUnit = part.TrimEnd('m', 's', 'h', 'd') ;
string partNoUnit = part.TrimEnd('m', 's', 'h', 'd');
if (!tryParseDoubleWithPoint(partNoUnit, out double length))
return false;
@ -417,7 +417,16 @@ namespace osu.Game.Screens.Select
minScale = Math.Min(minScale, scale);
}
return tryUpdateCriteriaRange(ref criteria.LastPlayed, op, totalLength, minScale / 2.0);
totalLength += minScale / 2;
// Limits the date to ~2000 years compared to now
// Might want to do it differently before 4000 A.C.
double limit = 86400000;
limit *= 365 * 2000;
totalLength = Math.Min(totalLength, limit);
DateTimeOffset dateTimeOffset = DateTimeOffset.Now;
return tryUpdateCriteriaRange(ref criteria.LastPlayed, op, dateTimeOffset.AddMilliseconds(-totalLength));
}
}
}