From 98e9e477314b6278e367d419ffa5d68ffd3eab6c Mon Sep 17 00:00:00 2001 From: Toaster2 Date: Tue, 17 Feb 2026 11:27:02 +0100 Subject: [PATCH] Fix infinity CR being applied to specific levels --- Refresh.Interfaces.Workers/Repeating/CoolLevelsJob.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Refresh.Interfaces.Workers/Repeating/CoolLevelsJob.cs b/Refresh.Interfaces.Workers/Repeating/CoolLevelsJob.cs index fc8bb496..87982ba6 100644 --- a/Refresh.Interfaces.Workers/Repeating/CoolLevelsJob.cs +++ b/Refresh.Interfaces.Workers/Repeating/CoolLevelsJob.cs @@ -147,10 +147,15 @@ private static float CalculatePositiveScore(GameLevel level, WorkContext context // Reward for a good ratio between plays and yays. // Doesn't apply to LBP1 levels. - float ratingRatio = (positiveRatings - negativeRatings) / (float)uniquePlays; - if (ratingRatio > 0.5f && level.GameVersion != TokenGame.LittleBigPlanet1) + // Skip this reward entirely if the level has no unique plays, as division by 0.0 floats + // results in infinity values, which should never happen and will also screw with API clients. + if (uniquePlays > 0) { - score += positiveRatings * (positiveRatingPoints * ratingRatio); + float ratingRatio = (positiveRatings - negativeRatings) / (float)uniquePlays; + if (ratingRatio > 0.5f && level.GameVersion != TokenGame.LittleBigPlanet1) + { + score += positiveRatings * (positiveRatingPoints * ratingRatio); + } } if (level.Publisher?.Role == GameUserRole.Trusted)